diff options
566 files changed, 19273 insertions, 5849 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index cc507d85e..9caa87f2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,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) ######################################################################## @@ -274,7 +275,6 @@ add_subdirectory(grc) add_subdirectory(gr-fec) add_subdirectory(gr-fft) add_subdirectory(gr-filter) -#add_subdirectory(gr-ctrlport) add_subdirectory(gr-analog) add_subdirectory(gr-digital) add_subdirectory(gr-atsc) diff --git a/cmake/Modules/FindGnuradio.cmake b/cmake/Modules/FindGnuradio.cmake new file mode 100644 index 000000000..14498488f --- /dev/null +++ b/cmake/Modules/FindGnuradio.cmake @@ -0,0 +1,105 @@ +INCLUDE(FindPkgConfig)
+INCLUDE(FindPackageHandleStandardArgs)
+
+# a subset of required modules can be set using the following syntax
+#set(GR_REQUIRED_MODULES CORE BLOCKS)
+
+# if GR_REQUIRED_MODULES is not defined, it will be set to the following list (all of them)
+if(NOT GR_REQUIRED_MODULES)
+ set(GR_REQUIRED_MODULES CORE ANALOG ATSC AUDIO BLOCKS CHANNELS DIGITAL FEC FFT FILTER NOAA PAGER QTGUI TRELLIS UHD VOCODER WAVELET)
+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_MODULES})
+ 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}
+ ${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(ANALOG gnuradio-analog analog/noise_type.h gnuradio-analog)
+GR_MODULE(ATSC gnuradio-atsc atsc_api.h gnuradio-atsc)
+GR_MODULE(AUDIO gnuradio-audio audio/sink.h gnuradio-audio)
+GR_MODULE(BLOCKS gnuradio-blocks blocks/delay.h gnuradio-blocks)
+GR_MODULE(CHANNELS gnuradio-channels channels/channel_model.h gnuradio-channels)
+GR_MODULE(DIGITAL gnuradio-digital digital/lfsr.h gnuradio-digital)
+GR_MODULE(FEC gnuradio-fec fec/rs.h gnuradio-fec)
+GR_MODULE(FFT gnuradio-fft fft/fft.h gnuradio-fft)
+GR_MODULE(FILTER gnuradio-filter filter/fir_filter.h gnuradio-filter)
+GR_MODULE(NOAA gnuradio-noaa noaa/hrpt.h gnuradio-noaa)
+GR_MODULE(PAGER gnuradio-pager noaa/flex_deinterleave.h gnuradio-pager)
+GR_MODULE(QTGUI gnuradio-qtgui qtgui/utils.h gnuradio-qtgui)
+GR_MODULE(TRELLIS gnuradio-trellis trellis/fsm.h gnuradio-trellis)
+GR_MODULE(UHD gnuradio-uhd gr_uhd/usrp_sink.h gnuradio-uhd)
+GR_MODULE(VOCODER gnuradio-vocoder vocoder/alaw_encode_sb.h gnuradio-vocoder)
+GR_MODULE(WAVELET gnuradio-wavelet wavelet/wavelet_ff.h gnuradio-wavelet)
+
diff --git a/cmake/Modules/FindLog4cpp.cmake b/cmake/Modules/FindLog4cpp.cmake new file mode 100644 index 000000000..fc314c61a --- /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/FindLog4cxx.cmake b/cmake/Modules/FindLog4cxx.cmake deleted file mode 100644 index b1e4f6f1f..000000000 --- a/cmake/Modules/FindLog4cxx.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# CMake module to find LOG4CXX library - -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_LOG4CXX liblog4cxx) - -FIND_PATH( - LOG4CXX_INCLUDE_DIRS - NAMES log4cxx/log4cxx.h - HINTS $ENV{LOG4CXX_DIR}/include - ${PC_LOG4CXX_INCLUDE_DIRS} - PATHS /usr/local/include - /usr/include -) - -FIND_LIBRARY( - LOG4CXX_LIBRARIES - NAMES log4cxx - HINTS $ENV{LOG4CXX_DIR}/lib - ${PC_LOG4CXX_LIBRARIES} - PATHS /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 -) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LOG4CXX DEFAULT_MSG LOG4CXX_LIBRARIES LOG4CXX_INCLUDE_DIRS) -MARK_AS_ADVANCED(LOG4CXX_LIBRARIES LOG4CXX_INCLUDE_DIRS) diff --git a/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake index c7fe77bc8..69ff1f5dd 100644 --- a/cmake/Modules/GrMiscUtils.cmake +++ b/cmake/Modules/GrMiscUtils.cmake @@ -218,36 +218,37 @@ endfunction(GR_GEN_TARGET_DEPS) # Can manually set with -DENABLE_GR_LOG=0|1 ######################################################################## function(GR_LOGGING) - find_package(Log4cxx) + 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 LOG4CXX; if we have it, use this version of the logger + # also test LOG4CPP; if we have it, use this version of the logger # otherwise, default to the stdout/stderr model. - if(LOG4CXX_FOUND) - SET(HAVE_LOG4CXX True CACHE INTERNAL "" FORCE) - add_definitions( -DHAVE_LOG4CXX ) - else(LOG4CXX_FOUND) - SET(HAVE_LOG4CXX False CACHE INTERNAL "" FORCE) - SET(LOG4CXX_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) - SET(LOG4CXX_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE) - SET(LOG4CXX_LIBRARIES "" CACHE INTERNAL "" FORCE) - endif(LOG4CXX_FOUND) + 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_LOG4CXX False CACHE INTERNAL "" FORCE) - SET(LOG4CXX_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) - SET(LOG4CXX_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE) - SET(LOG4CXX_LIBRARIES "" CACHE INTERNAL "" FORCE) + 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_LOG4CXX set to ${HAVE_LOG4CXX}.") + message(STATUS "HAVE_LOG4CPP set to ${HAVE_LOG4CPP}.") + message(STATUS "LOG4CPP_LIBRARIES set to ${LOG4CPP_LIBRARIES}.") endfunction(GR_LOGGING) diff --git a/config.h.in b/config.h.in index e46177e86..5e73835ea 100644 --- a/config.h.in +++ b/config.h.in @@ -26,6 +26,6 @@ #cmakedefine GR_PERFORMANCE_COUNTERS #cmakedefine GR_CTRLPORT #cmakedefine ENABLE_GR_LOG -#cmakedefine HAVE_LOG4CXX +#cmakedefine HAVE_LOG4CPP #endif /* GNURADIO_CONFIG_H */ diff --git a/docs/doxygen/other/extra_pages.dox b/docs/doxygen/other/extra_pages.dox index 44cdf9d48..94c741864 100644 --- a/docs/doxygen/other/extra_pages.dox +++ b/docs/doxygen/other/extra_pages.dox @@ -80,7 +80,7 @@ audio-osx and audio-windows to be either satisfied or built. \li comedilib (>= 0.8) http://www.comedi.org/ \subsection dep_gr_log gr-log: Logging Tools (Optional) -\li log4cxx (>= 0.10.0) http://logging.apache.org/log4cxx +\li log4cpp (>= 1.0) http://log4cpp.sourceforge.net/ \section build_gr_cmake Building GNU Radio diff --git a/docs/doxygen/other/logger.dox b/docs/doxygen/other/logger.dox index f98a64657..9a97172ed 100644 --- a/docs/doxygen/other/logger.dox +++ b/docs/doxygen/other/logger.dox @@ -4,20 +4,23 @@ 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 log4cxx (http://logging.apache.org/log4cxx) which is readily +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 log4cxx if it is available. If log4cxx +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: - TRACE < DEBUG < INFO < WARN < ERROR < FATAL +<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 @@ -42,14 +45,14 @@ stream or file. The four main configure options are: <pre> - log_level = all - debug_level = all + 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 (TRACE through FATAL). They are also configured not to +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. @@ -111,20 +114,21 @@ The various logging macros are defined in gr_logger.h. Here are some simple examples of using them: \code - GR_LOG_TRACE(LOG, "TRACE message"); 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_FATAL(LOG, "FATAL message"); - GR_ERRORIF(LOG, a>b, "CONDITIONAL ERROR message"); - GR_ASSERT(LOG, a>b, "ASSERT 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 log4cxx library is not found, then TRACE, -DEBUG, and INFO levels go to stdout and the rest to stderr. +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 @@ -133,11 +137,10 @@ 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 -log4cxx documentation (found through -http://logging.apache.org/log4cxx/) 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: +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 @@ -149,7 +152,7 @@ For the following examples, we will assume that our local \code [LOG] log_config = /opt/gr/etc/gnuadio/gr_log_default.xml -log_level = All +log_level = debug debug_level = Off \endcode @@ -163,7 +166,7 @@ specified in the XML file. Here, we have turned on the standard 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 "all." +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 @@ -196,7 +199,7 @@ except we would use "gr_log_debug." in the GR_LOG_GETLOGGER call): \endcode This creates a pointer called LOG (which is instantiated as a -log4cxx:LoggerPtr in the macro) that we can now use locally as the -input to our logging macros like 'GR_LOG_TRACE(LOG, "message")'. +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 6f422dfd8..f9e335061 100644 --- a/docs/doxygen/other/main_page.dox +++ b/docs/doxygen/other/main_page.dox @@ -227,7 +227,7 @@ class mytb(gr.top_block): self.add = blocks.add_cc() self.sub = blocks.sub_cc() self.head = gr.head(gr.sizeof_gr_complex, 1000000) - self.snk = gr.file_sink(gr.sizeof_gr_complex, "output.32fc") + self.snk = blocks.file_sink(gr.sizeof_gr_complex, "output.32fc") self.connect(self.src0, (self.add,0)) self.connect(self.src1, (self.add,1)) @@ -282,7 +282,7 @@ class mytb(gr.top_block): self.add = blocks.add_cc() self.sub = blocks.sub_cc() self.head = gr.head(gr.sizeof_gr_complex, 1000000) - self.snk = gr.file_sink(gr.sizeof_gr_complex, "output.32fc") + self.snk = blocks.file_sink(gr.sizeof_gr_complex, "output.32fc") self.connect(self.src0, (self.add,0)) self.connect(self.src1, (self.add,1)) diff --git a/docs/exploring-gnuradio/fm_demod.py b/docs/exploring-gnuradio/fm_demod.py index 7b19cd826..c6d8eaa58 100755 --- a/docs/exploring-gnuradio/fm_demod.py +++ b/docs/exploring-gnuradio/fm_demod.py @@ -7,7 +7,7 @@ from gnuradio import mc4020 import sys def high_speed_adc(fg, input_rate): - # return gr.file_source (gr.sizeof_short, "dummy.dat", False) + # return blocks.file_source (gr.sizeof_short, "dummy.dat", False) return mc4020.source(input_rate, mc4020.MCC_CH3_EN | mc4020.MCC_ALL_1V) # diff --git a/docs/exploring-gnuradio/fm_demod_example.xml b/docs/exploring-gnuradio/fm_demod_example.xml index 05c2ee163..38bfc1e84 100644 --- a/docs/exploring-gnuradio/fm_demod_example.xml +++ b/docs/exploring-gnuradio/fm_demod_example.xml @@ -11,7 +11,7 @@ from gnuradio import mc4020 import sys def high_speed_adc (fg, input_rate): - # return gr.file_source (gr.sizeof_short, "dummy.dat", False) + # return blocks.file_source (gr.sizeof_short, "dummy.dat", False) return mc4020.source (input_rate, mc4020.MCC_CH3_EN | mc4020.MCC_ALL_1V) # diff --git a/docs/sphinx/source/gr/index.rst b/docs/sphinx/source/gr/index.rst index b1663a7e2..bd43888ec 100644 --- a/docs/sphinx/source/gr/index.rst +++ b/docs/sphinx/source/gr/index.rst @@ -28,10 +28,6 @@ Signal Sources gnuradio.gr.vector_source_f gnuradio.gr.vector_source_i gnuradio.gr.vector_source_s - gnuradio.gr.file_descriptor_source - gnuradio.gr.file_source - gnuradio.gr.udp_source - gnuradio.gr.wavfile_source Signal Sinks ^^^^^^^^^^^^ @@ -47,12 +43,8 @@ Signal Sinks gnuradio.gr.vector_sink_f gnuradio.gr.vector_sink_i gnuradio.gr.vector_sink_s - gnuradio.gr.file_descriptor_sink - gnuradio.gr.file_sink gnuradio.gr.histo_sink_f gnuradio.gr.oscope_sink_f - gnuradio.gr.udp_sink - gnuradio.gr.wavfile_sink Information Coding and Decoding diff --git a/docs/sphinx/source/gr/sink_blk.rst b/docs/sphinx/source/gr/sink_blk.rst index 56b29efff..1e8276545 100644 --- a/docs/sphinx/source/gr/sink_blk.rst +++ b/docs/sphinx/source/gr/sink_blk.rst @@ -9,9 +9,5 @@ gnuradio.gr: Signal Sinks .. autooldblock:: gnuradio.gr.vector_sink_f .. autooldblock:: gnuradio.gr.vector_sink_i .. autooldblock:: gnuradio.gr.vector_sink_s -.. autooldblock:: gnuradio.gr.file_descriptor_sink -.. autooldblock:: gnuradio.gr.file_sink .. autooldblock:: gnuradio.gr.histo_sink_f .. autooldblock:: gnuradio.gr.oscope_sink_f -.. autooldblock:: gnuradio.gr.udp_sink -.. autooldblock:: gnuradio.gr.wavfile_sink diff --git a/docs/sphinx/source/gr/source_blk.rst b/docs/sphinx/source/gr/source_blk.rst index f3a1b4954..1ef77349f 100644 --- a/docs/sphinx/source/gr/source_blk.rst +++ b/docs/sphinx/source/gr/source_blk.rst @@ -8,8 +8,4 @@ gnuradio.gr: Signal Sources .. autooldblock:: gnuradio.gr.vector_source_f .. autooldblock:: gnuradio.gr.vector_source_i .. autooldblock:: gnuradio.gr.vector_source_s -.. autooldblock:: gnuradio.gr.file_descriptor_source -.. autooldblock:: gnuradio.gr.file_source -.. autooldblock:: gnuradio.gr.udp_source -.. autooldblock:: gnuradio.gr.wavfile_source diff --git a/gnuradio-core/CMakeLists.txt b/gnuradio-core/CMakeLists.txt index c7ecb3d6a..60fd11dd3 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,6 +60,8 @@ GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/hier ) +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 @@ -144,13 +147,13 @@ install( COMPONENT "core_runtime" ) -if(ENABLE_GR_LOG AND HAVE_LOG4CXX) +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_LOG4CXX) +endif(ENABLE_GR_LOG AND HAVE_LOG4CPP) ######################################################################## # Add subdirectories diff --git a/gnuradio-core/gnuradio-core.conf.in b/gnuradio-core/gnuradio-core.conf.in index 0db837a37..d41801aa2 100644 --- a/gnuradio-core/gnuradio-core.conf.in +++ b/gnuradio-core/gnuradio-core.conf.in @@ -12,9 +12,9 @@ max_messages = 100 [LOG] # Levels can be (case insensitive): -# trace, debug, info, warn, error, fatal -log_level = all -debug_level = all +# 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 diff --git a/gnuradio-core/src/examples/ctrlport/comparing_resamplers.grc b/gnuradio-core/src/examples/ctrlport/comparing_resamplers.grc new file mode 100644 index 000000000..4ac4af247 --- /dev/null +++ b/gnuradio-core/src/examples/ctrlport/comparing_resamplers.grc @@ -0,0 +1,390 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Fri Mar 15 11:01:13 2013</timestamp> + <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>(191, 125)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_ctrlport_probe2_c</key> + <param> + <key>id</key> + <value>probe_arc_resamp</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>name</key> + <value>arb_resampler</value> + </param> + <param> + <key>desc</key> + <value>PFB Arbitrary Resampler</value> + </param> + <param> + <key>len</key> + <value>1024</value> + </param> + <param> + <key>_coordinate</key> + <value>(9, 296)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>resamp_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>1.25</value> + </param> + <param> + <key>_coordinate</key> + <value>(272, 9)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>pfb_arb_resampler_xxx</key> + <param> + <key>id</key> + <value>pfb_arb_resampler_xxx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>ccf</value> + </param> + <param> + <key>rrate</key> + <value>resamp_rate</value> + </param> + <param> + <key>taps</key> + <value></value> + </param> + <param> + <key>nfilts</key> + <value>32</value> + </param> + <param> + <key>atten</key> + <value>60</value> + </param> + <param> + <key>_coordinate</key> + <value>(305, 280)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>gr_ctrlport_probe2_c</key> + <param> + <key>id</key> + <value>probe_frac_interp</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>name</key> + <value>fractional_interp</value> + </param> + <param> + <key>desc</key> + <value>Fractional Interpolator</value> + </param> + <param> + <key>len</key> + <value>1024</value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 204)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>fractional_interpolator_xx</key> + <param> + <key>id</key> + <value>fractional_interpolator_xx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>phase_shift</key> + <value>0</value> + </param> + <param> + <key>interp_ratio</key> + <value>1.0/resamp_rate</value> + </param> + <param> + <key>_coordinate</key> + <value>(354, 212)</value> + </param> + <param> + <key>_rotation</key> + <value>180</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>30e6</value> + </param> + <param> + <key>_coordinate</key> + <value>(181, 10)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>analog_sig_source_x</key> + <param> + <key>id</key> + <value>analog_sig_source_x_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>waveform</key> + <value>analog.GR_COS_WAVE</value> + </param> + <param> + <key>freq</key> + <value>samp_rate/10</value> + </param> + <param> + <key>amp</key> + <value>1</value> + </param> + <param> + <key>offset</key> + <value>0</value> + </param> + <param> + <key>_coordinate</key> + <value>(11, 93)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>channels_channel_model</key> + <param> + <key>id</key> + <value>channels_channel_model_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>noise_voltage</key> + <value>0.1</value> + </param> + <param> + <key>freq_offset</key> + <value>0.0</value> + </param> + <param> + <key>epsilon</key> + <value>1.0</value> + </param> + <param> + <key>taps</key> + <value>[1,]</value> + </param> + <param> + <key>seed</key> + <value>0</value> + </param> + <param> + <key>_coordinate</key> + <value>(382, 93)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>options</key> + <param> + <key>id</key> + <value>comparing_resamplers</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value></value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></value> + </param> + <param> + <key>window_size</key> + <value>570,390</value> + </param> + <param> + <key>generate_options</key> + <value>no_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>(10, 10)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>analog_sig_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>blocks_throttle_0</source_block_id> + <sink_block_id>channels_channel_model_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>channels_channel_model_0</source_block_id> + <sink_block_id>pfb_arb_resampler_xxx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>channels_channel_model_0</source_block_id> + <sink_block_id>fractional_interpolator_xx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>pfb_arb_resampler_xxx_0</source_block_id> + <sink_block_id>probe_arc_resamp</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>fractional_interpolator_xx_0</source_block_id> + <sink_block_id>probe_frac_interp</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc b/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc index 5287257d7..31914412b 100644 --- a/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc +++ b/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc @@ -1,59 +1,46 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Tue Feb 26 14:26:03 2013</timestamp> + <timestamp>Fri Mar 15 17:32:55 2013</timestamp> <block> - <key>options</key> + <key>variable</key> <param> <key>id</key> - <value>pfb_sync_test_qt</value> + <value>sps</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>title</key> - <value></value> - </param> - <param> - <key>author</key> - <value></value> - </param> - <param> - <key>description</key> - <value></value> - </param> - <param> - <key>window_size</key> - <value>1280, 1024</value> + <key>value</key> + <value>2</value> </param> <param> - <key>generate_options</key> - <value>qt_gui</value> + <key>_coordinate</key> + <value>(105, 126)</value> </param> <param> - <key>category</key> - <value>Custom</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>run_options</key> - <value>prompt</value> + <key>id</key> + <value>samp_rate</value> </param> <param> - <key>run</key> + <key>_enabled</key> <value>True</value> </param> <param> - <key>max_nouts</key> - <value>0</value> - </param> - <param> - <key>realtime_scheduling</key> - <value></value> + <key>value</key> + <value>300000</value> </param> <param> <key>_coordinate</key> - <value>(10, 10)</value> + <value>(14, 124)</value> </param> <param> <key>_rotation</key> @@ -61,22 +48,22 @@ </param> </block> <block> - <key>variable</key> + <key>import</key> <param> <key>id</key> - <value>graymap</value> + <value>import_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>[[3,1,0,2]]</value> + <key>import</key> + <value>import random, math, cmath</value> </param> <param> <key>_coordinate</key> - <value>(32, 387)</value> + <value>(14, 77)</value> </param> <param> <key>_rotation</key> @@ -84,22 +71,22 @@ </param> </block> <block> - <key>variable</key> + <key>ctrlport_monitor</key> <param> <key>id</key> - <value>amps</value> + <value>ctrlport_monitor_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>[1]</value> + <key>en</key> + <value>True</value> </param> <param> <key>_coordinate</key> - <value>(32, 451)</value> + <value>(175, 10)</value> </param> <param> <key>_rotation</key> @@ -107,22 +94,34 @@ </param> </block> <block> - <key>variable</key> + <key>gr_vector_source_x</key> <param> <key>id</key> - <value>nfilts</value> + <value>gr_vector_source_x_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>32</value> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>vector</key> + <value>0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50</value> + </param> + <param> + <key>repeat</key> + <value>True</value> + </param> + <param> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(99, 451)</value> + <value>(190, 71)</value> </param> <param> <key>_rotation</key> @@ -130,22 +129,34 @@ </param> </block> <block> - <key>variable</key> + <key>blocks_packed_to_unpacked_xx</key> <param> <key>id</key> - <value>sps</value> + <value>blocks_packed_to_unpacked_xx_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>2</value> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>bits_per_chunk</key> + <value>8</value> + </param> + <param> + <key>endianness</key> + <value>gr.GR_MSB_FIRST</value> + </param> + <param> + <key>num_ports</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(105, 126)</value> + <value>(419, 10)</value> </param> <param> <key>_rotation</key> @@ -153,22 +164,30 @@ </param> </block> <block> - <key>variable</key> + <key>blocks_throttle</key> <param> <key>id</key> - <value>samp_rate</value> + <value>blocks_throttle_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>300000</value> + <key>type</key> + <value>byte</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>(14, 124)</value> + <value>(436, 97)</value> </param> <param> <key>_rotation</key> @@ -176,22 +195,46 @@ </param> </block> <block> - <key>import</key> + <key>digital_psk_mod</key> <param> <key>id</key> - <value>import_0</value> + <value>digital_psk_mod_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>import</key> - <value>import random, math, cmath</value> + <key>constellation_points</key> + <value>4</value> + </param> + <param> + <key>mod_code</key> + <value>"gray"</value> + </param> + <param> + <key>differential</key> + <value>True</value> + </param> + <param> + <key>samples_per_symbol</key> + <value>sps</value> + </param> + <param> + <key>excess_bw</key> + <value>0.35</value> + </param> + <param> + <key>verbose</key> + <value>False</value> + </param> + <param> + <key>log</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(14, 77)</value> + <value>(627, 65)</value> </param> <param> <key>_rotation</key> @@ -199,54 +242,50 @@ </param> </block> <block> - <key>variable_qtgui_range</key> + <key>digital_pfb_clock_sync_xxx</key> <param> <key>id</key> - <value>phase</value> + <value>digital_pfb_clock_sync_xxx_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Phase</value> - </param> - <param> - <key>value</key> - <value>0.5</value> + <key>type</key> + <value>ccf</value> </param> <param> - <key>start</key> - <value>0</value> + <key>sps</key> + <value>sps</value> </param> <param> - <key>stop</key> - <value>2</value> + <key>loop_bw</key> + <value>2*3.14/100.0</value> </param> <param> - <key>step</key> - <value>0.01</value> + <key>taps</key> + <value>firdes.root_raised_cosine(nfilts, nfilts,1.0/sps, 0.35, int(22*sps*nfilts))</value> </param> <param> - <key>widget</key> - <value>counter_slider</value> + <key>filter_size</key> + <value>nfilts</value> </param> <param> - <key>orient</key> - <value>Qt.Horizontal</value> + <key>init_phase</key> + <value>nfilts/2</value> </param> <param> - <key>min_len</key> - <value>200</value> + <key>max_dev</key> + <value>1.5</value> </param> <param> - <key>gui_hint</key> - <value></value> + <key>osps</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(175, 387)</value> + <value>(339, 195)</value> </param> <param> <key>_rotation</key> @@ -254,26 +293,22 @@ </param> </block> <block> - <key>gr_null_sink</key> + <key>variable</key> <param> <key>id</key> - <value>gr_null_sink_0</value> + <value>nfilts</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> + <key>value</key> + <value>32</value> </param> <param> <key>_coordinate</key> - <value>(939, 313)</value> + <value>(74, 390)</value> </param> <param> <key>_rotation</key> @@ -281,54 +316,45 @@ </param> </block> <block> - <key>variable_qtgui_range</key> + <key>variable</key> <param> <key>id</key> - <value>noise</value> + <value>amps</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Noise</value> - </param> - <param> <key>value</key> - <value>0.050</value> - </param> - <param> - <key>start</key> - <value>0.0001</value> - </param> - <param> - <key>stop</key> - <value>2</value> + <value>[1]</value> </param> <param> - <key>step</key> - <value>0.01</value> + <key>_coordinate</key> + <value>(7, 390)</value> </param> <param> - <key>widget</key> - <value>counter_slider</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>orient</key> - <value>Qt.Horizontal</value> + <key>id</key> + <value>graymap</value> </param> <param> - <key>min_len</key> - <value>200</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>gui_hint</key> - <value></value> + <key>value</key> + <value>[[3,1,0,2]]</value> </param> <param> <key>_coordinate</key> - <value>(316, 389)</value> + <value>(7, 326)</value> </param> <param> <key>_rotation</key> @@ -387,7 +413,7 @@ </param> <param> <key>_coordinate</key> - <value>(949, 232)</value> + <value>(752, 196)</value> </param> <param> <key>_rotation</key> @@ -395,50 +421,69 @@ </param> </block> <block> - <key>digital_pfb_clock_sync_xxx</key> + <key>channels_channel_model</key> <param> <key>id</key> - <value>digital_pfb_clock_sync_xxx_0</value> + <value>channels_channel_model_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>ccf</value> + <key>noise_voltage</key> + <value>noise</value> </param> <param> - <key>sps</key> - <value>sps</value> + <key>freq_offset</key> + <value>0.0</value> </param> <param> - <key>loop_bw</key> - <value>2*3.14/100.0</value> + <key>epsilon</key> + <value>1.0</value> </param> <param> <key>taps</key> - <value>firdes.root_raised_cosine(nfilts, nfilts,1.0/sps, 0.35, int(22*sps*nfilts))</value> + <value>cmath.exp(1j*phase)</value> </param> <param> - <key>filter_size</key> - <value>nfilts</value> + <key>seed</key> + <value>0</value> </param> <param> - <key>init_phase</key> - <value>nfilts/2</value> + <key>_coordinate</key> + <value>(68, 211)</value> </param> <param> - <key>max_dev</key> - <value>1.5</value> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_ctrlport_probe2_c</key> + <param> + <key>id</key> + <value>received_probe2</value> </param> <param> - <key>osps</key> - <value>1</value> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>name</key> + <value>received</value> + </param> + <param> + <key>desc</key> + <value>Constellation Points</value> + </param> + <param> + <key>len</key> + <value>1024</value> </param> <param> <key>_coordinate</key> - <value>(322, 231)</value> + <value>(195, 519)</value> </param> <param> <key>_rotation</key> @@ -446,46 +491,54 @@ </param> </block> <block> - <key>digital_psk_mod</key> + <key>variable_qtgui_range</key> <param> <key>id</key> - <value>digital_psk_mod_0</value> + <value>phase</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>constellation_points</key> - <value>4</value> + <key>label</key> + <value>Phase</value> </param> <param> - <key>mod_code</key> - <value>"gray"</value> + <key>value</key> + <value>0.5</value> </param> <param> - <key>differential</key> - <value>True</value> + <key>start</key> + <value>0</value> </param> <param> - <key>samples_per_symbol</key> - <value>sps</value> + <key>stop</key> + <value>2</value> </param> <param> - <key>excess_bw</key> - <value>0.35</value> + <key>step</key> + <value>0.01</value> </param> <param> - <key>verbose</key> - <value>False</value> + <key>widget</key> + <value>counter_slider</value> </param> <param> - <key>log</key> - <value>False</value> + <key>orient</key> + <value>Qt.Horizontal</value> + </param> + <param> + <key>min_len</key> + <value>200</value> + </param> + <param> + <key>gui_hint</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(846, 32)</value> + <value>(266, 344)</value> </param> <param> <key>_rotation</key> @@ -493,38 +546,30 @@ </param> </block> <block> - <key>channels_channel_model</key> + <key>gr_ctrlport_probe2_c</key> <param> <key>id</key> - <value>channels_channel_model_0</value> + <value>time_probe2</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>noise_voltage</key> - <value>noise</value> - </param> - <param> - <key>freq_offset</key> - <value>0.0</value> - </param> - <param> - <key>epsilon</key> - <value>1.0</value> + <key>name</key> + <value>time locked</value> </param> <param> - <key>taps</key> - <value>cmath.exp(1j*noise)</value> + <key>desc</key> + <value>Constellation Points</value> </param> <param> - <key>seed</key> - <value>0</value> + <key>len</key> + <value>1024</value> </param> <param> <key>_coordinate</key> - <value>(80, 247)</value> + <value>(447, 440)</value> </param> <param> <key>_rotation</key> @@ -532,57 +577,54 @@ </param> </block> <block> - <key>digital_costas_loop_cc</key> + <key>variable_qtgui_range</key> <param> <key>id</key> - <value>digital_costas_loop_cc_0</value> + <value>noise</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>w</key> - <value>6.28/100.0</value> + <key>label</key> + <value>Noise</value> </param> <param> - <key>order</key> - <value>4</value> + <key>value</key> + <value>0.050</value> </param> <param> - <key>_coordinate</key> - <value>(641, 313)</value> + <key>start</key> + <value>0.0001</value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>stop</key> + <value>2</value> </param> - </block> - <block> - <key>gr_ctrlport_probe2_c</key> <param> - <key>id</key> - <value>probe2_c_0</value> + <key>step</key> + <value>0.01</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>widget</key> + <value>counter_slider</value> </param> <param> - <key>name</key> - <value>constellation</value> + <key>orient</key> + <value>Qt.Horizontal</value> </param> <param> - <key>desc</key> - <value>Constellation Points</value> + <key>min_len</key> + <value>200</value> </param> <param> - <key>len</key> - <value>1024</value> + <key>gui_hint</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(936, 396)</value> + <value>(7, 455)</value> </param> <param> <key>_rotation</key> @@ -590,22 +632,26 @@ </param> </block> <block> - <key>ctrlport_monitor</key> + <key>digital_costas_loop_cc</key> <param> <key>id</key> - <value>ctrlport_monitor_0</value> + <value>digital_costas_loop_cc_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>en</key> - <value>True</value> + <key>w</key> + <value>6.28/100.0</value> + </param> + <param> + <key>order</key> + <value>4</value> </param> <param> <key>_coordinate</key> - <value>(228, 9)</value> + <value>(610, 279)</value> </param> <param> <key>_rotation</key> @@ -613,10 +659,10 @@ </param> </block> <block> - <key>gr_vector_source_x</key> + <key>gr_null_sink</key> <param> <key>id</key> - <value>gr_vector_source_x_0</value> + <value>gr_null_sink_0</value> </param> <param> <key>_enabled</key> @@ -624,15 +670,7 @@ </param> <param> <key>type</key> - <value>byte</value> - </param> - <param> - <key>vector</key> - <value>0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50</value> - </param> - <param> - <key>repeat</key> - <value>True</value> + <value>complex</value> </param> <param> <key>vlen</key> @@ -640,7 +678,7 @@ </param> <param> <key>_coordinate</key> - <value>(234, 126)</value> + <value>(859, 279)</value> </param> <param> <key>_rotation</key> @@ -648,34 +686,30 @@ </param> </block> <block> - <key>gr_file_source</key> + <key>gr_ctrlport_probe2_c</key> <param> <key>id</key> - <value>gr_file_source_0</value> + <value>phase_probe2</value> </param> <param> <key>_enabled</key> - <value>False</value> - </param> - <param> - <key>file</key> - <value>/dev/urandom</value> + <value>True</value> </param> <param> - <key>type</key> - <value>byte</value> + <key>name</key> + <value>phase locked</value> </param> <param> - <key>repeat</key> - <value>True</value> + <key>desc</key> + <value>Constellation Points</value> </param> <param> - <key>vlen</key> - <value>1</value> + <key>len</key> + <value>1024</value> </param> <param> <key>_coordinate</key> - <value>(228, 56)</value> + <value>(681, 379)</value> </param> <param> <key>_rotation</key> @@ -683,65 +717,58 @@ </param> </block> <block> - <key>blocks_packed_to_unpacked_xx</key> + <key>options</key> <param> <key>id</key> - <value>blocks_packed_to_unpacked_xx_0</value> + <value>pfb_sync_test_qt</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>byte</value> + <key>title</key> + <value></value> </param> <param> - <key>bits_per_chunk</key> - <value>8</value> + <key>author</key> + <value></value> </param> <param> - <key>endianness</key> - <value>gr.GR_MSB_FIRST</value> + <key>description</key> + <value></value> </param> <param> - <key>num_ports</key> - <value>1</value> + <key>window_size</key> + <value>1280,1024</value> </param> <param> - <key>_coordinate</key> - <value>(419, 56)</value> + <key>generate_options</key> + <value>qt_gui</value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>category</key> + <value>Custom</value> </param> - </block> - <block> - <key>blocks_throttle</key> <param> - <key>id</key> - <value>blocks_throttle_0</value> + <key>run_options</key> + <value>prompt</value> </param> <param> - <key>_enabled</key> + <key>run</key> <value>True</value> </param> <param> - <key>type</key> - <value>byte</value> - </param> - <param> - <key>samples_per_second</key> - <value>samp_rate</value> + <key>max_nouts</key> + <value>0</value> </param> <param> - <key>vlen</key> - <value>1</value> + <key>realtime_scheduling</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(623, 64)</value> + <value>(10, 10)</value> </param> <param> <key>_rotation</key> @@ -756,12 +783,6 @@ </connection> <connection> <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> - <sink_block_id>digital_costas_loop_cc_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> <sink_block_id>qtgui_const_sink_x_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -792,7 +813,7 @@ </connection> <connection> <source_block_id>digital_costas_loop_cc_0</source_block_id> - <sink_block_id>probe2_c_0</sink_block_id> + <sink_block_id>phase_probe2</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> @@ -809,8 +830,20 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_file_source_0</source_block_id> - <sink_block_id>blocks_packed_to_unpacked_xx_0</sink_block_id> + <source_block_id>channels_channel_model_0</source_block_id> + <sink_block_id>received_probe2</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> + <sink_block_id>time_probe2</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> + <sink_block_id>digital_costas_loop_cc_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc b/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc index 20e8e7f7d..5b0bfeb79 100644 --- a/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc +++ b/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc @@ -523,10 +523,10 @@ </param> </block> <block> - <key>gr_file_source</key> + <key>blocks_file_source</key> <param> <key>id</key> - <value>gr_file_source_0</value> + <value>blocks_file_source_0</value> </param> <param> <key>_enabled</key> @@ -654,7 +654,7 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_file_source_0</source_block_id> + <source_block_id>blocks_file_source_0</source_block_id> <sink_block_id>blocks_packed_to_unpacked_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> diff --git a/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py b/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py index ac060c0cc..2f638e26e 100755 --- a/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py +++ b/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py @@ -50,7 +50,7 @@ class wfm_rx_block (gr.top_block): # build graph - self.src = gr.file_source(gr.sizeof_gr_complex, input_filename, False) + self.src = blocks.file_source(gr.sizeof_gr_complex, input_filename, False) adc_rate = 64e6 # 64 MS/s usrp_decim = 200 @@ -80,7 +80,7 @@ class wfm_rx_block (gr.top_block): # wave file as final sink if 1: - sink = gr.wavfile_sink(output_filename, 2, int(audio_rate), 16) + sink = blocks.wavfile_sink(output_filename, 2, int(audio_rate), 16) else: sink = audio.sink (int (audio_rate), options.audio_output, diff --git a/gnuradio-core/src/examples/network/audio_sink.py b/gnuradio-core/src/examples/network/audio_sink.py index 72a678816..0e412de5a 100755 --- a/gnuradio-core/src/examples/network/audio_sink.py +++ b/gnuradio-core/src/examples/network/audio_sink.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import sys @@ -34,8 +35,7 @@ except ImportError: class audio_sink(gr.top_block): def __init__(self, host, port, pkt_size, sample_rate, eof, wait): gr.top_block.__init__(self, "audio_sink") - src = gr.udp_source(gr.sizeof_float, host, port, pkt_size, - eof=eof, wait=wait) + src = blocks.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof) dst = audio.sink(sample_rate) self.connect(src, dst) @@ -51,8 +51,6 @@ if __name__ == '__main__': help="audio signal sample rate [default=%default]") parser.add_option("", "--no-eof", action="store_true", default=False, help="don't send EOF on disconnect") - parser.add_option("", "--no-wait", action="store_true", default=False, - help="don't wait for source") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() @@ -61,7 +59,7 @@ if __name__ == '__main__': # Create an instance of a hierarchical block top_block = audio_sink(options.host, options.port, options.packet_size, options.sample_rate, - not options.no_eof, not options.no_wait) + not options.no_eof) try: # Run forever diff --git a/gnuradio-core/src/examples/network/audio_source.py b/gnuradio-core/src/examples/network/audio_source.py index 0baf7d2e9..577beff84 100755 --- a/gnuradio-core/src/examples/network/audio_source.py +++ b/gnuradio-core/src/examples/network/audio_source.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import sys @@ -35,7 +36,7 @@ class audio_source(gr.top_block): def __init__(self, host, port, pkt_size, sample_rate, eof): gr.top_block.__init__(self, "audio_source") self.audio = audio.source(sample_rate) - self.sink = gr.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) + self.sink = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) self.connect(self.audio, self.sink) if __name__ == '__main__': diff --git a/gnuradio-core/src/examples/network/dial_tone_sink.py b/gnuradio-core/src/examples/network/dial_tone_sink.py index 83ad376c0..fee6ded84 100755 --- a/gnuradio-core/src/examples/network/dial_tone_sink.py +++ b/gnuradio-core/src/examples/network/dial_tone_sink.py @@ -21,14 +21,14 @@ # from gnuradio import gr, audio +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser class dial_tone_sink(gr.top_block): - def __init__(self, host, port, pkt_size, sample_rate, eof, wait): + def __init__(self, host, port, pkt_size, sample_rate, eof): gr.top_block.__init__(self, "dial_tone_sink") - udp = gr.udp_source(gr.sizeof_float, host, port, pkt_size, - eof=eof, wait=wait) + udp = blokcs.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof) sink = audio.sink(sample_rate) self.connect(udp, sink) @@ -44,8 +44,6 @@ if __name__ == '__main__': help="audio signal sample rate [default=%default]") parser.add_option("", "--no-eof", action="store_true", default=False, help="don't send EOF on disconnect") - parser.add_option("", "--no-wait", action="store_true", default=False, - help="don't wait for source") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() @@ -54,7 +52,7 @@ if __name__ == '__main__': # Create an instance of a hierarchical block top_block = dial_tone_sink(options.host, options.port, options.packet_size, options.sample_rate, - not options.no_eof, not options.no_wait) + not options.no_eof) try: # Run forever diff --git a/gnuradio-core/src/examples/network/dial_tone_source.py b/gnuradio-core/src/examples/network/dial_tone_source.py index d0d3cc7a8..44f05dc83 100755 --- a/gnuradio-core/src/examples/network/dial_tone_source.py +++ b/gnuradio-core/src/examples/network/dial_tone_source.py @@ -47,7 +47,7 @@ class dial_tone_source(gr.top_block): # Throttle needed here to account for the other side's audio card sampling rate thr = blocks.throttle(gr.sizeof_float, sample_rate) - sink = gr.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) + sink = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) self.connect(src0, (add, 0)) self.connect(src1, (add, 1)) self.connect(add, thr, sink) diff --git a/gnuradio-core/src/examples/network/vector_sink.py b/gnuradio-core/src/examples/network/vector_sink.py index e84a27d9f..c0397d1e4 100755 --- a/gnuradio-core/src/examples/network/vector_sink.py +++ b/gnuradio-core/src/examples/network/vector_sink.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -28,9 +29,8 @@ class vector_sink(gr.top_block): def __init__(self, host, port, pkt_size, eof, wait): gr.top_block.__init__(self, "vector_sink") - udp = gr.udp_source(gr.sizeof_float, host, port, pkt_size, - eof=eof, wait=wait) - sink = gr.file_sink(gr.sizeof_float, "received.dat") + udp = blocks.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof) + sink = blocks.file_sink(gr.sizeof_float, "received.dat") self.connect(udp, sink) if __name__ == "__main__": @@ -43,8 +43,6 @@ if __name__ == "__main__": help="packet size.") parser.add_option("", "--no-eof", action="store_true", default=False, help="don't send EOF on disconnect") - parser.add_option("", "--no-wait", action="store_true", default=False, - help="don't wait for source") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() @@ -53,7 +51,7 @@ if __name__ == "__main__": # Create an instance of a hierarchical block top_block = vector_sink(options.host, options.port, options.packet_size, - not options.no_eof, not options.no_wait) + not options.no_eof) try: # Run forever diff --git a/gnuradio-core/src/examples/network/vector_source.py b/gnuradio-core/src/examples/network/vector_source.py index d322dda3b..b960a6d96 100755 --- a/gnuradio-core/src/examples/network/vector_source.py +++ b/gnuradio-core/src/examples/network/vector_source.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -29,7 +30,7 @@ class vector_source(gr.top_block): gr.top_block.__init__(self, "vector_source") data = [i*0.01 for i in range(1000)] vec = gr.vector_source_f(data, True) - udp = gr.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) + udp = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) self.connect(vec, udp) if __name__ == '__main__': diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt index 89371a8b8..72b9f9bde 100644 --- a/gnuradio-core/src/lib/CMakeLists.txt +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -66,25 +66,25 @@ link_directories( ${FFTW3F_LIBRARY_DIRS} ) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Setup library ######################################################################## -# Only use if log4cxx is installed +# Only use if log4cpp is installed # Define ENABLE_GR_LOG so .h and .cc files can turn actual # logging and insert dummy functions. -#if(LOG4CXX_FOUND) +#if(LOG4CPP_FOUND) # add_definitions(-DENABLE_GR_LOG) -#endif(LOG4CXX_FOUND) +#endif(LOG4CPP_FOUND) list(APPEND gnuradio_core_libs gruel ${Boost_LIBRARIES} ${FFTW3F_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) if(FFTW3F_THREADS_LIBRARIES) @@ -161,6 +161,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} ${LOG4CXX_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/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index a8ad8573b..e3dc18520 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -53,8 +53,6 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_add_const_ss_generic.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.cc ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.cc ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.c ) @@ -81,8 +79,6 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_test_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_add_const_ss.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_15_1_0.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_32k.h @@ -99,7 +95,6 @@ if(ENABLE_PYTHON) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/general.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_constants.i - ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig" ) diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index dabdb1bdd..bcf4392bb 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -22,7 +22,6 @@ %{ -#include <gri_control_loop.h> #include <gr_nop.h> #include <gr_null_sink.h> #include <gr_null_source.h> @@ -50,7 +49,6 @@ #include <gr_vector_map.h> %} -%include "gri_control_loop.i" %include "gr_nop.i" %include "gr_null_sink.i" %include "gr_null_source.i" diff --git a/gnuradio-core/src/lib/general/gri_add_const_ss.h b/gnuradio-core/src/lib/general/gri_add_const_ss.h deleted file mode 100644 index 7433ee41b..000000000 --- a/gnuradio-core/src/lib/general/gri_add_const_ss.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- 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_ADD_CONST_SS_H -#define INCLUDED_GRI_ADD_CONST_SS_H - -/*! - * \brief Low-level, high-speed add_const_ss primitive - * - * copy src to dst adding konst - */ - -void -gri_add_const_ss (short *dst, const short *src, int nshorts, short konst); - - -#endif /* _INCLUDED_GRI_ADD_CONST_SS_H_ */ diff --git a/gnuradio-core/src/lib/general/gri_control_loop.cc b/gnuradio-core/src/lib/general/gri_control_loop.cc deleted file mode 100644 index bb3c4a326..000000000 --- a/gnuradio-core/src/lib/general/gri_control_loop.cc +++ /dev/null @@ -1,210 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gri_control_loop.h> -#include <gr_math.h> -#include <stdexcept> - -#define M_TWOPI (2.0f*M_PI) - -gri_control_loop::gri_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); -} - -gri_control_loop::~gri_control_loop() -{ -} - -void -gri_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 -gri_control_loop::advance_loop(float error) -{ - d_freq = d_freq + d_beta * error; - d_phase = d_phase + d_freq + d_alpha * error; -} - - -void -gri_control_loop::phase_wrap() -{ - while(d_phase>M_TWOPI) - d_phase -= M_TWOPI; - while(d_phase<-M_TWOPI) - d_phase += M_TWOPI; -} - -void -gri_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 -gri_control_loop::set_loop_bandwidth(float bw) -{ - if(bw < 0) { - throw std::out_of_range ("gri_control_loop: invalid bandwidth. Must be >= 0."); - } - - d_loop_bw = bw; - update_gains(); -} - -void -gri_control_loop::set_damping_factor(float df) -{ - if(df < 0 || df > 1.0) { - throw std::out_of_range ("gri_control_loop: invalid damping factor. Must be in [0,1]."); - } - - d_damping = df; - update_gains(); -} - -void -gri_control_loop::set_alpha(float alpha) -{ - if(alpha < 0 || alpha > 1.0) { - throw std::out_of_range ("gri_control_loop: invalid alpha. Must be in [0,1]."); - } - d_alpha = alpha; -} - -void -gri_control_loop::set_beta(float beta) -{ - if(beta < 0 || beta > 1.0) { - throw std::out_of_range ("gri_control_loop: invalid beta. Must be in [0,1]."); - } - d_beta = beta; -} - -void -gri_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 -gri_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 -gri_control_loop::set_max_freq(float freq) -{ - d_max_freq = freq; -} - -void -gri_control_loop::set_min_freq(float freq) -{ - d_min_freq = freq; -} - -/******************************************************************* - GET FUNCTIONS -*******************************************************************/ - - -float -gri_control_loop::get_loop_bandwidth() const -{ - return d_loop_bw; -} - -float -gri_control_loop::get_damping_factor() const -{ - return d_damping; -} - -float -gri_control_loop::get_alpha() const -{ - return d_alpha; -} - -float -gri_control_loop::get_beta() const -{ - return d_beta; -} - -float -gri_control_loop::get_frequency() const -{ - return d_freq; -} - -float -gri_control_loop::get_phase() const -{ - return d_phase; -} - -float -gri_control_loop::get_max_freq() const -{ - return d_max_freq; -} - -float -gri_control_loop::get_min_freq() const -{ - return d_min_freq; -} diff --git a/gnuradio-core/src/lib/general/gri_control_loop.h b/gnuradio-core/src/lib/general/gri_control_loop.h deleted file mode 100644 index 46aa6ae24..000000000 --- a/gnuradio-core/src/lib/general/gri_control_loop.h +++ /dev/null @@ -1,231 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - -#ifndef GRI_CONTROL_LOOP -#define GRI_CONTROL_LOOP - -#include <gr_core_api.h> - -class GR_CORE_API gri_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: - gri_control_loop() {}; - gri_control_loop(float loop_bw, float max_freq, float min_freq); - virtual ~gri_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 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 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; -}; - -#endif /* GRI_CONTROL_LOOP */ diff --git a/gnuradio-core/src/lib/general/gri_control_loop.i b/gnuradio-core/src/lib/general/gri_control_loop.i deleted file mode 100644 index 8a23207e5..000000000 --- a/gnuradio-core/src/lib/general/gri_control_loop.i +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - - -class gri_control_loop -{ - public: - gri_control_loop(float loop_bw, float max_freq, float min_freq); - virtual ~gri_control_loop(); - - void update_gains(); - void advance_loop(float error); - void phase_wrap(); - void frequency_limit(); - - /******************************************************************* - SET FUNCTIONS - *******************************************************************/ - - void set_loop_bandwidth(float bw); - void set_damping_factor(float df); - void set_alpha(float alpha); - void set_beta(float beta); - void set_frequency(float freq); - void set_phase(float phase); - - - /******************************************************************* - GET FUNCTIONS - *******************************************************************/ - - float get_loop_bandwidth() const; - float get_damping_factor() const; - float get_alpha() const; - float get_beta() const; - float get_frequency() const; - float get_phase() const; -}; 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 a9e3a0a3e..2b8207c02 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 b9126dc7b..b7de1d101 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 d4a940911..ee0ebf378 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 9f68f9cf1..19272ee24 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 fe02c1346..041cc47a4 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 4986c68a3..1f1479f94 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/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt index dc0ffe62b..7aeea798c 100644 --- a/gnuradio-core/src/lib/io/CMakeLists.txt +++ b/gnuradio-core/src/lib/io/CMakeLists.txt @@ -37,7 +37,6 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4937.cc ${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.cc ${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_wavfile.cc ) ######################################################################## @@ -58,7 +57,6 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/microtune_eval_board_defs.h ${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.h ${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_wavfile.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel" ) @@ -80,21 +78,11 @@ endif(ENABLE_PYTHON) # Handle triple-threat files that have cc, h, and i ######################################################################## set(gr_core_io_triple_threats - gr_file_sink - gr_file_sink_base - gr_file_source - gr_file_descriptor_sink - gr_file_descriptor_source microtune_xxxx_eval_board microtune_4702_eval_board microtune_4937_eval_board ppio sdr_1000 - gr_udp_sink - gr_udp_source - gr_wavfile_source - gr_wavfile_sink - gr_tagged_file_sink ) foreach(file_tt ${gr_core_io_triple_threats}) diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc deleted file mode 100644 index 099d46dbd..000000000 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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_file_descriptor_sink.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 - -gr_file_descriptor_sink::gr_file_descriptor_sink (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) -{ -} - -gr_file_descriptor_sink_sptr -gr_make_file_descriptor_sink (size_t itemsize, int fd) -{ - return gnuradio::get_initial_sptr(new gr_file_descriptor_sink (itemsize, fd)); -} - -gr_file_descriptor_sink::~gr_file_descriptor_sink () -{ - close (d_fd); -} - -int -gr_file_descriptor_sink::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 ("gr_file_descriptor_sink"); - return -1; // indicate we're done - } - } - else { - byte_size -= r; - inbuf += r; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i deleted file mode 100644 index 2c256e44d..000000000 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,file_descriptor_sink) - -gr_file_descriptor_sink_sptr -gr_make_file_descriptor_sink (size_t itemsize, int fd); - -class gr_file_descriptor_sink : public gr_sync_block -{ - protected: - gr_file_descriptor_sink (size_t itemsize, int fd); - - public: - ~gr_file_descriptor_sink (); -}; diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc b/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc deleted file mode 100644 index a63abf96b..000000000 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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_file_descriptor_source.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 - -gr_file_descriptor_source::gr_file_descriptor_source (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) -{ -} - -// public constructor that returns a shared_ptr - -gr_file_descriptor_source_sptr -gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat) -{ - return gr_file_descriptor_source_sptr ( - new gr_file_descriptor_source (itemsize, fd, repeat)); -} - -gr_file_descriptor_source::~gr_file_descriptor_source () -{ - close (d_fd); - delete [] d_residue; -} - -int -gr_file_descriptor_source::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; -} - -int -gr_file_descriptor_source::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 -gr_file_descriptor_source::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; -} diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.h b/gnuradio-core/src/lib/io/gr_file_descriptor_source.h deleted file mode 100644 index ebabd81ed..000000000 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- 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_GR_FILE_DESCRIPTOR_SOURCE_H -#define INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_file_descriptor_source; -typedef boost::shared_ptr<gr_file_descriptor_source> gr_file_descriptor_source_sptr; - -GR_CORE_API gr_file_descriptor_source_sptr -gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat = false); - -/*! - * \brief Read stream from file descriptor. - * \ingroup source_blk - */ - -class GR_CORE_API gr_file_descriptor_source : public gr_sync_block -{ - friend GR_CORE_API gr_file_descriptor_source_sptr - gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat); - private: - size_t d_itemsize; - int d_fd; - bool d_repeat; - - unsigned char *d_residue; - unsigned long d_residue_len; - - protected: - gr_file_descriptor_source (size_t itemsize, int fd, bool repeat); - - int read_items (char *buf, int nitems); - int handle_residue (char *buf, int nbytes_read); - void flush_residue () { d_residue_len = 0; } - - - public: - ~gr_file_descriptor_source (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H */ diff --git a/gnuradio-core/src/lib/io/gr_file_sink.cc b/gnuradio-core/src/lib/io/gr_file_sink.cc deleted file mode 100644 index 10c8360cb..000000000 --- a/gnuradio-core/src/lib/io/gr_file_sink.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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_file_sink.h> -#include <gr_io_signature.h> -#include <stdexcept> - - -gr_file_sink_sptr -gr_make_file_sink (size_t itemsize, const char *filename) -{ - return gnuradio::get_initial_sptr(new gr_file_sink (itemsize, filename)); -} - -gr_file_sink::gr_file_sink(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)), - gr_file_sink_base(filename, true), - d_itemsize(itemsize) -{ -} - -gr_file_sink::~gr_file_sink () -{ -} - -int -gr_file_sink::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; -} diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.cc b/gnuradio-core/src/lib/io/gr_file_sink_base.cc deleted file mode 100644 index d0aca418e..000000000 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2007,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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_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 - -gr_file_sink_base::gr_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"); -} - -gr_file_sink_base::~gr_file_sink_base () -{ - close(); - if (d_fp){ - fclose(d_fp); - d_fp = 0; - } -} - -bool -gr_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 -gr_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 -gr_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 -gr_file_sink_base::set_unbuffered(bool unbuffered) -{ - d_unbuffered = unbuffered; -} diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.h b/gnuradio-core/src/lib/io/gr_file_sink_base.h deleted file mode 100644 index 8a70cee76..000000000 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 <gr_core_api.h> -#include <boost/thread.hpp> -#include <cstdio> - -/*! - * \brief Common base class for file sinks - */ -class GR_CORE_API gr_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: - gr_file_sink_base(const char *filename, bool is_binary); - - public: - ~gr_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); -}; - - -#endif /* INCLUDED_GR_FILE_SINK_BASE_H */ diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.i b/gnuradio-core/src/lib/io/gr_file_sink_base.i deleted file mode 100644 index 993dba277..000000000 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.i +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR 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. - */ -class gr_file_sink_base -{ - protected: - gr_file_sink_base(const char *filename, bool is_binary); - - public: - ~gr_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 mode for slow outputs - */ - void set_unbuffered(bool unbuffered); -}; diff --git a/gnuradio-core/src/lib/io/gr_file_source.cc b/gnuradio-core/src/lib/io/gr_file_source.cc deleted file mode 100644 index 6da7abac2..000000000 --- a/gnuradio-core/src/lib/io/gr_file_source.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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/thread.h> -#include <gr_file_source.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <stdio.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 - -gr_file_source::gr_file_source(size_t itemsize, const char *filename, bool repeat) - : gr_sync_block("file_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, itemsize)), - d_itemsize(itemsize), d_fp(0), d_new_fp (0), d_repeat(repeat), - d_updated(false) -{ - open(filename, repeat); -} - -// public constructor that returns a shared_ptr - -gr_file_source_sptr -gr_make_file_source (size_t itemsize, const char *filename, bool repeat) -{ - return gnuradio::get_initial_sptr(new gr_file_source (itemsize, filename, repeat)); -} - -gr_file_source::~gr_file_source () -{ - close(); - if(d_fp) { - fclose(d_fp); - d_fp = 0; - } -} - -int -gr_file_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *o = (char *) output_items[0]; - int i; - int size = noutput_items; - - do_update(); // update d_fp is reqd - if(d_fp == NULL) - throw std::runtime_error("work with file not open"); - - gruel::scoped_lock lock(fp_mutex); // hold for the rest of this function - while (size) { - i = fread(o, d_itemsize, size, (FILE *) d_fp); - - size -= i; - o += i * d_itemsize; - - if (size == 0) // done - break; - - if (i > 0) // short read, try again - continue; - - // We got a zero from fread. This is either EOF or error. In - // any event, if we're in repeat mode, seek back to the beginning - // of the file and try again, else break - - if (!d_repeat) - break; - - if (fseek ((FILE *) d_fp, 0, SEEK_SET) == -1) { - std::stringstream s; - s << "[" << __FILE__ << "]" << " fseek failed" << std::endl; - throw std::runtime_error(s.str()); - } - } - - if (size > 0){ // EOF or error - if (size == noutput_items) // we didn't read anything; say we're done - return -1; - return noutput_items - size; // else return partial result - } - - return noutput_items; -} - -bool -gr_file_source::seek (long seek_point, int whence) -{ - // obtain exclusive access for duration of this function - gruel::scoped_lock lock(fp_mutex); - return fseek((FILE *) d_fp, seek_point * d_itemsize, whence) == 0; -} - -void -gr_file_source::open(const char *filename, bool repeat) -{ - // obtain exclusive access for duration of this function - gruel::scoped_lock lock(fp_mutex); - - int fd; - - // we use "open" to use to the O_LARGEFILE flag - 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_new_fp) { - fclose(d_new_fp); - d_new_fp = 0; - } - - if((d_new_fp = fdopen (fd, "rb")) == NULL) { - perror(filename); - ::close(fd); // don't leak file descriptor if fdopen fails - throw std::runtime_error("can't open file"); - } - - d_updated = true; - d_repeat = repeat; -} - -void -gr_file_source::close() -{ - // obtain exclusive access for duration of this function - gruel::scoped_lock lock(fp_mutex); - - if(d_new_fp != NULL) { - fclose(d_new_fp); - d_new_fp = NULL; - } - d_updated = true; -} - -void -gr_file_source::do_update() -{ - if(d_updated) { - gruel::scoped_lock lock(fp_mutex); // hold while in scope - - if(d_fp) - fclose(d_fp); - - d_fp = d_new_fp; // install new file pointer - d_new_fp = 0; - d_updated = false; - } -} diff --git a/gnuradio-core/src/lib/io/gr_file_source.h b/gnuradio-core/src/lib/io/gr_file_source.h deleted file mode 100644 index 0478fba04..000000000 --- a/gnuradio-core/src/lib/io/gr_file_source.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- 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_GR_FILE_SOURCE_H -#define INCLUDED_GR_FILE_SOURCE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <boost/thread/mutex.hpp> - -class gr_file_source; -typedef boost::shared_ptr<gr_file_source> gr_file_source_sptr; - -GR_CORE_API gr_file_source_sptr -gr_make_file_source (size_t itemsize, const char *filename, bool repeat = false); - -/*! - * \brief Read stream from file - * \ingroup source_blk - */ - -class GR_CORE_API gr_file_source : public gr_sync_block -{ - private: - size_t d_itemsize; - FILE *d_fp; - FILE *d_new_fp; - bool d_repeat; - bool d_updated; - - protected: - gr_file_source(size_t itemsize, const char *filename, bool repeat); - - void do_update(); - - boost::mutex fp_mutex; - - public: - /*! - * \brief Create a file source. - * - * Opens \p filename as a source of items into a flowgraph. The data - * is expected to be in binary format, item after item. The \p - * itemsize of the block determines the conversion from bits to - * items. - * - * If \p repeat is turned on, the file will repeat the file after - * it's reached the end. - * - * \param itemsize the size of each item in the file, in bytes - * \param filename name of the file to source from - * \param repeat repeat file from start - */ - friend GR_CORE_API gr_file_source_sptr - gr_make_file_source(size_t itemsize, - const char *filename, - bool repeat); - - ~gr_file_source(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - /*! - * \brief Seek file to \p seek_point relative to \p whence - * - * \param seek_point sample offset in file - * \param whence one of SEEK_SET, SEEK_CUR, SEEK_END (man fseek) - */ - bool seek(long seek_point, int whence); - - /*! - * \brief Opens a new file. - * - * \param filename name of the file to source from - * \param repeat repeat file from start - */ - void open(const char *filename, bool repeat); - - /*! - * \brief Close the file handle. - */ - void close(); - -}; - -#endif /* INCLUDED_GR_FILE_SOURCE_H */ diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc deleted file mode 100644 index 3288fcdd6..000000000 --- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc +++ /dev/null @@ -1,229 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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_tagged_file_sink.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 - - -gr_tagged_file_sink::gr_tagged_file_sink (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; -} - -gr_tagged_file_sink_sptr -gr_make_tagged_file_sink (size_t itemsize, double samp_rate) -{ - return gnuradio::get_initial_sptr(new gr_tagged_file_sink (itemsize, samp_rate)); -} - -gr_tagged_file_sink::~gr_tagged_file_sink () -{ -} - -int -gr_tagged_file_sink::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::string_to_symbol("burst"); - pmt::pmt_t tkey = 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::to_uint64(pmt::tuple_ref(time, 0)); - double tfrac = pmt::to_double(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::eqv((*vitr).key, bkey)) && - 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::to_uint64(pmt::tuple_ref(time, 0)); - double tfrac = pmt::to_double(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::eqv((*vitr).key, bkey)) && - 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("gr_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("gr_tagged_file_sink: error writing file"); - } - } - idx = noutput_items; - } - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.h b/gnuradio-core/src/lib/io/gr_tagged_file_sink.h deleted file mode 100644 index d6f931a67..000000000 --- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 <gr_core_api.h> -#include <gr_sync_block.h> -#include <cstdio> // for FILE - -class gr_tagged_file_sink; -typedef boost::shared_ptr<gr_tagged_file_sink> gr_tagged_file_sink_sptr; - -GR_CORE_API gr_tagged_file_sink_sptr gr_make_tagged_file_sink (size_t itemsize, - double samp_rate); - -/*! - * \brief Write stream to file descriptor. - * \ingroup sink_blk - */ - -class GR_CORE_API gr_tagged_file_sink : public gr_sync_block -{ - friend GR_CORE_API gr_tagged_file_sink_sptr gr_make_tagged_file_sink (size_t itemsize, - double samp_rate); - - 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; - - protected: - gr_tagged_file_sink (size_t itemsize, double samp_rate); - - public: - ~gr_tagged_file_sink (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_TAGGED_FILE_SINK_H */ diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.cc b/gnuradio-core/src/lib/io/gr_udp_sink.cc deleted file mode 100644 index 6b1d34ef7..000000000 --- a/gnuradio-core/src/lib/io/gr_udp_sink.cc +++ /dev/null @@ -1,304 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 <boost/asio.hpp> - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <gr_udp_sink.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <errno.h> -#include <stdio.h> -#include <string.h> -#if defined(HAVE_NETDB_H) -#include <netdb.h> -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> //usually included by <netdb.h>? -#endif -typedef void* optval_t; -#elif defined(HAVE_WINDOWS_H) -// if not posix, assume winsock -#define USING_WINSOCK -#include <winsock2.h> -#include <ws2tcpip.h> -#define SHUT_RDWR 2 -typedef char* optval_t; -#endif - -#include <gruel/thread.h> - -#define SNK_VERBOSE 0 - -static int is_error( int perr ) -{ - // Compare error to posix error code; return nonzero if match. -#if defined(USING_WINSOCK) -#define ENOPROTOOPT 109 -#define ECONNREFUSED 111 - // All codes to be checked for must be defined below - int werr = WSAGetLastError(); - switch( werr ) { - case WSAETIMEDOUT: - return( perr == EAGAIN ); - case WSAENOPROTOOPT: - return( perr == ENOPROTOOPT ); - case WSAECONNREFUSED: - return( perr == ECONNREFUSED ); - default: - fprintf(stderr,"gr_udp_source/is_error: unknown error %d\n", perr ); - throw std::runtime_error("internal error"); - } - return 0; -#else - return( perr == errno ); -#endif -} - -static void report_error( const char *msg1, const char *msg2 ) -{ - // Deal with errors, both posix and winsock -#if defined(USING_WINSOCK) - int werr = WSAGetLastError(); - fprintf(stderr, "%s: winsock error %d\n", msg1, werr ); -#else - perror(msg1); -#endif - if( msg2 != NULL ) - throw std::runtime_error(msg2); - return; -} - -gr_udp_sink::gr_udp_sink (size_t itemsize, - const char *host, unsigned short 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_socket(-1), d_connected(false) -{ -#if defined(USING_WINSOCK) // for Windows (with MinGW) - // initialize winsock DLL - WSADATA wsaData; - int iResult = WSAStartup( MAKEWORD(2,2), &wsaData ); - if( iResult != NO_ERROR ) { - report_error( "gr_udp_source WSAStartup", "can't open socket" ); - } -#endif - - // create socket - d_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if(d_socket == -1) { - report_error("socket open","can't open socket"); - } - - // Don't wait when shutting down - linger lngr; - lngr.l_onoff = 1; - lngr.l_linger = 0; - if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (optval_t)&lngr, sizeof(linger)) == -1) { - if( !is_error(ENOPROTOOPT) ) { // no SO_LINGER for SOCK_DGRAM on Windows - report_error("SO_LINGER","can't set socket option SO_LINGER"); - } - } - - // Get the destination address - connect(host, port); -} - -// public constructor that returns a shared_ptr - -gr_udp_sink_sptr -gr_make_udp_sink (size_t itemsize, - const char *host, unsigned short port, - int payload_size, bool eof) -{ - return gnuradio::get_initial_sptr(new gr_udp_sink (itemsize, - host, port, - payload_size, eof)); -} - -gr_udp_sink::~gr_udp_sink () -{ - if (d_connected) - disconnect(); - - if (d_socket != -1){ - shutdown(d_socket, SHUT_RDWR); -#if defined(USING_WINSOCK) - closesocket(d_socket); -#else - ::close(d_socket); -#endif - d_socket = -1; - } - -#if defined(USING_WINSOCK) // for Windows (with MinGW) - // free winsock resources - WSACleanup(); -#endif -} - -int -gr_udp_sink::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; - - #if SNK_VERBOSE - printf("Entered udp_sink\n"); - #endif - - 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) { - r = send(d_socket, (in+bytes_sent), bytes_to_send, 0); - if(r == -1) { // error on send command - if( is_error(ECONNREFUSED) ) - r = bytes_to_send; // discard data until receiver is started - else { - report_error("udp_sink",NULL); // there should be no error case where - return -1; // this function should not exit immediately - } - } - } - else - r = bytes_to_send; // discarded for lack of connection - bytes_sent += r; - - #if SNK_VERBOSE - printf("\tbyte sent: %d bytes\n", r); - #endif - } - - #if SNK_VERBOSE - printf("Sent: %d bytes (noutput_items: %d)\n", bytes_sent, noutput_items); - #endif - - return noutput_items; -} - -void gr_udp_sink::connect( const char *host, unsigned short port ) -{ - if(d_connected) - disconnect(); - - if(host != NULL ) { - // Get the destination address - struct addrinfo *ip_dst; - struct addrinfo hints; - memset( (void*)&hints, 0, sizeof(hints) ); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_protocol = IPPROTO_UDP; - char port_str[12]; - sprintf( port_str, "%d", port ); - - // FIXME leaks if report_error throws below - int ret = getaddrinfo( host, port_str, &hints, &ip_dst ); - if( ret != 0 ) - report_error("gr_udp_source/getaddrinfo", - "can't initialize destination socket" ); - - // don't need d_mutex lock when !d_connected - if(::connect(d_socket, ip_dst->ai_addr, ip_dst->ai_addrlen) == -1) { - report_error("socket connect","can't connect to socket"); - } - d_connected = true; - - freeaddrinfo(ip_dst); - } - - return; -} - -void gr_udp_sink::disconnect() -{ - if(!d_connected) - return; - - #if SNK_VERBOSE - printf("gr_udp_sink disconnecting\n"); - #endif - - gruel::scoped_lock guard(d_mutex); // protect d_socket from work() - - // Send a few zero-length packets to signal receiver we are done - if(d_eof) { - int i; - for( i = 0; i < 3; i++ ) - (void) send( d_socket, NULL, 0, 0 ); // ignore errors - } - - // Sending EOF can produce ERRCONNREFUSED errors that won't show up - // until the next send or recv, which might confuse us if it happens - // on a new connection. The following does a nonblocking recv to - // clear any such errors. - timeval timeout; - timeout.tv_sec = 0; // zero time for immediate return - timeout.tv_usec = 0; - fd_set readfds; - FD_ZERO(&readfds); - FD_SET(d_socket, &readfds); - int r = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout); - if(r < 0) { - #if SNK_VERBOSE - report_error("udp_sink/select",NULL); - #endif - } - else if(r > 0) { // call recv() to get error return - r = recv(d_socket, (char*)&readfds, sizeof(readfds), 0); - if(r < 0) { - #if SNK_VERBOSE - report_error("udp_sink/recv",NULL); - #endif - } - } - - // Since I can't find any way to disconnect a datagram socket in Cygwin, - // we just leave it connected but disable sending. -#if 0 - // zeroed address structure should reset connection - struct sockaddr addr; - memset( (void*)&addr, 0, sizeof(addr) ); - // addr.sa_family = AF_UNSPEC; // doesn't work on Cygwin - // addr.sa_family = AF_INET; // doesn't work on Cygwin - - if(::connect(d_socket, &addr, sizeof(addr)) == -1) - report_error("socket connect","can't connect to socket"); -#endif - - d_connected = false; - - return; -} diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.h b/gnuradio-core/src/lib/io/gr_udp_sink.h deleted file mode 100644 index bf042a6d1..000000000 --- a/gnuradio-core/src/lib/io/gr_udp_sink.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 <gr_core_api.h> -#include <gr_sync_block.h> -#include <gruel/thread.h> - -class gr_udp_sink; -typedef boost::shared_ptr<gr_udp_sink> gr_udp_sink_sptr; - -GR_CORE_API gr_udp_sink_sptr -gr_make_udp_sink (size_t itemsize, - const char *host, unsigned short port, - int payload_size=1472, bool eof=true); - -/*! - * \brief Write stream to an UDP socket. - * \ingroup sink_blk - * - * \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 - */ - -class GR_CORE_API gr_udp_sink : public gr_sync_block -{ - friend GR_CORE_API gr_udp_sink_sptr gr_make_udp_sink (size_t itemsize, - const char *host, - unsigned short port, - int payload_size, bool eof); - private: - size_t d_itemsize; - - int d_payload_size; // maximum transmission unit (packet length) - bool d_eof; // send zero-length packet on disconnect - int d_socket; // handle to socket - bool d_connected; // are we connected? - gruel::mutex d_mutex; // protects d_socket and d_connected - - protected: - /*! - * \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 - */ - gr_udp_sink (size_t itemsize, - const char *host, unsigned short port, - int payload_size, bool eof); - - public: - ~gr_udp_sink (); - - /*! \brief return the PAYLOAD_SIZE of the socket */ - int payload_size() { return d_payload_size; } - - /*! \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. - */ - void connect( const char *host, unsigned short port ); - - /*! \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.*/ - void disconnect(); - - // should we export anything else? - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_UDP_SINK_H */ diff --git a/gnuradio-core/src/lib/io/gr_udp_source.cc b/gnuradio-core/src/lib/io/gr_udp_source.cc deleted file mode 100644 index eca8e89d0..000000000 --- a/gnuradio-core/src/lib/io/gr_udp_source.cc +++ /dev/null @@ -1,374 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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_udp_source.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <errno.h> -#include <stdio.h> -#include <string.h> - -#if defined(HAVE_NETDB_H) -#include <netdb.h> -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif -typedef void* optval_t; - -// ntohs() on FreeBSD may require both netinet/in.h and arpa/inet.h, in order -#if defined(HAVE_NETINET_IN_H) -#include <netinet/in.h> -#endif -#if defined(HAVE_ARPA_INET_H) -#include <arpa/inet.h> -#endif - -#elif defined(HAVE_WINDOWS_H) -// if not posix, assume winsock -#define USING_WINSOCK -#include <winsock2.h> -#include <ws2tcpip.h> -#define SHUT_RDWR 2 -typedef char* optval_t; -#endif - -#define USE_SELECT 1 // non-blocking receive on all platforms -#define USE_RCV_TIMEO 0 // non-blocking receive on all but Cygwin -#define SRC_VERBOSE 0 - -static int is_error( int perr ) -{ - // Compare error to posix error code; return nonzero if match. -#if defined(USING_WINSOCK) -#define ENOPROTOOPT 109 - // All codes to be checked for must be defined below - int werr = WSAGetLastError(); - switch( werr ) { - case WSAETIMEDOUT: - return( perr == EAGAIN ); - case WSAENOPROTOOPT: - return( perr == ENOPROTOOPT ); - default: - fprintf(stderr,"gr_udp_source/is_error: unknown error %d\n", perr ); - throw std::runtime_error("internal error"); - } - return 0; -#else - return( perr == errno ); -#endif -} - -static void report_error( const char *msg1, const char *msg2 ) -{ - // Deal with errors, both posix and winsock -#if defined(USING_WINSOCK) - int werr = WSAGetLastError(); - fprintf(stderr, "%s: winsock error %d\n", msg1, werr ); -#else - perror(msg1); -#endif - if( msg2 != NULL ) - throw std::runtime_error(msg2); - return; -} - -gr_udp_source::gr_udp_source(size_t itemsize, const char *host, - unsigned short port, int payload_size, - bool eof, bool wait) - : 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_wait(wait), d_socket(-1), d_residual(0), d_temp_offset(0) -{ - int ret = 0; - -#if defined(USING_WINSOCK) // for Windows (with MinGW) - // initialize winsock DLL - WSADATA wsaData; - int iResult = WSAStartup( MAKEWORD(2,2), &wsaData ); - if( iResult != NO_ERROR ) { - report_error( "gr_udp_source WSAStartup", "can't open socket" ); - } -#endif - - // Set up the address stucture for the source address and port numbers - // Get the source IP address from the host name - struct addrinfo *ip_src; // store the source IP address to use - struct addrinfo hints; - memset( (void*)&hints, 0, sizeof(hints) ); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_protocol = IPPROTO_UDP; - hints.ai_flags = AI_PASSIVE; - char port_str[12]; - sprintf( port_str, "%d", port ); - - // FIXME leaks if report_error throws below - ret = getaddrinfo( host, port_str, &hints, &ip_src ); - if( ret != 0 ) - report_error("gr_udp_source/getaddrinfo", - "can't initialize source socket" ); - - // FIXME leaks if report_error throws below - d_temp_buff = new char[d_payload_size]; // allow it to hold up to payload_size bytes - - // create socket - d_socket = socket(ip_src->ai_family, ip_src->ai_socktype, - ip_src->ai_protocol); - if(d_socket == -1) { - report_error("socket open","can't open socket"); - } - - // Turn on reuse address - int opt_val = 1; - if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (optval_t)&opt_val, sizeof(int)) == -1) { - report_error("SO_REUSEADDR","can't set socket option SO_REUSEADDR"); - } - - // Don't wait when shutting down - linger lngr; - lngr.l_onoff = 1; - lngr.l_linger = 0; - if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (optval_t)&lngr, sizeof(linger)) == -1) { - if( !is_error(ENOPROTOOPT) ) { // no SO_LINGER for SOCK_DGRAM on Windows - report_error("SO_LINGER","can't set socket option SO_LINGER"); - } - } - -#if USE_RCV_TIMEO - // Set a timeout on the receive function to not block indefinitely - // This value can (and probably should) be changed - // Ignored on Cygwin -#if defined(USING_WINSOCK) - DWORD timeout = 1000; // milliseconds -#else - timeval timeout; - timeout.tv_sec = 1; - timeout.tv_usec = 0; -#endif - if(setsockopt(d_socket, SOL_SOCKET, SO_RCVTIMEO, (optval_t)&timeout, sizeof(timeout)) == -1) { - report_error("SO_RCVTIMEO","can't set socket option SO_RCVTIMEO"); - } -#endif // USE_RCV_TIMEO - - // bind socket to an address and port number to listen on - if(bind (d_socket, ip_src->ai_addr, ip_src->ai_addrlen) == -1) { - report_error("socket bind","can't bind socket"); - } - freeaddrinfo(ip_src); - -} - -gr_udp_source_sptr -gr_make_udp_source (size_t itemsize, const char *ipaddr, - unsigned short port, int payload_size, bool eof, bool wait) -{ - return gnuradio::get_initial_sptr(new gr_udp_source (itemsize, ipaddr, - port, payload_size, eof, wait)); -} - -gr_udp_source::~gr_udp_source () -{ - delete [] d_temp_buff; - - if (d_socket != -1){ - shutdown(d_socket, SHUT_RDWR); -#if defined(USING_WINSOCK) - closesocket(d_socket); -#else - ::close(d_socket); -#endif - d_socket = -1; - } - -#if defined(USING_WINSOCK) // for Windows (with MinGW) - // free winsock resources - WSACleanup(); -#endif -} - -int -gr_udp_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - char *out = (char *) output_items[0]; - ssize_t r=0, nbytes=0, bytes_received=0; - ssize_t total_bytes = (ssize_t)(d_itemsize*noutput_items); - - #if SRC_VERBOSE - printf("\nEntered udp_source\n"); - #endif - - // Remove items from temp buffer if they are in there - if(d_residual) { - nbytes = std::min(d_residual, total_bytes); - memcpy(out, d_temp_buff+d_temp_offset, nbytes); - bytes_received = nbytes; - - #if SRC_VERBOSE - printf("\tTemp buff size: %d offset: %d (bytes_received: %d) (noutput_items: %d)\n", - d_residual, d_temp_offset, bytes_received, noutput_items); - #endif - - // Increment pointer - out += bytes_received; - - // Update indexing of amount of bytes left in the buffer - d_residual -= nbytes; - d_temp_offset += nbytes; - - // Return now with what we've got. - assert(nbytes % d_itemsize == 0); - return nbytes/d_itemsize; - } - - while(1) { - // get the data into our output buffer and record the number of bytes - -#if USE_SELECT - // RCV_TIMEO doesn't work on all systems (e.g., Cygwin) - // use select() instead of, or in addition to RCV_TIMEO - fd_set readfds; - timeval timeout; - timeout.tv_sec = 1; // Init timeout each iteration. Select can modify it. - timeout.tv_usec = 0; - FD_ZERO(&readfds); - FD_SET(d_socket, &readfds); - r = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout); - if(r < 0) { - report_error("udp_source/select",NULL); - return -1; - } - else if(r == 0 ) { // timed out - if( d_wait ) { - // Allow boost thread interrupt, then try again - //boost::this_thread::interruption_point(); - //continue; - return 0; - } - else - return -1; - } -#endif // USE_SELECT - - // This is a non-blocking call with a timeout set in the constructor - r = recv(d_socket, d_temp_buff, d_payload_size, 0); // get the entire payload or the what's available - - // If r > 0, round it down to a multiple of d_itemsize - // (If sender is broken, don't propagate problem) - if (r > 0) - r = (r/d_itemsize) * d_itemsize; - - // Check if there was a problem; forget it if the operation just timed out - if(r == -1) { - if( is_error(EAGAIN) ) { // handle non-blocking call timeout - #if SRC_VERBOSE - printf("UDP receive timed out\n"); - #endif - - if( d_wait ) { - // Allow boost thread interrupt, then try again - //boost::this_thread::interruption_point(); - //continue; - return 0; - } - else - return -1; - } - else { - report_error("udp_source/recv",NULL); - return -1; - } - } - else if(r==0) { - if(d_eof) { - // zero-length packet interpreted as EOF - - #if SNK_VERBOSE - printf("\tzero-length packet received; returning EOF\n"); - #endif - - return -1; - } - else{ - // do we need to allow boost thread interrupt? - boost::this_thread::interruption_point(); - continue; - } - } - else { - // Calculate the number of bytes we can take from the buffer in this call - nbytes = std::min(r, total_bytes-bytes_received); - - // adjust the total number of bytes we have to round down to nearest integer of an itemsize - nbytes -= ((bytes_received+nbytes) % d_itemsize); - - // copy the number of bytes we want to look at here - memcpy(out, d_temp_buff, nbytes); - - d_residual = r - nbytes; // save the number of bytes stored - d_temp_offset=nbytes; // reset buffer index - - // keep track of the total number of bytes received - bytes_received += nbytes; - - // increment the pointer - out += nbytes; - - // Immediately return when data comes in - break; - } - - #if SNK_VERBOSE - printf("\tbytes received: %d bytes (nbytes: %d)\n", bytes, nbytes); - #endif - } - - #if SRC_VERBOSE - printf("Total Bytes Received: %d (bytes_received / noutput_items = %d / %d)\n", - bytes_received, bytes_received, noutput_items); - #endif - - // bytes_received is already set to some integer multiple of itemsize - return bytes_received/d_itemsize; -} - -// Return port number of d_socket -int gr_udp_source::get_port(void) -{ - sockaddr_in name; - socklen_t len = sizeof(name); - int ret = getsockname( d_socket, (sockaddr*)&name, &len ); - if( ret ) { - report_error("gr_udp_source/getsockname",NULL); - return -1; - } - return ntohs(name.sin_port); -} diff --git a/gnuradio-core/src/lib/io/gr_udp_source.h b/gnuradio-core/src/lib/io/gr_udp_source.h deleted file mode 100644 index 56dcb3c0a..000000000 --- a/gnuradio-core/src/lib/io/gr_udp_source.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 <gr_core_api.h> -#include <gr_sync_block.h> -#include <gruel/thread.h> - -class gr_udp_source; -typedef boost::shared_ptr<gr_udp_source> gr_udp_source_sptr; - -GR_CORE_API gr_udp_source_sptr gr_make_udp_source(size_t itemsize, const char *host, - unsigned short port, - int payload_size=1472, - bool eof=true, bool wait=true); - -/*! - * \brief Read stream from an UDP socket. - * \ingroup source_blk - * - * \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) - * \param wait Wait for data if not immediately available - * (default: true) - * -*/ - -class GR_CORE_API gr_udp_source : public gr_sync_block -{ - friend GR_CORE_API gr_udp_source_sptr gr_make_udp_source(size_t itemsize, - const char *host, - unsigned short port, - int payload_size, - bool eof, bool wait); - - private: - size_t d_itemsize; - int d_payload_size; // maximum transmission unit (packet length) - bool d_eof; // zero-length packet is EOF - bool d_wait; // wait if data if not immediately available - int d_socket; // handle to socket - char *d_temp_buff; // hold buffer between calls - ssize_t d_residual; // hold information about number of bytes stored in the temp buffer - size_t d_temp_offset; // point to temp buffer location offset - - protected: - /*! - * \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) - * \param wait Wait for data if not immediately available - * (default: true) - */ - gr_udp_source(size_t itemsize, const char *host, unsigned short port, - int payload_size, bool eof, bool wait); - - public: - ~gr_udp_source(); - - /*! \brief return the PAYLOAD_SIZE of the socket */ - int payload_size() { return d_payload_size; } - - /*! \brief return the port number of the socket */ - int get_port(); - - // should we export anything else? - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_UDP_SOURCE_H */ diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc b/gnuradio-core/src/lib/io/gr_wavfile_sink.cc deleted file mode 100644 index 8526032f6..000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc +++ /dev/null @@ -1,280 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2007,2008,2009,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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_wavfile_sink.h> -#include <gr_io_signature.h> -#include <gri_wavfile.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 - - -gr_wavfile_sink_sptr -gr_make_wavfile_sink(const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample) -{ - return gnuradio::get_initial_sptr(new gr_wavfile_sink (filename, - n_channels, - sample_rate, - bits_per_sample)); -} - -gr_wavfile_sink::gr_wavfile_sink(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 -gr_wavfile_sink::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 (!gri_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 -gr_wavfile_sink::close() -{ - gruel::scoped_lock guard(d_mutex); - - if (!d_fp) - return; - - close_wav(); -} - -void gr_wavfile_sink::close_wav() -{ - unsigned int byte_count = d_sample_count * d_bytes_per_sample; - - gri_wavheader_complete(d_fp, byte_count); - - fclose(d_fp); - d_fp = NULL; -} - - -gr_wavfile_sink::~gr_wavfile_sink () -{ - if (d_new_fp) { - fclose(d_new_fp); - } - - close(); -} - - -int -gr_wavfile_sink::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; - } - - gri_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 -gr_wavfile_sink::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 -gr_wavfile_sink::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 -gr_wavfile_sink::set_sample_rate(unsigned int sample_rate) -{ - gruel::scoped_lock guard(d_mutex); - d_sample_rate = sample_rate; -} - - -void -gr_wavfile_sink::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; -} diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.h b/gnuradio-core/src/lib/io/gr_wavfile_sink.h deleted file mode 100644 index 162151b7a..000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_sink.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_file_sink_base.h> -#include <boost/thread.hpp> - -class gr_wavfile_sink; -typedef boost::shared_ptr<gr_wavfile_sink> gr_wavfile_sink_sptr; - -/* - * \p filename The .wav file to be opened - * \p n_channels Number of channels (2 = stereo or I/Q output) - * \p sample_rate Sample rate [S/s] - * \p bits_per_sample 16 or 8 bit, default is 16 - */ -GR_CORE_API gr_wavfile_sink_sptr -gr_make_wavfile_sink (const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample = 16); - -/*! - * \brief Write stream to a Microsoft PCM (.wav) file. - * - * Values must be floats within [-1;1]. - * Check gr_make_wavfile_sink() for extra info. - * - * \ingroup sink_blk - */ -class GR_CORE_API gr_wavfile_sink : public gr_sync_block -{ -private: - friend GR_CORE_API gr_wavfile_sink_sptr gr_make_wavfile_sink (const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample); - - gr_wavfile_sink(const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample); - - 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: - ~gr_wavfile_sink (); - - /*! - * \brief Opens a new file and writes a WAV header. Thread-safe. - */ - bool open(const char* filename); - - /*! - * \brief Closes the currently active file and completes the WAV - * header. Thread-safe. - */ - void close(); - - /*! - * \brief Set the sample rate. This will not affect the WAV file - * currently opened. Any following open() calls will use this new - * sample rate. - */ - void set_sample_rate(unsigned int sample_rate); - - /*! - * \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. - */ - void set_bits_per_sample(int bits_per_sample); - - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif /* INCLUDED_GR_WAVFILE_SINK_H */ diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.i b/gnuradio-core/src/lib/io/gr_wavfile_sink.i deleted file mode 100644 index 48d1130bd..000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_sink.i +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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(gr,wavfile_sink); - -gr_wavfile_sink_sptr -gr_make_wavfile_sink (const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample = 16) throw (std::runtime_error); - -class gr_wavfile_sink : public gr_sync_block -{ -protected: - gr_wavfile_sink(const char *filename, - int n_channels, - unsigned int sample_rate, - int bits_per_sample) throw (std::runtime_error); - -public: - ~gr_wavfile_sink (); - bool open(const char* filename); - void close(); - void set_sample_rate(unsigned int sample_rate); - void set_bits_per_sample(int bits_per_sample); -}; - diff --git a/gnuradio-core/src/lib/io/gr_wavfile_source.cc b/gnuradio-core/src/lib/io/gr_wavfile_source.cc deleted file mode 100644 index c8372868b..000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_source.cc +++ /dev/null @@ -1,171 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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_wavfile_source.h> -#include <gr_io_signature.h> -#include <gri_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 - - -gr_wavfile_source_sptr -gr_make_wavfile_source (const char *filename, bool repeat) -{ - return gnuradio::get_initial_sptr(new gr_wavfile_source (filename, repeat)); -} - - -gr_wavfile_source::gr_wavfile_source (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 (!gri_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))); -} - - -gr_wavfile_source::~gr_wavfile_source () -{ - fclose(d_fp); -} - - -int -gr_wavfile_source::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 = gri_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; -} - - -float -gr_wavfile_source::convert_to_float(short int sample) -{ - float sample_out = (float) sample; - sample_out /= d_normalize_fac; - sample_out -= d_normalize_shift; - return sample_out; -} diff --git a/gnuradio-core/src/lib/io/gr_wavfile_source.h b/gnuradio-core/src/lib/io/gr_wavfile_source.h deleted file mode 100644 index 02e6e3678..000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_source.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 <gr_core_api.h> -#include <gr_sync_block.h> -#include <cstdio> // for FILE - -class gr_wavfile_source; -typedef boost::shared_ptr<gr_wavfile_source> gr_wavfile_source_sptr; - -GR_CORE_API gr_wavfile_source_sptr -gr_make_wavfile_source (const char *filename, bool repeat = false); - -/*! - * \brief Read stream from a Microsoft PCM (.wav) file, output floats - * - * Unless otherwise called, values are within [-1;1]. - * Check gr_make_wavfile_source() for extra info. - * - * \ingroup source_blk - */ - -class GR_CORE_API gr_wavfile_source : public gr_sync_block -{ -private: - friend GR_CORE_API gr_wavfile_source_sptr gr_make_wavfile_source (const char *filename, - bool repeat); - gr_wavfile_source(const char *filename, bool repeat); - - 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: - ~gr_wavfile_source (); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - /*! - * \brief Read the sample rate as specified in the wav file header - */ - unsigned int sample_rate() const { return d_sample_rate; }; - - /*! - * \brief Return the number of bits per sample as specified in the wav - * file header. Only 8 or 16 bit are supported here. - */ - int bits_per_sample() const { return d_bytes_per_sample * 8; }; - - /*! - * \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. - */ - int channels() const { return d_nchans; }; -}; - -#endif /* INCLUDED_GR_WAVFILE_SOURCE_H */ diff --git a/gnuradio-core/src/lib/io/gr_wavfile_source.i b/gnuradio-core/src/lib/io/gr_wavfile_source.i deleted file mode 100644 index 5af2224f1..000000000 --- a/gnuradio-core/src/lib/io/gr_wavfile_source.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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(gr,wavfile_source); - -gr_wavfile_source_sptr -gr_make_wavfile_source (const char *filename, - bool repeat = false) throw (std::runtime_error); - -class gr_wavfile_source : public gr_sync_block -{ -private: - gr_wavfile_source(const char *filename, - bool repeat) throw (std::runtime_error); - -public: - ~gr_wavfile_source(); - - unsigned int sample_rate(); - int bits_per_sample(); - int channels(); -}; - diff --git a/gnuradio-core/src/lib/io/gri_wavfile.cc b/gnuradio-core/src/lib/io/gri_wavfile.cc deleted file mode 100644 index 277e6b7b0..000000000 --- a/gnuradio-core/src/lib/io/gri_wavfile.cc +++ /dev/null @@ -1,251 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,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 <gri_wavfile.h> -#include <cstring> -#include <stdint.h> -#include <boost/detail/endian.hpp> //BOOST_BIG_ENDIAN - -# 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 __gri_wav_bs16(uint16_t x) - { - return (x>>8) | (x<<8); - } - - static inline uint32_t __gri_wav_bs32(uint32_t x) - { - return (uint32_t(__gri_wav_bs16(uint16_t(x&0xfffful)))<<16) | (__gri_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 -gri_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 -gri_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 -gri_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 -gri_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 -gri_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; -} diff --git a/gnuradio-core/src/lib/io/gri_wavfile.h b/gnuradio-core/src/lib/io/gri_wavfile.h deleted file mode 100644 index 16280e34a..000000000 --- a/gnuradio-core/src/lib/io/gri_wavfile.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along 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 <gr_core_api.h> -#include <cstdio> - -/*! - * \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 -gri_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. - * - * Takes care of endianness. - */ -short int -gri_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 -gri_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. - * - * Takes care of endianness. - */ -void -gri_wav_write_sample(FILE *fp, short int sample, int bytes_per_sample); - - -/*! - * \brief Complete a WAV header - * - * 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 -gri_wavheader_complete(FILE *fp, unsigned int byte_count); diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i index be2ce9937..6cd3e06f4 100644 --- a/gnuradio-core/src/lib/io/io.i +++ b/gnuradio-core/src/lib/io/io.i @@ -26,10 +26,6 @@ #include "config.h" #endif -#include <gr_file_sink.h> -#include <gr_file_source.h> -#include <gr_file_descriptor_sink.h> -#include <gr_file_descriptor_source.h> #include <gr_histo_sink_f.h> #include <microtune_4702_eval_board.h> #include <microtune_4937_eval_board.h> @@ -37,18 +33,8 @@ #include <gr_oscope_sink_x.h> #include <gr_oscope_sink_f.h> #include <ppio.h> -#include <gr_udp_sink.h> -#include <gr_udp_source.h> -#include <gr_wavfile_sink.h> -#include <gr_wavfile_source.h> -#include <gr_tagged_file_sink.h> %} -%include "gr_file_sink_base.i" -%include "gr_file_sink.i" -%include "gr_file_source.i" -%include "gr_file_descriptor_sink.i" -%include "gr_file_descriptor_source.i" %include "gr_histo_sink.i" %include "microtune_xxxx_eval_board.i" %include "microtune_4702_eval_board.i" @@ -56,10 +42,5 @@ %include "sdr_1000.i" %include "gr_oscope_sink.i" %include "ppio.i" -%include "gr_udp_sink.i" -%include "gr_udp_source.i" -%include "gr_wavfile_sink.i" -%include "gr_wavfile_source.i" -%include "gr_tagged_file_sink.i" diff --git a/gnuradio-core/src/lib/runtime/CMakeLists.txt b/gnuradio-core/src/lib/runtime/CMakeLists.txt index f6fce8fb1..a322d1b99 100644 --- a/gnuradio-core/src/lib/runtime/CMakeLists.txt +++ b/gnuradio-core/src/lib/runtime/CMakeLists.txt @@ -79,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 @@ -160,6 +161,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 @@ -218,6 +220,7 @@ 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 diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc index 2ff9cfb75..8c8b85dc7 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 * @@ -53,7 +53,7 @@ gr_block::gr_block (const std::string &name, global_block_registry.register_primitive(alias(), this); #ifdef ENABLE_GR_LOG -#ifdef HAVE_LOG4CXX +#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"); @@ -67,13 +67,13 @@ gr_block::gr_block (const std::string &name, GR_LOG_SET_LEVEL(LOG, log_level); if(log_file.size() > 0) { if(log_file == "stdout") { - GR_LOG_ADD_CONSOLE_APPENDER(LOG, "gr::log :%p: %c{1} - %m%n", "System.out"); + 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, "gr::log :%p: %c{1} - %m%n", "System.err"); + GR_LOG_ADD_CONSOLE_APPENDER(LOG, "cerr","gr::log :%p: %c{1} - %m%n"); } else { - GR_LOG_ADD_FILE_APPENDER(LOG, "%r :%p: %c{1} - %m%n", log_file, ""); + GR_LOG_ADD_FILE_APPENDER(LOG, log_file , true,"%r :%p: %c{1} - %m%n"); } } d_logger = LOG; @@ -82,17 +82,17 @@ gr_block::gr_block (const std::string &name, GR_LOG_SET_LEVEL(DLOG, debug_level); if(debug_file.size() > 0) { if(debug_file == "stdout") { - GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "gr::debug :%p: %c{1} - %m%n", "System.out"); + 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, "gr::debug :%p: %c{1} - %m%n", "System.err"); + GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "cerr", "gr::debug :%p: %c{1} - %m%n"); } else { - GR_LOG_ADD_FILE_APPENDER(DLOG, "%r :%p: %c{1} - %m%n", debug_file, ""); + GR_LOG_ADD_FILE_APPENDER(DLOG, debug_file, true, "%r :%p: %c{1} - %m%n"); } } d_debug_logger = DLOG; -#endif /* HAVE_LOG4CXX */ +#endif /* HAVE_LOG4CPP */ #else /* ENABLE_GR_LOG */ d_logger = NULL; d_debug_logger = NULL; @@ -330,6 +330,17 @@ gr_block::pc_noutput_items() } float +gr_block::pc_noutput_items_avg() +{ + if(d_detail) { + return d_detail->pc_noutput_items_avg(); + } + else { + return 0; + } +} + +float gr_block::pc_noutput_items_var() { if(d_detail) { @@ -352,6 +363,17 @@ gr_block::pc_nproduced() } float +gr_block::pc_nproduced_avg() +{ + if(d_detail) { + return d_detail->pc_nproduced_avg(); + } + else { + return 0; + } +} + +float gr_block::pc_nproduced_var() { if(d_detail) { @@ -374,6 +396,17 @@ gr_block::pc_input_buffers_full(int which) } float +gr_block::pc_input_buffers_full_avg(int which) +{ + if(d_detail) { + return d_detail->pc_input_buffers_full_avg(static_cast<size_t>(which)); + } + else { + return 0; + } +} + +float gr_block::pc_input_buffers_full_var(int which) { if(d_detail) { @@ -396,6 +429,17 @@ gr_block::pc_input_buffers_full() } std::vector<float> +gr_block::pc_input_buffers_full_avg() +{ + if(d_detail) { + return d_detail->pc_input_buffers_full_avg(); + } + else { + return std::vector<float>(1,0); + } +} + +std::vector<float> gr_block::pc_input_buffers_full_var() { if(d_detail) { @@ -418,6 +462,17 @@ gr_block::pc_output_buffers_full(int which) } float +gr_block::pc_output_buffers_full_avg(int which) +{ + if(d_detail) { + return d_detail->pc_output_buffers_full_avg(static_cast<size_t>(which)); + } + else { + return 0; + } +} + +float gr_block::pc_output_buffers_full_var(int which) { if(d_detail) { @@ -440,6 +495,17 @@ gr_block::pc_output_buffers_full() } std::vector<float> +gr_block::pc_output_buffers_full_avg() +{ + if(d_detail) { + return d_detail->pc_output_buffers_full_avg(); + } + else { + return std::vector<float>(1,0); + } +} + +std::vector<float> gr_block::pc_output_buffers_full_var() { if(d_detail) { @@ -462,6 +528,17 @@ gr_block::pc_work_time() } float +gr_block::pc_work_time_avg() +{ + if(d_detail) { + return d_detail->pc_work_time_avg(); + } + else { + return 0; + } +} + +float gr_block::pc_work_time_var() { if(d_detail) { @@ -487,7 +564,14 @@ gr_block::setup_pc_rpc() #ifdef GR_CTRLPORT d_rpc_vars.push_back( rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( - alias(), "avg noutput_items", &gr_block::pc_noutput_items, + alias(), "noutput_items", &gr_block::pc_noutput_items, + pmt::mp(0), pmt::mp(32768), pmt::mp(0), + "", "noutput items", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "avg noutput_items", &gr_block::pc_noutput_items_avg, pmt::mp(0), pmt::mp(32768), pmt::mp(0), "", "Average noutput items", RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); @@ -501,7 +585,14 @@ gr_block::setup_pc_rpc() d_rpc_vars.push_back( rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( - alias(), "avg nproduced", &gr_block::pc_nproduced, + alias(), "nproduced", &gr_block::pc_nproduced, + pmt::mp(0), pmt::mp(32768), pmt::mp(0), + "", "items produced", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "avg nproduced", &gr_block::pc_nproduced_avg, pmt::mp(0), pmt::mp(32768), pmt::mp(0), "", "Average items produced", RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); @@ -515,7 +606,14 @@ gr_block::setup_pc_rpc() d_rpc_vars.push_back( rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( - alias(), "avg work time", &gr_block::pc_work_time, + alias(), "work time", &gr_block::pc_work_time, + pmt::mp(0), pmt::mp(1e9), pmt::mp(0), + "", "clock cycles in call to work", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, float>( + alias(), "avg work time", &gr_block::pc_work_time_avg, pmt::mp(0), pmt::mp(1e9), pmt::mp(0), "", "Average clock cycles in call to work", RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); @@ -529,7 +627,14 @@ gr_block::setup_pc_rpc() d_rpc_vars.push_back( rpcbasic_sptr(new rpcbasic_register_get<gr_block, std::vector<float> >( - alias(), "avg input \% full", &gr_block::pc_input_buffers_full, + alias(), "input \% full", &gr_block::pc_input_buffers_full, + pmt::make_c32vector(0,0), pmt::make_c32vector(0,1), pmt::make_c32vector(0,0), + "", "how full input buffers are", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, std::vector<float> >( + alias(), "avg input \% full", &gr_block::pc_input_buffers_full_avg, pmt::make_c32vector(0,0), pmt::make_c32vector(0,1), pmt::make_c32vector(0,0), "", "Average of how full input buffers are", RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); @@ -543,7 +648,14 @@ gr_block::setup_pc_rpc() d_rpc_vars.push_back( rpcbasic_sptr(new rpcbasic_register_get<gr_block, std::vector<float> >( - alias(), "avg output \% full", &gr_block::pc_output_buffers_full, + alias(), "output \% full", &gr_block::pc_output_buffers_full, + pmt::make_c32vector(0,0), pmt::make_c32vector(0,1), pmt::make_c32vector(0,0), + "", "how full output buffers are", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<gr_block, std::vector<float> >( + alias(), "avg output \% full", &gr_block::pc_output_buffers_full_avg, pmt::make_c32vector(0,0), pmt::make_c32vector(0,1), pmt::make_c32vector(0,0), "", "Average of how full output buffers are", RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index dd17ea2ca..f13f54870 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -379,72 +379,108 @@ class GR_CORE_API gr_block : public gr_basic_block { // --------------- Performance counter functions ------------- /*! - * \brief Gets average noutput_items performance counter. + * \brief Gets instantaneous noutput_items performance counter. */ float pc_noutput_items(); /*! + * \brief Gets average noutput_items performance counter. + */ + float pc_noutput_items_avg(); + + /*! * \brief Gets variance of noutput_items performance counter. */ float pc_noutput_items_var(); /*! - * \brief Gets average num items produced performance counter. + * \brief Gets instantaneous num items produced performance counter. */ float pc_nproduced(); /*! + * \brief Gets average num items produced performance counter. + */ + float pc_nproduced_avg(); + + /*! * \brief Gets variance of num items produced performance counter. */ float pc_nproduced_var(); /*! - * \brief Gets average fullness of \p which input buffer. + * \brief Gets instantaneous fullness of \p which input buffer. */ float pc_input_buffers_full(int which); /*! + * \brief Gets average fullness of \p which input buffer. + */ + float pc_input_buffers_full_avg(int which); + + /*! * \brief Gets variance of fullness of \p which input buffer. */ float pc_input_buffers_full_var(int which); /*! - * \brief Gets average fullness of all input buffers. + * \brief Gets instantaneous fullness of all input buffers. */ std::vector<float> pc_input_buffers_full(); /*! + * \brief Gets average fullness of all input buffers. + */ + std::vector<float> pc_input_buffers_full_avg(); + + /*! * \brief Gets variance of fullness of all input buffers. */ std::vector<float> pc_input_buffers_full_var(); /*! - * \brief Gets average fullness of \p which input buffer. + * \brief Gets instantaneous fullness of \p which input buffer. */ float pc_output_buffers_full(int which); /*! + * \brief Gets average fullness of \p which input buffer. + */ + float pc_output_buffers_full_avg(int which); + + /*! * \brief Gets variance of fullness of \p which input buffer. */ float pc_output_buffers_full_var(int which); /*! - * \brief Gets average fullness of all output buffers. + * \brief Gets instantaneous fullness of all output buffers. */ std::vector<float> pc_output_buffers_full(); + + /*! + * \brief Gets average fullness of all output buffers. + */ + std::vector<float> pc_output_buffers_full_avg(); + /*! * \brief Gets variance of fullness of all output buffers. */ std::vector<float> pc_output_buffers_full_var(); /*! - * \brief Gets average clock cycles spent in work. + * \brief Gets instantaneous clock cycles spent in work. */ float pc_work_time(); /*! * \brief Gets average clock cycles spent in work. */ + float pc_work_time_avg(); + + /*! + * \brief Gets average clock cycles spent in work. + */ float pc_work_time_var(); /*! diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.cc b/gnuradio-core/src/lib/runtime/gr_block_detail.cc index c05b7b96a..c85c0e9fb 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.cc @@ -41,14 +41,19 @@ gr_block_detail::gr_block_detail (unsigned int ninputs, unsigned int noutputs) d_ninputs (ninputs), d_noutputs (noutputs), d_input (ninputs), d_output (noutputs), d_done (false), + d_ins_noutput_items(0), d_avg_noutput_items(0), d_var_noutput_items(0), + d_ins_nproduced(0), d_avg_nproduced(0), d_var_nproduced(0), + d_ins_input_buffers_full(ninputs, 0), d_avg_input_buffers_full(ninputs, 0), d_var_input_buffers_full(ninputs, 0), + d_ins_output_buffers_full(noutputs, 0), d_avg_output_buffers_full(noutputs, 0), d_var_output_buffers_full(noutputs, 0), + d_ins_work_time(0), d_avg_work_time(0), d_var_work_time(0), d_pc_counter(0) @@ -246,35 +251,43 @@ gr_block_detail::stop_perf_counters(int noutput_items, int nproduced) gruel::high_res_timer_type diff = d_end_of_work - d_start_of_work; if(d_pc_counter == 0) { + d_ins_work_time = diff; d_avg_work_time = diff; d_var_work_time = 0; + d_ins_nproduced = nproduced; d_avg_nproduced = nproduced; d_var_nproduced = 0; + d_ins_noutput_items = noutput_items; d_avg_noutput_items = noutput_items; d_var_noutput_items = 0; for(size_t i=0; i < d_input.size(); i++) { float pfull = static_cast<float>(d_input[i]->items_available()) / static_cast<float>(d_input[i]->max_possible_items_available()); + d_ins_input_buffers_full[i] = pfull; d_avg_input_buffers_full[i] = pfull; d_var_input_buffers_full[i] = 0; } for(size_t i=0; i < d_output.size(); i++) { float pfull = 1.0f - static_cast<float>(d_output[i]->space_available()) / static_cast<float>(d_output[i]->bufsize()); + d_ins_output_buffers_full[i] = pfull; d_avg_output_buffers_full[i] = pfull; d_var_output_buffers_full[i] = 0; } } else { float d = diff - d_avg_work_time; + d_ins_work_time = diff; d_avg_work_time = d_avg_work_time + d/d_pc_counter; d_var_work_time = d_var_work_time + d*d; d = nproduced - d_avg_nproduced; + d_ins_nproduced = nproduced; d_avg_nproduced = d_avg_nproduced + d/d_pc_counter; d_var_nproduced = d_var_nproduced + d*d; d = noutput_items - d_avg_noutput_items; + d_ins_noutput_items = noutput_items; d_avg_noutput_items = d_avg_noutput_items + d/d_pc_counter; d_var_noutput_items = d_var_noutput_items + d*d; @@ -283,6 +296,7 @@ gr_block_detail::stop_perf_counters(int noutput_items, int nproduced) static_cast<float>(d_input[i]->max_possible_items_available()); d = pfull - d_avg_input_buffers_full[i]; + d_ins_input_buffers_full[i] = pfull; d_avg_input_buffers_full[i] = d_avg_input_buffers_full[i] + d/d_pc_counter; d_var_input_buffers_full[i] = d_var_input_buffers_full[i] + d*d; } @@ -292,6 +306,7 @@ gr_block_detail::stop_perf_counters(int noutput_items, int nproduced) static_cast<float>(d_output[i]->bufsize()); d = pfull - d_avg_output_buffers_full[i]; + d_ins_output_buffers_full[i] = pfull; d_avg_output_buffers_full[i] = d_avg_output_buffers_full[i] + d/d_pc_counter; d_var_output_buffers_full[i] = d_var_output_buffers_full[i] + d*d; } @@ -309,18 +324,66 @@ gr_block_detail::reset_perf_counters() float gr_block_detail::pc_noutput_items() { - return d_avg_noutput_items; + return d_ins_noutput_items; } float gr_block_detail::pc_nproduced() { - return d_avg_nproduced; + return d_ins_nproduced; } float gr_block_detail::pc_input_buffers_full(size_t which) { + if(which < d_ins_input_buffers_full.size()) + return d_ins_input_buffers_full[which]; + else + return 0; +} + +std::vector<float> +gr_block_detail::pc_input_buffers_full() +{ + return d_ins_input_buffers_full; +} + +float +gr_block_detail::pc_output_buffers_full(size_t which) +{ + if(which < d_ins_output_buffers_full.size()) + return d_ins_output_buffers_full[which]; + else + return 0; +} + +std::vector<float> +gr_block_detail::pc_output_buffers_full() +{ + return d_ins_output_buffers_full; +} + +float +gr_block_detail::pc_work_time() +{ + return d_ins_work_time; +} + +float +gr_block_detail::pc_noutput_items_avg() +{ + return d_avg_noutput_items; +} + +float +gr_block_detail::pc_nproduced_avg() +{ + return d_avg_nproduced; +} + +float +gr_block_detail::pc_input_buffers_full_avg(size_t which) +{ if(which < d_avg_input_buffers_full.size()) return d_avg_input_buffers_full[which]; else @@ -328,13 +391,13 @@ gr_block_detail::pc_input_buffers_full(size_t which) } std::vector<float> -gr_block_detail::pc_input_buffers_full() +gr_block_detail::pc_input_buffers_full_avg() { return d_avg_input_buffers_full; } float -gr_block_detail::pc_output_buffers_full(size_t which) +gr_block_detail::pc_output_buffers_full_avg(size_t which) { if(which < d_avg_output_buffers_full.size()) return d_avg_output_buffers_full[which]; @@ -343,13 +406,13 @@ gr_block_detail::pc_output_buffers_full(size_t which) } std::vector<float> -gr_block_detail::pc_output_buffers_full() +gr_block_detail::pc_output_buffers_full_avg() { return d_avg_output_buffers_full; } float -gr_block_detail::pc_work_time() +gr_block_detail::pc_work_time_avg() { return d_avg_work_time; } diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.h b/gnuradio-core/src/lib/runtime/gr_block_detail.h index 32a01e763..8a5a08bcf 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.h @@ -184,6 +184,14 @@ class GR_CORE_API gr_block_detail { std::vector<float> pc_output_buffers_full(); float pc_work_time(); + float pc_noutput_items_avg(); + float pc_nproduced_avg(); + float pc_input_buffers_full_avg(size_t which); + std::vector<float> pc_input_buffers_full_avg(); + float pc_output_buffers_full_avg(size_t which); + std::vector<float> pc_output_buffers_full_avg(); + float pc_work_time_avg(); + float pc_noutput_items_var(); float pc_nproduced_var(); float pc_input_buffers_full_var(size_t which); @@ -205,15 +213,20 @@ class GR_CORE_API gr_block_detail { bool d_done; // Performance counters + float d_ins_noutput_items; float d_avg_noutput_items; float d_var_noutput_items; + float d_ins_nproduced; float d_avg_nproduced; float d_var_nproduced; + std::vector<float> d_ins_input_buffers_full; std::vector<float> d_avg_input_buffers_full; std::vector<float> d_var_input_buffers_full; + std::vector<float> d_ins_output_buffers_full; std::vector<float> d_avg_output_buffers_full; std::vector<float> d_var_output_buffers_full; gruel::high_res_timer_type d_start_of_work, d_end_of_work; + float d_ins_work_time; float d_avg_work_time; float d_var_work_time; float d_pc_counter; diff --git a/gnuradio-core/src/lib/runtime/gr_logger.cc b/gnuradio-core/src/lib/runtime/gr_logger.cc index e337920a3..530c66f96 100644 --- a/gnuradio-core/src/lib/runtime/gr_logger.cc +++ b/gnuradio-core/src/lib/runtime/gr_logger.cc @@ -21,63 +21,70 @@ */ /******************************************************************************* -* Copyright 2011 Johns Hopkins University Applied Physics Lab * Author: Mark Plett * Description: -* The gr_log module wraps the log4cxx library for logging in gnuradio. +* The gr_log module wraps the log4cpp library for logging in gnuradio. *******************************************************************************/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +//#ifdef HAVE_CONFIG_H +//#include "config.h" +//#endif #include <gr_logger.h> #include <stdexcept> #include <algorithm> #ifdef ENABLE_GR_LOG -#ifdef HAVE_LOG4CXX +#ifdef HAVE_LOG4CPP bool gr_logger_configured(false); void logger_load_config(const std::string &config_filename) { - if(!gr_logger_configured) { + if(!gr_logger_configured){ gr_logger_configured = true; - if(config_filename.size() > 0) { - if(config_filename.find(".xml") != std::string::npos) { - log4cxx::xml::DOMConfigurator::configure(config_filename); - } - else { - log4cxx::PropertyConfigurator::configure(config_filename); - } - } - } + 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) { - if(!gr_logger_configured) { +// NOTE:: NEEDS CODE TO WATCH FILE HERE + if(!gr_logger_configured){ gr_logger_configured = true; - if(config_filename.size() > 0) { - if(config_filename.find(".xml") != std::string::npos) { - log4cxx::xml::DOMConfigurator::configureAndWatch(config_filename, watch_period); - } - else { - log4cxx::PropertyConfigurator::configureAndWatch(config_filename, watch_period); - } - } - } + 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) -{ - log4cxx::LogManager::resetConfiguration(); - gr_logger_configured=false; +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 @@ -85,105 +92,113 @@ 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") - logger_set_level(logger, log4cxx::Level::getOff()); - else if(nocase == "all") - logger_set_level(logger, log4cxx::Level::getAll()); - else if(nocase == "trace") - logger_set_level(logger, log4cxx::Level::getTrace()); + + if(nocase == "off" || nocase == "notset") + logger_set_level(logger, log4cpp::Priority::NOTSET); else if(nocase == "debug") - logger_set_level(logger, log4cxx::Level::getDebug()); + logger_set_level(logger, log4cpp::Priority::DEBUG); else if(nocase == "info") - logger_set_level(logger, log4cxx::Level::getInfo()); + 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, log4cxx::Level::getWarn()); + logger_set_level(logger, log4cpp::Priority::WARN); else if(nocase == "error") - logger_set_level(logger, log4cxx::Level::getError()); - else if(nocase == "fatal") - logger_set_level(logger, log4cxx::Level::getFatal()); + 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, log4cxx::LevelPtr level) +logger_set_level(gr_logger_ptr logger, log4cpp::Priority::Value level) { - logger->setLevel(level); + logger->setPriority(level); } void logger_get_level(gr_logger_ptr logger, std::string &level) { - log4cxx::LevelPtr levelPtr = logger->getLevel(); - if(levelPtr == log4cxx::Level::getOff()) level = "off"; - if(levelPtr == log4cxx::Level::getAll()) level = "all"; - if(levelPtr == log4cxx::Level::getTrace()) level = "trace"; - if(levelPtr == log4cxx::Level::getDebug()) level = "debug"; - if(levelPtr == log4cxx::Level::getInfo()) level = "info"; - if(levelPtr == log4cxx::Level::getWarn()) level = "warn"; - if(levelPtr == log4cxx::Level::getError()) level = "error"; - if(levelPtr == log4cxx::Level::getFatal()) level = "fatal"; + 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, log4cxx::LevelPtr level) +logger_get_level(gr_logger_ptr logger,log4cpp::Priority::Value level) { - level = logger->getLevel(); + level = logger->getPriority(); } void -logger_add_console_appender(gr_logger_ptr logger, std::string layout, - std::string target) +logger_add_console_appender(gr_logger_ptr logger,std::string target,std::string pattern) { - log4cxx::PatternLayout *playout = - new log4cxx::PatternLayout(layout); - log4cxx::ConsoleAppender *appender = - new log4cxx::ConsoleAppender(log4cxx::LayoutPtr(playout), target); - log4cxx::helpers::Pool p; - appender->activateOptions(p); - logger->addAppender(appender); + + 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 layout, - std::string filename, bool append) +logger_add_file_appender(gr_logger_ptr logger,std::string filename,bool append,std::string pattern) { - log4cxx::PatternLayout *playout = - new log4cxx::PatternLayout(layout); - log4cxx::FileAppender *appender = - new log4cxx::FileAppender(log4cxx::LayoutPtr(playout), filename, append); - log4cxx::helpers::Pool p; - appender->activateOptions(p); - logger->addAppender(appender); + + 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 layout, - std::string filename, bool append, - int bkup_index, std::string filesize) +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) { - log4cxx::PatternLayout *playout = - new log4cxx::PatternLayout(layout); - log4cxx::RollingFileAppender *appender = - new log4cxx::RollingFileAppender(log4cxx::LayoutPtr(playout), filename, append); - appender->setMaxBackupIndex(bkup_index); - appender->setMaxFileSize(filesize); - log4cxx::helpers::Pool p; - appender->activateOptions(p); - logger->addAppender(appender); + 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) -{ - log4cxx::LoggerList list = log4cxx::LogManager::getCurrentLoggers(); - log4cxx::LoggerList::iterator logger = list.begin(); +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 != list.end(); logger++) { + for (;logger!=loggers->end();logger++){ names.push_back((*logger)->getName()); - } + }; + } -#endif /* HAVE_LOG4CXX */ +#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 index 40684ec9d..13f31d60b 100644 --- a/gnuradio-core/src/lib/runtime/gr_logger.h +++ b/gnuradio-core/src/lib/runtime/gr_logger.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2012 Free Software Foundation, Inc. + * Copyright 2012-2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,10 +21,9 @@ */ /******************************************************************************* -* Copyright 2011 Johns Hopkins University Applied Physics Lab * Author: Mark Plett * Description: -* The gr_logger module wraps the log4cxx library for logging in gnuradio +* The gr_logger module wraps the log4cpp library for logging in gnuradio *******************************************************************************/ #ifndef INCLUDED_GR_LOGGER_H @@ -33,18 +32,30 @@ /*! * \file gr_logger.h * \ingroup logging -* \brief GNURADIO logging wrapper for log4cxx library (C++ port of log4j) +* \brief GNURADIO logging wrapper for log4cpp library (C++ port of log4j) * */ +#ifndef ENABLE_GR_LOG +#include "config.h" +//#define GR_LOG_CONFIG_H +#endif + #include <gr_core_api.h> #include <assert.h> #include <iostream> +//#ifndef ENABLE_GR_LOG +//#define ENABLE_GR_LOG 1 +//#endif +//#ifndef HAVE_LOG4CPP +//#define HAVE_LOG4CPP 2 +//#endif + #ifdef ENABLE_GR_LOG // We have three configurations... first logging to stdout/stderr -#ifndef HAVE_LOG4CXX +#ifndef HAVE_LOG4CPP //#warning GR logging Enabled and using std::cout typedef std::string gr_logger_ptr; @@ -52,69 +63,70 @@ 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) +#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,layout) -#define GR_LOG_ADD_CONSOLE_APPENDER(logger,layout) -#define GR_ADD_FILE_APPENDER(logger,layout,filename,append) -#define GR_LOG_ADD_FILE_APPENDER(logger,layout,filename,append) -#define GR_ADD_ROLLINGFILE_APPENDER(logger,layout,filename,append,bkup_index,filesize) -#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,layout,filename,append,bkup_index,filesize) +#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_TRACE(name, msg) std::cout<<"TRACE:"<<msg<<std::endl -#define GR_DEBUG(name, msg) std::cout<<"DEBUG:"<<msg<<std::endl -#define GR_INFO(name, msg) std::cout<<"INFO:"<<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_FATAL(name, msg) std::cerr<<"FATAL:"<<msg<<std::endl -#define GR_ERRORIF(name, cond, msg) if((cond)) std::cerr<<"ERROR:"<<msg<<std::endl -#define GR_ASSERT(name, cond, msg) std::cerr<<"ERROR:"<<msg<<std::endl; assert(cond) -#define GR_LOG_SET_LEVEL(logger, level) -#define GR_LOG_GET_LEVEL(logger, level) -#define GR_LOG_TRACE(logger, msg) std::cout<<"TRACE:"<<msg<<std::endl -#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_WARN(logger, msg) std::cerr<<"WARN:"<<msg<<std::endl -#define GR_LOG_ERROR(logger, msg) std::cerr<<"ERROR:"<<msg<<std::endl -#define GR_LOG_FATAL(logger, msg) std::cerr<<"FATAL:"<<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_LOG4CXX */ -// Second configuration...logging to log4cxx -//#warning GR logging Enabled and using LOG4CXX - -#include <log4cxx/logger.h> -#include <log4cxx/logmanager.h> -#include <log4cxx/basicconfigurator.h> -#include <log4cxx/xml/domconfigurator.h> -#include <log4cxx/propertyconfigurator.h> -#include <log4cxx/helpers/pool.h> -#include <log4cxx/fileappender.h> -#include <log4cxx/rollingfileappender.h> -#include <log4cxx/consoleappender.h> -#include <log4cxx/patternlayout.h> +#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 LOG4CXX_LEVEL macros. The availablie macros + * These macros wrap the standard LOG4CPP_LEVEL macros. The availablie macros * are: - * GR_LOG_TRACE * 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 log4cxx::LoggerPtr gr_logger_ptr; +typedef log4cpp::Category* gr_logger_ptr; /* Macros for Programmatic Configuration */ #define GR_LOG_DECLARE_LOGPTR(logger) \ @@ -130,42 +142,42 @@ typedef log4cxx::LoggerPtr gr_logger_ptr; logger_load_config_and_watch(config,period) #define GR_LOG_GETLOGGER(logger, name) \ - log4cxx::LoggerPtr logger = gr_logger::getLogger(name); + gr_logger_ptr logger = gr_logger::getLogger(name); #define GR_SET_LEVEL(name, level){ \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - logger_set_level(logger, 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){ \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ + 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,layout,terget){d \ - gr_logger_ptr logger = log4cxx::Logger::getLogger(name); \ - logger_add_console_appender(logger,layout, target);} +#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,layout,target){ \ - logger_add_console_appender(logger,layout,target);} +#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern){\ + logger_add_console_appender(logger,target,pattern);} -#define GR_ADD_FILE_APPENDER(name,layout,filename,append){\ - gr_logger_ptr logger = log4cxx::Logger::getLogger(name); \ - logger_add_file_appender(logger,layout,filename,append);} +#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,layout,filename,append){\ - logger_add_file_appender(logger,layout,filename,append);} +#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern){\ + logger_add_file_appender(logger,filename,append,pattern);} -#define GR_ADD_ROLLINGFILE_APPENDER(name,layout,filename,append,bkup_index,filesize){\ - gr_logger_ptr logger = log4cxx::Logger::getLogger(name); \ - logger_add_rollingfile_appender(logger,layout,filename,append,bkup_index,filesize);} +#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,layout,filename,append,bkup_index,filesize){\ - logger_add_rollingfile_appender(logger,layout,filename,append,bkup_index,filesize);} +#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);} @@ -174,64 +186,94 @@ typedef log4cxx::LoggerPtr gr_logger_ptr; logger_reset_config();} /* Logger name referenced macros */ -#define GR_TRACE(name, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_TRACE(logger, msg);} - #define GR_DEBUG(name, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_DEBUG(logger, msg);} + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::DEBUG << msg << log4cpp::eol;} #define GR_INFO(name, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_INFO(logger, 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) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_WARN(logger, msg);} + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::WARN << msg << log4cpp::eol;} #define GR_ERROR(name, msg) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_ERROR(logger, 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) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_FATAL(logger, 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) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_ASSERT(logger, !(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) { \ - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ - LOG4CXX_ASSERT(logger, (cond), msg); \ - assert((cond));} +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_TRACE(logger, msg) { \ - LOG4CXX_TRACE(logger, msg);} - #define GR_LOG_DEBUG(logger, msg) { \ - LOG4CXX_DEBUG(logger, msg);} + *logger << log4cpp::Priority::DEBUG << msg << log4cpp::eol;} #define GR_LOG_INFO(logger, msg) { \ - LOG4CXX_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) { \ - LOG4CXX_WARN(logger, msg);} + *logger << log4cpp::Priority::WARN << msg << log4cpp::eol;} #define GR_LOG_ERROR(logger, msg) { \ - LOG4CXX_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) { \ - LOG4CXX_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) { \ - LOG4CXX_ASSERT(logger, !(cond), msg);} +if((!cond)){\ + *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;};\ + assert(0);\ +}; #define GR_LOG_ASSERT(logger, cond, msg) { \ - LOG4CXX_ASSERT(logger, (cond), msg); \ - assert((cond));} +if((!cond)){\ + *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;};\ + assert(0);\ +}; /*! * \brief Load logger's configuration file. @@ -256,14 +298,16 @@ GR_CORE_API void logger_reset_config(void); * Sets the level of the logger. This takes a string that is * translated to the standard levels and can be (case insensitive): * - * \li off - * \li all - * \li trace + * \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. @@ -273,22 +317,24 @@ 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 Log4cxx::Level + * Sets the level of the logger. This takes the actual Log4cpp::Priority * data type, which can be: * - * \li log4cxx::Level::getOff() - * \li log4cxx::Level::getAll() - * \li log4cxx::Level::getTrace() - * \li log4cxx::Level::getDebug() - * \li log4cxx::Level::getInfo() - * \li log4cxx::Level::getWarn() - * \li log4cxx::Level::getError() - * \li log4cxx::Level::getFatal() + * \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 Log4cxx::Level + * \param level new logger level of type Log4cpp::Priority */ -GR_CORE_API void logger_set_level(gr_logger_ptr logger, log4cxx::LevelPtr level); +void logger_set_level(gr_logger_ptr logger, log4cpp::Priority::Value level); /*! @@ -297,14 +343,16 @@ GR_CORE_API void logger_set_level(gr_logger_ptr logger, log4cxx::LevelPtr level) * Gets the level of the logger. This returns a string that * corresponds to the standard levels and can be (case insensitive): * - * \li off - * \li all - * \li trace + * \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. @@ -314,32 +362,31 @@ 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 Log4cxx::Level + * Gets the level of the logger. This returns the actual Log4cpp::Level * data type, which can be: * - * \li log4cxx::Level::getOff() - * \li log4cxx::Level::getAll() - * \li log4cxx::Level::getTrace() - * \li log4cxx::Level::getDebug() - * \li log4cxx::Level::getInfo() - * \li log4cxx::Level::getWarn() - * \li log4cxx::Level::getError() - * \li log4cxx::Level::getFatal() + * \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, log4cxx::LevelPtr level); +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_console_appender(gr_logger_ptr logger, std::string layout, - std::string target); +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_file_appender(gr_logger_ptr logger, std::string layout, - std::string filename, bool append); - -GR_CORE_API void logger_add_rollingfile_appender(gr_logger_ptr logger, std::string layout, - std::string filename, bool append, - int bkup_index, std::string filesize); +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); @@ -366,25 +413,22 @@ class gr_logger gr_logger(std::string config_filename, int watchPeriodSec) { // Load configuration file - if(config_filename.find(".xml")!=std::string::npos) { - log4cxx::xml::DOMConfigurator::configureAndWatch(config_filename, watchPeriodSec); - } - else { - log4cxx::PropertyConfigurator::configureAndWatch(config_filename, watchPeriodSec); - } + logger_load_config_and_watch(config_filename,watchPeriodSec); + }; - static log4cxx::LoggerPtr getLogger(std::string name) + static gr_logger_ptr getLogger(std::string name) { - if(log4cxx::LogManager::exists(name)) { - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); - return logger; - } - else { - log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); - logger->setLevel(log4cxx::Level::getOff()); - return logger; - }; + 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 @@ -394,64 +438,82 @@ class gr_logger /*! \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 LOG4CXX_TRACE for TRACE message */ - void trace(std::string name,std::string msg){GR_TRACE(name,msg);}; - - /*! \brief inline function, wrapper for LOG4CXX_DEBUG for DEBUG message */ + /*! \brief inline function, wrapper for DEBUG message */ void debug(std::string name,std::string msg){GR_DEBUG(name,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_INFO for INFO message */ + /*! \brief inline function, wrapper for INFO message */ void info(std::string name,std::string msg){GR_INFO(name,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_WARN for WARN message */ + /*! \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 LOG4CXX_ERROR for ERROR message */ + /*! \brief inline function, wrapper for ERROR message */ void error(std::string name,std::string msg){GR_ERROR(name,msg);}; - /*! \brief inline function, wrapper for LOG4CXX_FATAL for FATAL message */ + /*! \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 LOG4CXX_ASSERT for conditional ERROR message */ + /*! \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 LOG4CXX_ASSERT for conditional ERROR message */ + /*! \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(log4cxx::LoggerPtr logger,std::string level){GR_LOG_SET_LEVEL(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(log4cxx::LoggerPtr logger,std::string &level){GR_LOG_GET_LEVEL(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 LOG4CXX_TRACE for TRACE message */ - void log_trace(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_TRACE(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 LOG4CXX_DEBUG for DEBUG message */ - void log_debug(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_DEBUG(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 LOG4CXX_INFO for INFO message */ - void log_info(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_INFO(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 LOG4CXX_WARN for WARN message */ - void log_warn(log4cxx::LoggerPtr 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 LOG4CXX_ERROR for ERROR message */ - void log_error(log4cxx::LoggerPtr 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 LOG4CXX_FATAL for FATAL message */ - void log_fatal(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_FATAL(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 LOG4CXX_ASSERT for conditional ERROR message */ - void log_errorIF(log4cxx::LoggerPtr logger,bool cond,std::string msg){GR_LOG_ERRORIF(logger,cond,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 LOG4CXX_ASSERT for conditional ERROR message */ - void log_assert(log4cxx::LoggerPtr logger,bool cond,std::string msg){GR_LOG_ASSERT(logger,cond,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_LOG4CXX */ +#endif /* HAVE_LOG4CPP */ // If Logger disable do nothing #else /* ENABLE_GR_LOG */ @@ -461,36 +523,40 @@ 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) +#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,layout) -#define GR_LOG_ADD_CONSOLE_APPENDER(logger,layout) -#define GR_ADD_FILE_APPENDER(logger,layout,filename,append) -#define GR_LOG_ADD_FILE_APPENDER(logger,layout) -#define GR_ADD_ROLLINGFILE_APPENDER(logger,layout,filename,append,bkup_index,filesize) -#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,layout) +#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_TRACE(name, msg) #define GR_DEBUG(name, msg) #define GR_INFO(name, msg) -#define GR_WARN(name, msg) -#define GR_ERROR(name, msg) -#define GR_FATAL(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_SET_LEVEL(logger, level) -#define GR_LOG_GET_LEVEL(logger, level) -#define GR_LOG_TRACE(logger, msg) #define GR_LOG_DEBUG(logger, msg) -#define GR_LOG_INFO(logger, msg) -#define GR_LOG_WARN(logger, msg) -#define GR_LOG_ERROR(logger, msg) -#define GR_LOG_FATAL(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) diff --git a/gnuradio-core/src/lib/runtime/gr_logger.i b/gnuradio-core/src/lib/runtime/gr_logger.i index 1eedf3d60..70e50e02b 100644 --- a/gnuradio-core/src/lib/runtime/gr_logger.i +++ b/gnuradio-core/src/lib/runtime/gr_logger.i @@ -23,7 +23,7 @@ * Copyright 2011 Johns Hopkins University Applied Physics Lab * Author: Mark Plett * Description: -* SWIG interface generator file for gr_logger module. gr_logger wraps log4cxx logging +* SWIG interface generator file for gr_logger module. gr_logger wraps log4cpp logging * for gnuradio. *******************************************************************************/ @@ -40,23 +40,22 @@ //----------------------------------- #ifdef ENABLE_GR_LOG -#ifdef HAVE_LOG4CXX +#ifdef HAVE_LOG4CPP %{ // The .h files #include <gr_logger.h> -#include <log4cxx/logger.h> -#include <log4cxx/logmanager.h> +#include <log4cpp/Category.hh> %} -namespace log4cxx{ +namespace log4cpp{ class LoggerPtr { public: ~LoggerPtr(); }; }; void logger_load_config(const std::string &config_filename); -void logger_set_level(log4cxx::LoggerPtr logger, const std::string &level); +void logger_set_level(log4cpp::LoggerPtr logger, const std::string &level); %rename(log) gr_logger; @@ -69,28 +68,42 @@ public: 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 trace(std::string name,std::string msg); + 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 fatal(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 log4cxx::LoggerPtr getLogger(std::string name); - - void set_log_level(log4cxx::LoggerPtr logger,std::string level); - void get_log_level(log4cxx::LoggerPtr logger,std::string &level); - void log_trace(log4cxx::LoggerPtr logger,std::string msg); - void log_debug(log4cxx::LoggerPtr logger,std::string msg); - void log_info(log4cxx::LoggerPtr logger,std::string msg); - void log_warn(log4cxx::LoggerPtr logger,std::string msg); - void log_error(log4cxx::LoggerPtr logger,std::string msg); - void log_fatal(log4cxx::LoggerPtr logger,std::string msg); - void log_errorIF(log4cxx::LoggerPtr logger,bool cond,std::string msg); - void log_assert(log4cxx::LoggerPtr logger,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_LOG4CXX */ +#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 000000000..32b6a0903 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc @@ -0,0 +1,144 @@ +/* -*- 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_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::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::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::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) { + 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 000000000..a9d396c06 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.h @@ -0,0 +1,138 @@ +/* -*- 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 000000000..9fc803dca --- /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_top_block.h b/gnuradio-core/src/lib/runtime/gr_top_block.h index cb99752f3..694e9575b 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.h +++ b/gnuradio-core/src/lib/runtime/gr_top_block.h @@ -83,7 +83,7 @@ public: /*! * Wait for a flowgraph to complete. Flowgraphs complete when * either (1) all blocks indicate that they are done (typically only - * when using gr.file_source, or gr.head, or (2) after stop() has been + * when using blocks.file_source, or gr.head, or (2) after stop() has been * called to request shutdown. Calling wait on a top_block that is * not running IS NOT an error (wait returns w/o blocking). */ diff --git a/gnuradio-core/src/lib/runtime/qa_gr_logger.cc b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc index 3d21c1f30..a8e4a1d76 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_logger.cc +++ b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc @@ -38,14 +38,15 @@ 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,"errLoggerRoot"); - GR_LOG_TRACE(LOG,"test from c++ 1"); - GR_LOG_DEBUG(LOG,"test from c++ 1"); - GR_LOG_INFO(LOG,"test from c++ 1"); - GR_LOG_WARN(LOG,"test from c++ 1"); - GR_LOG_ERROR(LOG,"test from c++ 1"); - GR_LOG_FATAL(LOG,"test from c++ 1"); - GR_LOG_ERRORIF(LOG,2>1,"test from c++ 1"); + + 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/runtime.i b/gnuradio-core/src/lib/runtime/runtime.i index 73a816a14..ac0092f91 100644 --- a/gnuradio-core/src/lib/runtime/runtime.i +++ b/gnuradio-core/src/lib/runtime/runtime.i @@ -39,6 +39,7 @@ #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> %} @@ -67,6 +68,7 @@ %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 1be70f5c8..2132e2ca0 100644 --- a/gnuradio-core/src/lib/swig/CMakeLists.txt +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -25,15 +25,15 @@ set(GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) set(GR_SWIG_LIBRARIES gnuradio-core - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) -# Only use if log4cxx is installed +# 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") diff --git a/gnuradio-core/src/lib/swig/gnuradio.i b/gnuradio-core/src/lib/swig/gnuradio.i index 3a421ad5d..4378e6aad 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"); @@ -48,6 +49,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; @@ -64,7 +66,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 1994f0660..bbbabaf07 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/ctrlport/gr-perf-monitorx b/gnuradio-core/src/python/gnuradio/ctrlport/gr-perf-monitorx new file mode 100755 index 000000000..a65b0406e --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/ctrlport/gr-perf-monitorx @@ -0,0 +1,727 @@ +#!/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 random,math,operator +import networkx as nx; +import matplotlib.pyplot as plt + +from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas +from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar +from matplotlib.figure import Figure + +from gnuradio import gr, ctrlport + +from PyQt4 import QtCore,Qt,Qwt5 +import PyQt4.QtGui as QtGui +import sys, time, re, pprint +import itertools +import scipy +from scipy import spatial + +import Ice +from gnuradio.ctrlport.IceRadioClient import * +from gnuradio.ctrlport.GrDataPlotter import * +from gnuradio.ctrlport import GNURadio + +class MAINWindow(QtGui.QMainWindow): + def minimumSizeHint(self): + return QtGui.QSize(800,600) + + def __init__(self, radio, port, interface): + + super(MAINWindow, self).__init__() + self.conns = [] + self.plots = [] + self.knobprops = [] + self.interface = interface + + self.mdiArea = QtGui.QMdiArea() + self.mdiArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) + self.mdiArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) + self.setCentralWidget(self.mdiArea) + + self.mdiArea.subWindowActivated.connect(self.updateMenus) + self.windowMapper = QtCore.QSignalMapper(self) + self.windowMapper.mapped[QtGui.QWidget].connect(self.setActiveSubWindow) + + self.createActions() + self.createMenus() + self.createToolBars() + self.createStatusBar() + self.updateMenus() + + self.setWindowTitle("GNU Radio Performance Monitor") + self.setUnifiedTitleAndToolBarOnMac(True) + + self.newCon(radio, port) + icon = QtGui.QIcon(ctrlport.__path__[0] + "/icon.png" ) + self.setWindowIcon(icon) + + + def newSubWindow(self, window, title): + child = window; + child.setWindowTitle(title) + self.mdiArea.addSubWindow(child) + self.conns.append(child) + child.show(); + self.mdiArea.currentSubWindow().showMaximized() + + + def newCon(self, radio=None, port=None): + child = MForm(radio, port, len(self.conns), self) + if(child.radio is not None): + child.setWindowTitle(str(child.radio)) +# horizbar = QtGui.QScrollArea() +# horizbar.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) +# horizbar.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) +# horizbar.setWidget(child) +# self.mdiArea.addSubWindow(horizbar) + self.mdiArea.addSubWindow(child) + self.mdiArea.currentSubWindow().showMaximized() + + self.conns.append(child) + self.plots.append([]) + + def update(self, knobs, uid): + #sys.stderr.write("KNOB KEYS: {0}\n".format(knobs.keys())) + for plot in self.plots[uid]: + data = knobs[plot.name()].value + plot.update(data) + plot.stop() + plot.wait() + plot.start() + + def setActiveSubWindow(self, window): + if window: + self.mdiArea.setActiveSubWindow(window) + + + def createActions(self): + self.newConAct = QtGui.QAction("&New Connection", + self, shortcut=QtGui.QKeySequence.New, + statusTip="Create a new file", triggered=self.newCon) + + self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", + statusTip="Exit the application", + triggered=QtGui.qApp.closeAllWindows) + + self.closeAct = QtGui.QAction("Cl&ose", self, shortcut="Ctrl+F4", + statusTip="Close the active window", + triggered=self.mdiArea.closeActiveSubWindow) + + self.closeAllAct = QtGui.QAction("Close &All", self, + statusTip="Close all the windows", + triggered=self.mdiArea.closeAllSubWindows) + + + qks = QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_T); + self.tileAct = QtGui.QAction("&Tile", self, + statusTip="Tile the windows", + triggered=self.mdiArea.tileSubWindows, + shortcut=qks) + + qks = QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_C); + self.cascadeAct = QtGui.QAction("&Cascade", self, + statusTip="Cascade the windows", shortcut=qks, + triggered=self.mdiArea.cascadeSubWindows) + + self.nextAct = QtGui.QAction("Ne&xt", self, + shortcut=QtGui.QKeySequence.NextChild, + statusTip="Move the focus to the next window", + triggered=self.mdiArea.activateNextSubWindow) + + self.previousAct = QtGui.QAction("Pre&vious", self, + shortcut=QtGui.QKeySequence.PreviousChild, + statusTip="Move the focus to the previous window", + triggered=self.mdiArea.activatePreviousSubWindow) + + self.separatorAct = QtGui.QAction(self) + self.separatorAct.setSeparator(True) + + self.aboutAct = QtGui.QAction("&About", self, + statusTip="Show the application's About box", + triggered=self.about) + + self.aboutQtAct = QtGui.QAction("About &Qt", self, + statusTip="Show the Qt library's About box", + triggered=QtGui.qApp.aboutQt) + + def createMenus(self): + self.fileMenu = self.menuBar().addMenu("&File") + self.fileMenu.addAction(self.newConAct) + self.fileMenu.addSeparator() + self.fileMenu.addAction(self.exitAct) + + self.windowMenu = self.menuBar().addMenu("&Window") + self.updateWindowMenu() + self.windowMenu.aboutToShow.connect(self.updateWindowMenu) + + self.menuBar().addSeparator() + + self.helpMenu = self.menuBar().addMenu("&Help") + self.helpMenu.addAction(self.aboutAct) + self.helpMenu.addAction(self.aboutQtAct) + + def createToolBars(self): + self.fileToolBar = self.addToolBar("File") + self.fileToolBar.addAction(self.newConAct) + + self.fileToolBar = self.addToolBar("Window") + self.fileToolBar.addAction(self.tileAct) + self.fileToolBar.addAction(self.cascadeAct) + + def createStatusBar(self): + self.statusBar().showMessage("Ready") + + + def activeMdiChild(self): + activeSubWindow = self.mdiArea.activeSubWindow() + if activeSubWindow: + return activeSubWindow.widget() + return None + + def updateMenus(self): + hasMdiChild = (self.activeMdiChild() is not None) + self.closeAct.setEnabled(hasMdiChild) + self.closeAllAct.setEnabled(hasMdiChild) + self.tileAct.setEnabled(hasMdiChild) + self.cascadeAct.setEnabled(hasMdiChild) + self.nextAct.setEnabled(hasMdiChild) + self.previousAct.setEnabled(hasMdiChild) + self.separatorAct.setVisible(hasMdiChild) + + def updateWindowMenu(self): + self.windowMenu.clear() + self.windowMenu.addAction(self.closeAct) + self.windowMenu.addAction(self.closeAllAct) + self.windowMenu.addSeparator() + self.windowMenu.addAction(self.tileAct) + self.windowMenu.addAction(self.cascadeAct) + self.windowMenu.addSeparator() + self.windowMenu.addAction(self.nextAct) + self.windowMenu.addAction(self.previousAct) + self.windowMenu.addAction(self.separatorAct) + + def about(self): + about_info = \ +'''Copyright 2012 Free Software Foundation, Inc.\n +This program is part of GNU Radio.\n +GNU Radio is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.\n +GNU Radio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n +You should have received a copy of the GNU General Public License along with GNU Radio; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301, USA.''' + + QtGui.QMessageBox.about(None, "gr-ctrlport-monitor", about_info) + + +class ConInfoDialog(QtGui.QDialog): + def __init__(self, parent=None): + super(ConInfoDialog, self).__init__(parent) + + self.gridLayout = QtGui.QGridLayout(self) + + + self.host = QtGui.QLineEdit(self); + self.port = QtGui.QLineEdit(self); + self.host.setText("localhost"); + self.port.setText("43243"); + + self.buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | + QtGui.QDialogButtonBox.Cancel) + + self.gridLayout.addWidget(self.host); + self.gridLayout.addWidget(self.port); + self.gridLayout.addWidget(self.buttonBox); + + self.buttonBox.accepted.connect(self.accept) + self.buttonBox.rejected.connect(self.reject) + + + def accept(self): + self.done(1); + + def reject(self): + self.done(0); + + +class DataTable(QtGui.QWidget): + def update(self): + print "update" + + def __init__(self, radio, G): + QtGui.QWidget.__init__( self) + + self.layout = QtGui.QVBoxLayout(self); + self.hlayout = QtGui.QHBoxLayout(); + self.layout.addLayout(self.hlayout); + + self.G = G; + self.radio = radio; + + self._keymap = None + + # Create a combobox to set the type of statistic we want. + self._statistic = "Instantaneous" + self._statistics_table = {"Instantaneous": "", + "Average": "avg ", + "Variance": "var "} + self.stattype = QtGui.QComboBox() + self.stattype.addItem("Instantaneous") + self.stattype.addItem("Average") + self.stattype.addItem("Variance") + self.stattype.setMaximumWidth(200) + self.hlayout.addWidget(self.stattype); + self.stattype.currentIndexChanged.connect(self.stat_changed) + + # Create a checkbox to toggle sorting of graphs + self._sort = False + self.checksort = QtGui.QCheckBox("Sort") + self.checksort.setCheckState(self._sort) + self.hlayout.addWidget(self.checksort); + self.checksort.stateChanged.connect(self.checksort_changed) + + # set up table + self.perfTable = Qt.QTableWidget(); + self.perfTable.setColumnCount(2) + self.perfTable.verticalHeader().hide(); + self.perfTable.setHorizontalHeaderLabels( ["Block Name", "Percent Runtime"] ); + self.perfTable.horizontalHeader().setStretchLastSection(True); + self.perfTable.setSortingEnabled(True) + nodes = self.G.nodes(data=True) + + # set up plot + self.f = plt.figure(figsize=(10,8), dpi=90) + self.sp = self.f.add_subplot(111); + self.sp.autoscale_view(True,True,True); + self.sp.set_autoscale_on(True) + self.canvas = FigureCanvas(self.f) + + # set up tabs + self.tabber = QtGui.QTabWidget(); + self.layout.addWidget(self.tabber); + self.tabber.addTab(self.perfTable,"Table View"); + self.tabber.addTab(self.canvas, "Graph View"); + + # set up timer + self.timer = QtCore.QTimer() + self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.update) + self.timer.start(500) + + for i in range(0,len(nodes)): + self.perfTable.setItem( + i,0, + Qt.QTableWidgetItem(nodes[i][0])) + + def table_update(self,data): + for k in data.keys(): + weight = data[k] + existing = self.perfTable.findItems(str(k),QtCore.Qt.MatchFixedString) + if(len(existing) == 0): + i = self.perfTable.rowCount(); + self.perfTable.setRowCount( i+1) + self.perfTable.setItem( i,0, Qt.QTableWidgetItem(str(k))) + self.perfTable.setItem( i,1, Qt.QTableWidgetItem(str(weight))) + else: + self.perfTable.setItem( self.perfTable.row(existing[0]),1, Qt.QTableWidgetItem(str(weight))) + + def stat_changed(self, index): + self._statistic = str(self.stattype.currentText()) + + def checksort_changed(self, state): + self._sort = state > 0 + +class DataTableBuffers(DataTable): + def __init__(self, radio, G): + DataTable.__init__(self,radio,G) + self.perfTable.setHorizontalHeaderLabels( ["Block Name", "Percent Buffer Full"] ); + + def update(self): + nodes = self.G.nodes(); + + # get buffer fullness for all blocks + kl = map(lambda x: "%s::%soutput %% full" % \ + (x, self._statistics_table[self._statistic]), + nodes); + buf_knobs = self.radio.get(kl) + + # strip values out of ctrlport response + buffer_fullness = dict(zip( + map(lambda x: x.split("::")[0], buf_knobs.keys()), + map(lambda x: x.value, buf_knobs.values()))) + + blockport_fullness = {} + for blk in buffer_fullness: + for port in range(0,len(buffer_fullness[blk])): + blockport_fullness["%s:%d"%(blk,port)] = buffer_fullness[blk][port]; + + self.table_update(blockport_fullness); + + if(self._sort): + sorted_fullness = sorted(blockport_fullness.iteritems(), key=operator.itemgetter(1)) + self._keymap = map(operator.itemgetter(0), sorted_fullness) + else: + if self._keymap: + sorted_fullness = len(self._keymap)*['',] + for b in blockport_fullness: + sorted_fullness[self._keymap.index(b)] = (b, blockport_fullness[b]) + else: + sorted_fullness = blockport_fullness.items() + + self.sp.clear(); + plt.figure(self.f.number) + plt.subplot(111); + self.sp.bar(range(0,len(sorted_fullness)), map(lambda x: x[1], sorted_fullness), + alpha=0.5) + self.sp.set_ylabel("% Buffers Full"); + self.sp.set_xticks( map(lambda x: x+0.5, range(0,len(sorted_fullness)))) + self.sp.set_xticklabels( map(lambda x: " " + x, map(lambda x: x[0], sorted_fullness)), + rotation="vertical", verticalalignment="bottom" ) + self.canvas.draw(); + self.canvas.show(); + +class DataTableRuntimes(DataTable): + def __init__(self, radio, G): + DataTable.__init__(self,radio,G) + #self.perfTable.setRowCount(len( self.G.nodes() )) + + def update(self): + nodes = self.G.nodes(); + + # get work time for all blocks + kl = map(lambda x: "%s::%swork time" % \ + (x, self._statistics_table[self._statistic]), + nodes); + wrk_knobs = self.radio.get(kl) + + # strip values out of ctrlport response + total_work = sum(map(lambda x: x.value, wrk_knobs.values())) + work_times = dict(zip( + map(lambda x: x.split("::")[0], wrk_knobs.keys()), + map(lambda x: x.value/total_work, wrk_knobs.values()))) + + # update table view + self.table_update(work_times) + + if(self._sort): + sorted_work = sorted(work_times.iteritems(), key=operator.itemgetter(1)) + self._keymap = map(operator.itemgetter(0), sorted_work) + else: + if self._keymap: + sorted_work = len(self._keymap)*['',] + for b in work_times: + sorted_work[self._keymap.index(b)] = (b, work_times[b]) + else: + sorted_work = work_times.items() + + self.sp.clear(); + plt.figure(self.f.number) + plt.subplot(111); + self.sp.bar(range(0,len(sorted_work)), map(lambda x: x[1], sorted_work), + alpha=0.5) + self.sp.set_ylabel("% Runtime"); + self.sp.set_xticks( map(lambda x: x+0.5, range(0,len(sorted_work)))) + self.sp.set_xticklabels( map(lambda x: " " + x[0], sorted_work), + rotation="vertical", verticalalignment="bottom" ) + + self.canvas.draw(); + self.canvas.show(); + +class MForm(QtGui.QWidget): + def update(self): + try: + + nodes = self.G.nodes(); + + # get current buffer depths of all output buffers + kl = map(lambda x: "%s::%soutput %% full" % \ + (x, self._statistics_table[self._statistic]), + nodes); + + st = time.time() + buf_knobs = self.radio.get(kl) + td1 = time.time() - st; + + # strip values out of ctrlport response + buf_vals = dict(zip( + map(lambda x: x.split("::")[0], buf_knobs.keys()), + map(lambda x: x.value, buf_knobs.values()))) + + # get work time for all blocks + kl = map(lambda x: "%s::%swork time" % \ + (x, self._statistics_table[self._statistic]), + nodes); + st = time.time() + wrk_knobs = self.radio.get(kl) + td2 = time.time() - st; + + # strip values out of ctrlport response + total_work = sum(map(lambda x: x.value, wrk_knobs.values())) + work_times = dict(zip( + map(lambda x: x.split("::")[0], wrk_knobs.keys()), + map(lambda x: x.value/total_work, wrk_knobs.values()))) + + for n in nodes: + # ne is the list of edges away from this node! + ne = self.G.edges([n],True); + for e in ne: # iterate over edges from this block + # get the right output buffer/port weight for each edge + sourceport = e[2]["sourceport"]; + newweight = buf_vals[n][sourceport] + e[2]["weight"] = newweight; + + # set updated weights + self.node_weights = map(lambda x: 20+2000*work_times[x], nodes); + self.edge_weights = map(lambda x: 100.0*x[2]["weight"], self.G.edges(data=True)); + + # draw graph updates + self.updateGraph(); + + latency = td1 + td2; + self.parent.statusBar().showMessage("Current GNU Radio Control Port Query Latency: %f ms"%\ + (latency*1000)) + + except Exception, e: + sys.stderr.write("ctrlport-monitor: radio.get threw exception ({0}).\n".format(e)) + if(type(self.parent) is MAINWindow): + # Find window of connection + remove = [] + for p in self.parent.mdiArea.subWindowList(): + if self.parent.conns[self.uid] == p.widget(): + remove.append(p) + + # Remove subwindows for connection and plots + for r in remove: + self.parent.mdiArea.removeSubWindow(r) + + # Clean up self + self.close() + else: + sys.exit(1) + return + + def rtt(self): + self.parent.newSubWindow( DataTableRuntimes(self.radio, self.G), "Runtime Table" ); + + def bpt(self): + self.parent.newSubWindow( DataTableBuffers(self.radio, self.G), "Buffers Table" ); + + def stat_changed(self, index): + self._statistic = str(self.stattype.currentText()) + + def __init__(self, radio=None, port=None, uid=0, parent=None): + + super(MForm, self).__init__() + + if(radio == None or port == None): + askinfo = ConInfoDialog(self); + if askinfo.exec_(): + host = str(askinfo.host.text()); + port = str(askinfo.port.text()); + radio = parent.interface.getRadio(host, port) + else: + self.radio = None + return + + + self.uid = uid + self.parent = parent + + self.layoutTop = QtGui.QVBoxLayout(self) + self.ctlBox = QtGui.QHBoxLayout(); + self.layout = QtGui.QHBoxLayout() + + self.layoutTop.addLayout(self.ctlBox); + self.layoutTop.addLayout(self.layout); + + self.rttAct = QtGui.QAction("Runtime Table", + self, statusTip="Runtime Table", triggered=self.rtt) + self.rttBut = Qt.QToolButton() + self.rttBut.setDefaultAction(self.rttAct); + self.ctlBox.addWidget(self.rttBut); + + self.bptAct = QtGui.QAction("Buffer Table", + self, statusTip="Buffer Table", triggered=self.bpt) + self.bptBut = Qt.QToolButton() + self.bptBut.setDefaultAction(self.bptAct); + self.ctlBox.addWidget(self.bptBut); + + self._statistic = "Instantaneous" + self._statistics_table = {"Instantaneous": "", + "Average": "avg ", + "Variance": "var "} + self.stattype = QtGui.QComboBox() + self.stattype.addItem("Instantaneous") + self.stattype.addItem("Average") + self.stattype.addItem("Variance") + self.stattype.setMaximumWidth(200) + self.ctlBox.addWidget(self.stattype); + self.stattype.currentIndexChanged.connect(self.stat_changed) + +# self.setLayout(self.layout); + + self.radio = radio + self.knobprops = self.radio.properties([]) + self.parent.knobprops.append(self.knobprops) + + self.timer = QtCore.QTimer() + self.constupdatediv = 0 + self.tableupdatediv = 0 + plotsize=250 + + + # Set up the graph of blocks + input_name = lambda x: x+"::avg input % full" + output_name = lambda x: x+"::avg output % full" + wtime_name = lambda x: x+"::avg work time" + nout_name = lambda x: x+"::avg noutput_items" + nprod_name = lambda x: x+"::avg nproduced" + + tmplist = [] + knobs = self.radio.get([]) + edgelist = None + for k in knobs: + propname = k.split("::") + blockname = propname[0] + keyname = propname[1] + if(keyname == "edge list"): + edgelist = knobs[k].value + elif(blockname not in tmplist): + # only take gr_blocks (no hier_block2) + if(knobs.has_key(input_name(blockname))): + tmplist.append(blockname) + + if not edgelist: + sys.stderr.write("Could not find list of edges from flowgraph. " + \ + "Make sure the option 'edges_list' is enabled " + \ + "in the ControlPort configuration.\n\n") + sys.exit(1) + + edges = edgelist.split("\n")[0:-1] + edgepairs = []; + for e in edges: + _e = e.split("->") + edgepairs.append( (_e[0].split(":")[0], _e[1].split(":")[0], + {"sourceport":int(_e[0].split(":")[1])}) ); + + self.G = nx.MultiDiGraph(); + self.G.add_edges_from(edgepairs); + + n_edges = self.G.edges(data=True); + for e in n_edges: + e[2]["weight"] = 5+random.random()*10; + + self.G.clear(); + self.G.add_edges_from(n_edges); + + + self.f = plt.figure(figsize=(10,8), dpi=90) + self.sp = self.f.add_subplot(111); + self.sp.autoscale_view(True,True,True); + self.sp.set_autoscale_on(True) + + self.canvas = FigureCanvas(self.f) + self.layout.addWidget(self.canvas); + + self.pos = nx.graphviz_layout(self.G); + #self.pos = nx.pygraphviz_layout(self.G); + #self.pos = nx.spectral_layout(self.G); + #self.pos = nx.circular_layout(self.G); + #self.pos = nx.shell_layout(self.G); + #self.pos = nx.spring_layout(self.G); + + # generate weights and plot + self.update(); + + # set up timer + self.timer = QtCore.QTimer() + self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.update) + self.timer.start(1000) + + # Set up mouse callback functions to move blocks around. + self._grabbed = False + self._current_block = '' + self.f.canvas.mpl_connect('button_press_event', + self.button_press) + self.f.canvas.mpl_connect('motion_notify_event', + self.mouse_move) + self.f.canvas.mpl_connect('button_release_event', + self.button_release) + + def button_press(self, event): + x, y = event.xdata, event.ydata + thrsh = 100 + + if(x is not None and y is not None): + nearby = map(lambda z: spatial.distance.euclidean((x,y), z), self.pos.values()) + i = nearby.index(min(nearby)) + if(abs(self.pos.values()[i][0] - x) < thrsh and + abs(self.pos.values()[i][1]-y) < thrsh): + self._current_block = self.pos.keys()[i] + #print "MOVING BLOCK: ", self._current_block + #print "CUR POS: ", self.pos.values()[i] + self._grabbed = True + + def mouse_move(self, event): + if self._grabbed: + x, y = event.xdata, event.ydata + if(x is not None and y is not None): + #print "NEW POS: ", (x,y) + self.pos[self._current_block] = (x,y) + self.updateGraph(); + + def button_release(self, event): + self._grabbed = False + + + def openMenu(self, pos): + index = self.table.treeWidget.selectedIndexes() + item = self.table.treeWidget.itemFromIndex(index[0]) + itemname = str(item.text(0)) + self.parent.propertiesMenu(itemname, self.radio, self.uid) + + def updateGraph(self): + + self.canvas.updateGeometry() + self.sp.clear(); + plt.figure(self.f.number) + plt.subplot(111); + nx.draw(self.G, self.pos, + edge_color=self.edge_weights, + node_color='#A0CBE2', + width=map(lambda x: 3+math.log(x), self.edge_weights), + node_shape="s", + node_size=self.node_weights, + #edge_cmap=plt.cm.Blues, + edge_cmap=plt.cm.Reds, + ax=self.sp, + arrows=False + ) + nx.draw_networkx_labels(self.G, self.pos, + font_size=12) + + self.canvas.draw(); + self.canvas.show(); + +class MyClient(IceRadioClient): + def __init__(self): + IceRadioClient.__init__(self, MAINWindow) + +sys.exit(MyClient().main(sys.argv)) diff --git a/gnuradio-core/src/tests/CMakeLists.txt b/gnuradio-core/src/tests/CMakeLists.txt index 60f394a96..ef58cf9ef 100644 --- a/gnuradio-core/src/tests/CMakeLists.txt +++ b/gnuradio-core/src/tests/CMakeLists.txt @@ -36,8 +36,8 @@ link_directories( ${CPPUNIT_LIBRARY_DIRS} ) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Build benchmarks and non-registered tests diff --git a/gr-analog/examples/tags/uhd_burst_detector.py b/gr-analog/examples/tags/uhd_burst_detector.py index 6e73e8ad1..c0a8d955c 100755 --- a/gr-analog/examples/tags/uhd_burst_detector.py +++ b/gr-analog/examples/tags/uhd_burst_detector.py @@ -70,7 +70,7 @@ class uhd_burst_detector(gr.top_block): self.f2s = blocks.float_to_short() # Use file sink burst tagger to capture bursts - self.fsnk = gr.tagged_file_sink(gr.sizeof_gr_complex, self.samp_rate) + self.fsnk = blocks.tagged_file_sink(gr.sizeof_gr_complex, self.samp_rate) ################################################## diff --git a/gr-analog/grc/analog_block_tree.xml b/gr-analog/grc/analog_block_tree.xml index 5d2ab6512..1c4e46c91 100644 --- a/gr-analog/grc/analog_block_tree.xml +++ b/gr-analog/grc/analog_block_tree.xml @@ -58,6 +58,7 @@ <block>analog_pll_carriertracking_cc</block> <block>analog_pll_freqdet_cf</block> <block>analog_pll_refout_cc</block> + <block>analog_plateau_detector_fb</block> </cat> <cat> <name>Probes</name> 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 000000000..f14efc97f --- /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 3c18c949a..1cbbf988f 100644 --- a/gr-analog/include/analog/CMakeLists.txt +++ b/gr-analog/include/analog/CMakeLists.txt @@ -95,6 +95,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 @@ -106,7 +107,7 @@ install(FILES quadrature_demod_cf.h rail_ff.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 92d777fa1..c304ba8f3 100644 --- a/gr-analog/include/analog/agc.h +++ b/gr-analog/include/analog/agc.h @@ -39,6 +39,14 @@ namespace gr { class ANALOG_API agc_cc { public: + /*! + * Construct a complex value AGC loop implementation object. + * + * \param rate the update rate of the loop. + * \param reference reference value to adjust signal power to. + * \param gain initial gain value. + * \param max_gain maximum gain value (0 for unlimited). + */ agc_cc(float rate = 1e-4, float reference = 1.0, float gain = 1.0, float max_gain = 0.0) : _rate(rate), _reference(reference), @@ -90,6 +98,14 @@ namespace gr { class ANALOG_API agc_ff { public: + /*! + * Construct a floating point value AGC loop implementation object. + * + * \param rate the update rate of the loop. + * \param reference reference value to adjust signal power to. + * \param gain initial gain value. + * \param max_gain maximum gain value (0 for unlimited). + */ agc_ff(float rate = 1e-4, float reference = 1.0, float gain = 1.0, float max_gain = 0.0) : _rate(rate), _reference(reference), _gain(gain), diff --git a/gr-analog/include/analog/agc2.h b/gr-analog/include/analog/agc2.h index 75a203e9f..8d1958d29 100644 --- a/gr-analog/include/analog/agc2.h +++ b/gr-analog/include/analog/agc2.h @@ -39,6 +39,15 @@ namespace gr { class ANALOG_API agc2_cc { public: + /*! + * Construct a comple value AGC loop implementation object. + * + * \param attack_rate the update rate of the loop when in attack mode. + * \param decay_rate the update rate of the loop when in decay mode. + * \param reference reference value to adjust signal power to. + * \param gain initial gain value. + * \param max_gain maximum gain value (0 for unlimited). + */ agc2_cc(float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, float gain = 1.0, float max_gain = 0.0) @@ -99,6 +108,15 @@ namespace gr { class ANALOG_API agc2_ff { public: + /*! + * Construct a floating point value AGC loop implementation object. + * + * \param attack_rate the update rate of the loop when in attack mode. + * \param decay_rate the update rate of the loop when in decay mode. + * \param reference reference value to adjust signal power to. + * \param gain initial gain value. + * \param max_gain maximum gain value (0 for unlimited). + */ agc2_ff(float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, float gain = 1.0, float max_gain = 0.0) diff --git a/gr-analog/include/analog/agc2_cc.h b/gr-analog/include/analog/agc2_cc.h index c922ccd4d..7f3a7c24b 100644 --- a/gr-analog/include/analog/agc2_cc.h +++ b/gr-analog/include/analog/agc2_cc.h @@ -31,7 +31,8 @@ namespace gr { namespace analog { /*! - * \brief high performance Automatic Gain Control class + * \brief high performance Automatic Gain Control class with + * attack and decay rates. * \ingroup level_blk * * For Power the absolute value of the complex number is used. @@ -42,6 +43,15 @@ namespace gr { // gr::analog::agc2_cc::sptr typedef boost::shared_ptr<agc2_cc> sptr; + /*! + * Build a complex value AGC loop block with attack and decay rates. + * + * \param attack_rate the update rate of the loop when in attack mode. + * \param decay_rate the update rate of the loop when in decay mode. + * \param reference reference value to adjust signal power to. + * \param gain initial gain value. + * \param max_gain maximum gain value (0 for unlimited). + */ static sptr make(float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, float gain = 1.0, float max_gain = 0.0); diff --git a/gr-analog/include/analog/agc2_ff.h b/gr-analog/include/analog/agc2_ff.h index 27dd6d92e..4bb7b0f64 100644 --- a/gr-analog/include/analog/agc2_ff.h +++ b/gr-analog/include/analog/agc2_ff.h @@ -31,7 +31,8 @@ namespace gr { namespace analog { /*! - * \brief high performance Automatic Gain Control class + * \brief high performance Automatic Gain Control class with + * attack and decay rates. * * \ingroup level_blk * Power is approximated by absolute value @@ -42,6 +43,15 @@ namespace gr { // gr::analog::agc2_ff::sptr typedef boost::shared_ptr<agc2_ff> sptr; + /*! + * Build a floating point AGC loop block with attack and decay rates. + * + * \param attack_rate the update rate of the loop when in attack mode. + * \param decay_rate the update rate of the loop when in decay mode. + * \param reference reference value to adjust signal power to. + * \param gain initial gain value. + * \param max_gain maximum gain value (0 for unlimited). + */ static sptr make(float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, float gain = 1.0, float max_gain = 0.0); diff --git a/gr-analog/include/analog/agc_cc.h b/gr-analog/include/analog/agc_cc.h index b2b1a9b43..0e59f8593 100644 --- a/gr-analog/include/analog/agc_cc.h +++ b/gr-analog/include/analog/agc_cc.h @@ -42,6 +42,14 @@ namespace gr { // gr::analog::agc_cc::sptr typedef boost::shared_ptr<agc_cc> sptr; + /*! + * Build a complex value AGC loop block. + * + * \param rate the update rate of the loop. + * \param reference reference value to adjust signal power to. + * \param gain initial gain value. + * \param max_gain maximum gain value (0 for unlimited). + */ static sptr make(float rate = 1e-4, float reference = 1.0, float gain = 1.0, float max_gain = 0.0); diff --git a/gr-analog/include/analog/agc_ff.h b/gr-analog/include/analog/agc_ff.h index 30d1ae1fd..6046d6f64 100644 --- a/gr-analog/include/analog/agc_ff.h +++ b/gr-analog/include/analog/agc_ff.h @@ -42,6 +42,14 @@ namespace gr { // gr::analog::agc_ff::sptr typedef boost::shared_ptr<agc_ff> sptr; + /*! + * Build a floating point AGC loop block. + * + * \param rate the update rate of the loop. + * \param reference reference value to adjust signal power to. + * \param gain initial gain value. + * \param max_gain maximum gain value (0 for unlimited). + */ static sptr make(float rate = 1e-4, float reference = 1.0, float gain = 1.0, float max_gain = 0.0); diff --git a/gr-analog/include/analog/cpm.h b/gr-analog/include/analog/cpm.h index d22e02321..aff0dd19e 100644 --- a/gr-analog/include/analog/cpm.h +++ b/gr-analog/include/analog/cpm.h @@ -28,6 +28,9 @@ namespace gr { namespace analog { + /*! \brief Return the taps for an interpolating FIR filter + * (gr::filter::interp_fir_filter_fff). + */ class ANALOG_API cpm { public: @@ -40,25 +43,30 @@ namespace gr { GENERIC = 999 }; - /*! \brief Return the taps for an interpolating FIR filter (gr_interp_fir_filter_fff). + /*! \brief Return the taps for an interpolating FIR filter + * (gr::filter::interp_fir_filter_fff). * - * These taps represent the phase response \f$g(k)\f$ for use in a CPM modulator, - * see also gr_cpmmod_bc. + * These taps represent the phase response \f$g(k)\f$ for use in + * a CPM modulator, see also gr_cpmmod_bc. * - * \param type The CPM type (Rectangular, Raised Cosine, Spectral Raised Cosine, - * Tamed FM or Gaussian). + * \param type The CPM type (Rectangular, Raised Cosine, + * Spectral Raised Cosine, Tamed FM or Gaussian). * \param samples_per_sym Samples per symbol. * \param L The length of the phase response in symbols. - * \param beta For Spectral Raised Cosine, this is the rolloff factor. For Gaussian - * phase responses, this the 3dB-time-bandwidth product. For all other - * cases, it is ignored. + * \param beta For Spectral Raised Cosine, this is the rolloff + * factor. For Gaussian phase responses, this the + * 3dB-time-bandwidth product. For all other cases, + * it is ignored. * - * Output: returns a vector of length \a K = \p samples_per_sym x \p L. - * This can be used directly in an interpolating FIR filter such as - * gr_interp_fir_filter_fff with interpolation factor \p samples_per_sym. + * Output: returns a vector of length \a K = \p samples_per_sym + * x \p L. This can be used directly in an + * interpolating FIR filter such as + * gr_interp_fir_filter_fff with interpolation factor \p + * samples_per_sym. * - * All phase responses are normalised s.t. \f$ \sum_{k=0}^{K-1} g(k) = 1\f$; this will cause - * a maximum phase change of \f$ h \cdot \pi\f$ between two symbols, where \a h is the + * All phase responses are normalised s.t. \f$ \sum_{k=0}^{K-1} + * g(k) = 1\f$; this will cause a maximum phase change of \f$ h + * \cdot \pi\f$ between two symbols, where \a h is the * modulation index. * * The following phase responses can be generated: @@ -77,7 +85,8 @@ namespace gr { * [1]: Anderson, Aulin and Sundberg; Digital Phase Modulation */ static std::vector<float> - phase_response(cpm_type type, unsigned samples_per_sym, unsigned L, double beta=0.3); + phase_response(cpm_type type, unsigned samples_per_sym, + unsigned L, double beta=0.3); }; } // namespace analog } // namespace gr diff --git a/gr-analog/include/analog/ctcss_squelch_ff.h b/gr-analog/include/analog/ctcss_squelch_ff.h index f88029917..b63876714 100644 --- a/gr-analog/include/analog/ctcss_squelch_ff.h +++ b/gr-analog/include/analog/ctcss_squelch_ff.h @@ -31,7 +31,7 @@ namespace gr { namespace analog { /*! - * \brief gate or zero output if ctcss tone not present + * \brief gate or zero output if CTCSS tone not present * \ingroup level_blk */ class ANALOG_API ctcss_squelch_ff : @@ -47,6 +47,14 @@ namespace gr { /*! * \brief Make CTCSS tone squelch block. + * + * \param rate gain of the internal frequency filters. + * \param freq frequency value to use as the squelch tone. + * \param level threshold level for the squelch tone. + * \param len length of the frequency filters. + * \param ramp sets response characteristic. + * \param gate if true, no output if no squelch tone. + * if false, output 0's if no squelch tone. */ static sptr make(int rate, float freq, float level, int len, int ramp, bool gate); diff --git a/gr-analog/include/analog/feedforward_agc_cc.h b/gr-analog/include/analog/feedforward_agc_cc.h index 9e259a4eb..743b9b3a3 100644 --- a/gr-analog/include/analog/feedforward_agc_cc.h +++ b/gr-analog/include/analog/feedforward_agc_cc.h @@ -30,7 +30,8 @@ namespace gr { namespace analog { /*! - * \brief Non-causal AGC which computes required gain based on max absolute value over nsamples + * \brief Non-causal AGC which computes required gain based on max + * absolute value over nsamples * \ingroup level_blk */ class ANALOG_API feedforward_agc_cc : virtual public gr_sync_block @@ -38,7 +39,13 @@ namespace gr { public: // gr::analog::feedforward_agc_cc::sptr typedef boost::shared_ptr<feedforward_agc_cc> sptr; - + + /*! + * Build a complex valued feed-forward AGC loop block. + * + * \param nsamples number of samples to look ahead. + * \param reference reference value to adjust signal power to. + */ static sptr make(int nsamples, float reference); }; diff --git a/gr-analog/include/analog/frequency_modulator_fc.h b/gr-analog/include/analog/frequency_modulator_fc.h index 8706d513a..67be1ff00 100644 --- a/gr-analog/include/analog/frequency_modulator_fc.h +++ b/gr-analog/include/analog/frequency_modulator_fc.h @@ -41,6 +41,11 @@ namespace gr { // gr::analog::frequency_modulator_fc::sptr typedef boost::shared_ptr<frequency_modulator_fc> sptr; + /*! + * Build a frequency modulator block. + * + * \param sensitivity radians/sample = amplitude * sensitivity + */ static sptr make(double sensitivity); virtual void set_sensitivity(float sens) = 0; 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 000000000..33629bd18 --- /dev/null +++ b/gr-analog/include/analog/plateau_detector_fb.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_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. + * + * 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. + * + * \ingroup analog + * + */ + 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/pwr_squelch_cc.h b/gr-analog/include/analog/pwr_squelch_cc.h index 79364a86b..e3f6fb67f 100644 --- a/gr-analog/include/analog/pwr_squelch_cc.h +++ b/gr-analog/include/analog/pwr_squelch_cc.h @@ -50,8 +50,9 @@ namespace gr { * * \param db threshold (in dB) for power squelch * \param alpha Gain of averaging filter - * \param ramp - * \param gate + * \param ramp sets response characteristic. + * \param gate if true, no output if no squelch tone. + * if false, output 0's if no squelch tone. */ static sptr make(double db, double alpha=0.0001, int ramp=0, bool gate=false); diff --git a/gr-analog/include/analog/pwr_squelch_ff.h b/gr-analog/include/analog/pwr_squelch_ff.h index 6fdebec74..f8f7b4aac 100644 --- a/gr-analog/include/analog/pwr_squelch_ff.h +++ b/gr-analog/include/analog/pwr_squelch_ff.h @@ -50,8 +50,9 @@ namespace gr { * * \param db threshold (in dB) for power squelch * \param alpha Gain of averaging filter - * \param ramp - * \param gate + * \param ramp sets response characteristic. + * \param gate if true, no output if no squelch tone. + * if false, output 0's if no squelch tone. */ static sptr make(double db, double alpha=0.0001, int ramp=0, bool gate=false); diff --git a/gr-analog/include/analog/quadrature_demod_cf.h b/gr-analog/include/analog/quadrature_demod_cf.h index 916d8b2ec..fc29e494d 100644 --- a/gr-analog/include/analog/quadrature_demod_cf.h +++ b/gr-analog/include/analog/quadrature_demod_cf.h @@ -42,6 +42,12 @@ namespace gr { // gr::analog::quadrature_demod_cf::sptr typedef boost::shared_ptr<quadrature_demod_cf> sptr; + /* \brief Make a quadrature demodulator block. + * + * \param gain Gain setting to adjust the output amplitude. Set + * based on converting the phase difference between + * samples to a nominal output value. + */ static sptr make(float gain); virtual void set_gain(float gain) = 0; diff --git a/gr-analog/include/analog/rail_ff.h b/gr-analog/include/analog/rail_ff.h index e51b2fc93..120ca2815 100644 --- a/gr-analog/include/analog/rail_ff.h +++ b/gr-analog/include/analog/rail_ff.h @@ -39,6 +39,12 @@ namespace gr { // gr::analog::rail_ff::sptr typedef boost::shared_ptr<rail_ff> sptr; + /*! + * Build a rail block. + * + * \param lo the low value to clip to. + * \param hi the high value to clip to. + */ static sptr make(float lo, float hi); virtual float lo() const = 0; diff --git a/gr-analog/include/analog/sincos.h b/gr-analog/include/analog/sincos.h index 38b9d96da..a71164c88 100644 --- a/gr-analog/include/analog/sincos.h +++ b/gr-analog/include/analog/sincos.h @@ -28,8 +28,10 @@ namespace gr { namespace analog { - // compute sine and cosine at the same time + //! compute double sine and cosine at the same time ANALOG_API void sincos(double x, double *sin, double *cos); + + //! compute floating point sine and cosine at the same time ANALOG_API void sincosf(float x, float *sin, float *cos); } /* namespace analog */ diff --git a/gr-analog/lib/CMakeLists.txt b/gr-analog/lib/CMakeLists.txt index a85c90851..53cbb00a5 100644 --- a/gr-analog/lib/CMakeLists.txt +++ b/gr-analog/lib/CMakeLists.txt @@ -128,6 +128,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 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 000000000..0d2890bc5 --- /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/gnuradio-core/src/lib/io/gr_file_sink.i b/gr-analog/lib/plateau_detector_fb_impl.h index 47ab9e964..daf1dd56d 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink.i +++ b/gr-analog/lib/plateau_detector_fb_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,26 +20,31 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,file_sink) +#ifndef INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_IMPL_H +#define INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_IMPL_H -gr_file_sink_sptr -gr_make_file_sink (size_t itemsize, const char *filename); +#include <analog/plateau_detector_fb.h> -class gr_file_sink : public gr_sync_block, public gr_file_sink_base +namespace gr { + namespace analog { + +class plateau_detector_fb_impl : public plateau_detector_fb { - protected: - gr_file_sink (size_t itemsize, const char *filename); + private: + int d_max_len; + float d_threshold; public: - ~gr_file_sink (); - - /*! - * \brief open filename and begin output to it. - */ - bool open(const char *filename); + plateau_detector_fb_impl(int max_len, float threshold); + ~plateau_detector_fb_impl(); - /*! - * \brief close current output file. - */ - void close(); + 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/lib/pll_carriertracking_cc_impl.cc b/gr-analog/lib/pll_carriertracking_cc_impl.cc index c53e0f433..9213a5e68 100644 --- a/gr-analog/lib/pll_carriertracking_cc_impl.cc +++ b/gr-analog/lib/pll_carriertracking_cc_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2010-2012 Free Software Foundation, Inc. + * Copyright 2006,2010-2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -50,7 +50,7 @@ namespace gr { : gr_sync_block("pll_carriertracking_cc", gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signature(1, 1, sizeof(gr_complex))), - gri_control_loop(loop_bw, max_freq, min_freq), + blocks::control_loop(loop_bw, max_freq, min_freq), d_locksig(0), d_lock_threshold(0), d_squelch_enable(false) { } @@ -130,98 +130,98 @@ namespace gr { void pll_carriertracking_cc_impl::set_loop_bandwidth(float bw) { - gri_control_loop::set_loop_bandwidth(bw); + blocks::control_loop::set_loop_bandwidth(bw); } void pll_carriertracking_cc_impl::set_damping_factor(float df) { - gri_control_loop::set_damping_factor(df); + blocks::control_loop::set_damping_factor(df); } void pll_carriertracking_cc_impl::set_alpha(float alpha) { - gri_control_loop::set_alpha(alpha); + blocks::control_loop::set_alpha(alpha); } void pll_carriertracking_cc_impl::set_beta(float beta) { - gri_control_loop::set_beta(beta); + blocks::control_loop::set_beta(beta); } void pll_carriertracking_cc_impl::set_frequency(float freq) { - gri_control_loop::set_frequency(freq); + blocks::control_loop::set_frequency(freq); } void pll_carriertracking_cc_impl::set_phase(float phase) { - gri_control_loop::set_phase(phase); + blocks::control_loop::set_phase(phase); } void pll_carriertracking_cc_impl::set_min_freq(float freq) { - gri_control_loop::set_min_freq(freq); + blocks::control_loop::set_min_freq(freq); } void pll_carriertracking_cc_impl::set_max_freq(float freq) { - gri_control_loop::set_max_freq(freq); + blocks::control_loop::set_max_freq(freq); } float pll_carriertracking_cc_impl::get_loop_bandwidth() const { - return gri_control_loop::get_loop_bandwidth(); + return blocks::control_loop::get_loop_bandwidth(); } float pll_carriertracking_cc_impl::get_damping_factor() const { - return gri_control_loop::get_damping_factor(); + return blocks::control_loop::get_damping_factor(); } float pll_carriertracking_cc_impl::get_alpha() const { - return gri_control_loop::get_alpha(); + return blocks::control_loop::get_alpha(); } float pll_carriertracking_cc_impl::get_beta() const { - return gri_control_loop::get_beta(); + return blocks::control_loop::get_beta(); } float pll_carriertracking_cc_impl::get_frequency() const { - return gri_control_loop::get_frequency(); + return blocks::control_loop::get_frequency(); } float pll_carriertracking_cc_impl::get_phase() const { - return gri_control_loop::get_phase(); + return blocks::control_loop::get_phase(); } float pll_carriertracking_cc_impl::get_min_freq() const { - return gri_control_loop::get_min_freq(); + return blocks::control_loop::get_min_freq(); } float pll_carriertracking_cc_impl::get_max_freq() const { - return gri_control_loop::get_max_freq(); + return blocks::control_loop::get_max_freq(); } } /* namespace analog */ diff --git a/gr-analog/lib/pll_carriertracking_cc_impl.h b/gr-analog/lib/pll_carriertracking_cc_impl.h index d67223db8..54de4442d 100644 --- a/gr-analog/lib/pll_carriertracking_cc_impl.h +++ b/gr-analog/lib/pll_carriertracking_cc_impl.h @@ -24,13 +24,13 @@ #define INCLUDED_ANALOG_PLL_CARRIERTRACKING_CC_IMPL_H #include <analog/pll_carriertracking_cc.h> -#include <gri_control_loop.h> +#include <blocks/control_loop.h> namespace gr { namespace analog { class pll_carriertracking_cc_impl - : public pll_carriertracking_cc, public gri_control_loop + : public pll_carriertracking_cc, public blocks::control_loop { private: float d_locksig,d_lock_threshold; diff --git a/gr-analog/lib/pll_freqdet_cf_impl.cc b/gr-analog/lib/pll_freqdet_cf_impl.cc index 27e8d02aa..9e55d9bed 100644 --- a/gr-analog/lib/pll_freqdet_cf_impl.cc +++ b/gr-analog/lib/pll_freqdet_cf_impl.cc @@ -47,7 +47,7 @@ namespace gr { : gr_sync_block("pll_freqdet_cf", gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signature(1, 1, sizeof(float))), - gri_control_loop(loop_bw, max_freq, min_freq) + blocks::control_loop(loop_bw, max_freq, min_freq) { } @@ -100,98 +100,98 @@ namespace gr { void pll_freqdet_cf_impl::set_loop_bandwidth(float bw) { - gri_control_loop::set_loop_bandwidth(bw); + blocks::control_loop::set_loop_bandwidth(bw); } void pll_freqdet_cf_impl::set_damping_factor(float df) { - gri_control_loop::set_damping_factor(df); + blocks::control_loop::set_damping_factor(df); } void pll_freqdet_cf_impl::set_alpha(float alpha) { - gri_control_loop::set_alpha(alpha); + blocks::control_loop::set_alpha(alpha); } void pll_freqdet_cf_impl::set_beta(float beta) { - gri_control_loop::set_beta(beta); + blocks::control_loop::set_beta(beta); } void pll_freqdet_cf_impl::set_frequency(float freq) { - gri_control_loop::set_frequency(freq); + blocks::control_loop::set_frequency(freq); } void pll_freqdet_cf_impl::set_phase(float phase) { - gri_control_loop::set_phase(phase); + blocks::control_loop::set_phase(phase); } void pll_freqdet_cf_impl::set_min_freq(float freq) { - gri_control_loop::set_min_freq(freq); + blocks::control_loop::set_min_freq(freq); } void pll_freqdet_cf_impl::set_max_freq(float freq) { - gri_control_loop::set_max_freq(freq); + blocks::control_loop::set_max_freq(freq); } float pll_freqdet_cf_impl::get_loop_bandwidth() const { - return gri_control_loop::get_loop_bandwidth(); + return blocks::control_loop::get_loop_bandwidth(); } float pll_freqdet_cf_impl::get_damping_factor() const { - return gri_control_loop::get_damping_factor(); + return blocks::control_loop::get_damping_factor(); } float pll_freqdet_cf_impl::get_alpha() const { - return gri_control_loop::get_alpha(); + return blocks::control_loop::get_alpha(); } float pll_freqdet_cf_impl::get_beta() const { - return gri_control_loop::get_beta(); + return blocks::control_loop::get_beta(); } float pll_freqdet_cf_impl::get_frequency() const { - return gri_control_loop::get_frequency(); + return blocks::control_loop::get_frequency(); } float pll_freqdet_cf_impl::get_phase() const { - return gri_control_loop::get_phase(); + return blocks::control_loop::get_phase(); } float pll_freqdet_cf_impl::get_min_freq() const { - return gri_control_loop::get_min_freq(); + return blocks::control_loop::get_min_freq(); } float pll_freqdet_cf_impl::get_max_freq() const { - return gri_control_loop::get_max_freq(); + return blocks::control_loop::get_max_freq(); } } /* namespace analog */ diff --git a/gr-analog/lib/pll_freqdet_cf_impl.h b/gr-analog/lib/pll_freqdet_cf_impl.h index 7acf53ebb..10bcdc215 100644 --- a/gr-analog/lib/pll_freqdet_cf_impl.h +++ b/gr-analog/lib/pll_freqdet_cf_impl.h @@ -24,13 +24,13 @@ #define INCLUDED_ANALOG_PLL_FREQDET_CF_IMPL_H #include <analog/pll_freqdet_cf.h> -#include <gri_control_loop.h> +#include <blocks/control_loop.h> namespace gr { namespace analog { class pll_freqdet_cf_impl : - public pll_freqdet_cf, public gri_control_loop + public pll_freqdet_cf, public blocks::control_loop { private: float phase_detector(gr_complex sample,float ref_phase); diff --git a/gr-analog/lib/pll_refout_cc_impl.cc b/gr-analog/lib/pll_refout_cc_impl.cc index b94e3660a..3f0ccc7df 100644 --- a/gr-analog/lib/pll_refout_cc_impl.cc +++ b/gr-analog/lib/pll_refout_cc_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010-2012 Free Software Foundation, Inc. + * Copyright 2004,2010-2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -48,7 +48,7 @@ namespace gr { : gr_sync_block("pll_refout_cc", gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signature(1, 1, sizeof(gr_complex))), - gri_control_loop(loop_bw, max_freq, min_freq) + blocks::control_loop(loop_bw, max_freq, min_freq) { } @@ -103,98 +103,98 @@ namespace gr { void pll_refout_cc_impl::set_loop_bandwidth(float bw) { - gri_control_loop::set_loop_bandwidth(bw); + blocks::control_loop::set_loop_bandwidth(bw); } void pll_refout_cc_impl::set_damping_factor(float df) { - gri_control_loop::set_damping_factor(df); + blocks::control_loop::set_damping_factor(df); } void pll_refout_cc_impl::set_alpha(float alpha) { - gri_control_loop::set_alpha(alpha); + blocks::control_loop::set_alpha(alpha); } void pll_refout_cc_impl::set_beta(float beta) { - gri_control_loop::set_beta(beta); + blocks::control_loop::set_beta(beta); } void pll_refout_cc_impl::set_frequency(float freq) { - gri_control_loop::set_frequency(freq); + blocks::control_loop::set_frequency(freq); } void pll_refout_cc_impl::set_phase(float phase) { - gri_control_loop::set_phase(phase); + blocks::control_loop::set_phase(phase); } void pll_refout_cc_impl::set_min_freq(float freq) { - gri_control_loop::set_min_freq(freq); + blocks::control_loop::set_min_freq(freq); } void pll_refout_cc_impl::set_max_freq(float freq) { - gri_control_loop::set_max_freq(freq); + blocks::control_loop::set_max_freq(freq); } float pll_refout_cc_impl::get_loop_bandwidth() const { - return gri_control_loop::get_loop_bandwidth(); + return blocks::control_loop::get_loop_bandwidth(); } float pll_refout_cc_impl::get_damping_factor() const { - return gri_control_loop::get_damping_factor(); + return blocks::control_loop::get_damping_factor(); } float pll_refout_cc_impl::get_alpha() const { - return gri_control_loop::get_alpha(); + return blocks::control_loop::get_alpha(); } float pll_refout_cc_impl::get_beta() const { - return gri_control_loop::get_beta(); + return blocks::control_loop::get_beta(); } float pll_refout_cc_impl::get_frequency() const { - return gri_control_loop::get_frequency(); + return blocks::control_loop::get_frequency(); } float pll_refout_cc_impl::get_phase() const { - return gri_control_loop::get_phase(); + return blocks::control_loop::get_phase(); } float pll_refout_cc_impl::get_min_freq() const { - return gri_control_loop::get_min_freq(); + return blocks::control_loop::get_min_freq(); } float pll_refout_cc_impl::get_max_freq() const { - return gri_control_loop::get_max_freq(); + return blocks::control_loop::get_max_freq(); } } /* namespace analog */ diff --git a/gr-analog/lib/pll_refout_cc_impl.h b/gr-analog/lib/pll_refout_cc_impl.h index 9e8ae286b..f8572f9b6 100644 --- a/gr-analog/lib/pll_refout_cc_impl.h +++ b/gr-analog/lib/pll_refout_cc_impl.h @@ -24,13 +24,13 @@ #define INCLUDED_ANALOG_PLL_REFOUT_CC_IMPL_H #include <analog/pll_refout_cc.h> -#include <gri_control_loop.h> +#include <blocks/control_loop.h> namespace gr { namespace analog { class pll_refout_cc_impl - : public pll_refout_cc, public gri_control_loop + : public pll_refout_cc, public blocks::control_loop { private: float mod_2pi (float in); diff --git a/gr-analog/python/CMakeLists.txt b/gr-analog/python/CMakeLists.txt index a3f789ddf..44e38621a 100644 --- a/gr-analog/python/CMakeLists.txt +++ b/gr-analog/python/CMakeLists.txt @@ -59,3 +59,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_agc.py b/gr-analog/python/qa_agc.py index 2733ed3fa..263f9a647 100755 --- a/gr-analog/python/qa_agc.py +++ b/gr-analog/python/qa_agc.py @@ -24,14 +24,12 @@ from gnuradio import gr, gr_unittest import analog_swig as analog import math -test_output = False +class test_agc(gr_unittest.TestCase): -class test_agc (gr_unittest.TestCase): + def setUp(self): + self.tb = gr.top_block() - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): + def tearDown(self): self.tb = None @@ -116,9 +114,6 @@ class test_agc (gr_unittest.TestCase): tb.connect(head, agc) tb.connect(agc, dst1) - if test_output == True: - tb.connect(agc, gr.file_sink(gr.sizeof_gr_complex, "test_agc_cc.dat")) - tb.run() dst_data = dst1.data() self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 4) @@ -204,9 +199,6 @@ class test_agc (gr_unittest.TestCase): tb.connect (head, agc) tb.connect (agc, dst1) - if test_output == True: - tb.connect (agc, gr.file_sink(gr.sizeof_float, "test_agc_ff.dat")) - tb.run () dst_data = dst1.data () self.assertFloatTuplesAlmostEqual (expected_result, dst_data, 4) @@ -294,9 +286,6 @@ class test_agc (gr_unittest.TestCase): tb.connect(head, agc) tb.connect(agc, dst1) - if test_output == True: - tb.connect(agc, gr.file_sink(gr.sizeof_gr_complex, "test_agc2_cc.dat")) - tb.run() dst_data = dst1.data() self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 4) @@ -384,9 +373,6 @@ class test_agc (gr_unittest.TestCase): tb.connect(head, agc) tb.connect(agc, dst1) - if test_output == True: - tb.connect(agc, gr.file_sink(gr.sizeof_float, "test_agc2_ff.dat")) - tb.run() dst_data = dst1.data() self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4) @@ -460,9 +446,6 @@ class test_agc (gr_unittest.TestCase): tb.connect(head, agc) tb.connect(agc, dst1) - if test_output == True: - tb.connect(agc, gr.file_sink(gr.sizeof_gr_complex, "test_agc2_cc.dat")) - tb.run() dst_data = dst1.data() self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 4) @@ -481,10 +464,6 @@ class test_agc (gr_unittest.TestCase): dst = gr.vector_sink_c() self.tb.connect(src, agc, dst) - if test_output == True: - self.tb.connect(agc, gr.file_sink(gr.sizeof_gr_complex, - "test_feedforward_cc.dat")) - self.tb.run() dst_data = dst.data()[0:len(expected_result)] 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 000000000..5f8abc74e --- /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 ab7beb3c0..2c6f5a66c 100644 --- a/gr-analog/swig/analog_swig.i +++ b/gr-analog/swig/analog_swig.i @@ -49,6 +49,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" @@ -91,6 +92,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" @@ -130,6 +132,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/CMakeLists.txt b/gr-atsc/CMakeLists.txt index 10a7904b2..df7ac54f0 100644 --- a/gr-atsc/CMakeLists.txt +++ b/gr-atsc/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 # @@ -36,7 +36,8 @@ GR_REGISTER_COMPONENT("gr-atsc" ENABLE_GR_ATSC ) GR_SET_GLOBAL(GR_ATSC_INCLUDE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/src/lib + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_BINARY_DIR}/lib ) ######################################################################## @@ -88,9 +89,11 @@ CPACK_COMPONENT("atsc_swig" ######################################################################## # Add subdirectories ######################################################################## -add_subdirectory(src/lib) +add_subdirectory(lib) +add_subdirectory(include/atsc) if(ENABLE_PYTHON) - add_subdirectory(src/python) + add_subdirectory(swig) + add_subdirectory(python) endif(ENABLE_PYTHON) ######################################################################## diff --git a/gr-atsc/include/atsc/CMakeLists.txt b/gr-atsc/include/atsc/CMakeLists.txt new file mode 100644 index 000000000..cdf818aab --- /dev/null +++ b/gr-atsc/include/atsc/CMakeLists.txt @@ -0,0 +1,103 @@ +# 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. + +######################################################################## +# Install header files +######################################################################## +install(FILES + api.h + basic_trellis_encoder_impl.h + bit_timing_loop.h + CMakeLists.txt + consts.h + convolutional_interleaver.h + create_atsci_equalizer.h + create_atsci_fs_checker.h + create_atsci_fs_correlator.h + data_interleaver_impl.h + deinterleaver.h + depad.h + derandomizer.h + diag_output_impl.h + ds_to_softds.h + equalizer.h + equalizer_impl.h + equalizer_lms2_impl.h + equalizer_lms_impl.h + equalizer_nop_impl.h + exp2_lp_impl.h + fake_single_viterbi_impl.h + field_sync_demux.h + field_sync_mux.h + fpll.h + fs_checker.h + fs_checker_impl.h + fs_checker_naive_impl.h + fs_correlator_impl.h + fs_correlator_naive_impl.h + GrAtscBitTimingLoop2.h + GrAtscBitTimingLoop3.h + GrAtscBitTimingLoop.h + GrAtscConvert2xTo20.h + GrAtscDataSegToSoftDataSeg.h + GrAtscDeinterleaver.h + GrAtscDerandomizer.h + GrAtscEqualizer.h + GrAtscFieldSyncChecker.h + GrAtscFieldSyncCorrelator.h + GrAtscFieldSyncDemux.h + GrAtscFieldSyncMux.h + GrAtscFPLL.h + GrAtscInterleaver.h + GrAtscRandomizer.h + GrAtscRSDecoder.h + GrAtscRSEncoder.h + GrAtscSegSymSync.h + GrAtscSegSymSyncImpl_export.h + GrAtscSegSymSyncImpl.h + GrAtscSymbolMapper.h + GrAtscTrellisEncoder.h + GrAtscViterbiDecoder.h + interleaver_fifo.h + interleaver.h + pad.h + pnXXX_impl.h + randomizer.h + randomizer_impl.h + reed_solomon_impl.h + root_raised_cosine_bandpass_impl.h + root_raised_cosine_impl.h + rs_decoder.h + rs_encoder.h + single_viterbi_impl.h + slicer_agc_impl.h + sliding_correlator_impl.h + sssr_impl.h + syminfo_impl.h + sync_tag_impl.h + trellis_encoder.h + trellis_encoder_impl.h + types.h + viterbi_decoder.h + viterbi_decoder_impl.h + vsbtx_lp_impl.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/atsc + COMPONENT "atsc_devel" +) + diff --git a/gr-atsc/src/lib/GrAtscBitTimingLoop.h b/gr-atsc/include/atsc/GrAtscBitTimingLoop.h index fa64f4d37..1bedbb39e 100644 --- a/gr-atsc/src/lib/GrAtscBitTimingLoop.h +++ b/gr-atsc/include/atsc/GrAtscBitTimingLoop.h @@ -23,16 +23,16 @@ #ifndef _GRATSCBITTIMINGLOOP_H_ #define _GRATSCBITTIMINGLOOP_H_ -#include <gr_nco.h> +#include <blocks/nco.h> #include <VrSigProc.h> #include <VrHistoryProc.h> #include <VrDecimatingSigProc.h> -#include <interleaver_fifo.h> -#include <gr_single_pole_iir.h> -#include <gr_mmse_fir_interpolator.h> -#include <atsci_slicer_agc.h> +#include <atsc/interleaver_fifo.h> +#include <filter/single_pole_iir.h> +#include <filter/mmse_fir_interpolator.h> +#include <atsc/slicer_agc_impl.h> #include <stdio.h> -#include <atsci_diag_output.h> +#include <atsc/diag_output_impl.h> /*! diff --git a/gr-atsc/src/lib/GrAtscBitTimingLoop2.h b/gr-atsc/include/atsc/GrAtscBitTimingLoop2.h index 4f36c902e..64d25da01 100644 --- a/gr-atsc/src/lib/GrAtscBitTimingLoop2.h +++ b/gr-atsc/include/atsc/GrAtscBitTimingLoop2.h @@ -23,13 +23,13 @@ #ifndef _GRATSCBITTIMINGLOOP2_H_ #define _GRATSCBITTIMINGLOOP2_H_ -#include <gr_nco.h> +#include <blocks/nco.h> #include <VrSigProc.h> #include <VrHistoryProc.h> #include <VrDecimatingSigProc.h> -#include <interleaver_fifo.h> -#include <gr_single_pole_iir.h> -#include <gr_mmse_fir_interpolator.h> +#include <atsc/interleaver_fifo.h> +#include <filtersingle_pole_iir.h> +#include <filter/mmse_fir_interpolator.h> /*! * \brief ATSC BitTimingLoop diff --git a/gr-atsc/src/lib/GrAtscBitTimingLoop3.h b/gr-atsc/include/atsc/GrAtscBitTimingLoop3.h index 7e019e49c..c0fb333ac 100644 --- a/gr-atsc/src/lib/GrAtscBitTimingLoop3.h +++ b/gr-atsc/include/atsc/GrAtscBitTimingLoop3.h @@ -25,9 +25,9 @@ #include <cstdio> #include <VrDecimatingSigProc.h> -#include <atsci_diag_output.h> -#include <atsci_sssr.h> -#include <atsci_syminfo.h> +#include <atsc/diag_output_impl.h> +#include <atsc/sssr_impl.h> +#include <atsc/syminfo_impl.h> /*! * \brief ATSC BitTimingLoop3 diff --git a/gr-atsc/src/lib/GrAtscConvert2xTo20.h b/gr-atsc/include/atsc/GrAtscConvert2xTo20.h index 05b1023e5..47ea4fb59 100644 --- a/gr-atsc/src/lib/GrAtscConvert2xTo20.h +++ b/gr-atsc/include/atsc/GrAtscConvert2xTo20.h @@ -23,7 +23,7 @@ #define _GRATSCCONVERT2XTO20_H_ #include <VrDecimatingSigProc.h> -#include <gr_mmse_fir_interpolator.h> +#include <filter/mmse_fir_interpolator.h> class GrAtscConvert2xTo20 : public VrDecimatingSigProc<float,float> { gr_mmse_fir_interpolator d_interp; diff --git a/gr-atsc/src/lib/GrAtscDataSegToSoftDataSeg.h b/gr-atsc/include/atsc/GrAtscDataSegToSoftDataSeg.h index 207324d55..5fcb89432 100644 --- a/gr-atsc/src/lib/GrAtscDataSegToSoftDataSeg.h +++ b/gr-atsc/include/atsc/GrAtscDataSegToSoftDataSeg.h @@ -24,7 +24,7 @@ #define _GRATSCDATASEGTOSOFTDATASEG_H_ #include <VrHistoryProc.h> -#include <atsc_types.h> +#include <atsc/types.h> /*! * \brief Debug glue routine (atsc_data_segment --> atsc_soft_data_segment) diff --git a/gr-atsc/src/lib/GrAtscDeinterleaver.h b/gr-atsc/include/atsc/GrAtscDeinterleaver.h index f0f9830b6..8b602fa2d 100644 --- a/gr-atsc/src/lib/GrAtscDeinterleaver.h +++ b/gr-atsc/include/atsc/GrAtscDeinterleaver.h @@ -24,8 +24,8 @@ #define _GRATSCDEINTERLEAVER_H_ #include <VrHistoryProc.h> -#include <atsc_types.h> -#include <atsci_data_interleaver.h> +#include <atsc/types.h> +#include <atsc/data_interleaver_impl.h> /*! * \brief Deinterleave RS encoded ATSC data ( atsc_mpeg_packet_rs_encoded --> atsc_mpeg_packet_rs_encoded) diff --git a/gr-atsc/src/lib/GrAtscDerandomizer.h b/gr-atsc/include/atsc/GrAtscDerandomizer.h index bd0d70d94..0075ae299 100644 --- a/gr-atsc/src/lib/GrAtscDerandomizer.h +++ b/gr-atsc/include/atsc/GrAtscDerandomizer.h @@ -24,8 +24,8 @@ #define _GRATSCDERANDOMIZER_H_ #include <VrHistoryProc.h> -#include <atsc_types.h> -#include <atsci_randomizer.h> +#include <atsc/types.h> +#include <atsc/randomizer_impl.h> /*! * \brief Derandomize ATSC data (atsc_mpeg_packet_no_sync --> atsc_mpeg_packet) diff --git a/gr-atsc/src/lib/GrAtscEqualizer.h b/gr-atsc/include/atsc/GrAtscEqualizer.h index ff944deb7..ff944deb7 100644 --- a/gr-atsc/src/lib/GrAtscEqualizer.h +++ b/gr-atsc/include/atsc/GrAtscEqualizer.h diff --git a/gr-atsc/src/lib/GrAtscFPLL.h b/gr-atsc/include/atsc/GrAtscFPLL.h index 597a4a891..c1e3302a1 100644 --- a/gr-atsc/src/lib/GrAtscFPLL.h +++ b/gr-atsc/include/atsc/GrAtscFPLL.h @@ -24,13 +24,13 @@ #ifndef _GRATSCFPLL_H_ #define _GRATSCFPLL_H_ -#include <gr_nco.h> -#include <gr_iir.h> -#include <gr_single_pole_iir.h> -#include <gr_agc.h> +#include <blocks/nco.h> +#include <filter/iir.h> +#include <filter/single_pole_iir.h> +#include <analog/agc.h> #include <VrSigProc.h> #include <stdio.h> -#include <atsci_diag_output.h> +#include <atsc/diag_output_impl.h> /*! * \brief ATSC FPLL (2nd Version) diff --git a/gr-atsc/src/lib/GrAtscFieldSyncChecker.h b/gr-atsc/include/atsc/GrAtscFieldSyncChecker.h index 28458a19b..28458a19b 100644 --- a/gr-atsc/src/lib/GrAtscFieldSyncChecker.h +++ b/gr-atsc/include/atsc/GrAtscFieldSyncChecker.h diff --git a/gr-atsc/src/lib/GrAtscFieldSyncCorrelator.h b/gr-atsc/include/atsc/GrAtscFieldSyncCorrelator.h index 1a16048b2..1a16048b2 100644 --- a/gr-atsc/src/lib/GrAtscFieldSyncCorrelator.h +++ b/gr-atsc/include/atsc/GrAtscFieldSyncCorrelator.h diff --git a/gr-atsc/src/lib/GrAtscFieldSyncDemux.h b/gr-atsc/include/atsc/GrAtscFieldSyncDemux.h index f5bab9b87..248c25791 100644 --- a/gr-atsc/src/lib/GrAtscFieldSyncDemux.h +++ b/gr-atsc/include/atsc/GrAtscFieldSyncDemux.h @@ -24,7 +24,7 @@ #define _GRATSCFIELDSYNCDEMUX_H_ #include <VrDecimatingSigProc.h> -#include <atsc_types.h> +#include <atsc/types.h> /*! * \brief ATSC Field Sync Demux diff --git a/gr-atsc/src/lib/GrAtscFieldSyncMux.h b/gr-atsc/include/atsc/GrAtscFieldSyncMux.h index ae52b8e5c..3045f3284 100644 --- a/gr-atsc/src/lib/GrAtscFieldSyncMux.h +++ b/gr-atsc/include/atsc/GrAtscFieldSyncMux.h @@ -24,7 +24,7 @@ #define _GRATSCFIELDSYNCMUX_H_ #include <VrHistoryProc.h> -#include <atsc_types.h> +#include <atsc/types.h> /*! * \brief Insert ATSC Field Syncs as required (atsc_data_segment --> atsc_data_segment) diff --git a/gr-atsc/src/lib/GrAtscInterleaver.h b/gr-atsc/include/atsc/GrAtscInterleaver.h index 76be38a21..5b6ad4849 100644 --- a/gr-atsc/src/lib/GrAtscInterleaver.h +++ b/gr-atsc/include/atsc/GrAtscInterleaver.h @@ -24,8 +24,8 @@ #define _GRATSCINTERLEAVER_H_ #include <VrHistoryProc.h> -#include <atsc_types.h> -#include <atsci_data_interleaver.h> +#include <atsc/types.h> +#include <atsc/data_interleaver_impl.h> /*! * \brief Interleave RS encoded ATSC data ( atsc_mpeg_packet_rs_encoded --> atsc_mpeg_packet_rs_encoded) diff --git a/gr-atsc/src/lib/GrAtscRSDecoder.h b/gr-atsc/include/atsc/GrAtscRSDecoder.h index d64102d10..9321b66a5 100644 --- a/gr-atsc/src/lib/GrAtscRSDecoder.h +++ b/gr-atsc/include/atsc/GrAtscRSDecoder.h @@ -24,8 +24,8 @@ #define _GRATSCRSDECODER_H_ #include <VrHistoryProc.h> -#include <atsc_types.h> -#include <atsci_reed_solomon.h> +#include <atsc/types.h> +#include <atsc/reed_solomon_impl.h> /*! * \brief Pass ATSC data Reed-Solomon decoder( atsc_mpeg_packet_rs_encoded --> atsc_mpeg_rs_no_sync) diff --git a/gr-atsc/src/lib/GrAtscRSEncoder.h b/gr-atsc/include/atsc/GrAtscRSEncoder.h index 29921d8b3..e18b6bd63 100644 --- a/gr-atsc/src/lib/GrAtscRSEncoder.h +++ b/gr-atsc/include/atsc/GrAtscRSEncoder.h @@ -24,8 +24,8 @@ #define _GRATSCRSENCODER_H_ #include <VrHistoryProc.h> -#include <atsc_types.h> -#include <atsci_reed_solomon.h> +#include <atsc/types.h> +#include <atsc/reed_solomon_impl.h> /*! * \brief Encode using Reed Solomon ATSC data (atsc_mpeg_packet_no_sync --> atsc_mpeg_packet_rs_encoded) diff --git a/gr-atsc/src/lib/GrAtscRandomizer.h b/gr-atsc/include/atsc/GrAtscRandomizer.h index f56f7178e..565ea7b8e 100644 --- a/gr-atsc/src/lib/GrAtscRandomizer.h +++ b/gr-atsc/include/atsc/GrAtscRandomizer.h @@ -24,8 +24,8 @@ #define _GRATSCRANDOMIZER_H_ #include <VrHistoryProc.h> -#include <atsc_types.h> -#include <atsci_randomizer.h> +#include <atsc/types.h> +#include <atsc/randomizer_impl.h> /*! * \brief Randomize ATSC data (atsc_mpeg_packet --> atsc_mpeg_packet_no_sync) diff --git a/gr-atsc/src/lib/GrAtscSegSymSync.h b/gr-atsc/include/atsc/GrAtscSegSymSync.h index 750483f54..750483f54 100644 --- a/gr-atsc/src/lib/GrAtscSegSymSync.h +++ b/gr-atsc/include/atsc/GrAtscSegSymSync.h diff --git a/gr-atsc/src/lib/GrAtscSegSymSyncImpl.h b/gr-atsc/include/atsc/GrAtscSegSymSyncImpl.h index 650dab569..779f311f4 100644 --- a/gr-atsc/src/lib/GrAtscSegSymSyncImpl.h +++ b/gr-atsc/include/atsc/GrAtscSegSymSyncImpl.h @@ -23,7 +23,7 @@ #define _GRATSCSEGSYMSYNCIMPL_H_ #include <GrAtscSegSymSync.h> -#include <atsci_sssr.h> +#include <atsc/sssr_impl.h> /*! diff --git a/gr-atsc/src/lib/GrAtscSegSymSyncImpl_export.h b/gr-atsc/include/atsc/GrAtscSegSymSyncImpl_export.h index 187f1a039..187f1a039 100644 --- a/gr-atsc/src/lib/GrAtscSegSymSyncImpl_export.h +++ b/gr-atsc/include/atsc/GrAtscSegSymSyncImpl_export.h diff --git a/gr-atsc/src/lib/GrAtscSymbolMapper.h b/gr-atsc/include/atsc/GrAtscSymbolMapper.h index a37703f1f..c4e4083aa 100644 --- a/gr-atsc/src/lib/GrAtscSymbolMapper.h +++ b/gr-atsc/include/atsc/GrAtscSymbolMapper.h @@ -25,8 +25,8 @@ #include <VrInterpolatingSigProcNoWork.h> -#include <atsc_types.h> -#include <gr_nco.h> +#include <atsc/types.h> +#include <blocks/nco.h> /*! * \brief take atsc_data_segments and map them to symbols. diff --git a/gr-atsc/src/lib/GrAtscTrellisEncoder.h b/gr-atsc/include/atsc/GrAtscTrellisEncoder.h index e4de388ae..b1a047ce2 100644 --- a/gr-atsc/src/lib/GrAtscTrellisEncoder.h +++ b/gr-atsc/include/atsc/GrAtscTrellisEncoder.h @@ -23,7 +23,7 @@ #ifndef _GRATSCTRELLISENCODER_H_ #include <VrHistoryProc.h> -#include <atsci_trellis_encoder.h> +#include <atsc/trellis_encoder_impl.h> /*! * \brief ATSC 12-way interleaved trellis encoder (atsc_mpeg_packet_rs_encoded --> atsc_data_segment) diff --git a/gr-atsc/src/lib/GrAtscViterbiDecoder.h b/gr-atsc/include/atsc/GrAtscViterbiDecoder.h index 1b3bdd84a..35b1ea0dc 100644 --- a/gr-atsc/src/lib/GrAtscViterbiDecoder.h +++ b/gr-atsc/include/atsc/GrAtscViterbiDecoder.h @@ -23,7 +23,7 @@ #ifndef _GRATSCVITERBIDECODER_H_ #include <VrHistoryProc.h> -#include <atsci_viterbi_decoder.h> +#include <atsc/viterbi_decoder_impl.h> /*! * \brief ATSC 12-way interleaved viterbi decoder (atsc_soft_data_segment --> atsc_mpeg_packet_rs_encoded) diff --git a/gr-atsc/src/lib/atsc_api.h b/gr-atsc/include/atsc/api.h index 5add37762..5add37762 100644 --- a/gr-atsc/src/lib/atsc_api.h +++ b/gr-atsc/include/atsc/api.h diff --git a/gr-atsc/src/lib/atsci_basic_trellis_encoder.h b/gr-atsc/include/atsc/basic_trellis_encoder_impl.h index a1bbbf5a0..396ca9495 100644 --- a/gr-atsc/src/lib/atsci_basic_trellis_encoder.h +++ b/gr-atsc/include/atsc/basic_trellis_encoder_impl.h @@ -19,10 +19,11 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef _ATSC_BASIC_TRELLIS_ENCODER_H_ #define _ATSC_BASIC_TRELLIS_ENCODER_H_ -#include <atsc_api.h> +#include <atsc/api.h> #include <assert.h> /*! diff --git a/gr-atsc/src/lib/atsc_bit_timing_loop.h b/gr-atsc/include/atsc/bit_timing_loop.h index 8b352f7eb..eee2b2f73 100644 --- a/gr-atsc/src/lib/atsc_bit_timing_loop.h +++ b/gr-atsc/include/atsc/bit_timing_loop.h @@ -19,15 +19,16 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_BIT_TIMING_LOOP_H #define INCLUDED_ATSC_BIT_TIMING_LOOP_H -#include <atsc_api.h> +#include <atsc/api.h> #include <cstdio> #include <gr_block.h> -#include <atsci_diag_output.h> -#include <atsci_sssr.h> -#include <atsci_syminfo.h> +#include <atsc/diag_output_impl.h> +#include <atsc/sssr_impl.h> +#include <atsc/syminfo_impl.h> class atsc_bit_timing_loop; typedef boost::shared_ptr<atsc_bit_timing_loop> atsc_bit_timing_loop_sptr; diff --git a/gr-atsc/src/lib/atsc_consts.h b/gr-atsc/include/atsc/consts.h index bbe2ec69a..bbe2ec69a 100644 --- a/gr-atsc/src/lib/atsc_consts.h +++ b/gr-atsc/include/atsc/consts.h diff --git a/gr-atsc/src/lib/convolutional_interleaver.h b/gr-atsc/include/atsc/convolutional_interleaver.h index 35a31d487..00c843b01 100644 --- a/gr-atsc/src/lib/convolutional_interleaver.h +++ b/gr-atsc/include/atsc/convolutional_interleaver.h @@ -24,7 +24,7 @@ #define _CONVOLUTIONAL_INTERLEAVER_H_ #include <vector> -#include <interleaver_fifo.h> +#include <atsc/interleaver_fifo.h> #include <assert.h> /*! diff --git a/gr-atsc/src/lib/create_atsci_equalizer.h b/gr-atsc/include/atsc/create_atsci_equalizer.h index b291e0bbd..adc499170 100644 --- a/gr-atsc/src/lib/create_atsci_equalizer.h +++ b/gr-atsc/include/atsc/create_atsci_equalizer.h @@ -19,10 +19,11 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef _CREATE_ATSC_EQUALIZER_H_ #define _CREATE_ATSC_EQUALIZER_H_ -#include <atsc_api.h> +#include <atsc/api.h> class atsci_equalizer; diff --git a/gr-atsc/src/lib/create_atsci_fs_checker.h b/gr-atsc/include/atsc/create_atsci_fs_checker.h index 42119a6d4..5d8e9ea40 100644 --- a/gr-atsc/src/lib/create_atsci_fs_checker.h +++ b/gr-atsc/include/atsc/create_atsci_fs_checker.h @@ -23,7 +23,7 @@ #ifndef _CREATE_ATSC_FS_CHECKER_H_ #define _CREATE_ATSC_FS_CHECKER_H_ -#include <atsc_api.h> +#include <atsc/api.h> class atsci_fs_checker; diff --git a/gr-atsc/src/lib/create_atsci_fs_correlator.h b/gr-atsc/include/atsc/create_atsci_fs_correlator.h index b9b037403..0488645ac 100644 --- a/gr-atsc/src/lib/create_atsci_fs_correlator.h +++ b/gr-atsc/include/atsc/create_atsci_fs_correlator.h @@ -23,7 +23,7 @@ #ifndef _CREATE_ATSC_FS_CORRELATOR_H_ #define _CREATE_ATSC_FS_CORRELATOR_H_ -#include <atsc_api.h> +#include <atsc/api.h> class atsci_fs_correlator; diff --git a/gr-atsc/src/lib/atsci_data_interleaver.h b/gr-atsc/include/atsc/data_interleaver_impl.h index 290607ea3..a7765bd43 100644 --- a/gr-atsc/src/lib/atsci_data_interleaver.h +++ b/gr-atsc/include/atsc/data_interleaver_impl.h @@ -23,9 +23,9 @@ #ifndef _ATSC_DATA_INTERLEAVER_H_ #define _ATSC_DATA_INTERLEAVER_H_ -#include <atsc_api.h> -#include <atsc_types.h> -#include <convolutional_interleaver.h> +#include <atsc/api.h> +#include <atsc/types.h> +#include <atsc/convolutional_interleaver.h> /*! * \brief atsc convolutional data interleaver diff --git a/gr-atsc/src/lib/atsc_deinterleaver.h b/gr-atsc/include/atsc/deinterleaver.h index e398dfcc7..7864526cf 100644 --- a/gr-atsc/src/lib/atsc_deinterleaver.h +++ b/gr-atsc/include/atsc/deinterleaver.h @@ -19,12 +19,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_DEINTERLEAVER_H #define INCLUDED_ATSC_DEINTERLEAVER_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> -#include <atsci_data_interleaver.h> +#include <atsc/data_interleaver_impl.h> class atsc_deinterleaver; typedef boost::shared_ptr<atsc_deinterleaver> atsc_deinterleaver_sptr; diff --git a/gr-atsc/src/lib/atsc_depad.h b/gr-atsc/include/atsc/depad.h index 9d1a381bf..ffced87a3 100644 --- a/gr-atsc/src/lib/atsc_depad.h +++ b/gr-atsc/include/atsc/depad.h @@ -22,7 +22,7 @@ #ifndef INCLUDED_ATSC_DEPAD_H #define INCLUDED_ATSC_DEPAD_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_interpolator.h> class atsc_depad; diff --git a/gr-atsc/src/lib/atsc_derandomizer.h b/gr-atsc/include/atsc/derandomizer.h index 1881a69a3..4def872aa 100644 --- a/gr-atsc/src/lib/atsc_derandomizer.h +++ b/gr-atsc/include/atsc/derandomizer.h @@ -22,9 +22,9 @@ #ifndef INCLUDED_ATSC_DERANDOMIZER_H #define INCLUDED_ATSC_DERANDOMIZER_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> -#include <atsci_randomizer.h> +#include <atsc/randomizer_impl.h> class atsc_derandomizer; typedef boost::shared_ptr<atsc_derandomizer> atsc_derandomizer_sptr; diff --git a/gr-atsc/src/lib/atsci_diag_output.h b/gr-atsc/include/atsc/diag_output_impl.h index 09fd763d6..09fd763d6 100644 --- a/gr-atsc/src/lib/atsci_diag_output.h +++ b/gr-atsc/include/atsc/diag_output_impl.h diff --git a/gr-atsc/src/lib/atsc_ds_to_softds.h b/gr-atsc/include/atsc/ds_to_softds.h index 0ba61c7d6..635650666 100644 --- a/gr-atsc/src/lib/atsc_ds_to_softds.h +++ b/gr-atsc/include/atsc/ds_to_softds.h @@ -19,12 +19,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_DS_TO_SOFTDS_H #define INCLUDED_ATSC_DS_TO_SOFTDS_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> -#include <atsc_types.h> +#include <atsc/types.h> class atsc_ds_to_softds; typedef boost::shared_ptr<atsc_ds_to_softds> atsc_ds_to_softds_sptr; diff --git a/gr-atsc/src/lib/atsc_equalizer.h b/gr-atsc/include/atsc/equalizer.h index aca5e63b4..a910ab756 100644 --- a/gr-atsc/src/lib/atsc_equalizer.h +++ b/gr-atsc/include/atsc/equalizer.h @@ -19,12 +19,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_EQUALIZER_H #define INCLUDED_ATSC_EQUALIZER_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> -#include <atsci_equalizer.h> +#include <atsc/equalizer_impl.h> #include <vector> class atsc_equalizer; diff --git a/gr-atsc/src/lib/atsci_equalizer.h b/gr-atsc/include/atsc/equalizer_impl.h index b0c243b51..e2baf537d 100644 --- a/gr-atsc/src/lib/atsci_equalizer.h +++ b/gr-atsc/include/atsc/equalizer_impl.h @@ -23,8 +23,8 @@ #ifndef _ATSC_EQUALIZER_H_ #define _ATSC_EQUALIZER_H_ -#include <atsc_api.h> -#include <atsci_syminfo.h> +#include <atsc/api.h> +#include <atsc/syminfo_impl.h> #include <vector> /*! diff --git a/gr-atsc/src/lib/atsci_equalizer_lms2.h b/gr-atsc/include/atsc/equalizer_lms2_impl.h index d0f2660d5..ebd6c13d0 100644 --- a/gr-atsc/src/lib/atsci_equalizer_lms2.h +++ b/gr-atsc/include/atsc/equalizer_lms2_impl.h @@ -23,8 +23,8 @@ #ifndef _ATSC_EQUALIZER_LMS2_H_ #define _ATSC_EQUALIZER_LMS2_H_ -#include <atsc_api.h> -#include <atsci_equalizer.h> +#include <atsc/api.h> +#include <atsc/equalizer_impl.h> #include <vector> #include <stdio.h> diff --git a/gr-atsc/src/lib/atsci_equalizer_lms.h b/gr-atsc/include/atsc/equalizer_lms_impl.h index eac72f75b..c91349de6 100644 --- a/gr-atsc/src/lib/atsci_equalizer_lms.h +++ b/gr-atsc/include/atsc/equalizer_lms_impl.h @@ -23,8 +23,8 @@ #ifndef _ATSC_EQUALIZER_LMS_H_ #define _ATSC_EQUALIZER_LMS_H_ -#include <atsc_api.h> -#include <atsci_equalizer.h> +#include <atsc/api.h> +#include <atsc/equalizer_impl.h> #include <vector> #include <stdio.h> diff --git a/gr-atsc/src/lib/atsci_equalizer_nop.h b/gr-atsc/include/atsc/equalizer_nop_impl.h index d29fded64..85549e326 100644 --- a/gr-atsc/src/lib/atsci_equalizer_nop.h +++ b/gr-atsc/include/atsc/equalizer_nop_impl.h @@ -23,8 +23,8 @@ #ifndef _ATSC_EQUALIZER_NOP_H_ #define _ATSC_EQUALIZER_NOP_H_ -#include <atsc_api.h> -#include <atsci_equalizer.h> +#include <atsc/api.h> +#include <atsc/equalizer_impl.h> class ATSC_API atsci_equalizer_nop : public atsci_equalizer { diff --git a/gr-atsc/src/lib/atsci_exp2_lp.h b/gr-atsc/include/atsc/exp2_lp_impl.h index e04c42528..b0fbc4643 100644 --- a/gr-atsc/src/lib/atsci_exp2_lp.h +++ b/gr-atsc/include/atsc/exp2_lp_impl.h @@ -23,7 +23,7 @@ #ifndef _ATSC_EXP2_LP_H_ #define _ATSC_EXP2_LP_H_ -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_fir_builder.h> class ATSC_API atsci_exp2_lp : public gr_fir_builder diff --git a/gr-atsc/src/lib/atsci_fake_single_viterbi.h b/gr-atsc/include/atsc/fake_single_viterbi_impl.h index 561afb3d3..5895e0ac6 100644 --- a/gr-atsc/src/lib/atsci_fake_single_viterbi.h +++ b/gr-atsc/include/atsc/fake_single_viterbi_impl.h @@ -23,7 +23,7 @@ #ifndef _ATSCFAKESINGLEVITERBI_H_ #define _ATSCFAKESINGLEVITERBI_H_ -#include <atsc_api.h> +#include <atsc/api.h> /*! * \brief single channel viterbi decoder diff --git a/gr-atsc/src/lib/atsc_field_sync_demux.h b/gr-atsc/include/atsc/field_sync_demux.h index ea9a5d1ac..bec359009 100644 --- a/gr-atsc/src/lib/atsc_field_sync_demux.h +++ b/gr-atsc/include/atsc/field_sync_demux.h @@ -22,9 +22,9 @@ #ifndef INCLUDED_ATSC_FIELD_SYNC_DEMUX_H #define INCLUDED_ATSC_FIELD_SYNC_DEMUX_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_block.h> -#include <atsc_types.h> +#include <atsc/types.h> class atsc_field_sync_demux; typedef boost::shared_ptr<atsc_field_sync_demux> atsc_field_sync_demux_sptr; diff --git a/gr-atsc/src/lib/atsc_field_sync_mux.h b/gr-atsc/include/atsc/field_sync_mux.h index ce4514e9c..21a2f0fda 100644 --- a/gr-atsc/src/lib/atsc_field_sync_mux.h +++ b/gr-atsc/include/atsc/field_sync_mux.h @@ -19,12 +19,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_FIELD_SYNC_MUX_H #define INCLUDED_ATSC_FIELD_SYNC_MUX_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> -#include <atsc_types.h> +#include <atsc/types.h> class atsc_field_sync_mux; typedef boost::shared_ptr<atsc_field_sync_mux> atsc_field_sync_mux_sptr; diff --git a/gr-atsc/src/lib/atsc_fpll.h b/gr-atsc/include/atsc/fpll.h index 28912df37..00d6b1e54 100644 --- a/gr-atsc/src/lib/atsc_fpll.h +++ b/gr-atsc/include/atsc/fpll.h @@ -19,16 +19,17 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_FPLL_H #define INCLUDED_ATSC_FPLL_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> #include <blocks/nco.h> #include <filter/single_pole_iir.h> #include <analog/agc.h> #include <stdio.h> -#include <atsci_diag_output.h> +#include <atsc/diag_output_impl.h> using namespace gr; diff --git a/gr-atsc/src/lib/atsc_fs_checker.h b/gr-atsc/include/atsc/fs_checker.h index d034fdd28..1bd304090 100644 --- a/gr-atsc/src/lib/atsc_fs_checker.h +++ b/gr-atsc/include/atsc/fs_checker.h @@ -19,11 +19,12 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_FS_CHECKER_H #define INCLUDED_ATSC_FS_CHECKER_H -#include <atsc_api.h> -#include <atsci_fs_checker.h> +#include <atsc/api.h> +#include <atsc/fs_checker_impl.h> #include <gr_sync_block.h> class atsc_fs_checker; diff --git a/gr-atsc/src/lib/atsci_fs_checker.h b/gr-atsc/include/atsc/fs_checker_impl.h index 7a426b742..a4975d243 100644 --- a/gr-atsc/src/lib/atsci_fs_checker.h +++ b/gr-atsc/include/atsc/fs_checker_impl.h @@ -22,8 +22,8 @@ #ifndef _ATSC_FS_CHECKER_H_ #define _ATSC_FS_CHECKER_H_ -#include <atsc_api.h> -#include <atsci_syminfo.h> +#include <atsc/api.h> +#include <atsc/syminfo_impl.h> /*! * \brief abstract base class for ATSC field sync checker diff --git a/gr-atsc/src/lib/atsci_fs_checker_naive.h b/gr-atsc/include/atsc/fs_checker_naive_impl.h index 21c628a1d..0056bf69c 100644 --- a/gr-atsc/src/lib/atsci_fs_checker_naive.h +++ b/gr-atsc/include/atsc/fs_checker_naive_impl.h @@ -23,8 +23,8 @@ #ifndef _ATSC_FS_CHECKER_NAIVE_H_ #define _ATSC_FS_CHECKER_NAIVE_H_ -#include <atsc_api.h> -#include <atsci_fs_checker.h> +#include <atsc/api.h> +#include <atsc/fs_checker_impl.h> /*! * \brief Naive concrete implementation of field sync checker diff --git a/gr-atsc/src/lib/atsci_fs_correlator.h b/gr-atsc/include/atsc/fs_correlator_impl.h index ff70245c9..b55b1b985 100644 --- a/gr-atsc/src/lib/atsci_fs_correlator.h +++ b/gr-atsc/include/atsc/fs_correlator_impl.h @@ -19,10 +19,11 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef _ATSC_FS_CORRELATOR_H_ #define _ATSC_FS_CORRELATOR_H_ -#include <atsc_api.h> +#include <atsc/api.h> /*! * \brief abstract base class for ATSC field sync correlator diff --git a/gr-atsc/src/lib/atsci_fs_correlator_naive.h b/gr-atsc/include/atsc/fs_correlator_naive_impl.h index d8afc2ca6..e2fd19557 100644 --- a/gr-atsc/src/lib/atsci_fs_correlator_naive.h +++ b/gr-atsc/include/atsc/fs_correlator_naive_impl.h @@ -23,8 +23,8 @@ #ifndef _ATSC_FS_CORRELATOR_NAIVE_H_ #define _ATSC_FS_CORRELATOR_NAIVE_H_ -#include <atsc_api.h> -#include <atsci_fs_correlator.h> +#include <atsc/api.h> +#include <atsc/fs_correlator_impl.h> /*! * \brief Naive concrete implementation of field sync correlator diff --git a/gr-atsc/src/lib/atsc_interleaver.h b/gr-atsc/include/atsc/interleaver.h index 3090d49de..f426381ad 100644 --- a/gr-atsc/src/lib/atsc_interleaver.h +++ b/gr-atsc/include/atsc/interleaver.h @@ -19,12 +19,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_INTERLEAVER_H #define INCLUDED_ATSC_INTERLEAVER_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> -#include <atsci_data_interleaver.h> +#include <atsc/data_interleaver_impl.h> class atsc_interleaver; typedef boost::shared_ptr<atsc_interleaver> atsc_interleaver_sptr; diff --git a/gr-atsc/src/lib/interleaver_fifo.h b/gr-atsc/include/atsc/interleaver_fifo.h index cacac85a3..5c29a8256 100644 --- a/gr-atsc/src/lib/interleaver_fifo.h +++ b/gr-atsc/include/atsc/interleaver_fifo.h @@ -24,7 +24,7 @@ #define _INTERLEAVER_FIFO_H_ -#include <interleaver_fifo.h> +#include <atsc/interleaver_fifo.h> #include <string.h> /*! diff --git a/gr-atsc/src/lib/atsc_pad.h b/gr-atsc/include/atsc/pad.h index 139d951a6..b48d17f7b 100644 --- a/gr-atsc/src/lib/atsc_pad.h +++ b/gr-atsc/include/atsc/pad.h @@ -19,10 +19,11 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_PAD_H #define INCLUDED_ATSC_PAD_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_decimator.h> class atsc_pad; diff --git a/gr-atsc/src/lib/atsci_pnXXX.h b/gr-atsc/include/atsc/pnXXX_impl.h index 612ed2034..3de6eb1f5 100644 --- a/gr-atsc/src/lib/atsci_pnXXX.h +++ b/gr-atsc/include/atsc/pnXXX_impl.h @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsc_api.h> +#include <atsc/api.h> ATSC_API extern const unsigned char atsc_pn511[]; ATSC_API extern const unsigned char atsc_pn63[]; diff --git a/gr-atsc/src/lib/atsc_randomizer.h b/gr-atsc/include/atsc/randomizer.h index 7d00efcf9..8825062bb 100644 --- a/gr-atsc/src/lib/atsc_randomizer.h +++ b/gr-atsc/include/atsc/randomizer.h @@ -19,12 +19,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_RANDOMIZER_H #define INCLUDED_ATSC_RANDOMIZER_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> -#include <atsci_randomizer.h> +#include <atsc/randomizer_impl.h> class atsc_randomizer; typedef boost::shared_ptr<atsc_randomizer> atsc_randomizer_sptr; diff --git a/gr-atsc/src/lib/atsci_randomizer.h b/gr-atsc/include/atsc/randomizer_impl.h index aedd0d808..4fdbebc06 100644 --- a/gr-atsc/src/lib/atsci_randomizer.h +++ b/gr-atsc/include/atsc/randomizer_impl.h @@ -23,8 +23,8 @@ #ifndef _ATSC_RANDOMIZER_H_ #define _ATSC_RANDOMIZER_H_ -#include <atsc_api.h> -#include <atsc_types.h> +#include <atsc/api.h> +#include <atsc/types.h> /*! * \brief ATSC data "whitener" diff --git a/gr-atsc/src/lib/atsci_reed_solomon.h b/gr-atsc/include/atsc/reed_solomon_impl.h index 8f6e26426..484b6d0ce 100644 --- a/gr-atsc/src/lib/atsci_reed_solomon.h +++ b/gr-atsc/include/atsc/reed_solomon_impl.h @@ -23,8 +23,8 @@ #ifndef _ATSC_REED_SOLOMON_H_ #define _ATSC_REED_SOLOMON_H_ -#include <atsc_api.h> -#include <atsc_types.h> +#include <atsc/api.h> +#include <atsc/types.h> /*! * \brief ATSC Reed-Solomon encoder / decoder diff --git a/gr-atsc/src/lib/atsci_root_raised_cosine_bandpass.h b/gr-atsc/include/atsc/root_raised_cosine_bandpass_impl.h index bdb33c28d..50548bec8 100644 --- a/gr-atsc/src/lib/atsci_root_raised_cosine_bandpass.h +++ b/gr-atsc/include/atsc/root_raised_cosine_bandpass_impl.h @@ -19,11 +19,12 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef _ATSC_RRC_BANDPASS_H_ #define _ATSC_RRC_BANDPASS_H_ -#include <atsc_api.h> -#include <atsci_root_raised_cosine.h> +#include <atsc/api.h> +#include <atsc/root_raised_cosine_impl.h> class ATSC_API atsc_root_raised_cosine_bandpass : public atsc_root_raised_cosine { diff --git a/gr-atsc/src/lib/atsci_root_raised_cosine.h b/gr-atsc/include/atsc/root_raised_cosine_impl.h index f24606992..ae884bfb1 100644 --- a/gr-atsc/src/lib/atsci_root_raised_cosine.h +++ b/gr-atsc/include/atsc/root_raised_cosine_impl.h @@ -19,10 +19,11 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef _ATSC_RRC_H_ #define _ATSC_RRC_H_ -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_fir_builder.h> class ATSC_API atsc_root_raised_cosine : public gr_fir_builder diff --git a/gr-atsc/src/lib/atsc_rs_decoder.h b/gr-atsc/include/atsc/rs_decoder.h index 9e4bf8d44..308fb4643 100644 --- a/gr-atsc/src/lib/atsc_rs_decoder.h +++ b/gr-atsc/include/atsc/rs_decoder.h @@ -19,12 +19,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_RS_DECODER_H #define INCLUDED_ATSC_RS_DECODER_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> -#include <atsci_reed_solomon.h> +#include <atsc/reed_solomon_impl.h> class atsc_rs_decoder; typedef boost::shared_ptr<atsc_rs_decoder> atsc_rs_decoder_sptr; diff --git a/gr-atsc/src/lib/atsc_rs_encoder.h b/gr-atsc/include/atsc/rs_encoder.h index b0d69d95d..ace2806da 100644 --- a/gr-atsc/src/lib/atsc_rs_encoder.h +++ b/gr-atsc/include/atsc/rs_encoder.h @@ -19,12 +19,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_RS_ENCODER_H #define INCLUDED_ATSC_RS_ENCODER_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> -#include <atsci_reed_solomon.h> +#include <atsc/reed_solomon_impl.h> class atsc_rs_encoder; typedef boost::shared_ptr<atsc_rs_encoder> atsc_rs_encoder_sptr; diff --git a/gr-atsc/src/lib/atsci_single_viterbi.h b/gr-atsc/include/atsc/single_viterbi_impl.h index 01b13fb25..d92ded80e 100644 --- a/gr-atsc/src/lib/atsci_single_viterbi.h +++ b/gr-atsc/include/atsc/single_viterbi_impl.h @@ -23,7 +23,7 @@ #ifndef _ATSCSINGLEVITERBI_H_ #define _ATSCSINGLEVITERBI_H_ -#include <atsc_api.h> +#include <atsc/api.h> /*! * \brief single channel viterbi decoder diff --git a/gr-atsc/src/lib/atsci_slicer_agc.h b/gr-atsc/include/atsc/slicer_agc_impl.h index 8a3927b70..91694c09d 100644 --- a/gr-atsc/src/lib/atsci_slicer_agc.h +++ b/gr-atsc/include/atsc/slicer_agc_impl.h @@ -23,9 +23,9 @@ #ifndef _ATSC_SLICER_AGC_H_ #define _ATSC_SLICER_AGC_H_ -#include <atsc_api.h> +#include <atsc/api.h> #include <math.h> -#include <gr_single_pole_iir.h> +#include <filter/single_pole_iir.h> /*! * \brief Automatic Gain Control class for atsc slicer diff --git a/gr-atsc/src/lib/atsci_sliding_correlator.h b/gr-atsc/include/atsc/sliding_correlator_impl.h index ffa2124ed..45c0caa24 100644 --- a/gr-atsc/src/lib/atsci_sliding_correlator.h +++ b/gr-atsc/include/atsc/sliding_correlator_impl.h @@ -19,13 +19,14 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef _ATSC_SLIDING_CORRELATOR_H_ #define _ATSC_SLIDING_CORRELATOR_H_ -#include <atsc_api.h> +#include <atsc/api.h> #include <string.h> -#include <atsci_pnXXX.h> +#include <atsc/pnXXX_impl.h> //extern const unsigned char atsc_pn511[511]; //extern const unsigned char atsc_pn63[63]; diff --git a/gr-atsc/src/lib/atsci_sssr.h b/gr-atsc/include/atsc/sssr_impl.h index 1eb626eb1..60d116577 100644 --- a/gr-atsc/src/lib/atsci_sssr.h +++ b/gr-atsc/include/atsc/sssr_impl.h @@ -27,8 +27,8 @@ #ifndef _ATSC_SSSR_H_ #define _ATSC_SSSR_H_ -#include <atsc_api.h> -#include <atsc_consts.h> +#include <atsc/api.h> +#include <atsc/consts.h> #include <filter/mmse_fir_interpolator_ff.h> #include <filter/single_pole_iir.h> #include <cstdio> diff --git a/gr-atsc/src/lib/atsci_syminfo.h b/gr-atsc/include/atsc/syminfo_impl.h index 9f25e4902..9f25e4902 100644 --- a/gr-atsc/src/lib/atsci_syminfo.h +++ b/gr-atsc/include/atsc/syminfo_impl.h diff --git a/gr-atsc/src/lib/atsci_sync_tag.h b/gr-atsc/include/atsc/sync_tag_impl.h index bdb64c5d3..bdb64c5d3 100644 --- a/gr-atsc/src/lib/atsci_sync_tag.h +++ b/gr-atsc/include/atsc/sync_tag_impl.h diff --git a/gr-atsc/src/lib/atsc_trellis_encoder.h b/gr-atsc/include/atsc/trellis_encoder.h index da51f633d..243dd7c2c 100644 --- a/gr-atsc/src/lib/atsc_trellis_encoder.h +++ b/gr-atsc/include/atsc/trellis_encoder.h @@ -22,9 +22,9 @@ #ifndef INCLUDED_ATSC_TRELLIS_ENCODER_H #define INCLUDED_ATSC_TRELLIS_ENCODER_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> -#include <atsci_trellis_encoder.h> +#include <atsc/trellis_encoder_impl.h> class atsc_trellis_encoder; typedef boost::shared_ptr<atsc_trellis_encoder> atsc_trellis_encoder_sptr; diff --git a/gr-atsc/src/lib/atsci_trellis_encoder.h b/gr-atsc/include/atsc/trellis_encoder_impl.h index 294ad860f..d20885ef3 100644 --- a/gr-atsc/src/lib/atsci_trellis_encoder.h +++ b/gr-atsc/include/atsc/trellis_encoder_impl.h @@ -23,9 +23,9 @@ #ifndef _ATSC_TRELLIS_ENCODER_H_ #define _ATSC_TRELLIS_ENCODER_H_ -#include <atsc_api.h> -#include <atsci_basic_trellis_encoder.h> -#include <atsc_types.h> +#include <atsc/api.h> +#include <atsc/basic_trellis_encoder_impl.h> +#include <atsc/types.h> /*! * \brief fancy, schmancy 12-way interleaved trellis encoder for ATSC diff --git a/gr-atsc/src/lib/atsc_types.h b/gr-atsc/include/atsc/types.h index ed4dedace..759ef68ba 100644 --- a/gr-atsc/src/lib/atsc_types.h +++ b/gr-atsc/include/atsc/types.h @@ -23,7 +23,7 @@ #ifndef _ATSC_TYPES_H_ #define _ATSC_TYPES_H_ -#include <atsc_consts.h> +#include <atsc/consts.h> #include <cstring> #include <cassert> diff --git a/gr-atsc/src/lib/atsc_viterbi_decoder.h b/gr-atsc/include/atsc/viterbi_decoder.h index de571db33..e11933755 100644 --- a/gr-atsc/src/lib/atsc_viterbi_decoder.h +++ b/gr-atsc/include/atsc/viterbi_decoder.h @@ -19,12 +19,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_ATSC_VITERBI_DECODER_H #define INCLUDED_ATSC_VITERBI_DECODER_H -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_sync_block.h> -#include <atsci_viterbi_decoder.h> +#include <atsc/viterbi_decoder_impl.h> class atsc_viterbi_decoder; typedef boost::shared_ptr<atsc_viterbi_decoder> atsc_viterbi_decoder_sptr; diff --git a/gr-atsc/src/lib/atsci_viterbi_decoder.h b/gr-atsc/include/atsc/viterbi_decoder_impl.h index f339ce79a..307b157a9 100644 --- a/gr-atsc/src/lib/atsci_viterbi_decoder.h +++ b/gr-atsc/include/atsc/viterbi_decoder_impl.h @@ -25,15 +25,15 @@ #define USE_SIMPLE_SLICER 0 -#include <atsc_api.h> -#include <atsc_types.h> -#include <interleaver_fifo.h> +#include <atsc/api.h> +#include <atsc/types.h> +#include <atsc/interleaver_fifo.h> #if (USE_SIMPLE_SLICER) -#include <atsci_fake_single_viterbi.h> +#include <atsc/fake_single_viterbi_impl.h> typedef atsci_fake_single_viterbi single_viterbi_t; #else -#include <atsci_single_viterbi.h> +#include <atsc/single_viterbi_impl.h> typedef atsci_single_viterbi single_viterbi_t; #endif diff --git a/gr-atsc/src/lib/atsci_vsbtx_lp.h b/gr-atsc/include/atsc/vsbtx_lp_impl.h index b892641c9..d9640ca48 100644 --- a/gr-atsc/src/lib/atsci_vsbtx_lp.h +++ b/gr-atsc/include/atsc/vsbtx_lp_impl.h @@ -23,7 +23,7 @@ #ifndef _ATSC_VSBTX_LP_H_ #define _ATSC_VSBTX_LP_H_ -#include <atsc_api.h> +#include <atsc/api.h> #include <gr_fir_builder.h> class ATSC_API atsc_vsbtx_lp : public gr_fir_builder diff --git a/gr-atsc/src/lib/CMakeLists.txt b/gr-atsc/lib/CMakeLists.txt index 30e78d709..b30581be7 100644 --- a/gr-atsc/src/lib/CMakeLists.txt +++ b/gr-atsc/lib/CMakeLists.txt @@ -21,6 +21,8 @@ # Setup the include and linker paths ######################################################################## include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ${GR_ATSC_INCLUDE_DIRS} ${GR_FILTER_INCLUDE_DIRS} ${GR_ANALOG_INCLUDE_DIRS} @@ -28,13 +30,12 @@ include_directories( ${GR_BLOCKS_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories(${Boost_LIBRARY_DIRS}) - -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Generate viterbi mux source @@ -122,7 +123,7 @@ list(APPEND atsc_libs gnuradio-fec gnuradio-blocks ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-atsc SHARED ${gr_atsc_sources}) @@ -161,104 +162,3 @@ target_link_libraries(test_atsci gnuradio-atsc gnuradio-core ${CPPUNIT_LIBRARIES GR_ADD_TEST(atsci-test test_atsci) endif(ENABLE_TESTING) - -######################################################################## -# Install public header files -######################################################################## -install(FILES - atsc_api.h - atsc_consts.h - atsc_derandomizer.h - atsc_randomizer.h - atsc_rs_decoder.h - atsc_rs_encoder.h - atsc_interleaver.h - atsc_deinterleaver.h - atsc_trellis_encoder.h - atsc_viterbi_decoder.h - atsc_ds_to_softds.h - atsc_field_sync_mux.h - atsc_field_sync_demux.h - atsc_equalizer.h - atsc_fs_checker.h - atsc_bit_timing_loop.h - atsc_fpll.h - atsc_depad.h - atsc_pad.h - atsc_types.h - atsci_basic_trellis_encoder.h - atsci_data_interleaver.h - atsci_diag_output.h - atsci_equalizer.h - atsci_equalizer_lms.h - atsci_equalizer_lms2.h - atsci_equalizer_nop.h - atsci_exp2_lp.h - atsci_fake_single_viterbi.h - atsci_fs_checker.h - atsci_fs_checker_naive.h - atsci_fs_correlator.h - atsci_fs_correlator_naive.h - atsci_pnXXX.h - atsci_randomizer.h - atsci_reed_solomon.h - atsci_root_raised_cosine.h - atsci_root_raised_cosine_bandpass.h - atsci_single_viterbi.h - atsci_slicer_agc.h - atsci_sliding_correlator.h - atsci_sssr.h - atsci_syminfo.h - atsci_sync_tag.h - atsci_trellis_encoder.h - atsci_viterbi_decoder.h - atsci_vsbtx_lp.h - convolutional_interleaver.h - create_atsci_equalizer.h - create_atsci_fs_checker.h - create_atsci_fs_correlator.h - fpll_btloop_coupling.h - interleaver_fifo.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "atsc_devel" -) - -######################################################################## -# Setup swig generation -######################################################################## -if(ENABLE_PYTHON) -include(GrPython) -include(GrSwig) - -set(GR_SWIG_INCLUDE_DIRS - ${GR_ATSC_INCLUDE_DIRS} - ${GR_FILTER_INCLUDE_DIRS} - ${GR_ANALOG_INCLUDE_DIRS} - ${GR_FEC_INCLUDE_DIRS} - ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} - ${GRUEL_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} -) - -# add Doxygen docs to python -set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/atsc_swig_doc.i) -set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) - -set(GR_SWIG_LIBRARIES gnuradio-atsc) - -GR_SWIG_MAKE(atsc atsc.i) - -GR_SWIG_INSTALL( - TARGETS atsc - DESTINATION ${GR_PYTHON_DIR}/gnuradio - COMPONENT "atsc_python" -) - -install( - FILES atsc.i - ${CMAKE_CURRENT_BINARY_DIR}/atsc_swig_doc.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "atsc_swig" -) - -endif(ENABLE_PYTHON) diff --git a/gr-atsc/src/lib/GrAtscBitTimingLoop.cc b/gr-atsc/lib/GrAtscBitTimingLoop.cc index 8053736ee..f2e666892 100644 --- a/gr-atsc/src/lib/GrAtscBitTimingLoop.cc +++ b/gr-atsc/lib/GrAtscBitTimingLoop.cc @@ -21,10 +21,10 @@ */ #include <cmath> -#include <GrAtscBitTimingLoop.h> +#include <atsc/GrAtscBitTimingLoop.h> #include "fpll_btloop_coupling.h" #include <algorithm> -#include <atsc_consts.h> +#include <atsc/consts.h> #include <stdio.h> #include <assert.h> diff --git a/gr-atsc/src/lib/GrAtscBitTimingLoop2.cc b/gr-atsc/lib/GrAtscBitTimingLoop2.cc index c741a5bb2..d856123fc 100644 --- a/gr-atsc/src/lib/GrAtscBitTimingLoop2.cc +++ b/gr-atsc/lib/GrAtscBitTimingLoop2.cc @@ -20,9 +20,9 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscBitTimingLoop2.h> +#include <atsc/GrAtscBitTimingLoop2.h> #include <algorithm> -#include <atsc_consts.h> +#include <atsc/consts.h> #include <stdio.h> #include <assert.h> diff --git a/gr-atsc/src/lib/GrAtscBitTimingLoop3.cc b/gr-atsc/lib/GrAtscBitTimingLoop3.cc index f9c1eb02e..647b34c15 100644 --- a/gr-atsc/src/lib/GrAtscBitTimingLoop3.cc +++ b/gr-atsc/lib/GrAtscBitTimingLoop3.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscBitTimingLoop3.h> +#include <atsc/GrAtscBitTimingLoop3.h> #include <cmath> #include <cstdio> #include <assert.h> diff --git a/gr-atsc/src/lib/GrAtscConvert2xTo20.cc b/gr-atsc/lib/GrAtscConvert2xTo20.cc index 1f540464d..ac22ee125 100644 --- a/gr-atsc/src/lib/GrAtscConvert2xTo20.cc +++ b/gr-atsc/lib/GrAtscConvert2xTo20.cc @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscConvert2xTo20.h> -#include <atsc_consts.h> +#include <atsc/GrAtscConvert2xTo20.h> +#include <atsc/consts.h> #include <cmath> #include <cstdio> diff --git a/gr-atsc/src/lib/GrAtscDataSegToSoftDataSeg.cc b/gr-atsc/lib/GrAtscDataSegToSoftDataSeg.cc index 09c3db4e0..2406c0c33 100644 --- a/gr-atsc/src/lib/GrAtscDataSegToSoftDataSeg.cc +++ b/gr-atsc/lib/GrAtscDataSegToSoftDataSeg.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscDataSegToSoftDataSeg.h> +#include <atsc/GrAtscDataSegToSoftDataSeg.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscDeinterleaver.cc b/gr-atsc/lib/GrAtscDeinterleaver.cc index fd67d7a20..69fac69aa 100644 --- a/gr-atsc/src/lib/GrAtscDeinterleaver.cc +++ b/gr-atsc/lib/GrAtscDeinterleaver.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscDeinterleaver.h> +#include <atsc/GrAtscDeinterleaver.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscDerandomizer.cc b/gr-atsc/lib/GrAtscDerandomizer.cc index db3583a62..ac1701d90 100644 --- a/gr-atsc/src/lib/GrAtscDerandomizer.cc +++ b/gr-atsc/lib/GrAtscDerandomizer.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscDerandomizer.h> +#include <atsc/GrAtscDerandomizer.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscEqualizer.cc b/gr-atsc/lib/GrAtscEqualizer.cc index 27f64c2b7..3e9f8a002 100644 --- a/gr-atsc/src/lib/GrAtscEqualizer.cc +++ b/gr-atsc/lib/GrAtscEqualizer.cc @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscEqualizer.h> -#include <atsci_equalizer.h> +#include <atsc/GrAtscEqualizer.h> +#include <atsc/equalizer_impl.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscFPLL.cc b/gr-atsc/lib/GrAtscFPLL.cc index df7d6b8c0..fc796c3c1 100644 --- a/gr-atsc/src/lib/GrAtscFPLL.cc +++ b/gr-atsc/lib/GrAtscFPLL.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscFPLL.h> +#include <atsc/GrAtscFPLL.h> #include <algorithm> #include "fpll_btloop_coupling.h" diff --git a/gr-atsc/src/lib/GrAtscFieldSyncChecker.cc b/gr-atsc/lib/GrAtscFieldSyncChecker.cc index d2c82d6d4..0aaa98e4f 100644 --- a/gr-atsc/src/lib/GrAtscFieldSyncChecker.cc +++ b/gr-atsc/lib/GrAtscFieldSyncChecker.cc @@ -20,9 +20,9 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscFieldSyncChecker.h> -#include <create_atsci_fs_checker.h> -#include <atsci_fs_checker.h> +#include <atsc/GrAtscFieldSyncChecker.h> +#include <atsc/create_atsci_fs_checker.h> +#include <atsc/fs_checker_impl.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscFieldSyncCorrelator.cc b/gr-atsc/lib/GrAtscFieldSyncCorrelator.cc index 42f93aa8c..5d42d3b5a 100644 --- a/gr-atsc/src/lib/GrAtscFieldSyncCorrelator.cc +++ b/gr-atsc/lib/GrAtscFieldSyncCorrelator.cc @@ -20,9 +20,9 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscFieldSyncCorrelator.h> -#include <create_atsci_fs_correlator.h> -#include <atsci_fs_correlator.h> +#include <atsc/GrAtscFieldSyncCorrelator.h> +#include <atsc/create_atsci_fs_correlator.h> +#include <atsc/fs_correlator_impl.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscFieldSyncDemux.cc b/gr-atsc/lib/GrAtscFieldSyncDemux.cc index e311acc8a..171d25d23 100644 --- a/gr-atsc/src/lib/GrAtscFieldSyncDemux.cc +++ b/gr-atsc/lib/GrAtscFieldSyncDemux.cc @@ -21,10 +21,10 @@ */ #include <cmath> -#include <GrAtscFieldSyncDemux.h> -#include <atsc_consts.h> -#include <atsc_types.h> -#include <atsci_syminfo.h> +#include <atsc/GrAtscFieldSyncDemux.h> +#include <atsc/consts.h> +#include <atsc/types.h> +#include <atsc/syminfo_impl.h> #include <stdio.h> #include <assert.h> diff --git a/gr-atsc/src/lib/GrAtscFieldSyncMux.cc b/gr-atsc/lib/GrAtscFieldSyncMux.cc index 7ebab72ad..50ad55448 100644 --- a/gr-atsc/src/lib/GrAtscFieldSyncMux.cc +++ b/gr-atsc/lib/GrAtscFieldSyncMux.cc @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscFieldSyncMux.h> -#include <atsci_pnXXX.h> +#include <atsc/GrAtscFieldSyncMux.h> +#include <atsc/pnXXX_impl.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscInterleaver.cc b/gr-atsc/lib/GrAtscInterleaver.cc index 2c8f0c7e8..58113bd5d 100644 --- a/gr-atsc/src/lib/GrAtscInterleaver.cc +++ b/gr-atsc/lib/GrAtscInterleaver.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscInterleaver.h> +#include <atsc/GrAtscInterleaver.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscRSDecoder.cc b/gr-atsc/lib/GrAtscRSDecoder.cc index fd0122ad2..211c569ef 100644 --- a/gr-atsc/src/lib/GrAtscRSDecoder.cc +++ b/gr-atsc/lib/GrAtscRSDecoder.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscRSDecoder.h> +#include <atsc/GrAtscRSDecoder.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscRSEncoder.cc b/gr-atsc/lib/GrAtscRSEncoder.cc index 249678427..f7a457351 100644 --- a/gr-atsc/src/lib/GrAtscRSEncoder.cc +++ b/gr-atsc/lib/GrAtscRSEncoder.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscRSEncoder.h> +#include <atsc/GrAtscRSEncoder.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscRandomizer.cc b/gr-atsc/lib/GrAtscRandomizer.cc index c5172699c..b4123c788 100644 --- a/gr-atsc/src/lib/GrAtscRandomizer.cc +++ b/gr-atsc/lib/GrAtscRandomizer.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscRandomizer.h> +#include <atsc/GrAtscRandomizer.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscSegSymSync.cc b/gr-atsc/lib/GrAtscSegSymSync.cc index 2d9419c25..53d5d3b4b 100644 --- a/gr-atsc/src/lib/GrAtscSegSymSync.cc +++ b/gr-atsc/lib/GrAtscSegSymSync.cc @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscSegSymSync.h> -#include <GrAtscSegSymSyncImpl_export.h> +#include <atsc/GrAtscSegSymSync.h> +#include <atsc/GrAtscSegSymSyncImpl_export.h> #include <iostream> #include <assert.h> diff --git a/gr-atsc/src/lib/GrAtscSegSymSyncImpl.cc b/gr-atsc/lib/GrAtscSegSymSyncImpl.cc index 8e2cfc208..425ab36d1 100644 --- a/gr-atsc/src/lib/GrAtscSegSymSyncImpl.cc +++ b/gr-atsc/lib/GrAtscSegSymSyncImpl.cc @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscSegSymSyncImpl.h> -#include <GrAtscSegSymSyncImpl_export.h> +#include <atsc/GrAtscSegSymSyncImpl.h> +#include <atsc/GrAtscSegSymSyncImpl_export.h> #include <cmath> #include <assert.h> diff --git a/gr-atsc/src/lib/GrAtscTrellisEncoder.cc b/gr-atsc/lib/GrAtscTrellisEncoder.cc index a0df3e9a7..abe67d2a9 100644 --- a/gr-atsc/src/lib/GrAtscTrellisEncoder.cc +++ b/gr-atsc/lib/GrAtscTrellisEncoder.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscTrellisEncoder.h> +#include <atsc/GrAtscTrellisEncoder.h> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/GrAtscViterbiDecoder.cc b/gr-atsc/lib/GrAtscViterbiDecoder.cc index c89b3556b..986fe001d 100644 --- a/gr-atsc/src/lib/GrAtscViterbiDecoder.cc +++ b/gr-atsc/lib/GrAtscViterbiDecoder.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <GrAtscViterbiDecoder.h> +#include <atsc/GrAtscViterbiDecoder.h> #include <iostream> // typedefs for fundamental i/o types diff --git a/gr-atsc/src/lib/atsc_bit_timing_loop.cc b/gr-atsc/lib/atsc_bit_timing_loop.cc index dc43d28bc..7287eee19 100644 --- a/gr-atsc/src/lib/atsc_bit_timing_loop.cc +++ b/gr-atsc/lib/atsc_bit_timing_loop.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_bit_timing_loop.h> +#include <atsc/bit_timing_loop.h> #include <gr_io_signature.h> -#include <atsc_consts.h> +#include <atsc/consts.h> #include <string.h> // Input rate changed from 20MHz to 19.2 to support usrp at 3 * 6.4MHz diff --git a/gr-atsc/src/lib/atsc_deinterleaver.cc b/gr-atsc/lib/atsc_deinterleaver.cc index f251c7f4e..bc6d742bf 100644 --- a/gr-atsc/src/lib/atsc_deinterleaver.cc +++ b/gr-atsc/lib/atsc_deinterleaver.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_deinterleaver.h> +#include <atsc/deinterleaver.h> #include <gr_io_signature.h> -#include <atsc_consts.h> +#include <atsc/consts.h> atsc_deinterleaver_sptr diff --git a/gr-atsc/src/lib/atsc_depad.cc b/gr-atsc/lib/atsc_depad.cc index 9792a4e6a..7dd6ba1c6 100644 --- a/gr-atsc/src/lib/atsc_depad.cc +++ b/gr-atsc/lib/atsc_depad.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_depad.h> +#include <atsc/depad.h> #include <gr_io_signature.h> -#include <atsc_types.h> +#include <atsc/types.h> atsc_depad_sptr atsc_make_depad() diff --git a/gr-atsc/src/lib/atsc_derandomizer.cc b/gr-atsc/lib/atsc_derandomizer.cc index 6642adb25..79b3612af 100644 --- a/gr-atsc/src/lib/atsc_derandomizer.cc +++ b/gr-atsc/lib/atsc_derandomizer.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_derandomizer.h> +#include <atsc/derandomizer.h> #include <gr_io_signature.h> -#include <atsc_consts.h> +#include <atsc/consts.h> atsc_derandomizer_sptr diff --git a/gr-atsc/src/lib/atsc_ds_to_softds.cc b/gr-atsc/lib/atsc_ds_to_softds.cc index a8f93bde4..06ea9686c 100644 --- a/gr-atsc/src/lib/atsc_ds_to_softds.cc +++ b/gr-atsc/lib/atsc_ds_to_softds.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_ds_to_softds.h> +#include <atsc/ds_to_softds.h> #include <gr_io_signature.h> -#include <atsc_consts.h> +#include <atsc/consts.h> atsc_ds_to_softds_sptr diff --git a/gr-atsc/src/lib/atsc_equalizer.cc b/gr-atsc/lib/atsc_equalizer.cc index b8f31aeb4..6838cc154 100644 --- a/gr-atsc/src/lib/atsc_equalizer.cc +++ b/gr-atsc/lib/atsc_equalizer.cc @@ -24,11 +24,11 @@ #include <config.h> #endif -#include <atsc_equalizer.h> -#include <create_atsci_equalizer.h> +#include <atsc/equalizer.h> +#include <atsc/create_atsci_equalizer.h> #include <gr_io_signature.h> -#include <atsc_consts.h> -#include <atsci_syminfo.h> +#include <atsc/consts.h> +#include <atsc/syminfo_impl.h> atsc_equalizer_sptr diff --git a/gr-atsc/src/lib/atsc_field_sync_demux.cc b/gr-atsc/lib/atsc_field_sync_demux.cc index 2783e4a90..7697a02c6 100644 --- a/gr-atsc/src/lib/atsc_field_sync_demux.cc +++ b/gr-atsc/lib/atsc_field_sync_demux.cc @@ -25,11 +25,11 @@ #endif #include <cmath> -#include <atsc_field_sync_demux.h> +#include <atsc/field_sync_demux.h> #include <gr_io_signature.h> -#include <atsc_types.h> -#include <atsc_consts.h> -#include <atsci_syminfo.h> +#include <atsc/types.h> +#include <atsc/consts.h> +#include <atsc/syminfo_impl.h> #include <stdio.h> #include <assert.h> #include <iostream> diff --git a/gr-atsc/src/lib/atsc_field_sync_mux.cc b/gr-atsc/lib/atsc_field_sync_mux.cc index 99fa5bff3..578af9eff 100644 --- a/gr-atsc/src/lib/atsc_field_sync_mux.cc +++ b/gr-atsc/lib/atsc_field_sync_mux.cc @@ -24,10 +24,10 @@ #include <config.h> #endif -#include <atsc_field_sync_mux.h> +#include <atsc/field_sync_mux.h> #include <gr_io_signature.h> -#include <atsc_consts.h> -#include <atsci_pnXXX.h> +#include <atsc/consts.h> +#include <atsc/pnXXX_impl.h> atsc_field_sync_mux_sptr diff --git a/gr-atsc/src/lib/atsc_fpll.cc b/gr-atsc/lib/atsc_fpll.cc index c8d62c415..999a326be 100644 --- a/gr-atsc/src/lib/atsc_fpll.cc +++ b/gr-atsc/lib/atsc_fpll.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_fpll.h> +#include <atsc/fpll.h> #include <gr_io_signature.h> -#include <atsc_consts.h> +#include <atsc/consts.h> #include <algorithm> #include "fpll_btloop_coupling.h" #include <gr_math.h> diff --git a/gr-atsc/src/lib/atsc_fs_checker.cc b/gr-atsc/lib/atsc_fs_checker.cc index f8c4e43d5..41d16d20b 100644 --- a/gr-atsc/src/lib/atsc_fs_checker.cc +++ b/gr-atsc/lib/atsc_fs_checker.cc @@ -24,12 +24,12 @@ #include <config.h> #endif -#include <atsc_fs_checker.h> -#include <create_atsci_fs_checker.h> -#include <atsci_fs_checker.h> +#include <atsc/fs_checker.h> +#include <atsc/create_atsci_fs_checker.h> +#include <atsc/fs_checker_impl.h> #include <gr_io_signature.h> -#include <atsc_consts.h> -#include <atsci_syminfo.h> +#include <atsc/consts.h> +#include <atsc/syminfo_impl.h> atsc_fs_checker_sptr diff --git a/gr-atsc/src/lib/atsc_interleaver.cc b/gr-atsc/lib/atsc_interleaver.cc index fff5b2fa6..e7c22316b 100644 --- a/gr-atsc/src/lib/atsc_interleaver.cc +++ b/gr-atsc/lib/atsc_interleaver.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_interleaver.h> +#include <atsc/interleaver.h> #include <gr_io_signature.h> -#include <atsc_consts.h> +#include <atsc/consts.h> atsc_interleaver_sptr diff --git a/gr-atsc/src/lib/atsc_pad.cc b/gr-atsc/lib/atsc_pad.cc index 317b16aca..9b181a8b7 100644 --- a/gr-atsc/src/lib/atsc_pad.cc +++ b/gr-atsc/lib/atsc_pad.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_pad.h> +#include <atsc/pad.h> #include <gr_io_signature.h> -#include <atsc_types.h> +#include <atsc/types.h> static const int INTR = ATSC_MPEG_PKT_LENGTH; diff --git a/gr-atsc/src/lib/atsc_randomizer.cc b/gr-atsc/lib/atsc_randomizer.cc index 73375e84c..8f88c51a2 100644 --- a/gr-atsc/src/lib/atsc_randomizer.cc +++ b/gr-atsc/lib/atsc_randomizer.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_randomizer.h> +#include <atsc/randomizer.h> #include <gr_io_signature.h> -#include <atsc_consts.h> +#include <atsc/consts.h> atsc_randomizer_sptr diff --git a/gr-atsc/src/lib/atsc_rs_decoder.cc b/gr-atsc/lib/atsc_rs_decoder.cc index e4bb6e57a..80ff41c2b 100644 --- a/gr-atsc/src/lib/atsc_rs_decoder.cc +++ b/gr-atsc/lib/atsc_rs_decoder.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_rs_decoder.h> +#include <atsc/rs_decoder.h> #include <gr_io_signature.h> -#include <atsc_consts.h> +#include <atsc/consts.h> atsc_rs_decoder_sptr diff --git a/gr-atsc/src/lib/atsc_rs_encoder.cc b/gr-atsc/lib/atsc_rs_encoder.cc index 7c4ec293b..9773f9448 100644 --- a/gr-atsc/src/lib/atsc_rs_encoder.cc +++ b/gr-atsc/lib/atsc_rs_encoder.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_rs_encoder.h> +#include <atsc/rs_encoder.h> #include <gr_io_signature.h> -#include <atsc_consts.h> +#include <atsc/consts.h> atsc_rs_encoder_sptr diff --git a/gr-atsc/src/lib/atsc_trellis_encoder.cc b/gr-atsc/lib/atsc_trellis_encoder.cc index fa0a889aa..615864d97 100644 --- a/gr-atsc/src/lib/atsc_trellis_encoder.cc +++ b/gr-atsc/lib/atsc_trellis_encoder.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_trellis_encoder.h> +#include <atsc/trellis_encoder.h> #include <gr_io_signature.h> -#include <atsc_consts.h> +#include <atsc/consts.h> atsc_trellis_encoder_sptr diff --git a/gr-atsc/src/lib/atsc_viterbi_decoder.cc b/gr-atsc/lib/atsc_viterbi_decoder.cc index 72b9a965b..ca32c6d99 100644 --- a/gr-atsc/src/lib/atsc_viterbi_decoder.cc +++ b/gr-atsc/lib/atsc_viterbi_decoder.cc @@ -24,9 +24,9 @@ #include <config.h> #endif -#include <atsc_viterbi_decoder.h> +#include <atsc/viterbi_decoder.h> #include <gr_io_signature.h> -#include <atsc_consts.h> +#include <atsc/consts.h> #include <iostream> using std::cerr; diff --git a/gr-atsc/src/lib/atsci_basic_trellis_encoder.cc b/gr-atsc/lib/atsci_basic_trellis_encoder.cc index 2ae481cbc..a4fa3d6d8 100644 --- a/gr-atsc/src/lib/atsci_basic_trellis_encoder.cc +++ b/gr-atsc/lib/atsci_basic_trellis_encoder.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_basic_trellis_encoder.h> +#include <atsc/basic_trellis_encoder_impl.h> #include <assert.h> const unsigned char atsci_basic_trellis_encoder::next_state[32] = { diff --git a/gr-atsc/src/lib/atsci_data_interleaver.cc b/gr-atsc/lib/atsci_data_interleaver.cc index a2eef0fea..9aa254141 100644 --- a/gr-atsc/src/lib/atsci_data_interleaver.cc +++ b/gr-atsc/lib/atsci_data_interleaver.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_data_interleaver.h> +#include <atsc/data_interleaver_impl.h> void atsci_data_interleaver::interleave (atsc_mpeg_packet_rs_encoded &out, diff --git a/gr-atsc/src/lib/atsci_equalizer.cc b/gr-atsc/lib/atsci_equalizer.cc index 4aec47495..6646810a2 100644 --- a/gr-atsc/src/lib/atsci_equalizer.cc +++ b/gr-atsc/lib/atsci_equalizer.cc @@ -20,10 +20,10 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_equalizer.h> +#include <atsc/equalizer_impl.h> #include <algorithm> #include <iostream> -#include <atsc_types.h> +#include <atsc/types.h> using std::cerr; using std::endl; diff --git a/gr-atsc/src/lib/atsci_equalizer_lms.cc b/gr-atsc/lib/atsci_equalizer_lms.cc index bab962e32..b4776faea 100644 --- a/gr-atsc/src/lib/atsci_equalizer_lms.cc +++ b/gr-atsc/lib/atsci_equalizer_lms.cc @@ -20,10 +20,10 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_equalizer_lms.h> +#include <atsc/equalizer_lms_impl.h> #include <assert.h> #include <algorithm> -#include <atsci_pnXXX.h> +#include <atsc/pnXXX_impl.h> #include <stdio.h> diff --git a/gr-atsc/src/lib/atsci_equalizer_lms2.cc b/gr-atsc/lib/atsci_equalizer_lms2.cc index 2825aad50..2fad19b74 100644 --- a/gr-atsc/src/lib/atsci_equalizer_lms2.cc +++ b/gr-atsc/lib/atsci_equalizer_lms2.cc @@ -20,10 +20,10 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_equalizer_lms2.h> +#include <atsc/equalizer_lms2_impl.h> #include <assert.h> #include <algorithm> -#include <atsci_pnXXX.h> +#include <atsc/pnXXX_impl.h> #include <cmath> #include <stdlib.h> #include <gr_math.h> diff --git a/gr-atsc/src/lib/atsci_equalizer_nop.cc b/gr-atsc/lib/atsci_equalizer_nop.cc index 5af2cc4e7..61fed43d2 100644 --- a/gr-atsc/src/lib/atsci_equalizer_nop.cc +++ b/gr-atsc/lib/atsci_equalizer_nop.cc @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_equalizer_nop.h> -#include <atsci_sync_tag.h> +#include <atsc/equalizer_nop_impl.h> +#include <atsc/sync_tag_impl.h> #include <assert.h> atsci_equalizer_nop::atsci_equalizer_nop () diff --git a/gr-atsc/src/lib/atsci_exp2_lp.cc b/gr-atsc/lib/atsci_exp2_lp.cc index 8f411977e..93e15f702 100644 --- a/gr-atsc/src/lib/atsci_exp2_lp.cc +++ b/gr-atsc/lib/atsci_exp2_lp.cc @@ -21,7 +21,7 @@ */ #include <atsc_consts.h> -#include <atsci_exp2_lp.h> +#include <atsc/exp2_lp_impl.h> #include <stdexcept> #include <cmath> #include <iostream> diff --git a/gr-atsc/src/lib/atsci_exp2_lp20.dat b/gr-atsc/lib/atsci_exp2_lp20.dat index d09c5aca2..d09c5aca2 100644 --- a/gr-atsc/src/lib/atsci_exp2_lp20.dat +++ b/gr-atsc/lib/atsci_exp2_lp20.dat diff --git a/gr-atsc/src/lib/atsci_exp2_lp2x.dat b/gr-atsc/lib/atsci_exp2_lp2x.dat index 67dd204cb..67dd204cb 100644 --- a/gr-atsc/src/lib/atsci_exp2_lp2x.dat +++ b/gr-atsc/lib/atsci_exp2_lp2x.dat diff --git a/gr-atsc/src/lib/atsci_fake_single_viterbi.cc b/gr-atsc/lib/atsci_fake_single_viterbi.cc index 6246a9050..e94e7f073 100644 --- a/gr-atsc/src/lib/atsci_fake_single_viterbi.cc +++ b/gr-atsc/lib/atsci_fake_single_viterbi.cc @@ -21,7 +21,7 @@ */ #include <math.h> -#include <atsci_fake_single_viterbi.h> +#include <atsc/fake_single_viterbi_impl.h> #include <iostream> #include <algorithm> diff --git a/gr-atsc/src/lib/atsci_fs_checker.cc b/gr-atsc/lib/atsci_fs_checker.cc index 7d321307c..e43f88e33 100644 --- a/gr-atsc/src/lib/atsci_fs_checker.cc +++ b/gr-atsc/lib/atsci_fs_checker.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_fs_checker.h> +#include <atsc/fs_checker_impl.h> // empty constructor atsci_fs_checker::atsci_fs_checker () diff --git a/gr-atsc/src/lib/atsci_fs_checker_naive.cc b/gr-atsc/lib/atsci_fs_checker_naive.cc index f14472aa2..392bf7039 100644 --- a/gr-atsc/src/lib/atsci_fs_checker_naive.cc +++ b/gr-atsc/lib/atsci_fs_checker_naive.cc @@ -20,9 +20,9 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_fs_checker_naive.h> -#include <atsci_syminfo.h> -#include <atsci_pnXXX.h> +#include <atsc/fs_checker_naive_impl.h> +#include <atsc/syminfo_impl.h> +#include <atsc/pnXXX_impl.h> #include <iostream> #include <cstring> diff --git a/gr-atsc/src/lib/atsci_fs_correlator.cc b/gr-atsc/lib/atsci_fs_correlator.cc index efeb35176..1dccfc5e2 100644 --- a/gr-atsc/src/lib/atsci_fs_correlator.cc +++ b/gr-atsc/lib/atsci_fs_correlator.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_fs_correlator.h> +#include <atsc/fs_correlator_impl.h> // empty constructor atsci_fs_correlator::atsci_fs_correlator () diff --git a/gr-atsc/src/lib/atsci_fs_correlator_naive.cc b/gr-atsc/lib/atsci_fs_correlator_naive.cc index ccf903531..5bddcfa79 100644 --- a/gr-atsc/src/lib/atsci_fs_correlator_naive.cc +++ b/gr-atsc/lib/atsci_fs_correlator_naive.cc @@ -20,9 +20,9 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_fs_correlator_naive.h> -#include <atsci_sync_tag.h> -#include <atsci_pnXXX.h> +#include <atsc/fs_correlator_naive_impl.h> +#include <atsc/sync_tag_impl.h> +#include <atsc/pnXXX_impl.h> #include <iostream> #include <cstring> diff --git a/gr-atsc/src/lib/atsci_pnXXX.cc b/gr-atsc/lib/atsci_pnXXX.cc index 128582d2d..93c9b2295 100644 --- a/gr-atsc/src/lib/atsci_pnXXX.cc +++ b/gr-atsc/lib/atsci_pnXXX.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_pnXXX.h> +#include <atsc/pnXXX_impl.h> const unsigned char atsc_pn511[511] = { 0,0,0,0, 0,0,0,1, 0,1,1,1, 1,1,1,1, 1,1,0,0, 1,0,1,0, 1,0,1,0, 1,1,1,0, diff --git a/gr-atsc/src/lib/atsci_randomizer.cc b/gr-atsc/lib/atsci_randomizer.cc index 8766bbef0..6deadfecf 100644 --- a/gr-atsc/src/lib/atsci_randomizer.cc +++ b/gr-atsc/lib/atsci_randomizer.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_randomizer.h> +#include <atsc/randomizer_impl.h> #include <assert.h> unsigned char atsci_randomizer::s_output_map[1 << 14]; diff --git a/gr-atsc/src/lib/atsci_reed_solomon.cc b/gr-atsc/lib/atsci_reed_solomon.cc index 8ac97344b..6aff353b4 100644 --- a/gr-atsc/src/lib/atsci_reed_solomon.cc +++ b/gr-atsc/lib/atsci_reed_solomon.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_reed_solomon.h> +#include <atsc/reed_solomon_impl.h> #include <assert.h> #include <string.h> diff --git a/gr-atsc/src/lib/atsci_root_raised_cosine.cc b/gr-atsc/lib/atsci_root_raised_cosine.cc index 3323ca89e..c5cedbd1f 100644 --- a/gr-atsc/src/lib/atsci_root_raised_cosine.cc +++ b/gr-atsc/lib/atsci_root_raised_cosine.cc @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include <atsc_consts.h> -#include <atsci_root_raised_cosine.h> +#include <atsc/consts.h> +#include <atsc/root_raised_cosine_impl.h> #include <filter/firdes.h> vector<float> diff --git a/gr-atsc/src/lib/atsci_root_raised_cosine_bandpass.cc b/gr-atsc/lib/atsci_root_raised_cosine_bandpass.cc index f795a4166..5dd770554 100644 --- a/gr-atsc/src/lib/atsci_root_raised_cosine_bandpass.cc +++ b/gr-atsc/lib/atsci_root_raised_cosine_bandpass.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_root_raised_cosine_bandpass.h> +#include <atsc/root_raised_cosine_bandpass_impl.h> #include <iostream> #include <cmath> diff --git a/gr-atsc/src/lib/atsci_single_viterbi.cc b/gr-atsc/lib/atsci_single_viterbi.cc index a1bf2ea49..f53f16c8e 100644 --- a/gr-atsc/src/lib/atsci_single_viterbi.cc +++ b/gr-atsc/lib/atsci_single_viterbi.cc @@ -21,7 +21,7 @@ */ #include <math.h> -#include <atsci_single_viterbi.h> +#include <atsc/single_viterbi_impl.h> #include <iostream> using std::cerr; diff --git a/gr-atsc/src/lib/atsci_sliding_correlator.cc b/gr-atsc/lib/atsci_sliding_correlator.cc index 877037db7..b79adfb53 100644 --- a/gr-atsc/src/lib/atsci_sliding_correlator.cc +++ b/gr-atsc/lib/atsci_sliding_correlator.cc @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_sliding_correlator.h> -#include <atsci_pnXXX.h> +#include <atsc/sliding_correlator_impl.h> +#include <atsc/pnXXX_impl.h> // #define TRY_BACKWARDS diff --git a/gr-atsc/src/lib/atsci_sssr.cc b/gr-atsc/lib/atsci_sssr.cc index 56a0c6a00..5deeda86c 100644 --- a/gr-atsc/src/lib/atsci_sssr.cc +++ b/gr-atsc/lib/atsci_sssr.cc @@ -20,12 +20,12 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_sssr.h> +#include <atsc/sssr_impl.h> #include <algorithm> #include <cmath> #include <cstdio> #include <assert.h> -#include <atsci_diag_output.h> +#include <atsc/diag_output_impl.h> #include <gr_math.h> #include <stdio.h> #include <boost/math/special_functions/sign.hpp> diff --git a/gr-atsc/src/lib/atsci_trellis_encoder.cc b/gr-atsc/lib/atsci_trellis_encoder.cc index 2b3e851bc..4e81c87e3 100644 --- a/gr-atsc/src/lib/atsci_trellis_encoder.cc +++ b/gr-atsc/lib/atsci_trellis_encoder.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_trellis_encoder.h> +#include <atsc/trellis_encoder_impl.h> #include <assert.h> #include <stdio.h> #include <string.h> diff --git a/gr-atsc/src/lib/atsci_viterbi_decoder.cc b/gr-atsc/lib/atsci_viterbi_decoder.cc index 8804f6007..26f5577de 100644 --- a/gr-atsc/src/lib/atsci_viterbi_decoder.cc +++ b/gr-atsc/lib/atsci_viterbi_decoder.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsci_viterbi_decoder.h> +#include <atsc/viterbi_decoder.h> #include <assert.h> #include <stdio.h> #include <cmath> diff --git a/gr-atsc/src/lib/atsci_viterbi_gen.cc b/gr-atsc/lib/atsci_viterbi_gen.cc index bff3c4773..bff3c4773 100644 --- a/gr-atsc/src/lib/atsci_viterbi_gen.cc +++ b/gr-atsc/lib/atsci_viterbi_gen.cc diff --git a/gr-atsc/src/lib/atsci_vsbtx_lp.cc b/gr-atsc/lib/atsci_vsbtx_lp.cc index 704cd00ca..4b6f82af3 100644 --- a/gr-atsc/src/lib/atsci_vsbtx_lp.cc +++ b/gr-atsc/lib/atsci_vsbtx_lp.cc @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include <atsc_consts.h> -#include <atsci_vsbtx_lp.h> +#include <atsc/consts.h> +#include <atsc/vsbtx_lp_impl.h> #include <stdexcept> #include <cmath> #include <iostream> diff --git a/gr-atsc/src/lib/atsci_vsbtx_lp.dat b/gr-atsc/lib/atsci_vsbtx_lp.dat index 0fa54d42b..0fa54d42b 100644 --- a/gr-atsc/src/lib/atsci_vsbtx_lp.dat +++ b/gr-atsc/lib/atsci_vsbtx_lp.dat diff --git a/gr-atsc/src/lib/create_atsci_equalizer.cc b/gr-atsc/lib/create_atsci_equalizer.cc index f784116d2..17874cdd4 100644 --- a/gr-atsc/src/lib/create_atsci_equalizer.cc +++ b/gr-atsc/lib/create_atsci_equalizer.cc @@ -20,10 +20,10 @@ * Boston, MA 02110-1301, USA. */ -#include <create_atsci_equalizer.h> -#include <atsci_equalizer_nop.h> -#include <atsci_equalizer_lms.h> -#include <atsci_equalizer_lms2.h> +#include <atsc/create_atsci_equalizer.h> +#include <atsc/equalizer_nop_impl.h> +#include <atsc/equalizer_lms_impl.h> +#include <atsc/equalizer_lms2_impl.h> atsci_equalizer * create_atsci_equalizer_nop () diff --git a/gr-atsc/src/lib/create_atsci_fs_checker.cc b/gr-atsc/lib/create_atsci_fs_checker.cc index 5b9a4092c..1eea7bcc0 100644 --- a/gr-atsc/src/lib/create_atsci_fs_checker.cc +++ b/gr-atsc/lib/create_atsci_fs_checker.cc @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include <create_atsci_fs_checker.h> -#include <atsci_fs_checker_naive.h> +#include <atsc/create_atsci_fs_checker.h> +#include <atsc/fs_checker_naive_impl.h> atsci_fs_checker * create_atsci_fs_checker () diff --git a/gr-atsc/src/lib/create_atsci_fs_correlator.cc b/gr-atsc/lib/create_atsci_fs_correlator.cc index 414b2d7f4..021d315de 100644 --- a/gr-atsc/src/lib/create_atsci_fs_correlator.cc +++ b/gr-atsc/lib/create_atsci_fs_correlator.cc @@ -20,8 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include <create_atsci_fs_correlator.h> -#include <atsci_fs_correlator_naive.h> +#include <atsc/create_atsci_fs_correlator.h> +#include <atsc/fs_correlator_naive_impl.h> atsci_fs_correlator * create_atsci_fs_correlator () diff --git a/gr-atsc/src/lib/fpll_btloop_coupling.h b/gr-atsc/lib/fpll_btloop_coupling.h index 9a1a99d86..9a1a99d86 100644 --- a/gr-atsc/src/lib/fpll_btloop_coupling.h +++ b/gr-atsc/lib/fpll_btloop_coupling.h diff --git a/gr-atsc/src/lib/gen_encoder.py b/gr-atsc/lib/gen_encoder.py index 6c8fabf7a..6c8fabf7a 100755 --- a/gr-atsc/src/lib/gen_encoder.py +++ b/gr-atsc/lib/gen_encoder.py diff --git a/gr-atsc/src/lib/gnuradio-atsc.rc.in b/gr-atsc/lib/gnuradio-atsc.rc.in index f0d7699f0..f0d7699f0 100644 --- a/gr-atsc/src/lib/gnuradio-atsc.rc.in +++ b/gr-atsc/lib/gnuradio-atsc.rc.in diff --git a/gr-atsc/src/lib/plinfo.cc b/gr-atsc/lib/plinfo.cc index 30e192907..8ad28c600 100644 --- a/gr-atsc/src/lib/plinfo.cc +++ b/gr-atsc/lib/plinfo.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <atsc_types.h> +#include <atsc/types.h> #include <assert.h> void diff --git a/gr-atsc/src/lib/qa_atsci.cc b/gr-atsc/lib/qa_atsci.cc index 8dc940bcb..611440e96 100644 --- a/gr-atsc/src/lib/qa_atsci.cc +++ b/gr-atsc/lib/qa_atsci.cc @@ -25,20 +25,20 @@ * add them here. */ -#include <qa_atsci.h> -#include <qa_atsci_randomizer.h> -#include <qa_atsci_reed_solomon.h> -#include <qa_interleaver_fifo.h> -#include <qa_convolutional_interleaver.h> -#include <qa_atsci_data_interleaver.h> -#include <qa_atsci_basic_trellis_encoder.h> -#include <qa_atsci_sliding_correlator.h> -#include <qa_atsci_fake_single_viterbi.h> -#include <qa_atsci_single_viterbi.h> -#include <qa_atsci_trellis_encoder.h> -#include <qa_atsci_viterbi_decoder.h> -#include <qa_atsci_fs_correlator.h> -#include <qa_atsci_equalizer_nop.h> +#include "qa_atsci.h" +#include "qa_atsci_randomizer.h" +#include "qa_atsci_reed_solomon.h" +#include "qa_interleaver_fifo.h" +#include "qa_convolutional_interleaver.h" +#include "qa_atsci_data_interleaver.h" +#include "qa_atsci_basic_trellis_encoder.h" +#include "qa_atsci_sliding_correlator.h" +#include "qa_atsci_fake_single_viterbi.h" +#include "qa_atsci_single_viterbi.h" +#include "qa_atsci_trellis_encoder.h" +#include "qa_atsci_viterbi_decoder.h" +#include "qa_atsci_fs_correlator.h" +#include "qa_atsci_equalizer_nop.h" CppUnit::TestSuite * qa_atsc::suite () diff --git a/gr-atsc/src/lib/qa_atsci.h b/gr-atsc/lib/qa_atsci.h index 86aca2d32..86aca2d32 100644 --- a/gr-atsc/src/lib/qa_atsci.h +++ b/gr-atsc/lib/qa_atsci.h diff --git a/gr-atsc/src/lib/qa_atsci_basic_trellis_encoder.cc b/gr-atsc/lib/qa_atsci_basic_trellis_encoder.cc index 4a8137424..2b64759c1 100644 --- a/gr-atsc/src/lib/qa_atsci_basic_trellis_encoder.cc +++ b/gr-atsc/lib/qa_atsci_basic_trellis_encoder.cc @@ -25,7 +25,7 @@ #endif #include <cppunit/TestAssert.h> -#include <qa_atsci_basic_trellis_encoder.h> +#include "qa_atsci_basic_trellis_encoder.h" #include <stdlib.h> #include <stdio.h> diff --git a/gr-atsc/src/lib/qa_atsci_basic_trellis_encoder.h b/gr-atsc/lib/qa_atsci_basic_trellis_encoder.h index e413d0d3d..c1e6e8f8c 100644 --- a/gr-atsc/src/lib/qa_atsci_basic_trellis_encoder.h +++ b/gr-atsc/lib/qa_atsci_basic_trellis_encoder.h @@ -25,7 +25,7 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -#include <atsci_basic_trellis_encoder.h> +#include <atsc/basic_trellis_encoder_impl.h> class qa_atsci_basic_trellis_encoder : public CppUnit::TestCase { diff --git a/gr-atsc/src/lib/qa_atsci_data_interleaver.cc b/gr-atsc/lib/qa_atsci_data_interleaver.cc index 6069e8680..87cb45f49 100644 --- a/gr-atsc/src/lib/qa_atsci_data_interleaver.cc +++ b/gr-atsc/lib/qa_atsci_data_interleaver.cc @@ -21,7 +21,7 @@ */ #include <cppunit/TestAssert.h> -#include <qa_atsci_data_interleaver.h> +#include "qa_atsci_data_interleaver.h" #include <string.h> diff --git a/gr-atsc/src/lib/qa_atsci_data_interleaver.h b/gr-atsc/lib/qa_atsci_data_interleaver.h index 6b9408c9a..32c9e79c4 100644 --- a/gr-atsc/src/lib/qa_atsci_data_interleaver.h +++ b/gr-atsc/lib/qa_atsci_data_interleaver.h @@ -27,7 +27,7 @@ #include <cppunit/TestCase.h> #include <stdio.h> -#include <atsci_data_interleaver.h> +#include <atsc/data_interleaver_impl.h> class qa_atsci_data_interleaver : public CppUnit::TestCase { public: diff --git a/gr-atsc/src/lib/qa_atsci_equalizer_nop.cc b/gr-atsc/lib/qa_atsci_equalizer_nop.cc index 7039eeb8e..927e23fda 100644 --- a/gr-atsc/src/lib/qa_atsci_equalizer_nop.cc +++ b/gr-atsc/lib/qa_atsci_equalizer_nop.cc @@ -20,11 +20,11 @@ * Boston, MA 02110-1301, USA. */ -#include <qa_atsci_equalizer_nop.h> -#include <atsci_equalizer.h> -#include <atsci_equalizer_nop.h> -#include <atsci_pnXXX.h> -#include <atsc_types.h> +#include "qa_atsci_equalizer_nop.h" +#include <atsc/equalizer_impl.h> +#include <atsc/equalizer_nop_impl.h> +#include <atsc/pnXXX_impl.h> +#include <atsc/types.h> #include <cppunit/TestAssert.h> #include <assert.h> #include <iostream> diff --git a/gr-atsc/src/lib/qa_atsci_equalizer_nop.h b/gr-atsc/lib/qa_atsci_equalizer_nop.h index 244daf8b3..244daf8b3 100644 --- a/gr-atsc/src/lib/qa_atsci_equalizer_nop.h +++ b/gr-atsc/lib/qa_atsci_equalizer_nop.h diff --git a/gr-atsc/src/lib/qa_atsci_fake_single_viterbi.cc b/gr-atsc/lib/qa_atsci_fake_single_viterbi.cc index 2cc646daf..88e2fdb92 100644 --- a/gr-atsc/src/lib/qa_atsci_fake_single_viterbi.cc +++ b/gr-atsc/lib/qa_atsci_fake_single_viterbi.cc @@ -26,8 +26,8 @@ #include <cppunit/TestAssert.h> #include <stdio.h> -#include <atsci_fake_single_viterbi.h> -#include <qa_atsci_fake_single_viterbi.h> +#include <atsc/fake_single_viterbi_impl.h> +#include "qa_atsci_fake_single_viterbi.h" #include <random.h> #include <string.h> diff --git a/gr-atsc/src/lib/qa_atsci_fake_single_viterbi.h b/gr-atsc/lib/qa_atsci_fake_single_viterbi.h index 47805952c..373f4b6c6 100644 --- a/gr-atsc/src/lib/qa_atsci_fake_single_viterbi.h +++ b/gr-atsc/lib/qa_atsci_fake_single_viterbi.h @@ -26,8 +26,8 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -#include <atsci_fake_single_viterbi.h> -#include <atsci_basic_trellis_encoder.h> +#include <atsc/fake_single_viterbi_impl.h> +#include <atsc/basic_trellis_encoder_impl.h> class qa_atsci_fake_single_viterbi : public CppUnit::TestCase { private: diff --git a/gr-atsc/src/lib/qa_atsci_fs_correlator.cc b/gr-atsc/lib/qa_atsci_fs_correlator.cc index 591c84050..a00731ab4 100644 --- a/gr-atsc/src/lib/qa_atsci_fs_correlator.cc +++ b/gr-atsc/lib/qa_atsci_fs_correlator.cc @@ -24,14 +24,14 @@ #include <config.h> #endif -#include <qa_atsci_fs_correlator.h> -#include <atsci_fs_correlator.h> -#include <create_atsci_fs_correlator.h> -#include <atsci_sync_tag.h> +#include "qa_atsci_fs_correlator.h" +#include <atsc/fs_correlator_impl.h> +#include <atsc/create_atsci_fs_correlator.h> +#include <atsc/sync_tag_impl.h> #include <stdlib.h> #include <algorithm> -#include <atsci_pnXXX.h> -#include <atsc_types.h> +#include <atsc/pnXXX_impl.h> +#include <atsc/types.h> #include <cppunit/TestAssert.h> #include <assert.h> #include <random.h> diff --git a/gr-atsc/src/lib/qa_atsci_fs_correlator.h b/gr-atsc/lib/qa_atsci_fs_correlator.h index 4785f096e..4785f096e 100644 --- a/gr-atsc/src/lib/qa_atsci_fs_correlator.h +++ b/gr-atsc/lib/qa_atsci_fs_correlator.h diff --git a/gr-atsc/src/lib/qa_atsci_randomizer.cc b/gr-atsc/lib/qa_atsci_randomizer.cc index c12582dfd..a750fbb5d 100644 --- a/gr-atsc/src/lib/qa_atsci_randomizer.cc +++ b/gr-atsc/lib/qa_atsci_randomizer.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <qa_atsci_randomizer.h> +#include "qa_atsci_randomizer.h" #include <cppunit/TestAssert.h> #include <string.h> diff --git a/gr-atsc/src/lib/qa_atsci_randomizer.h b/gr-atsc/lib/qa_atsci_randomizer.h index 16d12754f..0255d8a4a 100644 --- a/gr-atsc/src/lib/qa_atsci_randomizer.h +++ b/gr-atsc/lib/qa_atsci_randomizer.h @@ -25,7 +25,7 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -#include <atsci_randomizer.h> +#include <atsc/randomizer_impl.h> class qa_atsci_randomizer : public CppUnit::TestCase { private: diff --git a/gr-atsc/src/lib/qa_atsci_reed_solomon.cc b/gr-atsc/lib/qa_atsci_reed_solomon.cc index 81766f856..50acb76a0 100644 --- a/gr-atsc/src/lib/qa_atsci_reed_solomon.cc +++ b/gr-atsc/lib/qa_atsci_reed_solomon.cc @@ -27,8 +27,8 @@ #include <cppunit/TestAssert.h> #include <stdlib.h> #include <stdio.h> -#include <atsci_reed_solomon.h> -#include <qa_atsci_reed_solomon.h> +#include <atsc/reed_solomon_impl.h> +#include "qa_atsci_reed_solomon.h" #include <string.h> diff --git a/gr-atsc/src/lib/qa_atsci_reed_solomon.h b/gr-atsc/lib/qa_atsci_reed_solomon.h index 95d642e72..097d68130 100644 --- a/gr-atsc/src/lib/qa_atsci_reed_solomon.h +++ b/gr-atsc/lib/qa_atsci_reed_solomon.h @@ -26,7 +26,7 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -#include <atsci_reed_solomon.h> +#include <atsc/reed_solomon_impl.h> class qa_atsci_reed_solomon : public CppUnit::TestCase { diff --git a/gr-atsc/src/lib/qa_atsci_single_viterbi.cc b/gr-atsc/lib/qa_atsci_single_viterbi.cc index 699dce952..be5187dc2 100644 --- a/gr-atsc/src/lib/qa_atsci_single_viterbi.cc +++ b/gr-atsc/lib/qa_atsci_single_viterbi.cc @@ -27,8 +27,8 @@ #include <cppunit/TestAssert.h> #include <stdlib.h> #include <stdio.h> -#include <atsci_single_viterbi.h> -#include <qa_atsci_single_viterbi.h> +#include <atsc/single_viterbi_impl.h> +#include "qa_atsci_single_viterbi.h" #include <random.h> #include <string.h> diff --git a/gr-atsc/src/lib/qa_atsci_single_viterbi.h b/gr-atsc/lib/qa_atsci_single_viterbi.h index 07585de22..bfd911ab0 100644 --- a/gr-atsc/src/lib/qa_atsci_single_viterbi.h +++ b/gr-atsc/lib/qa_atsci_single_viterbi.h @@ -26,8 +26,8 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -#include <atsci_single_viterbi.h> -#include <atsci_basic_trellis_encoder.h> +#include <atsc/single_viterbi_impl.h> +#include <atsc/basic_trellis_encoder_impl.h> class qa_atsci_single_viterbi : public CppUnit::TestCase { private: diff --git a/gr-atsc/src/lib/qa_atsci_sliding_correlator.cc b/gr-atsc/lib/qa_atsci_sliding_correlator.cc index 4b215ba85..8b00e0ff0 100644 --- a/gr-atsc/src/lib/qa_atsci_sliding_correlator.cc +++ b/gr-atsc/lib/qa_atsci_sliding_correlator.cc @@ -21,7 +21,7 @@ */ #include <cppunit/TestAssert.h> -#include <qa_atsci_sliding_correlator.h> +#include "qa_atsci_sliding_correlator.h" #include <cstdio> void diff --git a/gr-atsc/src/lib/qa_atsci_sliding_correlator.h b/gr-atsc/lib/qa_atsci_sliding_correlator.h index bdcd09319..34f12cbcb 100644 --- a/gr-atsc/src/lib/qa_atsci_sliding_correlator.h +++ b/gr-atsc/lib/qa_atsci_sliding_correlator.h @@ -27,7 +27,7 @@ #include <cppunit/TestCase.h> #include <stdio.h> -#include <atsci_sliding_correlator.h> +#include <atsc/sliding_correlator_impl.h> class qa_atsci_sliding_correlator : public CppUnit::TestCase { diff --git a/gr-atsc/src/lib/qa_atsci_trellis_encoder.cc b/gr-atsc/lib/qa_atsci_trellis_encoder.cc index d3a3482f0..902dcebf8 100644 --- a/gr-atsc/src/lib/qa_atsci_trellis_encoder.cc +++ b/gr-atsc/lib/qa_atsci_trellis_encoder.cc @@ -25,7 +25,7 @@ #endif #include <cppunit/TestAssert.h> -#include <qa_atsci_trellis_encoder.h> +#include "qa_atsci_trellis_encoder.h" #include <cstdio> #include <string.h> #include <stdlib.h> diff --git a/gr-atsc/src/lib/qa_atsci_trellis_encoder.h b/gr-atsc/lib/qa_atsci_trellis_encoder.h index fcd114330..a93c0c389 100644 --- a/gr-atsc/src/lib/qa_atsci_trellis_encoder.h +++ b/gr-atsc/lib/qa_atsci_trellis_encoder.h @@ -27,7 +27,7 @@ #include <cppunit/TestCase.h> #include <stdio.h> -#include <atsci_trellis_encoder.h> +#include <atsc/trellis_encoder_impl.h> class qa_atsci_trellis_encoder : public CppUnit::TestCase { diff --git a/gr-atsc/src/lib/qa_atsci_trellis_encoder_t1_input.dat b/gr-atsc/lib/qa_atsci_trellis_encoder_t1_input.dat index e6109ddfc..e6109ddfc 100644 --- a/gr-atsc/src/lib/qa_atsci_trellis_encoder_t1_input.dat +++ b/gr-atsc/lib/qa_atsci_trellis_encoder_t1_input.dat diff --git a/gr-atsc/src/lib/qa_atsci_trellis_encoder_t1_output.dat b/gr-atsc/lib/qa_atsci_trellis_encoder_t1_output.dat index 175d482b4..175d482b4 100644 --- a/gr-atsc/src/lib/qa_atsci_trellis_encoder_t1_output.dat +++ b/gr-atsc/lib/qa_atsci_trellis_encoder_t1_output.dat diff --git a/gr-atsc/src/lib/qa_atsci_viterbi_decoder.cc b/gr-atsc/lib/qa_atsci_viterbi_decoder.cc index 8902b6eb8..cd1980476 100644 --- a/gr-atsc/src/lib/qa_atsci_viterbi_decoder.cc +++ b/gr-atsc/lib/qa_atsci_viterbi_decoder.cc @@ -25,8 +25,8 @@ #endif #include <cppunit/TestAssert.h> -#include <qa_atsci_viterbi_decoder.h> -#include <qa_atsci_trellis_encoder.h> +#include "qa_atsci_viterbi_decoder.h" +#include "qa_atsci_trellis_encoder.h" #include <cstdio> #include <string.h> #include <stdlib.h> diff --git a/gr-atsc/src/lib/qa_atsci_viterbi_decoder.h b/gr-atsc/lib/qa_atsci_viterbi_decoder.h index 440c79caf..94b5ce21d 100644 --- a/gr-atsc/src/lib/qa_atsci_viterbi_decoder.h +++ b/gr-atsc/lib/qa_atsci_viterbi_decoder.h @@ -27,7 +27,7 @@ #include <cppunit/TestCase.h> #include <stdio.h> -#include <atsci_viterbi_decoder.h> +#include <atsc/viterbi_decoder_impl.h> class qa_atsci_viterbi_decoder : public CppUnit::TestCase { diff --git a/gr-atsc/src/lib/qa_atsci_viterbi_decoder_t1_input.dat b/gr-atsc/lib/qa_atsci_viterbi_decoder_t1_input.dat index b2f356c87..b2f356c87 100644 --- a/gr-atsc/src/lib/qa_atsci_viterbi_decoder_t1_input.dat +++ b/gr-atsc/lib/qa_atsci_viterbi_decoder_t1_input.dat diff --git a/gr-atsc/src/lib/qa_atsci_viterbi_decoder_t1_output.dat b/gr-atsc/lib/qa_atsci_viterbi_decoder_t1_output.dat index 462b664b5..462b664b5 100644 --- a/gr-atsc/src/lib/qa_atsci_viterbi_decoder_t1_output.dat +++ b/gr-atsc/lib/qa_atsci_viterbi_decoder_t1_output.dat diff --git a/gr-atsc/src/lib/qa_convolutional_interleaver.cc b/gr-atsc/lib/qa_convolutional_interleaver.cc index bfe86f0ea..c7b8494f1 100644 --- a/gr-atsc/src/lib/qa_convolutional_interleaver.cc +++ b/gr-atsc/lib/qa_convolutional_interleaver.cc @@ -21,7 +21,7 @@ */ #include <cppunit/TestAssert.h> -#include <qa_convolutional_interleaver.h> +#include "qa_convolutional_interleaver.h" void qa_convolutional_interleaver::t0 () diff --git a/gr-atsc/src/lib/qa_convolutional_interleaver.h b/gr-atsc/lib/qa_convolutional_interleaver.h index b60181d73..afe795a54 100644 --- a/gr-atsc/src/lib/qa_convolutional_interleaver.h +++ b/gr-atsc/lib/qa_convolutional_interleaver.h @@ -26,7 +26,7 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -#include <convolutional_interleaver.h> +#include <atsc/convolutional_interleaver.h> class qa_convolutional_interleaver : public CppUnit::TestCase { private: diff --git a/gr-atsc/src/lib/qa_interleaver_fifo.cc b/gr-atsc/lib/qa_interleaver_fifo.cc index a9de97ff3..7ce98630e 100644 --- a/gr-atsc/src/lib/qa_interleaver_fifo.cc +++ b/gr-atsc/lib/qa_interleaver_fifo.cc @@ -21,7 +21,7 @@ */ #include <cppunit/TestAssert.h> -#include <qa_interleaver_fifo.h> +#include "qa_interleaver_fifo.h" void qa_interleaver_fifo::t0 () diff --git a/gr-atsc/src/lib/qa_interleaver_fifo.h b/gr-atsc/lib/qa_interleaver_fifo.h index 9783548ca..d0651b591 100644 --- a/gr-atsc/src/lib/qa_interleaver_fifo.h +++ b/gr-atsc/lib/qa_interleaver_fifo.h @@ -26,7 +26,7 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -#include <interleaver_fifo.h> +#include <atsc/interleaver_fifo.h> class qa_interleaver_fifo : public CppUnit::TestCase { private: diff --git a/gr-atsc/src/lib/test_atsci.cc b/gr-atsc/lib/test_atsci.cc index bf0a7eafc..9aeb718cb 100644 --- a/gr-atsc/src/lib/test_atsci.cc +++ b/gr-atsc/lib/test_atsci.cc @@ -23,7 +23,7 @@ #include <gr_unittests.h> #include <cppunit/TextTestRunner.h> #include <cppunit/XmlOutputter.h> -#include <qa_atsci.h> +#include "qa_atsci.h" int main (int argc, char **argv) diff --git a/gr-atsc/src/python/CMakeLists.txt b/gr-atsc/python/CMakeLists.txt index aaa5bd93c..aaa5bd93c 100644 --- a/gr-atsc/src/python/CMakeLists.txt +++ b/gr-atsc/python/CMakeLists.txt diff --git a/gr-atsc/src/python/README b/gr-atsc/python/README index 74d6ba134..74d6ba134 100644 --- a/gr-atsc/src/python/README +++ b/gr-atsc/python/README diff --git a/gr-atsc/src/python/all_atsc.py b/gr-atsc/python/all_atsc.py index 6fcb02fda..7cac78514 100644 --- a/gr-atsc/src/python/all_atsc.py +++ b/gr-atsc/python/all_atsc.py @@ -49,7 +49,7 @@ def graph (args): tb = gr.top_block () # Convert to a from shorts to a stream of complex numbers. - srcf = gr.file_source (gr.sizeof_short,infile) + srcf = blocks.file_source (gr.sizeof_short,infile) s2ss = blocks.stream_to_streams(gr.sizeof_short,2) s2f1 = blocks.short_to_float() s2f2 = blocks.short_to_float() @@ -128,10 +128,10 @@ def graph (args): rs_dec = atsc.rs_decoder() derand = atsc.derandomizer() depad = atsc.depad() - dst = gr.file_sink(gr.sizeof_char, outfile) + dst = blocks.file_sink(gr.sizeof_char, outfile) tb.connect(fsd, viterbi, deinter, rs_dec, derand, depad, dst) - dst2 = gr.file_sink(gr.sizeof_gr_complex, "atsc_complex.data") + dst2 = blocks.file_sink(gr.sizeof_gr_complex, "atsc_complex.data") tb.connect(src0, dst2) tb.run () diff --git a/gr-atsc/src/python/atsc_utils.py b/gr-atsc/python/atsc_utils.py index fc2465bed..fc2465bed 100644 --- a/gr-atsc/src/python/atsc_utils.py +++ b/gr-atsc/python/atsc_utils.py diff --git a/gr-atsc/src/python/btl-fsd.py b/gr-atsc/python/btl-fsd.py index 826e71016..6bcab3dce 100755 --- a/gr-atsc/src/python/btl-fsd.py +++ b/gr-atsc/python/btl-fsd.py @@ -22,6 +22,7 @@ from gnuradio import gr from gnuradio import atsc +from gnuradio import blocks import os print os.getpid() @@ -33,9 +34,9 @@ fsc = atsc.fs_checker() eq = atsc.equalizer() fsd = atsc.field_sync_demux() -out_data = gr.file_sink(atsc.sizeof_atsc_soft_data_segment,"/tmp/atsc_pipe_5") +out_data = blocks.file_sink(atsc.sizeof_atsc_soft_data_segment,"/tmp/atsc_pipe_5") -inp = gr.file_source(gr.sizeof_float,"/tmp/atsc_pipe_3") +inp = blocks.file_source(gr.sizeof_float,"/tmp/atsc_pipe_3") tb.connect(inp,btl) tb.connect((btl,0),(fsc,0),(eq,0),(fsd,0)) diff --git a/gr-atsc/src/python/fpll.py b/gr-atsc/python/fpll.py index 69749420b..dee81da13 100755 --- a/gr-atsc/src/python/fpll.py +++ b/gr-atsc/python/fpll.py @@ -31,7 +31,7 @@ def main(): tb = gr.top_block() - u = gr.file_source(gr.sizeof_float,"/tmp/atsc_pipe_2") + u = blocks.file_source(gr.sizeof_float,"/tmp/atsc_pipe_2") input_rate = 19.2e6 IF_freq = 5.75e6 @@ -69,8 +69,8 @@ def main(): iir = filter.single_pole_iir_filter_ff(alpha) remove_dc = blocks.sub_ff() - out = gr.file_sink(gr.sizeof_float,"/tmp/atsc_pipe_3") - # out = gr.file_sink(gr.sizeof_float,"/mnt/sata/atsc_data_float") + out = blocks.file_sink(gr.sizeof_float,"/tmp/atsc_pipe_3") + # out = blocks.file_sink(gr.sizeof_float,"/mnt/sata/atsc_data_float") tb.connect(u, fpll, lp_filter) tb.connect(lp_filter, iir) diff --git a/gr-atsc/src/python/interp.py b/gr-atsc/python/interp.py index 39e1caea0..ee2d23489 100755 --- a/gr-atsc/src/python/interp.py +++ b/gr-atsc/python/interp.py @@ -32,6 +32,7 @@ # then at 0 with edges at -3.2MHz and 3.2MHz. from gnuradio import gr +from gnuradio import blocks import sys def graph(args): @@ -45,13 +46,13 @@ def graph(args): tb = gr.top_block() - src0 = gr.file_source(gr.sizeof_gr_complex, infile) + src0 = blocks.file_source(gr.sizeof_gr_complex, infile) lp_coeffs = filter.firdes.low_pass(3, 19.2e6, 3.2e6, .5e6, filter.firdes.WIN_HAMMING ) lp = filter.interp_fir_filter_ccf(1, lp_coeffs) - file = gr.file_sink(gr.sizeof_gr_complex, "/tmp/atsc_pipe_1") + file = blocks.file_sink(gr.sizeof_gr_complex, "/tmp/atsc_pipe_1") tb.connect(src0, lp, file) diff --git a/gr-atsc/src/python/interp_short.py b/gr-atsc/python/interp_short.py index 749d15d0a..d07b941c1 100755 --- a/gr-atsc/src/python/interp_short.py +++ b/gr-atsc/python/interp_short.py @@ -50,7 +50,7 @@ def graph (args): tb = gr.top_block() - srcf = gr.file_source(gr.sizeof_short,infile) + srcf = blocks.file_source(gr.sizeof_short,infile) s2ss = blocks.stream_to_streams(gr.sizeof_short,2) s2f1 = blocks.short_to_float() s2f2 = blocks.short_to_float() @@ -61,7 +61,7 @@ def graph (args): filter.firdes.WIN_HAMMING) lp = filter.interp_fir_filter_ccf(3, lp_coeffs) - file = gr.file_sink(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1") + file = blocks.file_sink(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1") tb.connect( srcf, s2ss ) tb.connect( (s2ss, 0), s2f1, (src0,0) ) diff --git a/gr-atsc/src/python/qa_atsc.py b/gr-atsc/python/qa_atsc.py index 507bc8aa4..507bc8aa4 100755 --- a/gr-atsc/src/python/qa_atsc.py +++ b/gr-atsc/python/qa_atsc.py diff --git a/gr-atsc/src/python/viterbi-out.py b/gr-atsc/python/viterbi-out.py index 67edd99b2..cc60ffda4 100755 --- a/gr-atsc/src/python/viterbi-out.py +++ b/gr-atsc/python/viterbi-out.py @@ -21,6 +21,7 @@ # from gnuradio import gr, atsc +from gnuradio import blocks import sys, os def main(args): @@ -36,13 +37,13 @@ def main(args): tb = gr.top_block() - src = gr.file_source(atsc.sizeof_atsc_soft_data_segment, "/tmp/atsc_pipe_5") + src = blocks.file_source(atsc.sizeof_atsc_soft_data_segment, "/tmp/atsc_pipe_5") viterbi = atsc.viterbi_decoder() deinter = atsc.deinterleaver() rs_dec = atsc.rs_decoder() derand = atsc.derandomizer() depad = atsc.depad() - dst = gr.file_sink(gr.sizeof_char,outfile) + dst = blocks.file_sink(gr.sizeof_char,outfile) tb.connect(src, viterbi, deinter, rs_dec, derand, depad, dst) tb.run () diff --git a/gr-atsc/src/python/xlate.py b/gr-atsc/python/xlate.py index ca7aa667e..3d049ac52 100755 --- a/gr-atsc/src/python/xlate.py +++ b/gr-atsc/python/xlate.py @@ -42,13 +42,13 @@ def graph (): tb = gr.top_block () - src0 = gr.file_source(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1") + src0 = blocks.file_source(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1") duc_coeffs = filter.firdes.low_pass( 1, 19.2e6, 9e6, 1e6, filter.firdes.WIN_HAMMING ) duc = filter.freq_xlating_fir_filter_ccf( 1 duc_coeffs, 5.75e6, 19.2e6 ) c2f = blocks.complex_to_float() - file = gr.file_sink(gr.sizeof_float,"/tmp/atsc_pipe_2") + file = blocks.file_sink(gr.sizeof_float,"/tmp/atsc_pipe_2") tb.connect( src0, duc, c2f, file ) diff --git a/gr-atsc/swig/CMakeLists.txt b/gr-atsc/swig/CMakeLists.txt new file mode 100644 index 000000000..71039f80a --- /dev/null +++ b/gr-atsc/swig/CMakeLists.txt @@ -0,0 +1,55 @@ +# 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. + +######################################################################## +# Setup swig generation +######################################################################## +include(GrPython) +include(GrSwig) + +set(GR_SWIG_INCLUDE_DIRS + ${GR_ATSC_INCLUDE_DIRS} + ${GR_FILTER_INCLUDE_DIRS} + ${GR_BLOCKS_INCLUDE_DIRS} + ${GR_ANALOG_INCLUDE_DIRS} + ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ${FFTW3F_INCLUDE_DIRS} +) + +set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/atsc_swig_doc.i) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../lib) +set(GR_SWIG_LIBRARIES gnuradio-atsc gnuradio-fft) + +GR_SWIG_MAKE(atsc_swig atsc_swig.i) + +GR_SWIG_INSTALL( + TARGETS atsc_swig + DESTINATION ${GR_PYTHON_DIR}/gnuradio/atsc + COMPONENT "atsc_python" +) + +install( + FILES + atsc_swig.i + ${CMAKE_CURRENT_BINARY_DIR}/atsc_swig_doc.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "atsc_swig" +) diff --git a/gr-atsc/src/lib/atsc.i b/gr-atsc/swig/atsc_swig.i index 6b83a2315..4711d497e 100644 --- a/gr-atsc/src/lib/atsc.i +++ b/gr-atsc/swig/atsc_swig.i @@ -26,26 +26,26 @@ %include "atsc_swig_doc.i" %{ -#include <atsc_randomizer.h> -#include <atsc_derandomizer.h> -#include <atsc_rs_encoder.h> -#include <atsc_rs_decoder.h> -#include <atsc_interleaver.h> -#include <atsc_deinterleaver.h> -#include <atsc_trellis_encoder.h> -#include <atsc_viterbi_decoder.h> -#include <atsc_ds_to_softds.h> -#include <atsc_field_sync_mux.h> -#include <atsc_field_sync_demux.h> -#include <atsc_equalizer.h> -#include <atsc_fs_checker.h> -#include <atsc_bit_timing_loop.h> -#include <atsc_fpll.h> -#include <atsc_depad.h> -#include <atsc_pad.h> +#include <atsc/randomizer.h> +#include <atsc/derandomizer.h> +#include <atsc/rs_encoder.h> +#include <atsc/rs_decoder.h> +#include <atsc/interleaver.h> +#include <atsc/deinterleaver.h> +#include <atsc/trellis_encoder.h> +#include <atsc/viterbi_decoder.h> +#include <atsc/ds_to_softds.h> +#include <atsc/field_sync_mux.h> +#include <atsc/field_sync_demux.h> +#include <atsc/equalizer.h> +#include <atsc/fs_checker.h> +#include <atsc/bit_timing_loop.h> +#include <atsc/fpll.h> +#include <atsc/depad.h> +#include <atsc/pad.h> %} -%include "atsc_consts.h" +%include "atsc/consts.h" %constant int sizeof_atsc_mpeg_packet = sizeof(atsc_mpeg_packet); %constant int sizeof_atsc_mpeg_packet_no_sync = sizeof(atsc_mpeg_packet_no_sync); diff --git a/gr-audio/examples/python/audio_play.py b/gr-audio/examples/python/audio_play.py index 465590f69..94ea72498 100755 --- a/gr-audio/examples/python/audio_play.py +++ b/gr-audio/examples/python/audio_play.py @@ -22,6 +22,7 @@ from gnuradio import gr from gnuradio import audio +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -45,7 +46,7 @@ class my_top_block(gr.top_block): raise SystemExit, 1 sample_rate = int(options.sample_rate) - src = gr.file_source (gr.sizeof_float, options.filename, options.repeat) + src = blocks.file_source (gr.sizeof_float, options.filename, options.repeat) dst = audio.sink (sample_rate, options.audio_output) self.connect(src, dst) diff --git a/gr-audio/examples/python/audio_to_file.py b/gr-audio/examples/python/audio_to_file.py index 3f7a4f8d1..201ec90bf 100755 --- a/gr-audio/examples/python/audio_to_file.py +++ b/gr-audio/examples/python/audio_to_file.py @@ -22,6 +22,7 @@ from gnuradio import gr from gnuradio import audio +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -47,7 +48,7 @@ class my_top_block(gr.top_block): sample_rate = int(options.sample_rate) src = audio.source (sample_rate, options.audio_input) - dst = gr.file_sink (gr.sizeof_float, filename) + dst = blocks.file_sink (gr.sizeof_float, filename) if options.nsamples is None: self.connect((src, 0), dst) diff --git a/gr-audio/examples/python/dial_tone_wav.py b/gr-audio/examples/python/dial_tone_wav.py index 4d8d6b401..91bf744c9 100755 --- a/gr-audio/examples/python/dial_tone_wav.py +++ b/gr-audio/examples/python/dial_tone_wav.py @@ -23,6 +23,7 @@ # GNU Radio example program to record a dial tone to a WAV file from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -55,7 +56,7 @@ class my_top_block(gr.top_block): src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl) head0 = gr.head(gr.sizeof_float, int(options.samples)) head1 = gr.head(gr.sizeof_float, int(options.samples)) - dst = gr.wavfile_sink(args[0], 2, int(options.sample_rate), 16) + dst = blocks.wavfile_sink(args[0], 2, int(options.sample_rate), 16) self.connect(src0, head0, (dst, 0)) self.connect(src1, head1, (dst, 1)) diff --git a/gr-audio/lib/CMakeLists.txt b/gr-audio/lib/CMakeLists.txt index 86c553c73..73977752f 100644 --- a/gr-audio/lib/CMakeLists.txt +++ b/gr-audio/lib/CMakeLists.txt @@ -25,14 +25,14 @@ include_directories( ${GR_AUDIO_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories(${Boost_LIBRARY_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) -list(APPEND gr_audio_libs gnuradio-core ${Boost_LIBRARIES} ${LOG4CXX_LIBRARIES}) +list(APPEND gr_audio_libs gnuradio-core ${Boost_LIBRARIES} ${LOG4CPP_LIBRARIES}) list(APPEND gr_audio_sources audio_registry.cc) list(APPEND gr_audio_confs ${CMAKE_CURRENT_SOURCE_DIR}/gr-audio.conf) diff --git a/gr-blocks/CMakeLists.txt b/gr-blocks/CMakeLists.txt index 977280370..98f73d217 100644 --- a/gr-blocks/CMakeLists.txt +++ b/gr-blocks/CMakeLists.txt @@ -34,6 +34,7 @@ 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 ) diff --git a/gr-blocks/examples/metadata/file_metadata_source.grc b/gr-blocks/examples/metadata/file_metadata_source.grc index f45c151d3..5d0a0417a 100644 --- a/gr-blocks/examples/metadata/file_metadata_source.grc +++ b/gr-blocks/examples/metadata/file_metadata_source.grc @@ -209,10 +209,10 @@ </param> </block> <block> - <key>gr_file_sink</key> + <key>blocks_file_sink</key> <param> <key>id</key> - <value>gr_file_sink_1</value> + <value>blocks_file_sink_1</value> </param> <param> <key>_enabled</key> @@ -319,7 +319,7 @@ </block> <connection> <source_block_id>blocks_throttle_0</source_block_id> - <sink_block_id>gr_file_sink_1</sink_block_id> + <sink_block_id>blocks_file_sink_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-blocks/examples/metadata/file_metadata_vector_source.grc b/gr-blocks/examples/metadata/file_metadata_vector_source.grc index 584a033c2..3c2dda9de 100644 --- a/gr-blocks/examples/metadata/file_metadata_vector_source.grc +++ b/gr-blocks/examples/metadata/file_metadata_vector_source.grc @@ -84,10 +84,10 @@ </param> </block> <block> - <key>gr_file_sink</key> + <key>blocks_file_sink</key> <param> <key>id</key> - <value>gr_file_sink_1</value> + <value>blocks_file_sink_1</value> </param> <param> <key>_enabled</key> @@ -307,7 +307,7 @@ </block> <connection> <source_block_id>blocks_throttle_0</source_block_id> - <sink_block_id>gr_file_sink_1</sink_block_id> + <sink_block_id>blocks_file_sink_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-blocks/examples/tags/test_file_tags.py b/gr-blocks/examples/tags/test_file_tags.py index 1493864bd..92112325b 100755 --- a/gr-blocks/examples/tags/test_file_tags.py +++ b/gr-blocks/examples/tags/test_file_tags.py @@ -41,7 +41,7 @@ def main(): ann = gr.annotator_alltoall(1000000, gr.sizeof_short) tagger = blocks..burst_tagger(gr.sizeof_short) - fsnk = gr.tagged_file_sink(gr.sizeof_short, 1) + fsnk = blocks.tagged_file_sink(gr.sizeof_short, 1) tb = gr.top_block() tb.connect(src, thr, (tagger, 0)) diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml index 36e5e95f2..90d94bdb2 100644 --- a/gr-blocks/grc/blocks_block_tree.xml +++ b/gr-blocks/grc/blocks_block_tree.xml @@ -31,18 +31,26 @@ <cat> <name>Sources (New)</name> <block>blocks_file_source</block> + <block>blocks_file_descriptor_source</block> <block>blocks_file_meta_source</block> <block>blocks_pdu_to_tagged_stream</block> <block>blocks_random_pdu</block> <block>blocks_message_source</block> <block>blocks_message_burst_source</block> + <block>blocks_udp_source</block> + <block>blocks_wavfile_source</block> </cat> <cat> <name>Sinks (New)</name> + <block>blocks_file_sink</block> + <block>blocks_file_descriptor_sink</block> <block>blocks_file_meta_sink</block> <block>blocks_tagged_stream_to_pdu</block> <block>blocks_tag_debug</block> <block>blocks_message_sink</block> + <block>blocks_tagged_file_sink</block> + <block>blocks_udp_sink</block> + <block>blocks_wavfile_sink</block> </cat> <cat> <name>Math Operations (New) </name> @@ -89,6 +97,7 @@ <block>blocks_int_to_float</block> <block>blocks_interleaved_short_to_complex</block> <block>blocks_short_to_char</block> + <block>blocks_repack_bits_bb</block> <block>blocks_short_to_float</block> <block>blocks_uchar_to_float</block> </cat> @@ -125,6 +134,7 @@ <cat> <name>Misc (New) </name> <block>blocks_throttle</block> + <block>blocks_probe_rate</block> </cat> <cat> <name>Networking</name> diff --git a/gr-blocks/grc/blocks_complex_to_real.xml b/gr-blocks/grc/blocks_complex_to_real.xml index 0fe77dc1c..6737f1da3 100644 --- a/gr-blocks/grc/blocks_complex_to_real.xml +++ b/gr-blocks/grc/blocks_complex_to_real.xml @@ -24,13 +24,7 @@ </sink> <source> <name>re</name> - <type>real</type> + <type>float</type> <vlen>$vlen</vlen> </source> - <source> - <name>im</name> - <type>real</type> - <vlen>$vlen</vlen> - <optional>1</optional> - </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 000000000..211d86dfd --- /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/grc/blocks/gr_file_source.xml b/gr-blocks/grc/blocks_file_descriptor_source.xml index 5f0e16b27..b29335c3a 100644 --- a/grc/blocks/gr_file_source.xml +++ b/gr-blocks/grc/blocks_file_descriptor_source.xml @@ -5,16 +5,14 @@ ################################################### --> <block> - <name>File Source</name> - <key>gr_file_source</key> - <import>from gnuradio import gr</import> - <make>gr.file_source($type.size*$vlen, $file, $repeat)</make> - <callback>open($file, $repeat)</callback> + <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</name> - <key>file</key> - <value></value> - <type>file_open</type> + <name>File Descriptor</name> + <key>fd</key> + <type>int</type> </param> <param> <name>Output Type</name> diff --git a/grc/blocks/gr_file_sink.xml b/gr-blocks/grc/blocks_file_sink.xml index d0a693900..75ef86a6b 100644 --- a/grc/blocks/gr_file_sink.xml +++ b/gr-blocks/grc/blocks_file_sink.xml @@ -6,9 +6,9 @@ --> <block> <name>File Sink</name> - <key>gr_file_sink</key> - <import>from gnuradio import gr</import> - <make>gr.file_sink($type.size*$vlen, $file) + <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> diff --git a/gr-blocks/grc/blocks_probe_rate.xml b/gr-blocks/grc/blocks_probe_rate.xml new file mode 100644 index 000000000..08df23e0d --- /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 index f8836f05c..f4e945ab0 100644 --- a/gr-blocks/grc/blocks_probe_signal_vx.xml +++ b/gr-blocks/grc/blocks_probe_signal_vx.xml @@ -45,9 +45,11 @@ <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() 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 000000000..4ad5ec631 --- /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_tagged_file_sink.xml b/gr-blocks/grc/blocks_tagged_file_sink.xml new file mode 100644 index 000000000..a849c48c9 --- /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 000000000..40d98a334 --- /dev/null +++ b/gr-blocks/grc/blocks_tagged_stream_mux.xml @@ -0,0 +1,65 @@ +<block> + <name>Tagged Stream Mux</name> + <key>blocks_tagged_stream_mux</key> + <category>Stream Operations</category> + <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/grc/blocks/gr_udp_sink.xml b/gr-blocks/grc/blocks_udp_sink.xml index 45f81075f..a001b2f1b 100644 --- a/grc/blocks/gr_udp_sink.xml +++ b/gr-blocks/grc/blocks_udp_sink.xml @@ -6,9 +6,9 @@ --> <block> <name>UDP Sink</name> - <key>gr_udp_sink</key> - <import>from gnuradio import gr</import> - <make>gr.udp_sink($type.size*$vlen, $ipaddr, $port, $psize, $eof)</make> + <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> diff --git a/grc/blocks/gr_udp_source.xml b/gr-blocks/grc/blocks_udp_source.xml index a1b961651..bca1dff8b 100644 --- a/grc/blocks/gr_udp_source.xml +++ b/gr-blocks/grc/blocks_udp_source.xml @@ -6,9 +6,9 @@ --> <block> <name>UDP Source</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> + <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> @@ -65,12 +65,6 @@ <type>bool</type> </param> <param> - <name>Wait for Data</name> - <key>wait</key> - <value>True</value> - <type>bool</type> - </param> - <param> <name>Vec Length</name> <key>vlen</key> <value>1</value> diff --git a/grc/blocks/gr_wavfile_sink.xml b/gr-blocks/grc/blocks_wavfile_sink.xml index 651e16cb6..8e81d8d20 100644 --- a/grc/blocks/gr_wavfile_sink.xml +++ b/gr-blocks/grc/blocks_wavfile_sink.xml @@ -6,9 +6,9 @@ --> <block> <name>Wav File Sink</name> - <key>gr_wavfile_sink</key> - <import>from gnuradio import gr</import> - <make>gr.wavfile_sink($file, $nchan, $samp_rate, $bits_per_sample)</make> + <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> diff --git a/grc/blocks/gr_wavfile_source.xml b/gr-blocks/grc/blocks_wavfile_source.xml index 433bb0af2..deb48472a 100644 --- a/grc/blocks/gr_wavfile_source.xml +++ b/gr-blocks/grc/blocks_wavfile_source.xml @@ -6,9 +6,9 @@ --> <block> <name>Wav File Source</name> - <key>gr_wavfile_source</key> - <import>from gnuradio import gr</import> - <make>gr.wavfile_source($file, $repeat)</make> + <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> diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt index 6609ede24..0f158ff47 100644 --- a/gr-blocks/include/blocks/CMakeLists.txt +++ b/gr-blocks/include/blocks/CMakeLists.txt @@ -65,8 +65,8 @@ endmacro(expand_h) # Invoke macro to generate various sources ######################################################################## expand_h(add_XX ss ii cc) -expand_h(add_const_XX ss ii ff cc) -expand_h(add_const_vXX ss ii ff cc) +expand_h(add_const_XX bb ss ii ff cc) +expand_h(add_const_vXX bb 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) @@ -99,13 +99,16 @@ add_custom_target(blocks_generated_includes DEPENDS install(FILES ${generated_includes} api.h + control_loop.h count_bits.h + file_sink_base.h fxpt.h fxpt_nco.h fxpt_vco.h log2_const.h nco.h vco.h + wavfile.h add_ff.h bin_statistics_f.h burst_tagger.h @@ -151,7 +154,9 @@ install(FILES pdu_to_tagged_stream.h peak_detector2_fb.h random_pdu.h + probe_rate.h regenerate_bb.h + repack_bits_bb.h repeat.h rms_cf.h rms_ff.h @@ -165,16 +170,22 @@ install(FILES streams_to_vector.h stretch_ff.h tag_debug.h + tagged_file_sink.h tagged_stream_to_pdu.h threshold_ff.h throttle.h transcendental.h tuntap_pdu.h + tagged_stream_mux.h uchar_to_float.h + udp_sink.h + udp_source.h unpack_k_bits_bb.h vco_f.h vector_to_stream.h vector_to_streams.h + wavfile_sink.h + wavfile_source.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks COMPONENT "blocks_devel" ) diff --git a/gr-blocks/include/blocks/control_loop.h b/gr-blocks/include/blocks/control_loop.h new file mode 100644 index 000000000..475b28f94 --- /dev/null +++ b/gr-blocks/include/blocks/control_loop.h @@ -0,0 +1,234 @@ +/* -*- 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(void) {} + 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/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h b/gr-blocks/include/blocks/file_descriptor_sink.h index 3b1c1167f..df59e24c0 100644 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h +++ b/gr-blocks/include/blocks/file_descriptor_sink.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,37 +23,32 @@ #ifndef INCLUDED_GR_FILE_DESCRIPTOR_SINK_H #define INCLUDED_GR_FILE_DESCRIPTOR_SINK_H -#include <gr_core_api.h> +#include <blocks/api.h> #include <gr_sync_block.h> -class gr_file_descriptor_sink; -typedef boost::shared_ptr<gr_file_descriptor_sink> gr_file_descriptor_sink_sptr; - -GR_CORE_API gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd); - -/*! - * \brief Write stream to file descriptor. - * \ingroup sink_blk - */ - -class GR_CORE_API gr_file_descriptor_sink : public gr_sync_block -{ - friend GR_CORE_API gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd); - - private: - size_t d_itemsize; - int d_fd; - - protected: - gr_file_descriptor_sink (size_t itemsize, int fd); - - public: - ~gr_file_descriptor_sink (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - +namespace gr { + namespace blocks { + + /*! + * \brief Write stream to file descriptor. + * \ingroup sink_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 000000000..ff4f14792 --- /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 source_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/gnuradio-core/src/lib/io/gr_file_sink.h b/gr-blocks/include/blocks/file_sink.h index e40ec9ab8..08c2adf1f 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink.h +++ b/gr-blocks/include/blocks/file_sink.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2007 Free Software Foundation, Inc. + * Copyright 2004,2007,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,36 +23,33 @@ #ifndef INCLUDED_GR_FILE_SINK_H #define INCLUDED_GR_FILE_SINK_H -#include <gr_core_api.h> +#include <blocks/api.h> +#include <blocks/file_sink_base.h> #include <gr_sync_block.h> -#include <gr_file_sink_base.h> -class gr_file_sink; -typedef boost::shared_ptr<gr_file_sink> gr_file_sink_sptr; - -GR_CORE_API gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename); - -/*! - * \brief Write stream to file. - * \ingroup sink_blk - */ - -class GR_CORE_API gr_file_sink : public gr_sync_block, public gr_file_sink_base -{ - friend GR_CORE_API gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename); - - private: - size_t d_itemsize; - - protected: - gr_file_sink(size_t itemsize, const char *filename); - - public: - ~gr_file_sink(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; +namespace gr { + namespace blocks { + + /*! + * \brief Write stream to file. + * \ingroup sink_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 000000000..3eeb0e63d --- /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/fxpt_nco.h b/gr-blocks/include/blocks/fxpt_nco.h index 0faa73176..7db20fbb3 100644 --- a/gr-blocks/include/blocks/fxpt_nco.h +++ b/gr-blocks/include/blocks/fxpt_nco.h @@ -41,7 +41,7 @@ namespace gr { * to the fxpt_vco can also be used to set or adjust the current * phase. */ - class BLOCKS_API fxpt_nco + class fxpt_nco { private: uint32_t d_phase; diff --git a/gr-blocks/include/blocks/message_sink.h b/gr-blocks/include/blocks/message_sink.h index 5d14836dd..5d3084d02 100644 --- a/gr-blocks/include/blocks/message_sink.h +++ b/gr-blocks/include/blocks/message_sink.h @@ -40,7 +40,10 @@ namespace gr { // 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); + static sptr make(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); + static sptr make(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, + const std::string& lengthtagname); + }; } /* namespace blocks */ diff --git a/gr-blocks/include/blocks/message_source.h b/gr-blocks/include/blocks/message_source.h index 5b5519188..cf4bafc22 100644 --- a/gr-blocks/include/blocks/message_source.h +++ b/gr-blocks/include/blocks/message_source.h @@ -42,6 +42,8 @@ namespace gr { static sptr make(size_t itemsize, int msgq_limit=0); static sptr make(size_t itemsize, gr_msg_queue_sptr msgq); + static sptr make(size_t itemsize, gr_msg_queue_sptr msgq, + const std::string& lengthtagname); virtual gr_msg_queue_sptr msgq() const = 0; }; diff --git a/gr-blocks/include/blocks/mute_XX.h.t b/gr-blocks/include/blocks/mute_XX.h.t index 3033248c4..2b1c8b9a4 100644 --- a/gr-blocks/include/blocks/mute_XX.h.t +++ b/gr-blocks/include/blocks/mute_XX.h.t @@ -41,10 +41,10 @@ namespace gr { // gr::blocks::@NAME@::sptr typedef boost::shared_ptr<@NAME@> sptr; - static sptr make(bool mute); + static sptr make(bool mute=false); virtual bool mute() const = 0; - virtual void set_mute(bool mute) = 0; + virtual void set_mute(bool mute=false) = 0; }; } /* namespace blocks */ diff --git a/gr-blocks/include/blocks/peak_detector_XX.h.t b/gr-blocks/include/blocks/peak_detector_XX.h.t index 1c8ba0652..fead53d20 100644 --- a/gr-blocks/include/blocks/peak_detector_XX.h.t +++ b/gr-blocks/include/blocks/peak_detector_XX.h.t @@ -38,7 +38,7 @@ namespace gr { * If a peak is detected, this block outputs a 1, * or it outputs 0's. */ - class GR_CORE_API @NAME@ : virtual public gr_sync_block + class BLOCKS_API @NAME@ : virtual public gr_sync_block { public: // gr::blocks::@NAME@::sptr diff --git a/gr-blocks/include/blocks/probe_rate.h b/gr-blocks/include/blocks/probe_rate.h new file mode 100644 index 000000000..3401d2acd --- /dev/null +++ b/gr-blocks/include/blocks/probe_rate.h @@ -0,0 +1,60 @@ +/* -*- 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 + */ + 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/repack_bits_bb.h b/gr-blocks/include/blocks/repack_bits_bb.h new file mode 100644 index 000000000..9ade0a435 --- /dev/null +++ b/gr-blocks/include/blocks/repack_bits_bb.h @@ -0,0 +1,65 @@ +/* -*- 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 k bits of the output stream. + * \ingroup blocks + * + * 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/tagged_file_sink.h b/gr-blocks/include/blocks/tagged_file_sink.h new file mode 100644 index 000000000..62da72f78 --- /dev/null +++ b/gr-blocks/include/blocks/tagged_file_sink.h @@ -0,0 +1,65 @@ +/* -*- 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 sink_blk + * + * 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 000000000..23e8a9440 --- /dev/null +++ b/gr-blocks/include/blocks/tagged_stream_mux.h @@ -0,0 +1,61 @@ +/* -*- 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. + * + * \description + * 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. + * + * All other tags are propagated as expected, i.e. they stay associated + * with the same input item. + * + * \ingroup blocks + */ + class BLOCKS_API tagged_stream_mux : virtual public gr_tagged_stream_block + { + public: + typedef boost::shared_ptr<tagged_stream_mux> sptr; + + /* \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/udp_sink.h b/gr-blocks/include/blocks/udp_sink.h new file mode 100644 index 000000000..69c5f0ffa --- /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 sink_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 000000000..b72db30db --- /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 source_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/wavfile.h b/gr-blocks/include/blocks/wavfile.h new file mode 100644 index 000000000..b852c01e2 --- /dev/null +++ b/gr-blocks/include/blocks/wavfile.h @@ -0,0 +1,101 @@ +/* -*- 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 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. + * + * 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. + * + * Takes care of endianness. + */ + void + wav_write_sample(FILE *fp, short int sample, int bytes_per_sample); + + + /*! + * \brief Complete a WAV header + * + * 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 000000000..b095191d0 --- /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. + * + * Values must be floats within [-1;1]. + * Check gr_make_wavfile_sink() for extra info. + * + * \ingroup sink_blk + */ + class BLOCKS_API wavfile_sink : virtual public gr_sync_block + { + public: + // gr::blocks::wavfile_sink::sptr + typedef boost::shared_ptr<wavfile_sink> sptr; + + /* + * \p filename The .wav file to be opened + * \p n_channels Number of channels (2 = stereo or I/Q output) + * \p sample_rate Sample rate [S/s] + * \p 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 000000000..46cb82b69 --- /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 + * + * Unless otherwise called, values are within [-1;1]. + * Check gr_make_wavfile_source() for extra info. + * + * \ingroup source_blk + */ + 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/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index 818b8ae62..de73a8a30 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -91,8 +91,8 @@ endmacro(expand_cc_h_impl) # Invoke macro to generate various sources ######################################################################## expand_cc_h_impl(add_XX ss ii cc) -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(add_const_XX bb ss ii ff cc) +expand_cc_h_impl(add_const_vXX bb 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) @@ -141,8 +141,11 @@ endif(ENABLE_GR_CTRLPORT) ######################################################################## list(APPEND gr_blocks_sources ${generated_sources} + control_loop.cc count_bits.cc + file_sink_base.cc fxpt.cc + wavfile.cc add_ff_impl.cc bin_statistics_f_impl.cc burst_tagger_impl.cc @@ -158,6 +161,9 @@ list(APPEND gr_blocks_sources conjugate_cc_impl.cc deinterleave_impl.cc delay_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 @@ -192,7 +198,9 @@ list(APPEND gr_blocks_sources pdu_to_tagged_stream_impl.cc peak_detector2_fb_impl.cc random_pdu_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 @@ -206,18 +214,24 @@ list(APPEND gr_blocks_sources 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_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 @@ -239,6 +253,7 @@ list(APPEND blocks_libs volk ${Boost_LIBRARIES} ${BLOCKS_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-blocks SHARED ${gr_blocks_sources}) diff --git a/gr-blocks/lib/control_loop.cc b/gr-blocks/lib/control_loop.cc new file mode 100644 index 000000000..44f4e5339 --- /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/file_descriptor_sink_impl.cc b/gr-blocks/lib/file_descriptor_sink_impl.cc new file mode 100644 index 000000000..a1f26220d --- /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/gnuradio-core/src/lib/io/gr_file_source.i b/gr-blocks/lib/file_descriptor_sink_impl.h index e71cef0d1..90b02f416 100644 --- a/gnuradio-core/src/lib/io/gr_file_source.i +++ b/gr-blocks/lib/file_descriptor_sink_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,26 +20,30 @@ * Boston, MA 02110-1301, USA. */ +#ifndef INCLUDED_GR_FILE_DESCRIPTOR_SINK_IMPL_H +#define INCLUDED_GR_FILE_DESCRIPTOR_SINK_IMPL_H -%constant int SEEK_SET = 0; /* Seek from beginning of file. */ -%constant int SEEK_CUR = 1; /* Seek from current position. */ -%constant int SEEK_END = 2; /* Seek from end of file. */ +#include <blocks/file_descriptor_sink.h> +namespace gr { + namespace blocks { -GR_SWIG_BLOCK_MAGIC(gr,file_source) + class file_descriptor_sink_impl : public file_descriptor_sink + { + private: + size_t d_itemsize; + int d_fd; -gr_file_source_sptr -gr_make_file_source (size_t itemsize, const char *filename, bool repeat=false); + public: + file_descriptor_sink_impl(size_t itemsize, int fd); + ~file_descriptor_sink_impl(); -class gr_file_source : public gr_sync_block -{ - protected: - gr_file_source (size_t itemsize, const char *filename, bool repeat); + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; - public: - ~gr_file_source (); + } /* namespace blocks */ +} /* namespace gr */ - bool seek (long seek_point, int whence); - void open (const char *filename, bool repeat); - void close(); -}; +#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 000000000..667e96b7f --- /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 000000000..dd86e18af --- /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 000000000..47c8f9882 --- /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 000000000..88dcb5a02 --- /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/gnuradio-core/src/lib/io/gr_udp_sink.i b/gr-blocks/lib/file_sink_impl.h index ba7043937..8e802ad88 100644 --- a/gnuradio-core/src/lib/io/gr_udp_sink.i +++ b/gr-blocks/lib/file_sink_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2010 Free Software Foundation, Inc. + * Copyright 2004,2007,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,27 +20,29 @@ * Boston, MA 02110-1301, USA. */ +#ifndef INCLUDED_GR_FILE_SINK_IMPL_H +#define INCLUDED_GR_FILE_SINK_IMPL_H -GR_SWIG_BLOCK_MAGIC(gr,udp_sink) +#include <blocks/file_sink.h> -gr_udp_sink_sptr -gr_make_udp_sink (size_t itemsize, - const char *host, unsigned short port, - int payload_size=1472, bool eof=true) throw (std::runtime_error); +namespace gr { + namespace blocks { -class gr_udp_sink : public gr_sync_block -{ - protected: - gr_udp_sink (size_t itemsize, - const char *host, unsigned short port, - int payload_size, bool eof) - throw (std::runtime_error); + class file_sink_impl : public file_sink + { + private: + size_t d_itemsize; - public: - ~gr_udp_sink (); + public: + file_sink_impl(size_t itemsize, const char *filename); + ~file_sink_impl(); - int payload_size() { return d_payload_size; } - void connect( const char *host, unsigned short 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_FILE_SINK_IMPL_H */ diff --git a/gr-blocks/lib/message_sink_impl.cc b/gr-blocks/lib/message_sink_impl.cc index a8dbfb4c7..fbc7b27d5 100644 --- a/gr-blocks/lib/message_sink_impl.cc +++ b/gr-blocks/lib/message_sink_impl.cc @@ -44,11 +44,30 @@ namespace gr { (new message_sink_impl(itemsize, msgq, dont_block)); } + message_sink::sptr + message_sink::make(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, + const std::string& lengthtagname) + { + return gnuradio::get_initial_sptr + (new message_sink_impl(itemsize, msgq, dont_block, lengthtagname)); + } + 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) + d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block), + d_tags(false), d_items_read(0) + { + } + + message_sink_impl::message_sink_impl(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) { } @@ -61,23 +80,53 @@ namespace gr { 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); + const char *in = (const char *) input_items[0]; - d_msgq->handle(msg); // send it + 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::symbol_to_string(tags[i].key) == d_lengthtagname) { + packet_length = pmt::to_long(tags[i].value); + } + } + assert(packet_length != 0); + + // 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; + 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 index a3106bc05..280a46765 100644 --- a/gr-blocks/lib/message_sink_impl.h +++ b/gr-blocks/lib/message_sink_impl.h @@ -34,9 +34,15 @@ namespace gr { 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; public: message_sink_impl(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); + message_sink_impl(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, + const std::string& lengthtagname); + ~message_sink_impl(); int work(int noutput_items, diff --git a/gr-blocks/lib/message_source_impl.cc b/gr-blocks/lib/message_source_impl.cc index cda4fc16c..818cd336f 100644 --- a/gr-blocks/lib/message_source_impl.cc +++ b/gr-blocks/lib/message_source_impl.cc @@ -51,12 +51,20 @@ namespace gr { (new message_source_impl(itemsize, msgq)); } + message_source::sptr + message_source::make(size_t itemsize, gr_msg_queue_sptr msgq, + const std::string& lengthtagname) + { + return gnuradio::get_initial_sptr + (new message_source_impl(itemsize, msgq, lengthtagname)); + } + 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) + d_msg_offset(0), d_eof(false), d_tags(false) { } @@ -65,7 +73,17 @@ namespace gr { 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_msg_offset(0), d_eof(false), d_tags(false) + { + } + + message_source_impl::message_source_impl(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) { } @@ -82,42 +100,48 @@ namespace gr { 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"); - } + 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); + + if (d_tags && (d_msg_offset == 0)) { + const uint64_t offset = this->nitems_written(0) + nn; + pmt::pmt_t key = pmt::string_to_symbol(d_lengthtagname); + pmt::pmt_t value = 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(); + } + } + 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; diff --git a/gr-blocks/lib/message_source_impl.h b/gr-blocks/lib/message_source_impl.h index c42070447..8fbd209e0 100644 --- a/gr-blocks/lib/message_source_impl.h +++ b/gr-blocks/lib/message_source_impl.h @@ -37,10 +37,16 @@ namespace gr { 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; public: message_source_impl(size_t itemsize, int msgq_limit); message_source_impl(size_t itemsize, gr_msg_queue_sptr msgq); + message_source_impl(size_t itemsize, gr_msg_queue_sptr msgq, + const std::string& lengthtagname); + ~message_source_impl(); gr_msg_queue_sptr msgq() const { return d_msgq; } diff --git a/gr-blocks/lib/probe_rate_impl.cc b/gr-blocks/lib/probe_rate_impl.cc new file mode 100644 index 000000000..37749c85e --- /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 000000000..81f7b4e13 --- /dev/null +++ b/gr-blocks/lib/probe_rate_impl.h @@ -0,0 +1,63 @@ +/* -*- 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 + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#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/repack_bits_bb_impl.cc b/gr-blocks/lib/repack_bits_bb_impl.cc new file mode 100644 index 000000000..c7ed054c8 --- /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 000000000..bf39f8cb0 --- /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/tagged_file_sink_impl.cc b/gr-blocks/lib/tagged_file_sink_impl.cc new file mode 100644 index 000000000..7d011e45f --- /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::string_to_symbol("burst"); + pmt::pmt_t tkey = 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::to_uint64(pmt::tuple_ref(time, 0)); + double tfrac = pmt::to_double(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::eqv((*vitr).key, bkey)) && + 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::to_uint64(pmt::tuple_ref(time, 0)); + double tfrac = pmt::to_double(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::eqv((*vitr).key, bkey)) && + 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 000000000..f64cedf2f --- /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 000000000..59e36fa07 --- /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/gnuradio-core/src/lib/general/gri_add_const_ss_generic.cc b/gr-blocks/lib/tagged_stream_mux_impl.h index 3b5ee1824..19862e686 100644 --- a/gnuradio-core/src/lib/general/gri_add_const_ss_generic.cc +++ b/gr-blocks/lib/tagged_stream_mux_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,30 +20,35 @@ * Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H -#include "config.h" +#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 -#include <gri_add_const_ss.h> - -void -gri_add_const_ss (short *dst, const short *src, int nshorts, short konst) -{ - static const int STRIDE = 8; - - int i; - - for (i = 0; i < nshorts - (STRIDE - 1); i += STRIDE){ - dst[i + 0] = src[i + 0] + konst; - dst[i + 1] = src[i + 1] + konst; - dst[i + 2] = src[i + 2] + konst; - dst[i + 3] = src[i + 3] + konst; - dst[i + 4] = src[i + 4] + konst; - dst[i + 5] = src[i + 5] + konst; - dst[i + 6] = src[i + 6] + konst; - dst[i + 7] = src[i + 7] + konst; - } - - for (; i < nshorts; i++) - dst[i] = src[i] + konst; -} diff --git a/gr-blocks/lib/udp_sink_impl.cc b/gr-blocks/lib/udp_sink_impl.cc new file mode 100644 index 000000000..db21da3ee --- /dev/null +++ b/gr-blocks/lib/udp_sink_impl.cc @@ -0,0 +1,148 @@ +/* -*- 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/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 000000000..243d499b6 --- /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 000000000..e6e9caf8a --- /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 000000000..8927f5f93 --- /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/wavfile.cc b/gr-blocks/lib/wavfile.cc new file mode 100644 index 000000000..16d80adc8 --- /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 000000000..f8b09a114 --- /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 000000000..4ad995888 --- /dev/null +++ b/gr-blocks/lib/wavfile_sink_impl.h @@ -0,0 +1,94 @@ +/* -*- 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> + +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 000000000..2e3b0e240 --- /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 000000000..4875731a0 --- /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_burst_tagger.py b/gr-blocks/python/qa_burst_tagger.py index dfe9ec642..52d688d10 100644 --- a/gr-blocks/python/qa_burst_tagger.py +++ b/gr-blocks/python/qa_burst_tagger.py @@ -33,7 +33,6 @@ class test_burst_tagger(gr_unittest.TestCase): 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) trg_data = (-1, -1, 1, 1, -1, -1, 1, 1, -1, -1) src = gr.vector_source_i(src_data) 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 000000000..2898f760e --- /dev/null +++ b/gr-blocks/python/qa_file_source_sink.py @@ -0,0 +1,94 @@ +#!/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): + os.environ['GR_CONF_CONTROLPORT_ON'] = 'False' + 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_message_tags.py b/gr-blocks/python/qa_message_tags.py new file mode 100644 index 000000000..0ab857b1a --- /dev/null +++ b/gr-blocks/python/qa_message_tags.py @@ -0,0 +1,27 @@ +import time + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +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 = blocks.message_source(gr.sizeof_char, tx_msgq, "packet_length") + snk = blocks.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/gr-blocks/python/qa_repack_bits_bb.py b/gr-blocks/python/qa_repack_bits_bb.py new file mode 100755 index 000000000..3f88df4a6 --- /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.string_to_symbol(tag_name) + tag.value = 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.symbol_to_string(out_tag.key), tag_name) + self.assertEqual(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.string_to_symbol(tag_name) + tag.value = 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.symbol_to_string(out_tag.key), tag_name) + self.assertEqual(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_tag_file_sink.py b/gr-blocks/python/qa_tag_file_sink.py new file mode 100644 index 000000000..80e41a7dd --- /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_tagged_stream_mux.py b/gr-blocks/python/qa_tagged_stream_mux.py new file mode 100755 index 000000000..e39f8cac2 --- /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.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.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.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.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/gnuradio-core/src/python/gnuradio/gr/qa_udp_sink_source.py b/gr-blocks/python/qa_udp_source_sink.py index 0a719990e..8c5fa2821 100755..100644 --- a/gnuradio-core/src/python/gnuradio/gr/qa_udp_sink_source.py +++ b/gr-blocks/python/qa_udp_source_sink.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010 Free Software Foundation, Inc. +# Copyright 2008,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,11 +21,15 @@ # 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): + os.environ['GR_CONF_CONTROLPORT_ON'] = 'False' self.tb_snd = gr.top_block() self.tb_rcv = gr.top_block() @@ -34,24 +38,43 @@ class test_udp_sink_source(gr_unittest.TestCase): 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) - udp_snd = gr.udp_sink( gr.sizeof_float, 'localhost', port ) - self.tb_snd.connect( src, udp_snd ) + 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 = gr.udp_source( gr.sizeof_float, 'localhost', port ) + 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.connect(udp_rcv, dst) self.tb_rcv.start() self.tb_snd.run() udp_snd.disconnect() self.timeout = False - q = Timer(3.0,self.stop_rcv) + q = Timer(2.0,self.stop_rcv) q.start() self.tb_rcv.wait() q.cancel() @@ -60,12 +83,12 @@ class test_udp_sink_source(gr_unittest.TestCase): self.assertEqual(expected_result, result_data) self.assert_(not self.timeout) - def test_002(self): - udp_rcv = gr.udp_source( gr.sizeof_float, '0.0.0.0', 0, eof=False ) + 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 = gr.udp_sink( gr.sizeof_float, '127.0.0.1', 65500 ) - udp_snd.connect( 'localhost', rcv_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)] @@ -73,14 +96,14 @@ class test_udp_sink_source(gr_unittest.TestCase): 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_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(3.0,self.stop_rcv) + q = Timer(2.0,self.stop_rcv) q.start() self.tb_rcv.wait() q.cancel() diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_wavefile.py b/gr-blocks/python/qa_wavfile.py index 3b9a3eb20..b40b9b7ec 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_wavefile.py +++ b/gr-blocks/python/qa_wavfile.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010 Free Software Foundation, Inc. +# Copyright 2008,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,33 +21,34 @@ # 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") +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 setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test_001_checkwavread (self): - wf = gr.wavfile_source(g_in_file) + def test_001_checkwavread(self): + wf = blocks.wavfile_source(g_in_file) self.assertEqual(wf.sample_rate(), 8000) - def test_002_checkwavcopy (self): + def test_002_checkwavcopy(self): infile = g_in_file outfile = "test_out.wav" - wf_in = gr.wavfile_source(infile) - wf_out = gr.wavfile_sink(outfile, - wf_in.channels(), - wf_in.sample_rate(), - wf_in.bits_per_sample()) + 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() @@ -64,6 +65,5 @@ class test_wavefile(gr_unittest.TestCase): 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 000000000..0fe12a7a1 --- /dev/null +++ b/gr-blocks/python/test_16bit_1chunk.wav diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i index d63a5ae0e..5245721b6 100644 --- a/gr-blocks/swig/blocks_swig.i +++ b/gr-blocks/swig/blocks_swig.i @@ -36,10 +36,12 @@ #include "blocks/add_ii.h" #include "blocks/add_cc.h" #include "blocks/add_const_ff.h" +#include "blocks/add_const_bb.h" #include "blocks/add_const_ss.h" #include "blocks/add_const_ii.h" #include "blocks/add_const_cc.h" #include "blocks/add_const_vff.h" +#include "blocks/add_const_vbb.h" #include "blocks/add_const_vss.h" #include "blocks/add_const_vii.h" #include "blocks/add_const_vcc.h" @@ -64,12 +66,17 @@ #include "blocks/complex_to_mag_squared.h" #include "blocks/complex_to_arg.h" #include "blocks/conjugate_cc.h" +#include "blocks/control_loop.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_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" @@ -130,6 +137,7 @@ #include "blocks/peak_detector_ib.h" #include "blocks/peak_detector_sb.h" #include "blocks/peak_detector2_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" @@ -145,6 +153,7 @@ #include "blocks/or_ii.h" #include "blocks/random_pdu.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" @@ -166,12 +175,16 @@ #include "blocks/sub_ii.h" #include "blocks/sub_cc.h" #include "blocks/tag_debug.h" +#include "blocks/tagged_file_sink.h" +#include "blocks/tagged_stream_mux.h" #include "blocks/tagged_stream_to_pdu.h" #include "blocks/threshold_ff.h" #include "blocks/throttle.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" @@ -179,6 +192,8 @@ #include "blocks/vco_f.h" #include "blocks/vector_to_stream.h" #include "blocks/vector_to_streams.h" +#include "blocks/wavfile_sink.h" +#include "blocks/wavfile_source.h" #include "blocks/xor_bb.h" #include "blocks/xor_ss.h" #include "blocks/xor_ii.h" @@ -189,10 +204,12 @@ %include "blocks/add_ii.h" %include "blocks/add_cc.h" %include "blocks/add_const_ff.h" +%include "blocks/add_const_bb.h" %include "blocks/add_const_ss.h" %include "blocks/add_const_ii.h" %include "blocks/add_const_cc.h" %include "blocks/add_const_vff.h" +%include "blocks/add_const_vbb.h" %include "blocks/add_const_vss.h" %include "blocks/add_const_vii.h" %include "blocks/add_const_vcc.h" @@ -217,8 +234,13 @@ %include "blocks/complex_to_mag_squared.h" %include "blocks/complex_to_arg.h" %include "blocks/conjugate_cc.h" +%include "blocks/control_loop.h" %include "blocks/deinterleave.h" %include "blocks/delay.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" @@ -298,7 +320,9 @@ %include "blocks/peak_detector_sb.h" %include "blocks/peak_detector2_fb.h" %include "blocks/random_pdu.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" @@ -319,12 +343,16 @@ %include "blocks/sub_ss.h" %include "blocks/sub_ii.h" %include "blocks/sub_cc.h" +%include "blocks/tagged_file_sink.h" +%include "blocks/tagged_stream_mux.h" %include "blocks/tagged_stream_to_pdu.h" %include "blocks/threshold_ff.h" %include "blocks/throttle.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" @@ -332,6 +360,8 @@ %include "blocks/vco_f.h" %include "blocks/vector_to_stream.h" %include "blocks/vector_to_streams.h" +%include "blocks/wavfile_sink.h" +%include "blocks/wavfile_source.h" %include "blocks/xor_bb.h" %include "blocks/xor_ss.h" %include "blocks/xor_ii.h" @@ -341,10 +371,12 @@ GR_SWIG_BLOCK_MAGIC2(blocks, add_ss); GR_SWIG_BLOCK_MAGIC2(blocks, add_ii); GR_SWIG_BLOCK_MAGIC2(blocks, add_cc); GR_SWIG_BLOCK_MAGIC2(blocks, add_const_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, add_const_bb); GR_SWIG_BLOCK_MAGIC2(blocks, add_const_ss); GR_SWIG_BLOCK_MAGIC2(blocks, add_const_ii); GR_SWIG_BLOCK_MAGIC2(blocks, add_const_cc); GR_SWIG_BLOCK_MAGIC2(blocks, add_const_vff); +GR_SWIG_BLOCK_MAGIC2(blocks, add_const_vbb); GR_SWIG_BLOCK_MAGIC2(blocks, add_const_vss); GR_SWIG_BLOCK_MAGIC2(blocks, add_const_vii); GR_SWIG_BLOCK_MAGIC2(blocks, add_const_vcc); @@ -375,6 +407,9 @@ 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_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); @@ -435,6 +470,7 @@ 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, 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); @@ -450,6 +486,7 @@ 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); @@ -471,12 +508,16 @@ 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, tag_debug); +GR_SWIG_BLOCK_MAGIC2(blocks, tagged_file_sink); +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, throttle); 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); @@ -484,6 +525,8 @@ GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_ii); GR_SWIG_BLOCK_MAGIC2(blocks, vco_f); GR_SWIG_BLOCK_MAGIC2(blocks, vector_to_stream); GR_SWIG_BLOCK_MAGIC2(blocks, vector_to_streams); +GR_SWIG_BLOCK_MAGIC2(blocks, wavfile_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, wavfile_source); 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 index 8f7ba2f64..ec17c017f 100644 --- a/gr-blocks/tests/CMakeLists.txt +++ b/gr-blocks/tests/CMakeLists.txt @@ -37,8 +37,8 @@ link_directories( ${CPPUNIT_LIBRARY_DIRS} ) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Build benchmarks and non-registered tests @@ -51,6 +51,6 @@ set(tests_not_run #single source per test 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) + target_link_libraries(${name} test-gnuradio-core gnuradio-blocks ${LOG4CPP_LIBRARIES}) endforeach(test_not_run_src) diff --git a/gr-channels/lib/CMakeLists.txt b/gr-channels/lib/CMakeLists.txt index b9ed2a458..e7a462201 100644 --- a/gr-channels/lib/CMakeLists.txt +++ b/gr-channels/lib/CMakeLists.txt @@ -49,7 +49,7 @@ list(APPEND channels_sources #Add Windows DLL resource file if using MSVC if(MSVC) - include(${CMAKE_INSTALL_PREFIX}/cmake/Modules/GrVersion.cmake) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-channels.rc.in diff --git a/gr-channels/lib/fading_model_impl.cc b/gr-channels/lib/fading_model_impl.cc index b38ff8289..106cc19c5 100644 --- a/gr-channels/lib/fading_model_impl.cc +++ b/gr-channels/lib/fading_model_impl.cc @@ -135,21 +135,6 @@ namespace gr { pmt::mp(0), pmt::mp(1), pmt::mp(0.00001), "radians", "Maximum step size for random walk angle per sample", RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); - - add_rpc_variable( - rpcbasic_sptr(new rpcbasic_register_get<fading_model, float >( - alias(), "step", - &fading_model::step, - pmt::mp(0), pmt::mp(8), pmt::mp(4), - "radians", "Maximum step size for random walk angle per sample", - RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); - add_rpc_variable( - rpcbasic_sptr(new rpcbasic_register_set<fading_model, float >( - alias(), "step", - &fading_model::set_step, - pmt::mp(0), pmt::mp(1), pmt::mp(0.00001), - "radians", "Maximum step size for random walk angle per sample", - RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); #endif /* GR_CTRLPORT */ } diff --git a/gr-comedi/src/CMakeLists.txt b/gr-comedi/src/CMakeLists.txt new file mode 100644 index 000000000..0dc096001 --- /dev/null +++ b/gr-comedi/src/CMakeLists.txt @@ -0,0 +1,121 @@ +# Copyright 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. + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${GR_COMEDI_INCLUDE_DIRS} + ${GNURADIO_CORE_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ${COMEDI_INCLUDE_DIRS} +) + +link_directories( + ${Boost_LIBRARY_DIRS} + ${COMEDI_LIBRARY_DIRS} +) + +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + +######################################################################## +# Setup library +######################################################################## +list(APPEND gr_comedi_sources + comedi_sink_s.cc + comedi_source_s.cc + gri_comedi.cc +) + +list(APPEND comedi_libs + gnuradio-core + ${Boost_LIBRARIES} + ${COMEDI_LIBRARIES} + ${LOG4CPP_LIBRARIES} +) + +add_library(gnuradio-comedi SHARED ${gr_comedi_sources}) +target_link_libraries(gnuradio-comedi ${comedi_libs}) +GR_LIBRARY_FOO(gnuradio-comedi RUNTIME_COMPONENT "comedi_runtime" DEVEL_COMPONENT "comedi_devel") + +######################################################################## +# Install public header files +######################################################################## +install(FILES + comedi_sink_s.h + comedi_source_s.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "comedi_devel" +) + +######################################################################## +# Setup swig generation +######################################################################## +if(ENABLE_PYTHON) +include(GrPython) +include(GrSwig) + +set(GR_SWIG_INCLUDE_DIRS + ${GR_COMEDI_INCLUDE_DIRS} + ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} +) + +set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/comedi_swig_doc.i) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) + +set(GR_SWIG_LIBRARIES gnuradio-comedi) + +GR_SWIG_MAKE(comedi comedi.i) + +GR_SWIG_INSTALL( + TARGETS comedi + DESTINATION ${GR_PYTHON_DIR}/gnuradio + COMPONENT "comedi_python" +) + +install( + FILES comedi.i + ${CMAKE_CURRENT_BINARY_DIR}/comedi_swig_doc.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "comedi_swig" +) + +endif(ENABLE_PYTHON) + +######################################################################## +# Handle the unit tests +######################################################################## +if(ENABLE_TESTING AND ENABLE_PYTHON) + +list(APPEND GR_TEST_PYTHON_DIRS + ${CMAKE_BINARY_DIR}/gr-comedi/src +) +list(APPEND GR_TEST_TARGET_DEPS gnuradio-comedi) + +include(GrTest) +file(GLOB py_qa_test_files "qa_*.py") +foreach(py_qa_test_file ${py_qa_test_files}) + get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE) + GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) +endforeach(py_qa_test_file) +endif(ENABLE_TESTING AND ENABLE_PYTHON) diff --git a/gr-digital/CMakeLists.txt b/gr-digital/CMakeLists.txt index ac0dbb737..7d3046dc5 100644 --- a/gr-digital/CMakeLists.txt +++ b/gr-digital/CMakeLists.txt @@ -34,6 +34,8 @@ GR_REGISTER_COMPONENT("gr-digital" ENABLE_GR_DIGITAL ENABLE_GR_FILTER ENABLE_GR_BLOCKS ENABLE_GR_ANALOG + ENABLE_GR_BLOCKS + ENABLE_GR_FILTER ) GR_SET_GLOBAL(GR_DIGITAL_INCLUDE_DIRS @@ -89,6 +91,7 @@ CPACK_COMPONENT("digital_swig" ######################################################################## # Add subdirectories ######################################################################## +add_subdirectory(include) add_subdirectory(include/digital) add_subdirectory(lib) add_subdirectory(doc) diff --git a/gr-digital/examples/narrowband/benchmark_add_channel.py b/gr-digital/examples/narrowband/benchmark_add_channel.py index 28824dff4..b614895b6 100755 --- a/gr-digital/examples/narrowband/benchmark_add_channel.py +++ b/gr-digital/examples/narrowband/benchmark_add_channel.py @@ -42,14 +42,14 @@ class my_top_block(gr.top_block): noise_power = power_in_signal/SNR noise_voltage = math.sqrt(noise_power) - self.src = gr.file_source(gr.sizeof_gr_complex, ifile) + self.src = blocks.file_source(gr.sizeof_gr_complex, ifile) #self.throttle = blocks.throttle(gr.sizeof_gr_complex, options.sample_rate) self.channel = filter.channel_model(noise_voltage, frequency_offset, time_offset, noise_seed=-random.randint(0,100000)) self.phase = blocks.multiply_const_cc(complex(math.cos(phase_offset), math.sin(phase_offset))) - self.snk = gr.file_sink(gr.sizeof_gr_complex, ofile) + self.snk = blocks.file_sink(gr.sizeof_gr_complex, ofile) self.connect(self.src, self.channel, self.phase, self.snk) diff --git a/gr-digital/examples/narrowband/benchmark_rx.py b/gr-digital/examples/narrowband/benchmark_rx.py index 1962fdc4b..ce47bf87b 100755 --- a/gr-digital/examples/narrowband/benchmark_rx.py +++ b/gr-digital/examples/narrowband/benchmark_rx.py @@ -21,6 +21,7 @@ # from gnuradio import gr, gru +from gnuradio import blocks from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -57,7 +58,7 @@ class my_top_block(gr.top_block): elif(options.from_file is not None): sys.stderr.write(("Reading samples from '%s'.\n\n" % (options.from_file))) - self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) + self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file) else: sys.stderr.write("No source defined, pulling samples from null source.\n\n") self.source = gr.null_source(gr.sizeof_gr_complex) diff --git a/gr-digital/examples/narrowband/benchmark_tx.py b/gr-digital/examples/narrowband/benchmark_tx.py index 9afacb495..593abb3ca 100755 --- a/gr-digital/examples/narrowband/benchmark_tx.py +++ b/gr-digital/examples/narrowband/benchmark_tx.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -56,7 +57,7 @@ class my_top_block(gr.top_block): elif(options.to_file is not None): sys.stderr.write(("Saving samples to '%s'.\n\n" % (options.to_file))) - self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) + self.sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file) else: sys.stderr.write("No sink defined, dumping samples to null sink.\n\n") self.sink = gr.null_sink(gr.sizeof_gr_complex) diff --git a/gr-digital/examples/narrowband/digital_bert_rx.py b/gr-digital/examples/narrowband/digital_bert_rx.py index cc66456e9..cf4274273 100755 --- a/gr-digital/examples/narrowband/digital_bert_rx.py +++ b/gr-digital/examples/narrowband/digital_bert_rx.py @@ -27,6 +27,7 @@ import gnuradio.gr.gr_threading as _threading import sys, time, math from gnuradio import digital +from gnuradio import blocks # from current dir from uhd_interface import uhd_receiver @@ -124,7 +125,7 @@ class rx_psk_block(gr.top_block): options.samples_per_symbol = self._source._sps elif(options.from_file is not None): - self._source = gr.file_source(gr.sizeof_gr_complex, options.from_file) + self._source = blocks.file_source(gr.sizeof_gr_complex, options.from_file) else: self._source = gr.null_source(gr.sizeof_gr_complex) diff --git a/gr-digital/examples/narrowband/digital_bert_tx.py b/gr-digital/examples/narrowband/digital_bert_tx.py index 3be9d68f8..2a9913770 100755 --- a/gr-digital/examples/narrowband/digital_bert_tx.py +++ b/gr-digital/examples/narrowband/digital_bert_tx.py @@ -78,7 +78,7 @@ class tx_psk_block(gr.top_block): options.samples_per_symbol = self._sink._sps elif(options.to_file is not None): - self._sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) + self._sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file) else: self._sink = gr.null_sink(gr.sizeof_gr_complex) diff --git a/gr-digital/examples/narrowband/rx_voice.py b/gr-digital/examples/narrowband/rx_voice.py index f5d12b568..b2b4174cc 100755 --- a/gr-digital/examples/narrowband/rx_voice.py +++ b/gr-digital/examples/narrowband/rx_voice.py @@ -21,6 +21,7 @@ # from gnuradio import gr, audio, uhd +from gnuradio import blocks from gnuradio import filter from gnuradio import eng_notation from gnuradio.eng_option import eng_option @@ -83,7 +84,7 @@ class my_top_block(gr.top_block): elif(options.from_file is not None): self.thr = blocks.throttle(gr.sizeof_gr_complex, options.bitrate) - self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) + self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file) self.connect(self.source, self.thr, self.rxpath) else: diff --git a/gr-digital/examples/narrowband/tx_voice.py b/gr-digital/examples/narrowband/tx_voice.py index 3fc4fa46f..d3df9d788 100755 --- a/gr-digital/examples/narrowband/tx_voice.py +++ b/gr-digital/examples/narrowband/tx_voice.py @@ -80,7 +80,7 @@ class my_top_block(gr.top_block): rrate = usrp_rate / audio_rate elif(options.to_file is not None): - self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) + self.sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file) rrate = 1 else: self.sink = gr.null_sink(gr.sizeof_gr_complex) diff --git a/gr-digital/examples/ofdm/benchmark_add_channel.py b/gr-digital/examples/ofdm/benchmark_add_channel.py index 0d17efd05..f97214f78 100755 --- a/gr-digital/examples/ofdm/benchmark_add_channel.py +++ b/gr-digital/examples/ofdm/benchmark_add_channel.py @@ -44,14 +44,14 @@ class my_top_block(gr.top_block): frequency_offset = options.frequency_offset / options.fft_length - self.src = gr.file_source(gr.sizeof_gr_complex, ifile) + self.src = blocks.file_source(gr.sizeof_gr_complex, ifile) #self.throttle = blocks.throttle(gr.sizeof_gr_complex, options.sample_rate) self.channel = filter.channel_model(noise_voltage, frequency_offset, time_offset, noise_seed=-random.randint(0,100000)) self.phase = blocks.multiply_const_cc(complex(math.cos(phase_offset), math.sin(phase_offset))) - self.snk = gr.file_sink(gr.sizeof_gr_complex, ofile) + self.snk = blocks.file_sink(gr.sizeof_gr_complex, ofile) self.connect(self.src, self.channel, self.phase, self.snk) diff --git a/gr-digital/examples/ofdm/benchmark_rx.py b/gr-digital/examples/ofdm/benchmark_rx.py index f1b65276d..740e0aed0 100755 --- a/gr-digital/examples/ofdm/benchmark_rx.py +++ b/gr-digital/examples/ofdm/benchmark_rx.py @@ -25,6 +25,7 @@ from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser +from gnuradio import blocks from gnuradio import digital # from current dir @@ -44,7 +45,7 @@ class my_top_block(gr.top_block): options.spec, options.antenna, options.verbose) elif(options.from_file is not None): - self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) + self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file) else: self.source = gr.null_source(gr.sizeof_gr_complex) diff --git a/gr-digital/examples/ofdm/benchmark_tx.py b/gr-digital/examples/ofdm/benchmark_tx.py index 5962fe7ec..44b127e0c 100755 --- a/gr-digital/examples/ofdm/benchmark_tx.py +++ b/gr-digital/examples/ofdm/benchmark_tx.py @@ -27,6 +27,7 @@ from optparse import OptionParser import time, struct, sys from gnuradio import digital +from gnuradio import blocks # from current dir from transmit_path import transmit_path @@ -43,7 +44,7 @@ class my_top_block(gr.top_block): options.spec, options.antenna, options.verbose) elif(options.to_file is not None): - self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) + self.sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file) else: self.sink = gr.null_sink(gr.sizeof_gr_complex) diff --git a/gr-digital/examples/ofdm/ofdm_bugsquatch.py b/gr-digital/examples/ofdm/ofdm_bugsquatch.py new file mode 100644 index 000000000..3b900fb46 --- /dev/null +++ b/gr-digital/examples/ofdm/ofdm_bugsquatch.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +from gnuradio import gr, digital +from gnuradio.digital.utils import tagged_streams +import random + +if __name__ == '__main__': + tb = gr.top_block() + fft_len = 64 + cp_len = 16 + length_tag_name = "length" + src = gr.vector_source_c( + [random.randint(0, 1)*2-1 for i in range(10*fft_len)], True, fft_len, + tagged_streams.make_lengthtags((10,), (0,), length_tag_name)) + cyclic_prefixer = digital.ofdm_cyclic_prefixer( + fft_len, fft_len+cp_len, 0, length_tag_name) + sink = gr.null_sink(gr.sizeof_gr_complex) + checker = digital.tagged_stream_check(gr.sizeof_gr_complex*fft_len, length_tag_name) + checker2 = digital.tagged_stream_check(gr.sizeof_gr_complex*fft_len, length_tag_name) + tb.connect(src, checker, cyclic_prefixer, sink) + tb.run() + diff --git a/gr-digital/examples/ofdm/rx_ofdm.grc b/gr-digital/examples/ofdm/rx_ofdm.grc new file mode 100644 index 000000000..1541e8ded --- /dev/null +++ b/gr-digital/examples/ofdm/rx_ofdm.grc @@ -0,0 +1,1092 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Thu Feb 14 15:49:35 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>variable</key> + <param> + <key>id</key> + <value>pilot_symbols_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>((100,),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(762, 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>((0,),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(557, 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>(876, 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>((100,),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(659, 64)</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>(404, 64)</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>(-1, 185)</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>_coordinate</key> + <value>(368, 178)</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>(692, 175)</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>(885, 223)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_delay</key> + <param> + <key>id</key> + <value>blocks_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>(368, 253)</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>(0, 91)</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>sync_word</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>(165, 46)</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>(655, 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>(813, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>n_sync_symbols</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(168, 108)</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>(181, 200)</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>(854, 343)</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>(421, 320)</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>(651, 466)</value> + </param> + <param> + <key>_rotation</key> + <value>180</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>(53, 429)</value> + </param> + <param> + <key>_rotation</key> + <value>180</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>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>(718, 635)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_null_sink</key> + <param> + <key>id</key> + <value>gr_null_sink_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(938, 638)</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, n_sync_symbols).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>(265, 612)</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>(57, 605)</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_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>(649, 305)</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>(496, 597)</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_word</value> + </param> + <param> + <key>sync_symbol2</key> + <value>()</value> + </param> + <param> + <key>n_data_symbols</key> + <value>n_sync_symbols</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>(52, 305)</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>2</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>(340, 461)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <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>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>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>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>blocks_throttle_0</source_block_id> + <sink_block_id>blocks_delay_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_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_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_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>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_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>digital_packet_headerparser_b_0</source_block_id> + <sink_block_id>digital_header_payload_demux_0</sink_block_id> + <source_key>0</source_key> + <sink_key>2</sink_key> + </connection> + <connection> + <source_block_id>digital_header_payload_demux_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>digital_header_payload_demux_0</source_block_id> + <sink_block_id>fft_vxx_0_0</sink_block_id> + <source_key>1</source_key> + <sink_key>0</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> + <connection> + <source_block_id>digital_constellation_decoder_cb_0</source_block_id> + <sink_block_id>gr_null_sink_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>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>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> +</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 000000000..6c4f9797d --- /dev/null +++ b/gr-digital/examples/ofdm/tx_ofdm.grc @@ -0,0 +1,1143 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Tue Feb 5 14:47:32 2013</timestamp> + <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>no_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>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>(164, 45)</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>(399, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>pilot_symbols_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>((100,),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(735, 63)</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>(377, 63)</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>((100,),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(632, 63)</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>((0,),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(530, 63)</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>(311, 63)</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>(620, 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>(783, 0)</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>byte</value> + </param> + <param> + <key>samples_per_second</key> + <value>bit_rate/8</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(234, 167)</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>(164, 0)</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>(-1, 90)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sync_word</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>(95, 90)</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>(234, 91)</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>(849, 63)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_vector_source_x</key> + <param> + <key>id</key> + <value>gr_vector_source_x_1</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>(-1, 152)</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>(528, 0)</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>(761, 167)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>bit_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>3200000</value> + </param> + <param> + <key>_coordinate</key> + <value>(311, 0)</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>(516, 228)</value> + </param> + <param> + <key>_rotation</key> + <value>180</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>(279, 243)</value> + </param> + <param> + <key>_rotation</key> + <value>180</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>(319, 305)</value> + </param> + <param> + <key>_rotation</key> + <value>180</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>(44, 254)</value> + </param> + <param> + <key>_rotation</key> + <value>180</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>(56, 453)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_vector_source_x</key> + <param> + <key>id</key> + <value>sync_word_source</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>vector</key> + <value>numpy.array(sync_word) * numpy.sqrt(2)</value> + </param> + <param> + <key>tags</key> + <value>tagged_streams.make_lengthtags((len(sync_word)/fft_len,), (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>(56, 356)</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>(374, 382)</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>(765, 498)</value> + </param> + <param> + <key>_rotation</key> + <value>180</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>(488, 505)</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>False</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>1.0</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>50</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>(291, 460)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>gr_null_sink</key> + <param> + <key>id</key> + <value>gr_null_sink_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>_coordinate</key> + <value>(438, 633)</value> + </param> + <param> + <key>_rotation</key> + <value>180</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>(472, 159)</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>tdb</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>display</key> + <value>False</value> + </param> + <param> + <key>_coordinate</key> + <value>(819, 232)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>gr_vector_source_x_1</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>digital_crc32_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>digital_packet_headergenerator_bb_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_tagged_stream_mux_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>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>sync_word_source</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>digital_packet_headergenerator_bb_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>blocks_repack_bits_bb_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>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>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_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>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>digital_ofdm_cyclic_prefixer_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>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>digital_ofdm_cyclic_prefixer_0</source_block_id> + <sink_block_id>gr_null_sink_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_tag_debug_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 bace20847..9888247ca 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 04c679d35..762ac6653 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,2012 Free Software Foundation, Inc. This file is part of GNU Radio @@ -31,8 +30,35 @@ <cat> <name>Coding</name> <block>digital_additive_scrambler_bb</block> - <block>digital_descrambler_bb</block> <block>digital_scrambler_bb</block> + <block>digital_descrambler_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_crc32_bb</block> + <block>digital_descrambler_bb</block> + <block>digital_fll_band_edge_cc</block> + <block>digital_glfsr_source_x</block> + <block>digital_header_payload_demux</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_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_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> </cat> <cat> <name>Converters</name> @@ -92,14 +118,20 @@ <block>digital_gmsk_demod</block> </cat> <cat> - <name>OFDM</name> + <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_sink</block> + <block>digital_ofdm_frame_equalizer_vcvc</block> <block>digital_ofdm_insert_preamble</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> </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 000000000..d60f08f81 --- /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 000000000..b29d86435 --- /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 000000000..826778ff3 --- /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 000000000..e8b1571eb --- /dev/null +++ b/gr-digital/grc/digital_ofdm_chanest_vcvc.xml @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<block> + <name>OFDM channel & coarse frequency offset 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 d5e5d3894..80bf339cb 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 000000000..330b29a2f --- /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 000000000..7de9ff786 --- /dev/null +++ b/gr-digital/grc/digital_ofdm_mod2.xml @@ -0,0 +1,65 @@ +<block> + <name>OFDM Mod 2</name> + <key>digital_ofdm_mod2</key> + <category>OFDM</category> + <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_serializer_vcc.xml b/gr-digital/grc/digital_ofdm_serializer_vcc.xml new file mode 100644 index 000000000..c7596bbb0 --- /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 000000000..7865d248d --- /dev/null +++ b/gr-digital/grc/digital_ofdm_sync_sc_cfb.xml @@ -0,0 +1,29 @@ +<?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)</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> + <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_packet_headergenerator_bb.xml b/gr-digital/grc/digital_packet_headergenerator_bb.xml new file mode 100644 index 000000000..a0ec14ae8 --- /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 000000000..645b4cd25 --- /dev/null +++ b/gr-digital/grc/digital_packet_headergenerator_bb_default.xml @@ -0,0 +1,26 @@ +<block> + <name>Packet Header Generator</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 000000000..bab6bd22e --- /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 000000000..415f4839f --- /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/grc/digital_scale_tags.xml b/gr-digital/grc/digital_scale_tags.xml new file mode 100644 index 000000000..3e80ee21f --- /dev/null +++ b/gr-digital/grc/digital_scale_tags.xml @@ -0,0 +1,31 @@ +<block> + <name>Tag Scaler</name> + <key>digital_scale_tags</key> + <category>digital</category> + <import>from gnuradio import digital</import> + <make>digital.scale_tags($item_size, $tag_name, $scale_factor)</make> + <param> + <name>Item size</name> + <key>item_size</key> + <type>int</type> + </param> + <param> + <name>Tag Name</name> + <key>tag_name</key> + <type>string</type> + </param> + <param> + <name>Scale Factor</name> + <key>scale_factor</key> + <type>real</type> + </param> + <!--FIXME type should be choosable--> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-digital/include/CMakeLists.txt b/gr-digital/include/CMakeLists.txt new file mode 100644 index 000000000..a32f11ed4 --- /dev/null +++ b/gr-digital/include/CMakeLists.txt @@ -0,0 +1,34 @@ +# Copyright 2011,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. + +######################################################################## +# Install header files +######################################################################## +install(FILES + digital_crc32_bb.h + digital_ofdm_carrier_allocator_cvc.h + digital_ofdm_chanest_vcvc.h + digital_ofdm_cyclic_prefixer.h + digital_ofdm_equalizer_base.h + digital_ofdm_equalizer_simpledfe.h + digital_ofdm_equalizer_static.h + digital_ofdm_sync_sc_cfb.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 index 11cab8833..06438c092 100644 --- a/gr-digital/include/digital/CMakeLists.txt +++ b/gr-digital/include/digital/CMakeLists.txt @@ -75,54 +75,63 @@ add_custom_target(digital_generated_includes DEPENDS ######################################################################## install(FILES ${generated_includes} - api.h - constellation.h - crc32.h - lfsr.h - glfsr.h - mpsk_snr_est.h - simple_framer_sync.h additive_scrambler_bb.h + api.h binary_slicer_fb.h clock_recovery_mm_cc.h clock_recovery_mm_ff.h cma_equalizer_cc.h - cpmmod_bc.h - constellation_receiver_cb.h + constellation.h constellation_decoder_cb.h + constellation_receiver_cb.h correlate_access_code_bb.h correlate_access_code_tag_bb.h costas_loop_cc.h + cpmmod_bc.h + crc32.h descrambler_bb.h diff_decoder_bb.h diff_encoder_bb.h diff_phasor_cc.h - framer_sink_1.h fll_band_edge_cc.h + framer_sink_1.h + glfsr.h glfsr_source_b.h glfsr_source_f.h + header_payload_demux.h kurtotic_equalizer_cc.h + lfsr.h lms_dd_equalizer_cc.h map_bb.h metric_type.h mpsk_receiver_cc.h + mpsk_snr_est.h mpsk_snr_est_cc.h ofdm_cyclic_prefixer.h ofdm_frame_acquisition.h + ofdm_frame_equalizer_vcvc.h ofdm_frame_sink.h ofdm_insert_preamble.h ofdm_mapper_bcv.h ofdm_sampler.h + ofdm_serializer_vcc.h + packet_header_default.h + packet_header_ofdm.h + packet_headergenerator_bb.h + packet_headerparser_b.h packet_sink.h pfb_clock_sync_ccf.h pfb_clock_sync_fff.h pn_correlator_cc.h probe_density_b.h probe_mpsk_snr_est_c.h + scale_tags.h scrambler_bb.h - simple_framer.h simple_correlator.h + simple_framer.h + simple_framer_sync.h + tagged_stream_check.h + ts_insert_zeros_cc.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio/digital COMPONENT "digital_devel" ) - diff --git a/gr-digital/include/digital/constellation.h b/gr-digital/include/digital/constellation.h index ee7a704eb..a7a2ec202 100644 --- a/gr-digital/include/digital/constellation.h +++ b/gr-digital/include/digital/constellation.h @@ -82,7 +82,7 @@ namespace gr { //! Calculates metrics for all points in the constellation. //! For use with the viterbi algorithm. - virtual void calc_metric(const gr_complex *sample, float *metric, trellis_metric_type_t type); + virtual void calc_metric(const gr_complex *sample, float *metric, gr::digital::trellis_metric_type_t type); virtual void calc_euclidean_metric(const gr_complex *sample, float *metric); virtual void calc_hard_symbol_metric(const gr_complex *sample, float *metric); diff --git a/gr-digital/include/digital/fll_band_edge_cc.h b/gr-digital/include/digital/fll_band_edge_cc.h index 1a9fd0bf8..7b823630e 100644 --- a/gr-digital/include/digital/fll_band_edge_cc.h +++ b/gr-digital/include/digital/fll_band_edge_cc.h @@ -25,7 +25,7 @@ #include <digital/api.h> #include <gr_sync_block.h> -#include <gri_control_loop.h> +#include <blocks/control_loop.h> namespace gr { namespace digital { @@ -84,7 +84,7 @@ namespace gr { */ class DIGITAL_API fll_band_edge_cc : virtual public gr_sync_block, - virtual public gri_control_loop + virtual public blocks::control_loop { public: // gr::digital::fll_band_edge_cc::sptr 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 000000000..014e0304a --- /dev/null +++ b/gr-digital/include/digital/header_payload_demux.h @@ -0,0 +1,90 @@ +/* -*- 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 digital + * + * 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 000000000..d5d526ddc --- /dev/null +++ b/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.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_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 + * + * Performs equalization in one or two dimensions on a tagged OFDM frame. + * Input: a tagged series of OFDM symbols. + * Output: The same as the input, but equalized. + */ + 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 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 + */ + static sptr make( + digital_ofdm_equalizer_base_sptr equalizer, + const std::string &len_tag_key = "frame_len", + bool propagate_channel_state=false + ); + }; + + } // 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 000000000..3893d6674 --- /dev/null +++ b/gr-digital/include/digital/ofdm_serializer_vcc.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_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. + * + * 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 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, + 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 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, + 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 000000000..a4158e728 --- /dev/null +++ b/gr-digital/include/digital/packet_header_default.h @@ -0,0 +1,101 @@ +/* -*- 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 <+description of block+> + * \ingroup digital + * + */ + 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. + */ + 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 \in and writes a corresponding tag into \p tags. + * + */ + 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 000000000..6c3453ed1 --- /dev/null +++ b/gr-digital/include/digital/packet_header_ofdm.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_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="packet_len", + const std::string &frame_len_tag_key="frame_len", + const std::string &num_tag_key="packet_num", + int bits_per_sym=1); + ~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); + + 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_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 + }; + + } // 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 000000000..8d92bf84e --- /dev/null +++ b/gr-digital/include/digital/packet_headergenerator_bb.h @@ -0,0 +1,57 @@ +/* -*- 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 digital + * + * Input: A tagged stream. The first element must have a tag with the key + * specified in len_tag_key, which hold the exact number of elements + * in the PDU. + * Output: An tagged stream of length header_len. The output is determined + * by a header formatter. + */ + class DIGITAL_API packet_headergenerator_bb : virtual public gr_tagged_stream_block + { + public: + typedef boost::shared_ptr<packet_headergenerator_bb> sptr; + + static sptr make(const packet_header_default::sptr &header_formatter); + 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 000000000..a3db069cb --- /dev/null +++ b/gr-digital/include/digital/packet_headerparser_b.h @@ -0,0 +1,65 @@ +/* -*- 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 digital + * + * 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 message. + * + * 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/scale_tags.h b/gr-digital/include/digital/scale_tags.h new file mode 100644 index 000000000..8a9e3efba --- /dev/null +++ b/gr-digital/include/digital/scale_tags.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_DIGITAL_SCALE_TAGS_H +#define INCLUDED_DIGITAL_SCALE_TAGS_H + +#include <digital_ofdm_equalizer_base.h> // FIXME: Error without this line. No idea why. +#include <digital/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief <+description of block+> + * \ingroup block + * + */ + class DIGITAL_API scale_tags : virtual public gr_sync_block + { + public: + typedef boost::shared_ptr<scale_tags> sptr; + + /*! + * \brief Return a shared_ptr to a new instance of digital::scale_tags. + * + * To avoid accidental use of raw pointers, digital::scale_tags's + * constructor is in a private implementation + * class. digital::scale_tags::make is the public interface for + * creating new instances. + */ + static sptr make(size_t itemsize, const std::string&, float scale_factor); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_SCALE_TAGS_H */ + diff --git a/gr-digital/include/digital/tagged_stream_check.h b/gr-digital/include/digital/tagged_stream_check.h new file mode 100644 index 000000000..73b44a5bb --- /dev/null +++ b/gr-digital/include/digital/tagged_stream_check.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_TAGGED_STREAM_CHECK_H +#define INCLUDED_DIGITAL_TAGGED_STREAM_CHECK_H + +#include <digital_ofdm_equalizer_base.h> // FIXME: Error without this line. No idea why. +#include <digital/api.h> +#include <gr_sync_block.h> + + +namespace gr { + namespace digital { + + /*! + * \brief Checks a tagged stream to make sure it's valid. + * + * \description + * Produces error messages if the tags in a tagged stream aren't where + * they should be. + * + * \ingroup digital + * + */ + class DIGITAL_API tagged_stream_check : virtual public gr_sync_block + { + public: + typedef boost::shared_ptr<tagged_stream_check> sptr; + static sptr make(size_t itemsize, const std::string &lengthtagname); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_TAGGED_STREAM_CHECK_H */ + diff --git a/gr-digital/include/digital/ts_insert_zeros_cc.h b/gr-digital/include/digital/ts_insert_zeros_cc.h new file mode 100644 index 000000000..299062eb5 --- /dev/null +++ b/gr-digital/include/digital/ts_insert_zeros_cc.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_TS_INSERT_ZEROS_CC_H +#define INCLUDED_DIGITAL_TS_INSERT_ZEROS_CC_H + +#include <digital_ofdm_equalizer_base.h> // FIXME: Error without this line. No idea why. +#include <digital/api.h> +#include <gr_block.h> +#include <string> + + +namespace gr { + namespace digital { + + /*! + * \brief Inserts zeros between the packets of a tagged stream. + * + * \description + * Outputs zeros if a packet is not yet ready at the input, otherwise + * passes packets through. + * + * \ingroup digital + * + */ + class DIGITAL_API ts_insert_zeros_cc : virtual public gr_block + { + public: + typedef boost::shared_ptr<ts_insert_zeros_cc> sptr; + static sptr make(const std::string &lengthtagname); + }; + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_TS_INSERT_ZEROS_CC_H */ + diff --git a/gr-digital/include/digital_crc32_bb.h b/gr-digital/include/digital_crc32_bb.h new file mode 100644 index 000000000..efbf2d545 --- /dev/null +++ b/gr-digital/include/digital_crc32_bb.h @@ -0,0 +1,67 @@ +/* -*- 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 digital + * + * 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_ofdm_carrier_allocator_cvc.h b/gr-digital/include/digital_ofdm_carrier_allocator_cvc.h new file mode 100644 index 000000000..9052299aa --- /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 000000000..da03f9672 --- /dev/null +++ b/gr-digital/include/digital_ofdm_chanest_vcvc.h @@ -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. + */ + +#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 sync_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 normally. + * + * 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 new file mode 100644 index 000000000..563a311fa --- /dev/null +++ b/gr-digital/include/digital_ofdm_cyclic_prefixer.h @@ -0,0 +1,95 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004-2006,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. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H +#define INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H + +#include <digital/api.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; + +/*! + * \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 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_tagged_stream_block +{ + friend DIGITAL_API digital_ofdm_cyclic_prefixer_sptr + 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, 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_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + private: + 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 000000000..866539554 --- /dev/null +++ b/gr-digital/include/digital_ofdm_equalizer_base.h @@ -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. + */ + +#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 eq_blk + * + */ +class DIGITAL_API digital_ofdm_equalizer_base : public boost::enable_shared_from_this<digital_ofdm_equalizer_base> +{ + protected: + int d_fft_len; + int d_carr_offset; + + public: + digital_ofdm_equalizer_base(int fft_len); + ~digital_ofdm_equalizer_base(); + + virtual void reset() = 0; + void set_carrier_offset(int offset) { d_carr_offset = offset; }; + 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 data. + // (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 000000000..89b0b5cd6 --- /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 gr::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 eq_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 gr::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: + gr::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 000000000..4537d329f --- /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 eq_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 = 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(); + + /*! \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_sync_sc_cfb.h b/gr-digital/include/digital_ofdm_sync_sc_cfb.h new file mode 100644 index 000000000..cc728814e --- /dev/null +++ b/gr-digital/include/digital_ofdm_sync_sc_cfb.h @@ -0,0 +1,79 @@ +/* -*- 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 + */ +DIGITAL_API digital_ofdm_sync_sc_cfb_sptr +digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len); + +/*! + * \brief Schmidl & Cox synchronisation for OFDM + * \ingroup ofdm_blk + * \ingroup sync_blk + * + * 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); + digital_ofdm_sync_sc_cfb(int fft_len, int cp_len); + + public: + ~digital_ofdm_sync_sc_cfb(); + +}; + +#endif /* INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_H */ + diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index d47e7fb1f..517850604 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -26,15 +26,16 @@ include_directories( ${GR_ANALOG_INCLUDE_DIRS} ${GR_FFT_INCLUDE_DIRS} ${GR_FILTER_INCLUDE_DIRS} + ${GR_BLOCKS_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} ${VOLK_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories(${Boost_LIBRARY_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) if(ENABLE_GR_CTRLPORT) ADD_DEFINITIONS(-DGR_CTRLPORT) @@ -112,49 +113,67 @@ expand_cc(chunks_to_symbols_XX_impl bf bc sf sc if ic) ######################################################################## list(APPEND digital_sources ${generated_sources} - constellation.cc - crc32.cc - glfsr.cc - mpsk_snr_est.cc additive_scrambler_bb_impl.cc binary_slicer_fb_impl.cc clock_recovery_mm_cc_impl.cc clock_recovery_mm_ff_impl.cc cma_equalizer_cc_impl.cc - constellation_receiver_cb_impl.cc + constellation.cc constellation_decoder_cb_impl.cc + constellation_receiver_cb_impl.cc correlate_access_code_bb_impl.cc correlate_access_code_tag_bb_impl.cc costas_loop_cc_impl.cc cpmmod_bc_impl.cc + crc32.cc descrambler_bb_impl.cc diff_decoder_bb_impl.cc diff_encoder_bb_impl.cc diff_phasor_cc_impl.cc + digital_crc32_bb.cc + digital_ofdm_carrier_allocator_cvc.cc + digital_ofdm_chanest_vcvc.cc + digital_ofdm_cyclic_prefixer.cc + digital_ofdm_equalizer_base.cc + digital_ofdm_equalizer_simpledfe.cc + digital_ofdm_equalizer_static.cc + digital_ofdm_sync_sc_cfb.cc fll_band_edge_cc_impl.cc framer_sink_1_impl.cc + glfsr.cc glfsr_source_b_impl.cc glfsr_source_f_impl.cc + header_payload_demux_impl.cc kurtotic_equalizer_cc_impl.cc lms_dd_equalizer_cc_impl.cc map_bb_impl.cc mpsk_receiver_cc_impl.cc + mpsk_snr_est.cc mpsk_snr_est_cc_impl.cc ofdm_cyclic_prefixer_impl.cc ofdm_frame_acquisition_impl.cc + ofdm_frame_equalizer_vcvc_impl.cc ofdm_frame_sink_impl.cc ofdm_insert_preamble_impl.cc ofdm_mapper_bcv_impl.cc ofdm_sampler_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 packet_sink_impl.cc pfb_clock_sync_ccf_impl.cc pfb_clock_sync_fff_impl.cc pn_correlator_cc_impl.cc probe_density_b_impl.cc probe_mpsk_snr_est_c_impl.cc + scale_tags_impl.cc scrambler_bb_impl.cc - simple_framer_impl.cc simple_correlator_impl.cc + simple_framer_impl.cc + tagged_stream_check_impl.cc + ts_insert_zeros_cc_impl.cc ) #Add Windows DLL resource file if using MSVC @@ -178,13 +197,20 @@ list(APPEND digital_libs gnuradio-blocks gnuradio-analog ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-digital SHARED ${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-core gnuradio-filter gnuradio-analog) + +add_dependencies( + gnuradio-digital + digital_generated_includes + digital_generated_swigs + gnuradio-core + gnuradio-filter + gnuradio-analog + gnuradio-blocks +) diff --git a/gr-digital/lib/constellation_receiver_cb_impl.cc b/gr-digital/lib/constellation_receiver_cb_impl.cc index c3203e907..30be24aab 100644 --- a/gr-digital/lib/constellation_receiver_cb_impl.cc +++ b/gr-digital/lib/constellation_receiver_cb_impl.cc @@ -54,7 +54,7 @@ namespace gr { : gr_block("constellation_receiver_cb", gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signaturev(1, 5, iosig)), - gri_control_loop(loop_bw, fmax, fmin), + blocks::control_loop(loop_bw, fmax, fmin), d_constellation(constellation), d_current_const_point(0) { diff --git a/gr-digital/lib/constellation_receiver_cb_impl.h b/gr-digital/lib/constellation_receiver_cb_impl.h index 50946840a..763dabfde 100644 --- a/gr-digital/lib/constellation_receiver_cb_impl.h +++ b/gr-digital/lib/constellation_receiver_cb_impl.h @@ -26,13 +26,13 @@ #include <digital/constellation_receiver_cb.h> #include <gruel/attributes.h> #include <gr_complex.h> -#include <gri_control_loop.h> +#include <blocks/control_loop.h> namespace gr { namespace digital { class constellation_receiver_cb_impl - : public constellation_receiver_cb, gri_control_loop + : public constellation_receiver_cb, blocks::control_loop { public: constellation_receiver_cb_impl(constellation_sptr constell, diff --git a/gr-digital/lib/costas_loop_cc_impl.cc b/gr-digital/lib/costas_loop_cc_impl.cc index 5afabf429..fcdd45045 100644 --- a/gr-digital/lib/costas_loop_cc_impl.cc +++ b/gr-digital/lib/costas_loop_cc_impl.cc @@ -44,7 +44,7 @@ namespace gr { : gr_sync_block("costas_loop_cc", gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signature2(1, 2, sizeof(gr_complex), sizeof(float))), - gri_control_loop(loop_bw, 1.0, -1.0), + blocks::control_loop(loop_bw, 1.0, -1.0), d_order(order), d_phase_detector(NULL) { // Set up the phase detector to use based on the constellation order diff --git a/gr-digital/lib/costas_loop_cc_impl.h b/gr-digital/lib/costas_loop_cc_impl.h index 9310368b4..d9756ea2f 100644 --- a/gr-digital/lib/costas_loop_cc_impl.h +++ b/gr-digital/lib/costas_loop_cc_impl.h @@ -25,12 +25,12 @@ #define INCLUDED_DIGITAL_COSTAS_LOOP_CC_IMPL_H #include <digital/costas_loop_cc.h> -#include <gri_control_loop.h> +#include <blocks/control_loop.h> namespace gr { namespace digital { - class costas_loop_cc_impl : public costas_loop_cc, gri_control_loop + class costas_loop_cc_impl : public costas_loop_cc, blocks::control_loop { private: int d_order; diff --git a/gr-digital/lib/digital_crc32_bb.cc b/gr-digital/lib/digital_crc32_bb.cc new file mode 100644 index 000000000..40d313ba8 --- /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 = gr::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 = gr::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 000000000..e5b301330 --- /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 000000000..a48459457 --- /dev/null +++ b/gr-digital/lib/digital_ofdm_chanest_vcvc.cc @@ -0,0 +1,281 @@ +/* -*- c++ -*- */ +// vim: set sw=2: +/* 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, 1, 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] = sym[i] / d_ref_sym[i-carr_offset]; + } + } + + if (d_interpolate) { + for (int i = d_first_active_carrier + 1; i < d_last_active_carrier; i += 2) { + taps[i] = (taps[i-1] + taps[i+1]) / gr_complex(2.0, 0); + } + 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); + + 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; + this->get_tags_in_range(tags, 0, + this->nitems_read(0)+i*framesize, + this->nitems_read(0)+(i+1)*framesize); + for (unsigned t = 0; t < tags.size(); t++) { + int offset = tags[t].offset - (this->nitems_read(0) + i*framesize); + if (offset < d_n_sync_syms) { + offset = 0; + } else { + offset -= d_n_sync_syms; + } + tags[t].offset = offset + this->nitems_written(0) + i*d_n_data_syms; + this->add_item_tag(0, tags[t]); + } + + this->add_item_tag(0, this->nitems_written(0) + i*d_n_data_syms, + pmt::string_to_symbol("ofdm_sync_carr_offset"), + pmt::from_long(carr_offset)); + this->add_item_tag(0, this->nitems_written(0) + i*d_n_data_syms, + pmt::string_to_symbol("ofdm_sync_chan_taps"), + pmt::init_c32vector(d_fft_len, chan_taps)); + } + + consume_each(n_frames * framesize); + return n_frames * d_n_data_syms; +} + diff --git a/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc b/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc new file mode 100644 index 000000000..ada5742a5 --- /dev/null +++ b/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc @@ -0,0 +1,162 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifdef HAVE_CONFIG_H +#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, + int rolloff_len, + const std::string &len_tag_key) +{ + return gnuradio::get_initial_sptr(new digital_ofdm_cyclic_prefixer (input_size, + output_size, + rolloff_len, + len_tag_key)); +} + +digital_ofdm_cyclic_prefixer::digital_ofdm_cyclic_prefixer (size_t input_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_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]; + int symbols_to_read = 0; + + // 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; + } + + // 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; + } + + // 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 000000000..b4fa5df87 --- /dev/null +++ b/gr-digital/lib/digital_ofdm_equalizer_base.cc @@ -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. + */ + +#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), + d_carr_offset(0) +{ +} + + +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(symbols_skipped), + 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_symbols_skipped; +} + + +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 000000000..c6a05b9da --- /dev/null +++ b/gr-digital/lib/digital_ofdm_equalizer_simpledfe.cc @@ -0,0 +1,101 @@ +/* -*- 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 gr::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 gr::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.size() && d_pilot_carriers[d_pilot_carr_set][k-d_carr_offset]) { + 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-d_carr_offset]; + frame[i*d_fft_len+k] = d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset]; + } 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; + } + } + 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 000000000..66903fa90 --- /dev/null +++ b/gr-digital/lib/digital_ofdm_equalizer_static.cc @@ -0,0 +1,90 @@ +/* -*- 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" + +#include <iostream> + +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.size() && d_pilot_carriers[d_pilot_carr_set][k-d_carr_offset]) { + d_channel_state[k] = frame[i*d_fft_len + k] / d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset]; + frame[i*d_fft_len+k] = d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset]; + } 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 000000000..dbb8571c2 --- /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 <analog/plateau_detector_fb.h> +#include <blocks/complex_to_arg.h> +#include <blocks/complex_to_mag_squared.h> +#include <blocks/conjugate_cc.h> +#include <blocks/delay.h> +#include <blocks/divide_ff.h> +#include <blocks/multiply_cc.h> +#include <blocks/multiply_ff.h> +#include <blocks/sample_and_hold_ff.h> +#include <filter/fir_filter_ccf.h> +#include <filter/fir_filter_fff.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) +{ + return gnuradio::get_initial_sptr (new digital_ofdm_sync_sc_cfb(fft_len, cp_len)); +} + + +digital_ofdm_sync_sc_cfb::digital_ofdm_sync_sc_cfb (int fft_len, int cp_len) + : 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::blocks::delay::sptr delay(gr::blocks::delay::make(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, 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::blocks::sample_and_hold_ff::sptr sample_and_hold(gr::blocks::sample_and_hold_ff::make()); + + gr::analog::plateau_detector_fb::sptr plateau_detector(gr::analog::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/fll_band_edge_cc_impl.cc b/gr-digital/lib/fll_band_edge_cc_impl.cc index 980d3ab46..c438b813f 100644 --- a/gr-digital/lib/fll_band_edge_cc_impl.cc +++ b/gr-digital/lib/fll_band_edge_cc_impl.cc @@ -58,25 +58,25 @@ namespace gr { : gr_sync_block("fll_band_edge_cc", gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signaturev(1, 4, iosig)), - gri_control_loop(bandwidth, M_TWOPI*(2.0/samps_per_sym), - -M_TWOPI*(2.0/samps_per_sym)), + blocks::control_loop(bandwidth, M_TWOPI*(2.0/samps_per_sym), + -M_TWOPI*(2.0/samps_per_sym)), d_updated(false) { // Initialize samples per symbol if(samps_per_sym <= 0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid number of sps. Must be > 0."); + throw std::out_of_range("fll_band_edge_cc: invalid number of sps. Must be > 0."); } d_sps = samps_per_sym; // Initialize rolloff factor if(rolloff < 0 || rolloff > 1.0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); + throw std::out_of_range("fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); } d_rolloff = rolloff; // Initialize filter length if(filter_size <= 0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid filter size. Must be > 0."); + throw std::out_of_range("fll_band_edge_cc: invalid filter size. Must be > 0."); } d_filter_size = filter_size; @@ -97,7 +97,7 @@ namespace gr { fll_band_edge_cc_impl::set_samples_per_symbol(float sps) { if(sps <= 0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid number of sps. Must be > 0."); + throw std::out_of_range("fll_band_edge_cc: invalid number of sps. Must be > 0."); } d_sps = sps; design_filter(d_sps, d_rolloff, d_filter_size); @@ -107,7 +107,7 @@ namespace gr { fll_band_edge_cc_impl::set_rolloff(float rolloff) { if(rolloff < 0 || rolloff > 1.0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); + throw std::out_of_range("fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); } d_rolloff = rolloff; design_filter(d_sps, d_rolloff, d_filter_size); @@ -117,7 +117,7 @@ namespace gr { fll_band_edge_cc_impl::set_filter_size(int filter_size) { if(filter_size <= 0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid filter size. Must be > 0."); + throw std::out_of_range("fll_band_edge_cc: invalid filter size. Must be > 0."); } d_filter_size = filter_size; design_filter(d_sps, d_rolloff, d_filter_size); diff --git a/gr-digital/lib/fll_band_edge_cc_impl.h b/gr-digital/lib/fll_band_edge_cc_impl.h index 55e338b38..9eb3e6e7a 100644 --- a/gr-digital/lib/fll_band_edge_cc_impl.h +++ b/gr-digital/lib/fll_band_edge_cc_impl.h @@ -24,7 +24,7 @@ #define INCLUDED_DIGITAL_FLL_BAND_EDGE_CC_IMPL_H #include <digital/fll_band_edge_cc.h> -#include <gri_control_loop.h> +#include <blocks/control_loop.h> #include <filter/fir_filter.h> namespace gr { 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 000000000..a2e81c5b8 --- /dev/null +++ b/gr-digital/lib/header_payload_demux_impl.cc @@ -0,0 +1,292 @@ +/* -*- 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::string_to_symbol(length_tag_key)), + d_trigger_tag_key(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; + + while (nread < noutput_items && !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()) { + 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::is_integer(msg)) { + d_remaining_symbols = pmt::to_long(msg); + add_item_tag(1, nitems_written(1), d_len_tag_key, msg); + } else if (pmt::is_dict(msg)) { + pmt::pmt_t dict_items(pmt::dict_items(msg)); + while (!pmt::is_null(dict_items)) { + pmt::pmt_t this_item(pmt::car(dict_items)); + add_item_tag(1, nitems_written(1), pmt::car(this_item), pmt::cdr(this_item)); + if (pmt::equal(pmt::car(this_item), d_len_tag_key)) { + d_remaining_symbols = pmt::to_long(pmt::cdr(this_item)); + } + dict_items = pmt::cdr(dict_items); + } + if (d_remaining_symbols == -1) { + throw std::runtime_error("no length tag passed from header data"); + } + } else if (pmt::is_null(msg)) { // Blocking call was interrupted + 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 000000000..ceab9a862 --- /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/mpsk_receiver_cc_impl.cc b/gr-digital/lib/mpsk_receiver_cc_impl.cc index 31355c565..ea11b7cda 100644 --- a/gr-digital/lib/mpsk_receiver_cc_impl.cc +++ b/gr-digital/lib/mpsk_receiver_cc_impl.cc @@ -63,7 +63,7 @@ namespace gr { : gr_block("mpsk_receiver_cc", gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signature(1, 1, sizeof(gr_complex))), - gri_control_loop(loop_bw, fmax, fmin), + blocks::control_loop(loop_bw, fmax, fmin), d_M(M), d_theta(theta), d_current_const_point(0), d_mu(mu), d_gain_mu(gain_mu), d_gain_omega(gain_omega), diff --git a/gr-digital/lib/mpsk_receiver_cc_impl.h b/gr-digital/lib/mpsk_receiver_cc_impl.h index 3db6fa8b6..099dd424a 100644 --- a/gr-digital/lib/mpsk_receiver_cc_impl.h +++ b/gr-digital/lib/mpsk_receiver_cc_impl.h @@ -25,7 +25,7 @@ #include <digital/mpsk_receiver_cc.h> #include <gruel/attributes.h> -#include <gri_control_loop.h> +#include <blocks/control_loop.h> #include <gr_complex.h> #include <fstream> #include <filter/mmse_fir_interpolator_cc.h> @@ -34,7 +34,7 @@ namespace gr { namespace digital { class mpsk_receiver_cc_impl - : public mpsk_receiver_cc, public gri_control_loop + : public mpsk_receiver_cc, public blocks::control_loop { public: mpsk_receiver_cc_impl(unsigned int M, float theta, 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 000000000..49235db5b --- /dev/null +++ b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc @@ -0,0 +1,89 @@ +/* -*- 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_frame_equalizer_vcvc_impl.h" + +namespace gr { + namespace digital { + + ofdm_frame_equalizer_vcvc::sptr + ofdm_frame_equalizer_vcvc::make(digital_ofdm_equalizer_base_sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state) + { + return gnuradio::get_initial_sptr (new ofdm_frame_equalizer_vcvc_impl(equalizer, len_tag_key, propagate_channel_state)); + } + + ofdm_frame_equalizer_vcvc_impl::ofdm_frame_equalizer_vcvc_impl(digital_ofdm_equalizer_base_sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state) + : 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_eq(equalizer), + d_propagate_channel_state(propagate_channel_state), + d_channel_state(equalizer->fft_len(), gr_complex(1, 0)) + {} + + ofdm_frame_equalizer_vcvc_impl::~ofdm_frame_equalizer_vcvc_impl() + { + } + + + 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; + + 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::symbol_to_string(tags[i].key) == "ofdm_sync_chan_taps") { + d_channel_state = pmt::c32vector_elements(tags[i].value); + remove_item_tag(0, tags[i]); + } + } + + memcpy((void *) out, (void *) in, sizeof(gr_complex) * d_fft_len * ninput_items[0]); + d_eq->reset(); + d_eq->set_carrier_offset(carrier_offset); + d_eq->equalize(out, ninput_items[0], d_channel_state); + d_eq->get_channel_state(d_channel_state); + if (d_propagate_channel_state) { + add_item_tag(0, nitems_written(0), + pmt::string_to_symbol("ofdm_sync_chan_taps"), + pmt::init_c32vector(d_fft_len, d_channel_state)); + } + + return ninput_items[0]; + } + + } /* 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 000000000..cba2d513e --- /dev/null +++ b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h @@ -0,0 +1,57 @@ +/* -*- 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; + digital_ofdm_equalizer_base_sptr d_eq; + bool d_propagate_channel_state; + std::vector<gr_complex> d_channel_state; + + protected: + // This aren't really necessary, so let's override them with nuthin' + void remove_length_tags(const std::vector<std::vector<gr_tag_t> > &tags) {}; + void update_length_tags(int n_produced, int n_ports) {}; + + public: + ofdm_frame_equalizer_vcvc_impl(digital_ofdm_equalizer_base_sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state); + ~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 000000000..9c41daae7 --- /dev/null +++ b/gr-digital/lib/ofdm_serializer_vcc_impl.cc @@ -0,0 +1,205 @@ +/* -*- 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, + 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, 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, + 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, + 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, + 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::string_to_symbol(packet_len_tag_key)), + d_out_len_tag_key(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_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) % 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::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 (pmt::symbol_to_string(tags[i].key) == "ofdm_sync_carr_offset") { + carr_offset = pmt::to_long(tags[i].value); + } + if (tags[i].key == d_packet_len_tag_key) { + packet_length = 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[i].key, + tags[i].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 000000000..ef2f1c83b --- /dev/null +++ b/gr-digital/lib/ofdm_serializer_vcc_impl.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_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 + 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, + 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 000000000..890698533 --- /dev/null +++ b/gr-digital/lib/packet_header_default.cc @@ -0,0 +1,128 @@ +/* -*- 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_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::string_to_symbol(len_tag_key)), + d_num_tag_key(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::from_long(header_len); + tags.push_back(tag); + if (k >= d_header_len) { + return true; + } + 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::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 000000000..ed3d3586c --- /dev/null +++ b/gr-digital/lib/packet_header_ofdm.cc @@ -0,0 +1,115 @@ +/* -*- 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_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_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_sym) + : packet_header_default( + _get_header_len_from_occupied_carriers(occupied_carriers, n_syms), + len_tag_key, + num_tag_key, + bits_per_sym), + d_frame_len_tag_key(pmt::string_to_symbol(frame_len_tag_key)), + d_occupied_carriers(occupied_carriers), + d_syms_per_set(0) + { + 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 OFDM symbols + for (unsigned i = 0; i < tags.size(); i++) { + if (pmt::equal(tags[i].key, d_len_tag_key)) { + packet_len = pmt::to_long(tags[i].value); + break; + } + } + + 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::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 000000000..bcfaf6b63 --- /dev/null +++ b/gr-digital/lib/packet_headergenerator_bb_impl.cc @@ -0,0 +1,90 @@ +/* -*- 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 "packet_headergenerator_bb_impl.h" + +namespace gr { + namespace digital { + + packet_headergenerator_bb::sptr + packet_headergenerator_bb::make(const packet_header_default::sptr &header_formatter) + { + return gnuradio::get_initial_sptr (new packet_headergenerator_bb_impl(header_formatter)); + } + + + 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)); + } + + + packet_headergenerator_bb_impl::packet_headergenerator_bb_impl( + const gr::digital::packet_header_default::sptr &header_formatter + ) + : gr_tagged_stream_block("packet_headergenerator_bb_impl", + gr_make_io_signature(1, 1, sizeof (char)), + gr_make_io_signature(1, 1, sizeof (char)), + pmt::symbol_to_string(header_formatter->len_tag_key())), + d_formatter(header_formatter), + d_input_size(1), + d_header_len(header_formatter->header_len()), + d_len_tag_value(pmt::from_long(d_header_len)) + { + set_output_multiple(d_header_len); + // This is the worst case rate, because we don't know the true value, of course + set_relative_rate(d_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)) { + throw std::runtime_error("header formatter returned false."); + } + + return d_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 000000000..7d2494cf8 --- /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; + int d_input_size; + int d_header_len; + pmt::pmt_t d_len_tag_value; + + public: + packet_headergenerator_bb_impl(const packet_header_default::sptr &header_formatter); + ~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_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 000000000..825cfa3d8 --- /dev/null +++ b/gr-digital/lib/packet_headerparser_b_impl.cc @@ -0,0 +1,90 @@ +/* -*- 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 "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; + if (!d_header_formatter->header_parser(in, tags)) { + message_port_pub(msg_port_id, pmt::PMT_F); + } else { + pmt::pmt_t dict(pmt::make_dict()); + for (unsigned i = 0; i < tags.size(); i++) { + 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 000000000..a7ded1143 --- /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/lib/scale_tags_impl.cc b/gr-digital/lib/scale_tags_impl.cc new file mode 100644 index 000000000..33d100238 --- /dev/null +++ b/gr-digital/lib/scale_tags_impl.cc @@ -0,0 +1,84 @@ +/* -*- 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 "scale_tags_impl.h" + +namespace gr { + namespace digital { + + scale_tags::sptr + scale_tags::make(size_t itemsize, const std::string& tagname, float scale_factor) + { + return gnuradio::get_initial_sptr (new scale_tags_impl(itemsize, tagname, scale_factor)); + } + + /* + * The private constructor + */ + scale_tags_impl::scale_tags_impl(size_t itemsize, const std::string& tagname, float scale_factor) + : gr_sync_block("scale_tags", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), + d_tagname(tagname), + d_scale_factor(scale_factor) + { + set_tag_propagation_policy(TPP_DONT); + } + + /* + * Our virtual destructor. + */ + scale_tags_impl::~scale_tags_impl() + { + } + + int + scale_tags_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]; + std::vector<gr_tag_t> tags; + this->get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+noutput_items); + //const size_t ninput_items = noutput_items; //assumption for sync block, this can change + for (unsigned int j = 0; j < tags.size(); j++) { + long value = pmt::to_long(tags[j].value); + if (pmt::symbol_to_string(tags[j].key) == d_tagname) { + value = long(value*d_scale_factor); + } + this->add_item_tag(0, tags[j].offset, tags[j].key, pmt::from_long(value)); + } + memcpy((void *) out, (const void *) in, noutput_items*d_itemsize); + + // Tell runtime system how many output items we produced. + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/scale_tags_impl.h b/gr-digital/lib/scale_tags_impl.h new file mode 100644 index 000000000..667cda36e --- /dev/null +++ b/gr-digital/lib/scale_tags_impl.h @@ -0,0 +1,51 @@ +/* -*- 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_SCALE_TAGS_IMPL_H +#define INCLUDED_DIGITAL_SCALE_TAGS_IMPL_H + +#include <digital/scale_tags.h> + +namespace gr { + namespace digital { + + class scale_tags_impl : public scale_tags + { + private: + size_t d_itemsize; + std::string d_tagname; + float d_scale_factor; + + public: + scale_tags_impl(size_t itemsize, const std::string&, float scale_factor); + ~scale_tags_impl(); + + // Where all the action really happens + 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_SCALE_TAGS_IMPL_H */ + diff --git a/gr-digital/lib/tagged_stream_check_impl.cc b/gr-digital/lib/tagged_stream_check_impl.cc new file mode 100644 index 000000000..625645804 --- /dev/null +++ b/gr-digital/lib/tagged_stream_check_impl.cc @@ -0,0 +1,112 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 <+YOU OR YOUR COMPANY+>. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 software; 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_check_impl.h" +#include <iostream> +#include <vector> +#include <algorithm> +#include <string> +#include <sstream> + +namespace gr { + namespace digital { + + bool sort_tag_by_offset(gr_tag_t const & L, gr_tag_t const & R) { + return L.offset < R.offset; + } + + tagged_stream_check::sptr + tagged_stream_check::make(size_t itemsize, const std::string &lengthtagname) + { + return gnuradio::get_initial_sptr (new tagged_stream_check_impl(itemsize, lengthtagname)); + } + + /* + * The private constructor + */ + tagged_stream_check_impl::tagged_stream_check_impl(size_t itemsize, const std::string &lengthtagname) + : gr_sync_block("tagged_stream_check", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(1, 1, itemsize)), + d_lengthtagname(lengthtagname), d_itemsize(itemsize) + { + d_expected_offset = 0; + d_last_offset = 0; + } + + /* + * Our virtual destructor. + */ + tagged_stream_check_impl::~tagged_stream_check_impl() + { + } + + int + tagged_stream_check_impl::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + char *out = (char *) output_items[0]; + const char *in = (const char*) input_items[0]; + // Find all the length tags + std::vector<gr_tag_t> tags; + std::vector<gr_tag_t> lengthtags; + this->get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+noutput_items); + for (unsigned int j = 0; j < tags.size(); j++) { + if (pmt::symbol_to_string(tags[j].key) == d_lengthtagname) { + lengthtags.push_back(tags[j]); + } + } + // If there are no lengthtags then check that we weren't expecting one. + if (lengthtags.size() == 0) { + if (d_expected_offset < nitems_read(0)+noutput_items) { + std::ostringstream ss; + ss << "ERROR: "<<this->unique_id()<<" Expected a lengthtag at offset="<<d_expected_offset<<" but didn't find it"; + std::cout << ss.str() << std::endl; + } + } + // Sort them and make sure the lengthtags are in the proper places. + sort(lengthtags.begin(), lengthtags.end(), sort_tag_by_offset); + for (unsigned int j = 0; j < lengthtags.size(); j++) { + if (lengthtags[j].offset != d_expected_offset) { + std::cout << "****************************" << std::endl; + std::cout << "ERROR: "<<this->unique_id()<<" offset: " << lengthtags[j].offset << " The last tag had a length of " << d_expected_offset - d_last_offset << " but we got a length of " << lengthtags[j].offset - d_last_offset << std::endl; + } + long packet_length = pmt::to_long(lengthtags[j].value); + std::cout << "INFO: "<<this->unique_id()<<" offset: " << lengthtags[j].offset << std::endl; + d_expected_offset = lengthtags[j].offset + packet_length; + d_last_offset = lengthtags[j].offset; + } + memcpy((void *) out, (const void *) in, noutput_items*d_itemsize); + std::ostringstream ss; + ss << "checker: Produced data from " << nitems_read(0) << " to " << nitems_read(0) + noutput_items; + std::cout << ss.str() << std::endl; + return noutput_items; + } + + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/tagged_stream_check_impl.h b/gr-digital/lib/tagged_stream_check_impl.h new file mode 100644 index 000000000..0b0dfe5b1 --- /dev/null +++ b/gr-digital/lib/tagged_stream_check_impl.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 <+YOU OR YOUR COMPANY+>. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_DIGITAL_TAGGED_STREAM_CHECK_IMPL_H +#define INCLUDED_DIGITAL_TAGGED_STREAM_CHECK_IMPL_H + +#include <digital/tagged_stream_check.h> +#include <vector> + +namespace gr { + namespace digital { + + class tagged_stream_check_impl : public tagged_stream_check + { + private: + const std::string d_lengthtagname; + size_t d_itemsize; + uint64_t d_expected_offset; + uint64_t d_last_offset; + + public: + tagged_stream_check_impl(size_t itemsize, const std::string &lengthtagname); + ~tagged_stream_check_impl(); + + // Where all the action really happens + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + }; + + } // namespace digital +} // namespace gr + +#endif + diff --git a/gr-digital/lib/ts_insert_zeros_cc_impl.cc b/gr-digital/lib/ts_insert_zeros_cc_impl.cc new file mode 100644 index 000000000..1a78851c1 --- /dev/null +++ b/gr-digital/lib/ts_insert_zeros_cc_impl.cc @@ -0,0 +1,130 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 <+YOU OR YOUR COMPANY+>. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 software; 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 "ts_insert_zeros_cc_impl.h" +#include <iostream> +#include <vector> +#include <algorithm> +#include <string> +#include <sstream> + +namespace gr { + namespace digital { + + ts_insert_zeros_cc::sptr + ts_insert_zeros_cc::make(const std::string &lengthtagname) + { + return gnuradio::get_initial_sptr (new ts_insert_zeros_cc_impl(lengthtagname)); + } + + /* + * The private constructor + */ + ts_insert_zeros_cc_impl::ts_insert_zeros_cc_impl(const std::string &lengthtagname) + : gr_block("ts_insert_zeros_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex))), + d_lengthtagname(lengthtagname) + { + } + + /* + * Our virtual destructor. + */ + ts_insert_zeros_cc_impl::~ts_insert_zeros_cc_impl() + { + } + + void + ts_insert_zeros_cc_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) + { + ninput_items_required[0] = 0; + } + + int + ts_insert_zeros_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 + ) + { + gr_complex *out = (gr_complex *) output_items[0]; + const gr_complex*in = (const gr_complex*) input_items[0]; + + if (ninput_items[0]) { + // Check if we have an entire packet. + long packet_length = 0; + std::vector<gr_tag_t> tags; + // Get any tags associated with the first item on the input. + this->get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+1); + for (unsigned int j = 0; j < tags.size(); j++) { + if (pmt::symbol_to_string(tags[j].key) == d_lengthtagname) { + packet_length = pmt::to_long(tags[j].value); + } + } + if (!packet_length) { + throw std::runtime_error("no tag"); + } + if (ninput_items[0] < packet_length ) { + // We don't have enough input to produce a packet. + // Produces zeros instead. + } else { + // We have enough input. + if (noutput_items < packet_length) { + // But we don't have enough output space. + // We don't want to produce zeros, so return. + set_output_multiple(packet_length); + return 0; + } else { + // And we have enough output space. + // Produce the packet. + std::vector<gr_tag_t> tags; + this->get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+packet_length); + for (unsigned int j = 0; j < tags.size(); j++) { + const uint64_t offset = tags[j].offset - nitems_read(0) + nitems_written(0); + this->add_item_tag(0, offset, tags[j].key, tags[j].value); + } + if (noutput_items < packet_length) { + throw std::runtime_error("Not enough room in the output buffer."); + } + memcpy(out, in, packet_length*sizeof(gr_complex)); + consume(0, packet_length); + return packet_length; + } + } + } + // We're just producing zeros. + // Either we have no input data, or not an entire packet yet. + for (int i=0; i<noutput_items; i++) { + out[i] = 0; + } + return noutput_items; + } + + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/ts_insert_zeros_cc_impl.h b/gr-digital/lib/ts_insert_zeros_cc_impl.h new file mode 100644 index 000000000..4bdfbfe9f --- /dev/null +++ b/gr-digital/lib/ts_insert_zeros_cc_impl.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 <+YOU OR YOUR COMPANY+>. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_DIGITAL_TS_INSERT_ZEROS_CC_IMPL_H +#define INCLUDED_DIGITAL_TS_INSERT_ZEROS_CC_IMPL_H + +#include <digital/ts_insert_zeros_cc.h> +#include <vector> + +namespace gr { + namespace digital { + + class ts_insert_zeros_cc_impl : public ts_insert_zeros_cc + { + private: + const std::string d_lengthtagname; + + public: + ts_insert_zeros_cc_impl(const std::string &lengthtagname); + ~ts_insert_zeros_cc_impl(); + + 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 + ); + }; + + } // namespace digital +} // namespace gr + +#endif + diff --git a/gr-digital/python/CMakeLists.txt b/gr-digital/python/CMakeLists.txt index 7f35e3c2b..4dfaac362 100644 --- a/gr-digital/python/CMakeLists.txt +++ b/gr-digital/python/CMakeLists.txt @@ -28,6 +28,7 @@ GR_PYTHON_INSTALL( bpsk.py cpm.py crc.py + fftshift.py generic_mod_demod.py gmsk.py gfsk.py @@ -39,6 +40,7 @@ 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 @@ -55,6 +57,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" ) @@ -73,8 +76,10 @@ list(APPEND GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/gr-analog/swig ${CMAKE_BINARY_DIR}/gr-blocks/python ${CMAKE_BINARY_DIR}/gr-blocks/swig + ${CMAKE_BINARY_DIR}/gr-fft/python + ${CMAKE_BINARY_DIR}/gr-fft/swig ) -list(APPEND GR_TEST_TARGET_DEPS gnuradio-digital gnuradio-filter gnuradio-fft gnuradio-analog) +list(APPEND GR_TEST_TARGET_DEPS gnuradio-digital gnuradio-filter gnuradio-fft gnuradio-analog gnuradio-blocks) include(GrTest) file(GLOB py_qa_test_files "qa_*.py") diff --git a/gr-digital/python/__init__.py b/gr-digital/python/__init__.py index 962f21032..28b74261f 100644 --- a/gr-digital/python/__init__.py +++ b/gr-digital/python/__init__.py @@ -42,6 +42,8 @@ from ofdm_sync_fixed import * from ofdm_sync_ml import * from ofdm_sync_pnac import * from ofdm_sync_pn import * +from fftshift import fftshift, ifftshift +from ofdm_txrx import ofdm_tx, ofdm_rx import packet_utils import ofdm_packet_utils diff --git a/gr-digital/python/cpm.py b/gr-digital/python/cpm.py index a9915ba91..b27fb098f 100644 --- a/gr-digital/python/cpm.py +++ b/gr-digital/python/cpm.py @@ -26,6 +26,7 @@ from gnuradio import gr, filter from gnuradio import analog +from gnuradio import blocks from math import pi import numpy @@ -195,13 +196,13 @@ class cpm_mod(gr.hier_block2): def _setup_logging(self): print "Modulation logging turned on." self.connect(self.B2s, - gr.file_sink(gr.sizeof_float, "symbols.dat")) + blocks.file_sink(gr.sizeof_float, "symbols.dat")) self.connect(self.pam, - gr.file_sink(gr.sizeof_float, "pam.dat")) + blocks.file_sink(gr.sizeof_float, "pam.dat")) self.connect(self.filter, - gr.file_sink(gr.sizeof_float, "filter.dat")) + blocks.file_sink(gr.sizeof_float, "filter.dat")) self.connect(self.fmmod, - gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) + blocks.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) def add_options(parser): diff --git a/gr-digital/python/fftshift.py b/gr-digital/python/fftshift.py new file mode 100644 index 000000000..c8c7c7f14 --- /dev/null +++ b/gr-digital/python/fftshift.py @@ -0,0 +1,31 @@ +# +# 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. +# + +# Aliases for fftpack.(i)fftshift() + +from scipy import fftpack + +def fftshift(x): + return fftpack.fftshift(x) + +def ifftshift(x): + return fftpack.ifftshift(x) + diff --git a/gr-digital/python/generic_mod_demod.py b/gr-digital/python/generic_mod_demod.py index f5b208476..b812fe1c3 100644 --- a/gr-digital/python/generic_mod_demod.py +++ b/gr-digital/python/generic_mod_demod.py @@ -198,17 +198,17 @@ class generic_mod(gr.hier_block2): def _setup_logging(self): print "Modulation logging turned on." self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.8b")) + blocks.file_sink(gr.sizeof_char, "tx_bytes2chunks.8b")) if self.pre_diff_code: self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "tx_symbol_mapper.8b")) + blocks.file_sink(gr.sizeof_char, "tx_symbol_mapper.8b")) if self._differential: self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "tx_diffenc.8b")) + blocks.file_sink(gr.sizeof_char, "tx_diffenc.8b")) self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.32fc")) + blocks.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.32fc")) self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.32fc")) + blocks.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.32fc")) # ///////////////////////////////////////////////////////////////////////////// @@ -338,39 +338,39 @@ class generic_demod(gr.hier_block2): def _setup_logging(self): print "Modulation logging turned on." self.connect(self.agc, - gr.file_sink(gr.sizeof_gr_complex, "rx_agc.32fc")) + blocks.file_sink(gr.sizeof_gr_complex, "rx_agc.32fc")) self.connect((self.freq_recov, 0), - gr.file_sink(gr.sizeof_gr_complex, "rx_freq_recov.32fc")) + blocks.file_sink(gr.sizeof_gr_complex, "rx_freq_recov.32fc")) self.connect((self.freq_recov, 1), - gr.file_sink(gr.sizeof_float, "rx_freq_recov_freq.32f")) + blocks.file_sink(gr.sizeof_float, "rx_freq_recov_freq.32f")) self.connect((self.freq_recov, 2), - gr.file_sink(gr.sizeof_float, "rx_freq_recov_phase.32f")) + blocks.file_sink(gr.sizeof_float, "rx_freq_recov_phase.32f")) self.connect((self.freq_recov, 3), - gr.file_sink(gr.sizeof_float, "rx_freq_recov_error.32f")) + blocks.file_sink(gr.sizeof_float, "rx_freq_recov_error.32f")) self.connect((self.time_recov, 0), - gr.file_sink(gr.sizeof_gr_complex, "rx_time_recov.32fc")) + blocks.file_sink(gr.sizeof_gr_complex, "rx_time_recov.32fc")) self.connect((self.time_recov, 1), - gr.file_sink(gr.sizeof_float, "rx_time_recov_error.32f")) + blocks.file_sink(gr.sizeof_float, "rx_time_recov_error.32f")) self.connect((self.time_recov, 2), - gr.file_sink(gr.sizeof_float, "rx_time_recov_rate.32f")) + blocks.file_sink(gr.sizeof_float, "rx_time_recov_rate.32f")) self.connect((self.time_recov, 3), - gr.file_sink(gr.sizeof_float, "rx_time_recov_phase.32f")) + blocks.file_sink(gr.sizeof_float, "rx_time_recov_phase.32f")) self.connect((self.receiver, 0), - gr.file_sink(gr.sizeof_char, "rx_receiver.8b")) + blocks.file_sink(gr.sizeof_char, "rx_receiver.8b")) self.connect((self.receiver, 1), - gr.file_sink(gr.sizeof_float, "rx_receiver_error.32f")) + blocks.file_sink(gr.sizeof_float, "rx_receiver_error.32f")) self.connect((self.receiver, 2), - gr.file_sink(gr.sizeof_float, "rx_receiver_phase.32f")) + blocks.file_sink(gr.sizeof_float, "rx_receiver_phase.32f")) self.connect((self.receiver, 3), - gr.file_sink(gr.sizeof_float, "rx_receiver_freq.32f")) + blocks.file_sink(gr.sizeof_float, "rx_receiver_freq.32f")) if self._differential: self.connect(self.diffdec, - gr.file_sink(gr.sizeof_char, "rx_diffdec.8b")) + blocks.file_sink(gr.sizeof_char, "rx_diffdec.8b")) if self.pre_diff_code: self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "rx_symbol_mapper.8b")) + blocks.file_sink(gr.sizeof_char, "rx_symbol_mapper.8b")) self.connect(self.unpack, - gr.file_sink(gr.sizeof_char, "rx_unpack.8b")) + blocks.file_sink(gr.sizeof_char, "rx_unpack.8b")) def add_options(parser): """ diff --git a/gr-digital/python/gfsk.py b/gr-digital/python/gfsk.py index e4aeef8ef..54c94b88f 100644 --- a/gr-digital/python/gfsk.py +++ b/gr-digital/python/gfsk.py @@ -146,11 +146,11 @@ class gfsk_mod(gr.hier_block2): def _setup_logging(self): print "Modulation logging turned on." self.connect(self.nrz, - gr.file_sink(gr.sizeof_float, "nrz.dat")) + blocks.file_sink(gr.sizeof_float, "nrz.dat")) self.connect(self.gaussian_filter, - gr.file_sink(gr.sizeof_float, "gaussian_filter.dat")) + blocks.file_sink(gr.sizeof_float, "gaussian_filter.dat")) self.connect(self.fmmod, - gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) + blocks.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) def add_options(parser): @@ -272,11 +272,11 @@ class gfsk_demod(gr.hier_block2): def _setup_logging(self): print "Demodulation logging turned on." self.connect(self.fmdemod, - gr.file_sink(gr.sizeof_float, "fmdemod.dat")) + blocks.file_sink(gr.sizeof_float, "fmdemod.dat")) self.connect(self.clock_recovery, - gr.file_sink(gr.sizeof_float, "clock_recovery.dat")) + blocks.file_sink(gr.sizeof_float, "clock_recovery.dat")) self.connect(self.slicer, - gr.file_sink(gr.sizeof_char, "slicer.dat")) + blocks.file_sink(gr.sizeof_char, "slicer.dat")) def add_options(parser): """ diff --git a/gr-digital/python/gmsk.py b/gr-digital/python/gmsk.py index a90e49a52..055fc6002 100644 --- a/gr-digital/python/gmsk.py +++ b/gr-digital/python/gmsk.py @@ -142,11 +142,11 @@ class gmsk_mod(gr.hier_block2): def _setup_logging(self): print "Modulation logging turned on." self.connect(self.nrz, - gr.file_sink(gr.sizeof_float, "nrz.dat")) + blocks.file_sink(gr.sizeof_float, "nrz.dat")) self.connect(self.gaussian_filter, - gr.file_sink(gr.sizeof_float, "gaussian_filter.dat")) + blocks.file_sink(gr.sizeof_float, "gaussian_filter.dat")) self.connect(self.fmmod, - gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) + blocks.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) def add_options(parser): @@ -262,11 +262,11 @@ class gmsk_demod(gr.hier_block2): def _setup_logging(self): print "Demodulation logging turned on." self.connect(self.fmdemod, - gr.file_sink(gr.sizeof_float, "fmdemod.dat")) + blocks.file_sink(gr.sizeof_float, "fmdemod.dat")) self.connect(self.clock_recovery, - gr.file_sink(gr.sizeof_float, "clock_recovery.dat")) + blocks.file_sink(gr.sizeof_float, "clock_recovery.dat")) self.connect(self.slicer, - gr.file_sink(gr.sizeof_char, "slicer.dat")) + blocks.file_sink(gr.sizeof_char, "slicer.dat")) def add_options(parser): """ diff --git a/gr-digital/python/ofdm.py b/gr-digital/python/ofdm.py index 5bbe111f3..bf129675a 100644 --- a/gr-digital/python/ofdm.py +++ b/gr-digital/python/ofdm.py @@ -118,13 +118,13 @@ class ofdm_mod(gr.hier_block2): self._print_verbage() if options.log: - self.connect(self._pkt_input, gr.file_sink(gr.sizeof_gr_complex*options.fft_length, + self.connect(self._pkt_input, blocks.file_sink(gr.sizeof_gr_complex*options.fft_length, "ofdm_mapper_c.dat")) - self.connect(self.preambles, gr.file_sink(gr.sizeof_gr_complex*options.fft_length, + self.connect(self.preambles, blocks.file_sink(gr.sizeof_gr_complex*options.fft_length, "ofdm_preambles.dat")) - self.connect(self.ifft, gr.file_sink(gr.sizeof_gr_complex*options.fft_length, + self.connect(self.ifft, blocks.file_sink(gr.sizeof_gr_complex*options.fft_length, "ofdm_ifft_c.dat")) - self.connect(self.cp_adder, gr.file_sink(gr.sizeof_gr_complex, + self.connect(self.cp_adder, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_cp_adder_c.dat")) def send_pkt(self, payload='', eof=False): @@ -256,7 +256,7 @@ class ofdm_demod(gr.hier_block2): if options.log: self.connect(self.ofdm_demod, - gr.file_sink(gr.sizeof_gr_complex*self._occupied_tones, + blocks.file_sink(gr.sizeof_gr_complex*self._occupied_tones, "ofdm_frame_sink_c.dat")) else: self.connect(self.ofdm_demod, diff --git a/gr-digital/python/ofdm_receiver.py b/gr-digital/python/ofdm_receiver.py index f4fc5f5ba..4fbf76251 100644 --- a/gr-digital/python/ofdm_receiver.py +++ b/gr-digital/python/ofdm_receiver.py @@ -144,11 +144,11 @@ class ofdm_receiver(gr.hier_block2): self.connect((self.ofdm_frame_acq,1), (self,1)) # frame and symbol timing, and equalization if logging: - self.connect(self.chan_filt, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-chan_filt_c.dat")) - self.connect(self.fft_demod, gr.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-fft_out_c.dat")) + self.connect(self.chan_filt, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-chan_filt_c.dat")) + self.connect(self.fft_demod, blocks.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-fft_out_c.dat")) self.connect(self.ofdm_frame_acq, - gr.file_sink(gr.sizeof_gr_complex*occupied_tones, "ofdm_receiver-frame_acq_c.dat")) - self.connect((self.ofdm_frame_acq,1), gr.file_sink(1, "ofdm_receiver-found_corr_b.dat")) - self.connect(self.sampler, gr.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-sampler_c.dat")) - self.connect(self.sigmix, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-sigmix_c.dat")) - self.connect(self.nco, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-nco_c.dat")) + blocks.file_sink(gr.sizeof_gr_complex*occupied_tones, "ofdm_receiver-frame_acq_c.dat")) + self.connect((self.ofdm_frame_acq,1), blocks.file_sink(1, "ofdm_receiver-found_corr_b.dat")) + self.connect(self.sampler, blocks.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-sampler_c.dat")) + self.connect(self.sigmix, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-sigmix_c.dat")) + self.connect(self.nco, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-nco_c.dat")) diff --git a/gr-digital/python/ofdm_sync_fixed.py b/gr-digital/python/ofdm_sync_fixed.py index 9bac789bf..bd6496465 100644 --- a/gr-digital/python/ofdm_sync_fixed.py +++ b/gr-digital/python/ofdm_sync_fixed.py @@ -22,6 +22,7 @@ import math from gnuradio import gr +from gnuradio import blocks class ofdm_sync_fixed(gr.hier_block2): def __init__(self, fft_length, cp_length, nsymbols, freq_offset, logging=False): @@ -46,5 +47,5 @@ class ofdm_sync_fixed(gr.hier_block2): self.connect(self.peak_trigger, (self,1)) if logging: - self.connect(self.peak_trigger, gr.file_sink(gr.sizeof_char, "ofdm_sync_fixed-peaks_b.dat")) + self.connect(self.peak_trigger, blocks.file_sink(gr.sizeof_char, "ofdm_sync_fixed-peaks_b.dat")) diff --git a/gr-digital/python/ofdm_sync_ml.py b/gr-digital/python/ofdm_sync_ml.py index 76c00f3a5..3afd64709 100644 --- a/gr-digital/python/ofdm_sync_ml.py +++ b/gr-digital/python/ofdm_sync_ml.py @@ -158,18 +158,18 @@ class ofdm_sync_ml(gr.hier_block2): if logging: - self.connect(self.moving_sum_filter, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-energy_f.dat")) - self.connect(self.diff, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-theta_f.dat")) - self.connect(self.angle, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-epsilon_f.dat")) - self.connect(self.corrmag, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-corrmag_f.dat")) - self.connect(self.kscorr, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-kscorr_c.dat")) - self.connect(self.div, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-div_f.dat")) - self.connect(self.mul, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-mul_f.dat")) - self.connect(self.slice, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-slice_f.dat")) - self.connect(self.pk_detect, gr.file_sink(gr.sizeof_char, "ofdm_sync_ml-peaks_b.dat")) + self.connect(self.moving_sum_filter, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-energy_f.dat")) + self.connect(self.diff, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-theta_f.dat")) + self.connect(self.angle, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-epsilon_f.dat")) + self.connect(self.corrmag, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-corrmag_f.dat")) + self.connect(self.kscorr, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-kscorr_c.dat")) + self.connect(self.div, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-div_f.dat")) + self.connect(self.mul, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-mul_f.dat")) + self.connect(self.slice, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-slice_f.dat")) + self.connect(self.pk_detect, blocks.file_sink(gr.sizeof_char, "ofdm_sync_ml-peaks_b.dat")) if use_dpll: - self.connect(self.dpll, gr.file_sink(gr.sizeof_char, "ofdm_sync_ml-dpll_b.dat")) + self.connect(self.dpll, blocks.file_sink(gr.sizeof_char, "ofdm_sync_ml-dpll_b.dat")) - self.connect(self.sample_and_hold, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-sample_and_hold_f.dat")) - self.connect(self.input, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-input_c.dat")) + self.connect(self.sample_and_hold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-sample_and_hold_f.dat")) + self.connect(self.input, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-input_c.dat")) diff --git a/gr-digital/python/ofdm_sync_pn.py b/gr-digital/python/ofdm_sync_pn.py index 63e85135b..4c6a30f80 100644 --- a/gr-digital/python/ofdm_sync_pn.py +++ b/gr-digital/python/ofdm_sync_pn.py @@ -124,10 +124,10 @@ class ofdm_sync_pn(gr.hier_block2): self.connect(self.pk_detect, (self,1)) if logging: - self.connect(self.matched_filter, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-mf_f.dat")) - self.connect(self.normalize, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-theta_f.dat")) - self.connect(self.angle, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-epsilon_f.dat")) - self.connect(self.pk_detect, gr.file_sink(gr.sizeof_char, "ofdm_sync_pn-peaks_b.dat")) - self.connect(self.sample_and_hold, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-sample_and_hold_f.dat")) - self.connect(self.input, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pn-input_c.dat")) + self.connect(self.matched_filter, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-mf_f.dat")) + self.connect(self.normalize, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-theta_f.dat")) + self.connect(self.angle, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-epsilon_f.dat")) + self.connect(self.pk_detect, blocks.file_sink(gr.sizeof_char, "ofdm_sync_pn-peaks_b.dat")) + self.connect(self.sample_and_hold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pn-sample_and_hold_f.dat")) + self.connect(self.input, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pn-input_c.dat")) diff --git a/gr-digital/python/ofdm_sync_pnac.py b/gr-digital/python/ofdm_sync_pnac.py index 547b1e93c..ee7c82927 100644 --- a/gr-digital/python/ofdm_sync_pnac.py +++ b/gr-digital/python/ofdm_sync_pnac.py @@ -125,11 +125,11 @@ class ofdm_sync_pnac(gr.hier_block2): self.connect(self.peaks, (self,1)) if logging: - self.connect(self.compare, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-compare_f.dat")) - self.connect(self.c2mag, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-theta_f.dat")) - self.connect(self.power, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-inputpower_f.dat")) - self.connect(self.angle, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-epsilon_f.dat")) - self.connect(self.threshold, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-threshold_f.dat")) - self.connect(self.peaks, gr.file_sink(gr.sizeof_char, "ofdm_sync_pnac-peaks_b.dat")) - self.connect(self.sample_and_hold, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-sample_and_hold_f.dat")) - self.connect(self.input, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pnac-input_c.dat")) + self.connect(self.compare, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-compare_f.dat")) + self.connect(self.c2mag, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-theta_f.dat")) + self.connect(self.power, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-inputpower_f.dat")) + self.connect(self.angle, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-epsilon_f.dat")) + self.connect(self.threshold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-threshold_f.dat")) + self.connect(self.peaks, blocks.file_sink(gr.sizeof_char, "ofdm_sync_pnac-peaks_b.dat")) + self.connect(self.sample_and_hold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_pnac-sample_and_hold_f.dat")) + self.connect(self.input, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pnac-input_c.dat")) diff --git a/gr-digital/python/ofdm_txrx.py b/gr-digital/python/ofdm_txrx.py new file mode 100644 index 000000000..2734e9cc1 --- /dev/null +++ b/gr-digital/python/ofdm_txrx.py @@ -0,0 +1,268 @@ +# +# Copyright 2005,2006,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. +# +""" +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 = "frame_length" +_def_packet_num_tag_key = "" +_def_occupied_carriers=(range(1, 27) + range(38, 64),) +_def_pilot_carriers=((0,),) +_def_pilot_symbols=((100,),) +_seq_seed = 42 + +def _make_sync_word(fft_len, occupied_carriers, constellation): + """ Makes a random sync sequence """ + occupied_carriers = list(occupied_carriers[0]) + occupied_carriers = [occupied_carriers[x] + fft_len if occupied_carriers[x] < 0 else occupied_carriers[x] for x in range(len(occupied_carriers))] + numpy.random.seed(_seq_seed) + sync_sequence = [constellation.map_to_points_v(numpy.random.randint(constellation.arity()))[0] * numpy.sqrt(2) if x in occupied_carriers and x % 3 else 0 for x in range(fft_len)] + return sync_sequence + +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 (integer). + occupied_carriers: ?? + pilot_carriers: ?? + pilot_symbols: ?? + length_tag_key: The name of the tag giving packet length. + """ + def __init__(self, fft_len=_def_fft_len, cp_len=_def_cp_len, + frame_length_tag_key=_def_frame_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 + ): + gr.hier_block2.__init__(self, "ofdm_tx", + gr.io_signature(1, 1, gr.sizeof_char), + gr.io_signature(1, 1, gr.sizeof_gr_complex)) + self.fft_len = fft_len + self.cp_len = cp_len + self.frame_length_tag_key = frame_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 + header_constellation = _get_constellation(bps_header) + header_mod = digital.chunks_to_symbols_bc(header_constellation.points()) + self.sync_word1 = sync_word1 + if sync_word1 is None: + self.sync_word1 = _make_sync_word(fft_len, occupied_carriers, header_constellation) + 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_word2 = () + if sync_word2 is not None: + 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 + total_sync_word = sync_word1 + sync_word2 + crc = digital.crc32_bb(False, self.frame_length_tag_key) + formatter_object = digital.packet_header_ofdm( + occupied_carriers, 1, "", "", "", + bps_header + ) + header_gen = digital.packet_headergenerator_bb(formatter_object.base()) + header_payload_mux = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, self.frame_length_tag_key) + self.connect(self, crc, header_gen, header_mod, (header_payload_mux, 0)) + payload_constellation = _get_constellation(bps_payload) + payload_mod = digital.chunks_to_symbols_bc(payload_constellation.points()) + self.connect( + crc, + blocks.repack_bits_bb(8, bps_payload, frame_length_tag_key), + payload_mod, + (header_payload_mux, 1) + ) + self.connect(payload_mod, gr.tag_debug(gr.sizeof_gr_complex, "pmod")) + sync_word_gen = gr.vector_source_c( + total_sync_word, True, self.fft_len, + tagged_streams.make_lengthtags((n_sync_words,), (0,), self.frame_length_tag_key) + ) + allocator = digital.ofdm_carrier_allocator_cvc( + self.fft_len, + occupied_carriers=self.occupied_carriers, + pilot_carriers=self.pilot_carriers, + pilot_symbols=self.pilot_symbols, + len_tag_key=self.frame_length_tag_key + ) + syncword_data_mux = blocks.tagged_stream_mux(gr.sizeof_gr_complex*self.fft_len, self.frame_length_tag_key) + self.connect(sync_word_gen, (syncword_data_mux, 0)) + self.connect(header_payload_mux, allocator, (syncword_data_mux, 1)) + ffter = fft.fft_vcc(self.fft_len, False, (), False) + cyclic_prefixer = digital.ofdm_cyclic_prefixer( + self.fft_len, + self.fft_len+self.cp_len, + rolloff, + self.frame_length_tag_key + ) + self.connect(syncword_data_mux, ffter, cyclic_prefixer, self) + + +class ofdm_rx(gr.hier_block2): + """ + Hierarchical block for OFDM demodulation. + + 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 (integer). + occupied_carriers: ?? + pilot_carriers: ?? + pilot_symbols: ?? + length_tag_key: The name of the tag giving packet length. + """ + 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 + ): + gr.hier_block2.__init__(self, "ofdm_rx", + gr.io_signature(1, 1, gr.sizeof_gr_complex), + gr.io_signature(1, 1, gr.sizeof_char)) + 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 + header_constellation = _get_constellation(bps_header) + if sync_word1 is None: + self.sync_word1 = _make_sync_word(fft_len, occupied_carriers, header_constellation) + 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 not None: + 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 + else: + sync_word2 = () + # Receiver path + sync_detect = digital.ofdm_sync_sc_cfb(fft_len, cp_len) + oscillator = analog.frequency_modulator_fc(-2.0 / fft_len) + delay = gr.delay(gr.sizeof_gr_complex, fft_len+cp_len) + mixer = gr.multiply_cc() + hpd = digital.header_payload_demux(n_sync_words, fft_len, cp_len, + frame_length_tag_key, "", True) + self.connect(self, sync_detect) + self.connect((sync_detect, 0), oscillator, (mixer, 0)) + self.connect(self, delay, (mixer, 1)) + self.connect(mixer, (hpd, 0)) + self.connect((sync_detect, 1), (hpd, 1)) + # Header demodulation + header_fft = fft.fft_vcc(self.fft_len, True, (), True) + chanest = digital.ofdm_chanest_vcvc(self.sync_word1, self.sync_word2, 1) + header_equalizer = digital.ofdm_equalizer_simpledfe( + fft_len, header_constellation.base(), + occupied_carriers, pilot_carriers, pilot_symbols + ) + header_eq = digital.ofdm_frame_equalizer_vcvc(header_equalizer.base(), frame_length_tag_key, True) + header_serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers) + header_constellation = _get_constellation(bps_header) + 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") + # Payload demodulation + payload_fft = fft.fft_vcc(self.fft_len, True, (), True) + payload_equalizer = digital.ofdm_equalizer_simpledfe( + fft_len, header_constellation.base(), + occupied_carriers, pilot_carriers, pilot_symbols, 1 + ) + payload_eq = digital.ofdm_frame_equalizer_vcvc(payload_equalizer.base(), frame_length_tag_key) + payload_serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers) + payload_constellation = _get_constellation(bps_payload) + payload_demod = digital.constellation_decoder_cb(payload_constellation.base()) + bit_packer = blocks.repack_bits_bb(bps_payload, 8, packet_length_tag_key, True) + self.connect((hpd, 1), payload_fft, payload_eq, payload_serializer, payload_demod, bit_packer, self) + diff --git a/gr-digital/python/qa_crc32_bb.py b/gr-digital/python/qa_crc32_bb.py new file mode 100755 index 000000000..4574b9dca --- /dev/null +++ b/gr-digital/python/qa_crc32_bb.py @@ -0,0 +1,150 @@ +#!/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 blocks_swig as blocks +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.string_to_symbol(tag_name) + tag.value = 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.string_to_symbol(tag_name) + tag.value = 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.string_to_symbol(tag_name) + tag1.value = pmt.from_long(pack_len) + tag2 = gr.gr_tag_t() + tag2.offset = pack_len + tag2.key = pmt.string_to_symbol(tag_name) + tag2.value = pmt.from_long(pack_len) + testtag1 = gr.gr_tag_t() + testtag1.offset = 1 + testtag1.key = pmt.string_to_symbol("tag1") + testtag1.value = pmt.from_long(0) + testtag2 = gr.gr_tag_t() + testtag2.offset = pack_len + testtag2.key = pmt.string_to_symbol("tag2") + testtag2.value = pmt.from_long(0) + testtag3 = gr.gr_tag_t() + testtag3.offset = len(packets)-1 + testtag3.key = pmt.string_to_symbol("tag3") + testtag3.value = 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.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.string_to_symbol(tag_name) + tag.value = 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 = blocks.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.string_to_symbol(tag_name) + tag.value = pmt.from_long(len(data)) + testtag = gr.gr_tag_t() + testtag.offset = len(data)-1 + testtag.key = pmt.string_to_symbol('tag1') + testtag.value = 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.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 000000000..4073f24ac --- /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.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.intern('header_data'), + 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 000000000..2105727e0 --- /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.string_to_symbol(tag_name) + tag.value = 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.string_to_symbol(tag_name) + tag.value = 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.string_to_symbol(tag_name) + tag1.value = pmt.from_long(len(tx_symbols)) + tag2 = gr.gr_tag_t() + tag2.offset = len(tx_symbols) + tag2.key = pmt.string_to_symbol(tag_name) + tag2.value = pmt.from_long(len(tx_symbols)) + testtag1 = gr.gr_tag_t() + testtag1.offset = 0 + testtag1.key = pmt.string_to_symbol('tag1') + testtag1.value = pmt.from_long(0) + testtag2 = gr.gr_tag_t() + testtag2.offset = 7 # On the 2nd OFDM symbol + testtag2.key = pmt.string_to_symbol('tag2') + testtag2.value = pmt.from_long(0) + testtag3 = gr.gr_tag_t() + testtag3.offset = len(tx_symbols)+1 # First OFDM symbol of packet 2 + testtag3.key = pmt.string_to_symbol('tag3') + testtag3.value = 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.string_to_symbol('tag4') + testtag4.value = 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.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.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 000000000..c7c0d83a8 --- /dev/null +++ b/gr-digital/python/qa_ofdm_chanest_vcvc.py @@ -0,0 +1,284 @@ +#!/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 blocks_swig as blocks +import analog_swig as analog +import digital_swig as digital +import sys +import numpy +import random + +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.string_to_symbol("test_tag_1") + tag1.value = pmt.from_long(23) + tag2 = gr.gr_tag_t() + tag2.offset = 2 + tag2.key = pmt.string_to_symbol("test_tag_2") + tag2.value = 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.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + carr_offset_hat = pmt.to_long(tag.value) + self.assertEqual(pmt.to_long(tag.value), carr_offset) + if pmt.symbol_to_string(tag.key) == 'test_tag_1': + self.assertEqual(tag.offset, 0) + if pmt.symbol_to_string(tag.key) == 'test_tag_2': + self.assertEqual(tag.offset, 0) + detected_tags[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.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + carr_offset_hat = pmt.to_long(tag.value) + self.assertEqual(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 = blocks.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() + self.assertEqual(shift_tuple(sink.data(), -carr_offset), tuple(numpy.multiply(data_symbol, channel))) + for tag in tags: + if pmt.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + self.assertEqual(pmt.to_long(tag.value), carr_offset) + if pmt.symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': + self.assertEqual(pmt.c32vector_elements(tag.value), 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.5, 3, 2.5, 2, 2.5, 3, 2, 1, 1, 0) + src = gr.vector_source_c(tx_data, False, fft_len) + chan = blocks.multiply_const_vcc(channel) + chanest = digital.ofdm_chanest_vcvc(sync_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.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + self.assertEqual(pmt.to_long(tag.value), carr_offset) + if pmt.symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': + self.assertEqual(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 = blocks.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.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + self.assertEqual(pmt.to_long(tag.value), carr_offset) + if pmt.symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': + self.assertEqual(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) + 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 = blocks.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.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + self.assertEqual(pmt.to_long(tag.value), carr_offset) + if pmt.symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': + chan_est = pmt.c32vector_elements(tag.value) + for i in range(fft_len): + if shift_tuple(sync_symbol2, carr_offset)[i]: # Only here the channel can be estimated + self.assertEqual(chan_est[i], channel[i]) + 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 = 100 + 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 = blocks.multiply_const_vcc(channel) + noise = analog.noise_source_c(analog.GR_GAUSSIAN, wgn_amplitude) + add = blocks.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, blocks.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.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + carr_offset_hat = pmt.to_long(tag.value) + self.assertEqual(carr_offset, carr_offset_hat) + if pmt.symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': + channel_est = pmt.c32vector_elements(tag.value) + 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 000000000..003e987e9 --- /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.string_to_symbol(tag_name) + tag.value = pmt.from_long(2) + tag2 = gr.gr_tag_t() + tag2.offset = 1 + tag2.key = pmt.string_to_symbol("random_tag") + tag2.value = 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 000000000..9faface03 --- /dev/null +++ b/gr-digital/python/qa_ofdm_frame_equalizer_vcvc.py @@ -0,0 +1,161 @@ +#!/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 + +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 """ + 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.string_to_symbol(len_tag_key) + len_tag.value = pmt.from_long(n_syms) + chan_tag = gr.gr_tag_t() + chan_tag.offset = 0 + chan_tag.key = pmt.string_to_symbol("ofdm_sync_chan_taps") + chan_tag.value = 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(), 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()) + for tag in sink.tags(): + self.assertEqual(pmt.symbol_to_string(tag.key), len_tag_key) + self.assertEqual(pmt.to_long(tag.value), n_syms) + + def test_002_static (self): + 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... + 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.string_to_symbol(len_tag_key) + len_tag.value = pmt.from_long(4) + chan_tag = gr.gr_tag_t() + chan_tag.offset = 0 + chan_tag.key = pmt.string_to_symbol("ofdm_sync_chan_taps") + chan_tag.value = 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(), 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.symbol_to_string(tag.key) == len_tag_key: + self.assertEqual(pmt.to_long(tag.value), 4) + if pmt.symbol_to_string(tag.key) == "ofdm_sync_chan_taps": + self.assertEqual(list(pmt.c32vector_elements(tag.value)), channel[-fft_len:]) + + def test_002_simpledfe (self): + 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.string_to_symbol(len_tag_key) + len_tag.value = pmt.from_long(4) + chan_tag = gr.gr_tag_t() + chan_tag.offset = 0 + chan_tag.key = pmt.string_to_symbol("ofdm_sync_chan_taps") + chan_tag.value = 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(), 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.symbol_to_string(tag.key) == len_tag_key: + self.assertEqual(pmt.to_long(tag.value), 4) + if pmt.symbol_to_string(tag.key) == "ofdm_sync_chan_taps": + self.assertComplexTuplesAlmostEqual(list(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 000000000..107d6076c --- /dev/null +++ b/gr-digital/python/qa_ofdm_serializer_vcc.py @@ -0,0 +1,214 @@ +#!/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 blocks_swig as blocks +import fft_swig as fft +import analog_swig as analog +import digital_swig as digital +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 = 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)) + (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.string_to_symbol(tag_name) + tag.value = 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.symbol_to_string(result_tag.key), tag_name) + self.assertEqual(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.string_to_symbol(tag_name) + tag.value = pmt.from_long(n_syms) + offsettag = gr.gr_tag_t() + offsettag.offset = 0 + offsettag.key = pmt.string_to_symbol("ofdm_sync_carr_offset") + offsettag.value = 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, 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.symbol_to_string(tag.key) == tag_name: + self.assertEqual(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.string_to_symbol(tag_name) + tag.value = 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) + 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 = 2 + carr_offset = -2 + freq_offset = 2 * numpy.pi * carr_offset / fft_len # If the sampling rate == 1 + occupied_carriers = ((1, 2, -2, -1),) + pilot_carriers = ((3,),(5,)) + pilot_symbols = ((1j,),(-1j,)) + tx_data = tuple([numpy.random.randint(0, 10) for x in range(4 * n_syms)]) + #tx_data = (1,) * occupied_carriers[0] * n_syms + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.string_to_symbol(tag_name) + tag.value = pmt.from_long(len(tx_data)) + offsettag = gr.gr_tag_t() + offsettag.offset = 0 + offsettag.key = pmt.string_to_symbol("ofdm_sync_carr_offset") + offsettag.value = 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, ()) + offset_sig = analog.sig_source_c(1.0, analog.GR_COS_WAVE, freq_offset, 1.0) + mixer = blocks.multiply_cc() + rx_fft = fft.fft_vcc(fft_len, True, (), True) + serializer = digital.ofdm_serializer_vcc(alloc) + sink = gr.vector_sink_c() + self.tb.connect( + src, alloc, tx_ifft, + blocks.vector_to_stream(gr.sizeof_gr_complex, fft_len), + (mixer, 0), + blocks.stream_to_vector(gr.sizeof_gr_complex, fft_len), + rx_fft, serializer, sink + ) + self.tb.connect(offset_sig, (mixer, 1)) + self.tb.run () + # FIXME check this + #self.assertEqual(sink.data(), tx_data) + + 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.string_to_symbol(tag_name) + tag.value = pmt.from_long(n_syms) + tag2 = gr.gr_tag_t() + tag2.offset = 0 + tag2.key = pmt.string_to_symbol("packet_len") + tag2.value = 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.symbol_to_string(result_tag.key), "packet_len") + self.assertEqual(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") + gr_unittest.run(qa_ofdm_serializer_vcc) + 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 000000000..806ef931d --- /dev/null +++ b/gr-digital/python/qa_ofdm_sync_sc_cfb.py @@ -0,0 +1,203 @@ +#!/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 +import blocks_swig as blocks +import analog_swig as analog + +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 = blocks.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(analog.noise_source_c(analog.GR_GAUSSIAN, .01), (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 + freq_offset = 0.1 # Must stay < 2*pi/fft_len = 0.196 (otherwise, it's coarse) + 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 = blocks.multiply_cc() + add = blocks.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), (mult, 0), (add, 0)) + self.tb.connect(analog.sig_source_c(2 * numpy.pi, analog.GR_SIN_WAVE, freq_offset, 1.0), (mult, 1)) + self.tb.connect(analog.noise_source_c(analog.GR_GAUSSIAN, .01), (add, 1)) + self.tb.connect(add, 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 = blocks.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(analog.noise_source_c(analog.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() + self.assertEqual(numpy.sum(sink_detect.data()), n_bursts, + 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) + ) + + # FIXME ofdm_mod is currently not working + #def test_004_ofdm_packets (self): + #""" + #Send several bursts, see if the number of detects is correct. + #Burst lengths and content are random. + #""" + #n_bursts = 42 + #fft_len = 64 + #cp_len = 12 + #tx_signal = [] + #packets = [] + #tagname = "length" + #min_packet_length = 100 + #max_packet_length = 100 + #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( + #fft_len=fft_len, + #cp_len=cp_len, + #length_tag_name=tagname, + #occupied_carriers=(range(1, 27) + range(38, 64),), + #pilot_carriers=((0,),), + #pilot_symbols=((100,),), + #) + #rate_in = 16000 + #rate_out = 48000 + #ratio = float(rate_out) / rate_in + #throttle1 = gr.throttle(gr.sizeof_gr_complex, rate_in) + #insert_zeros = digital.ts_insert_zeros_cc(tagname) + #throttle2 = gr.throttle(gr.sizeof_gr_complex, rate_out) + #sink_countbursts = gr.vector_sink_c() + #head = gr.head(gr.sizeof_gr_complex, int(total_length * ratio*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() + #noise_level = 0.01 + #noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_level) + #self.tb.connect(src, mod, gr.null_sink(gr.sizeof_gr_complex)) + #self.tb.connect(insert_zeros, sink_countbursts) + #self.tb.connect(noise, (add, 1)) + #self.tb.connect(add, sync) + #self.tb.connect((sync, 0), sink_freq) + #self.tb.connect((sync, 1), sink_detect) + #self.tb.run() + #count_data = sink_countbursts.data() + #count_tags = sink_countbursts.tags() + #burstcount = tagged_streams.count_bursts(count_data, count_tags, tagname) + #self.assertEqual(numpy.sum(sink_detect.data()), burstcount) + + +if __name__ == '__main__': + #gr_unittest.run(qa_ofdm_sync_sc_cfb, "qa_ofdm_sync_sc_cfb.xml") + gr_unittest.run(qa_ofdm_sync_sc_cfb) + diff --git a/gr-digital/python/qa_ofdm_txrx.py b/gr-digital/python/qa_ofdm_txrx.py new file mode 100755 index 000000000..778f03f51 --- /dev/null +++ b/gr-digital/python/qa_ofdm_txrx.py @@ -0,0 +1,58 @@ +#!/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 +from gnuradio import gr, gr_unittest +import digital_swig + +class test_ofdm_txrx (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001 (self): + pass + #len_tag_key = 'frame_len' + #n_bytes = 100 + #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(frame_length_tag_key=len_tag_key) + #rx = ofdm_rx(frame_length_tag_key=len_tag_key) + #self.assertEqual(tx.sync_word1, rx.sync_word1) + #self.assertEqual(tx.sync_word2, rx.sync_word2) + #delay = gr.delay(gr.sizeof_gr_complex, 100) + #noise = gr.noise_source_c(gr.GR_GAUSSIAN, 0.05) + #add = gr.add_cc() + #sink = gr.vector_sink_b() + ##self.tb.connect(src, tx, add, rx, sink) + ##self.tb.connect(noise, (add, 1)) + #self.tb.connect(src, tx, gr.null_sink(gr.sizeof_gr_complex)) + #self.tb.run() + + +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 000000000..2e6e40156 --- /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, 1, 2, 3, 4) + tagname = "packet_len" + tag1 = gr.gr_tag_t() + tag1.offset = 0 + tag1.key = pmt.string_to_symbol(tagname) + tag1.value = pmt.from_long(4) + tag2 = gr.gr_tag_t() + tag2.offset = 4 + tag2.key = pmt.string_to_symbol(tagname) + tag2.value = pmt.from_long(2) + tag3 = gr.gr_tag_t() + tag3.offset = 6 + tag3.key = pmt.string_to_symbol(tagname) + tag3.value = pmt.from_long(4) + 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, + 0, 0, 1, 0, 0, 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.string_to_symbol(tagname) + tag1.value = pmt.from_long(4) + tag2 = gr.gr_tag_t() + tag2.offset = 4 + tag2.key = pmt.string_to_symbol(tagname) + tag2.value = pmt.from_long(2) + tag3 = gr.gr_tag_t() + tag3.offset = 6 + tag3.key = pmt.string_to_symbol(tagname) + tag3.value = 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.string_to_symbol(tagname) + tag1.value = pmt.from_long(4) + tag2 = gr.gr_tag_t() + tag2.offset = 4 + tag2.key = pmt.string_to_symbol(tagname) + tag2.value = pmt.from_long(2) + tag3 = gr.gr_tag_t() + tag3.offset = 6 + tag3.key = pmt.string_to_symbol(tagname) + tag3.value = 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()) + 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.string_to_symbol(tagname) + tag1.value = pmt.from_long(4) + tag2 = gr.gr_tag_t() + tag2.offset = 4 + tag2.key = pmt.string_to_symbol(tagname) + tag2.value = pmt.from_long(2) + tag3 = gr.gr_tag_t() + tag3.offset = 6 + tag3.key = pmt.string_to_symbol(tagname) + tag3.value = 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.symbol_to_string(formatter_object.len_tag_key()), tagname) + header = digital.packet_headergenerator_bb(formatter_object.formatter()) + 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 000000000..aec2f96b5 --- /dev/null +++ b/gr-digital/python/qa_packet_headerparser_b.py @@ -0,0 +1,72 @@ +#!/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 +from gnuradio import gr, gr_unittest +try: import pmt +except: from gruel import pmt +import blocks_swig as blocks +import digital_swig as digital + +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): + 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, 1, 0, 0, 0 + ) + tagname = "packet_len" + + src = gr.vector_source_b(expected_data) + parser = digital.packet_headerparser_b(32, tagname) + sink = blocks.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) + msg = sink.get_message(0) + #try: + #self.assertEqual(4, pmt.pmt_to_long(pmt.pmt_dict_ref(msg, pmt.pmt_string_to_symbol(tagname), pmt.PMT_F))) + #self.assertEqual(0, pmt.pmt_to_long(pmt.pmt_dict_ref(msg, pmt.pmt_string_to_symbol("packet_num"), pmt.PMT_F))) + + #except: + #self.fail() + # msg1: length 4, number 0 + # msg2: length 2, number 1 + # msg3: PMT_F because parity fail + + + +if __name__ == '__main__': + gr_unittest.run(qa_packet_headerparser_b, "qa_packet_headerparser_b.xml") diff --git a/gr-digital/python/qa_scale_tags.py b/gr-digital/python/qa_scale_tags.py new file mode 100755 index 000000000..deee77557 --- /dev/null +++ b/gr-digital/python/qa_scale_tags.py @@ -0,0 +1,57 @@ +#!/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 itertools + +from gnuradio import gr, gr_unittest +try: import pmt +except: from gruel import pmt +import blocks_swig as blocks +import digital_swig as digital +from utils import tagged_streams + +class qa_scale_tags (gr_unittest.TestCase): + + def test_utils(self): + packets = ((1, 2, 3), (4, 5, 6, 7, 8), (9, 10)) + tagname = "vector_length" + data, tags = tagged_streams.packets_to_vectors(packets, tagname) + new_packets = tagged_streams.vectors_to_packets(data, tags, tagname) + for np, op in zip(new_packets, packets): + for n, o in zip(np, op): + self.assertEqual(n, o) + + def test_001_t (self): + packets = ((1, 2, 3), (4, 5, 6, 7, 8), (9, 10)) + tagname = "packet_length" + data, tags = tagged_streams.packets_to_vectors(packets, tagname) + tb = gr.top_block() + src = gr.vector_source_b(data, False, 1, tags) + tag_scaler = digital.scale_tags(1, tagname, 2) + unpacker = blocks.packed_to_unpacked_bb(4, blocks.GR_MSB_FIRST) + snk = gr.vector_sink_b() + tb.connect(src, unpacker, tag_scaler, snk) + tb.run() + packets = tagged_streams.vectors_to_packets(snk.data(), snk.tags(), tagname) + +if __name__ == '__main__': + gr_unittest.run(qa_scale_tags, "qa_scale_tags.xml") diff --git a/gr-digital/python/qa_ts_insert_zeros.py b/gr-digital/python/qa_ts_insert_zeros.py new file mode 100644 index 000000000..d13a4c1c2 --- /dev/null +++ b/gr-digital/python/qa_ts_insert_zeros.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. +# + +import time +import itertools + +from gnuradio import gr, gr_unittest +try: import pmt +except: from gruel import pmt +import blocks_swig as blocks +import digital_swig as digital +from utils import tagged_streams + +class qa_ts_insert_zeros (gr_unittest.TestCase): + + def test_one(self): + n_packets = 10 + packet_length = 1000 + packets = [[i]*packet_length for i in range(1, n_packets+1)] + tagname = "packet_length" + data, tags = tagged_streams.packets_to_vectors(packets, tagname) + tb = gr.top_block() + src = gr.vector_source_c(data, False, 1, tags) + rate_in = 16000 + rate_out = 48000 + ratio = float(rate_out) / rate_in + throttle1 = blocks.throttle(gr.sizeof_gr_complex, rate_in) + insert_zeros = digital.ts_insert_zeros_cc(tagname) + throttle2 = blocks.throttle(gr.sizeof_gr_complex, rate_out) + head = gr.head(gr.sizeof_gr_complex, int(n_packets * packet_length * ratio*2)) + snk = gr.vector_sink_c() + tb.connect(src, throttle1, insert_zeros, throttle2, head, snk) + tb.run() + data = snk.data() + state = 1 + pos = 0 + last_non_zero = 0 + for i, d in enumerate(data): + if d != 0: + last_non_zero = i + if pos == 0: + if (d == state): + pos = pos + 1 + elif (d != 0): + raise ValueError("Invalid") + elif pos > 0: + if (d != state): + raise ValueError("Invalid") + pos = pos + 1 + if pos == packet_length: + state += 1 + pos = 0 + min_ratio = ratio-1 + max_ratio = ratio+1 + self.assertEqual(state-1, n_packets) + self.assertTrue(last_non_zero > min_ratio*packet_length*n_packets) + self.assertTrue(last_non_zero < max_ratio*packet_length*n_packets) + +if __name__ == '__main__': + gr_unittest.run(qa_ts_insert_zeros, "qa_ts_insert_zeros.xml") diff --git a/gr-digital/python/utils/tagged_streams.py b/gr-digital/python/utils/tagged_streams.py new file mode 100644 index 000000000..6a956aa64 --- /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.string_to_symbol(tagname) + tag.value = 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.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.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.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.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.string_to_symbol(lengthtagname) + tag.value = 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 6b6eb5e45..0db514042 100644 --- a/gr-digital/swig/CMakeLists.txt +++ b/gr-digital/swig/CMakeLists.txt @@ -34,8 +34,6 @@ set(GR_SWIG_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ) -set(GR_SWIG_LIBRARIES gnuradio-digital gnuradio-filter) - if(ENABLE_GR_CTRLPORT) ADD_DEFINITIONS(-DGR_CTRLPORT) list(APPEND GR_SWIG_INCLUDE_DIRS ${ICE_INCLUDE_DIR}) @@ -46,7 +44,8 @@ set(GR_SWIG_TARGET_DEPS digital_generated_includes) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/digital_swig_doc.i) set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../lib) -set(GR_SWIG_LIBRARIES gnuradio-digital gnuradio-filter gnuradio-analog) +set(GR_SWIG_LIBRARIES gnuradio-digital + gnuradio-filter gnuradio-analog gnuradio-blocks) GR_SWIG_MAKE(digital_swig digital_swig.i) @@ -59,6 +58,15 @@ GR_SWIG_INSTALL( install( FILES digital_swig.i + constellation.i + digital_crc32_bb.i + digital_ofdm_carrier_allocator_cvc.i + digital_ofdm_chanest_vcvc.i + digital_ofdm_equalizer_base.i + digital_ofdm_equalizer_simpledfe.i + digital_ofdm_equalizer_static.i + digital_ofdm_sync_sc_cfb.i + packet_header.i ${CMAKE_CURRENT_BINARY_DIR}/digital_swig_doc.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "digital_swig" diff --git a/gr-digital/swig/digital_crc32_bb.i b/gr-digital/swig/digital_crc32_bb.i new file mode 100644 index 000000000..45b240793 --- /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 000000000..1663a4de3 --- /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/gnuradio-core/src/lib/io/gr_udp_source.i b/gr-digital/swig/digital_ofdm_chanest_vcvc.i index 18823a356..aa6e79b5c 100644 --- a/gnuradio-core/src/lib/io/gr_udp_source.i +++ b/gr-digital/swig/digital_ofdm_chanest_vcvc.i @@ -1,41 +1,40 @@ /* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * +/* 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(gr,udp_source) +GR_SWIG_BLOCK_MAGIC(digital, ofdm_chanest_vcvc); -gr_udp_source_sptr -gr_make_udp_source (size_t itemsize, const char *host, - unsigned short port, int payload_size=1472, - bool eof=true, bool wait=true) throw (std::runtime_error); +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 gr_udp_source : public gr_sync_block +class digital_ofdm_chanest_vcvc : public gr_block { - protected: - gr_udp_source (size_t itemsize, const char *host, - unsigned short port, int payload_size, bool eof, bool wait) throw (std::runtime_error); + 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: - ~gr_udp_source (); - - int payload_size() { return d_payload_size; } - int get_port(); }; + diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.i b/gr-digital/swig/digital_ofdm_cyclic_prefixer.i index 2f2596e12..19ffd6a12 100644 --- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.i +++ b/gr-digital/swig/digital_ofdm_cyclic_prefixer.i @@ -1,35 +1,35 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Free Software Foundation, Inc. - * + * Copyright 2004-2006,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. */ -GR_SWIG_BLOCK_MAGIC(gr,tagged_file_sink) +GR_SWIG_BLOCK_MAGIC(digital,ofdm_cyclic_prefixer); -gr_tagged_file_sink_sptr -gr_make_tagged_file_sink (size_t itemsize, double samp_rate); +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 gr_tagged_file_sink : public gr_sync_block -{ - protected: - gr_tagged_file_sink (size_t itemsize, double samp_rate); - public: - ~gr_tagged_file_sink (); +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 000000000..c862fed09 --- /dev/null +++ b/gr-digital/swig/digital_ofdm_equalizer_base.i @@ -0,0 +1,64 @@ +/* -*- 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; + void set_carrier_offset(int offset) { d_carr_offset = offset; }; + 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 000000000..1ca31c1ed --- /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 gr::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 000000000..3e99403ff --- /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 000000000..6a863ca3f --- /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); + +class digital_ofdm_sync_sc_cfb : public gr_hier_block2 +{ + private: + digital_ofdm_sync_sc_cfb(int fft_len, int cp_len); +}; + diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i index 155efddf7..94e186d7b 100644 --- a/gr-digital/swig/digital_swig.i +++ b/gr-digital/swig/digital_swig.i @@ -30,29 +30,28 @@ %include "analog/cpm.h" -%include "gri_control_loop.h" +%{ +#include <blocks/control_loop.h> +%} // Used in the constellation objects %template(unsigned_int_vector) std::vector<unsigned int>; %{ -#include "digital/metric_type.h" -#include "digital/mpsk_snr_est.h" -#include "digital/lfsr.h" #include "digital/additive_scrambler_bb.h" #include "digital/binary_slicer_fb.h" -#include "digital/chunks_to_symbols_bf.h" #include "digital/chunks_to_symbols_bc.h" -#include "digital/chunks_to_symbols_sf.h" -#include "digital/chunks_to_symbols_sc.h" -#include "digital/chunks_to_symbols_if.h" +#include "digital/chunks_to_symbols_bf.h" #include "digital/chunks_to_symbols_ic.h" +#include "digital/chunks_to_symbols_if.h" +#include "digital/chunks_to_symbols_sc.h" +#include "digital/chunks_to_symbols_sf.h" #include "digital/clock_recovery_mm_cc.h" #include "digital/clock_recovery_mm_ff.h" #include "digital/cma_equalizer_cc.h" #include "digital/constellation.h" -#include "digital/constellation_receiver_cb.h" #include "digital/constellation_decoder_cb.h" +#include "digital/constellation_receiver_cb.h" #include "digital/correlate_access_code_bb.h" #include "digital/correlate_access_code_tag_bb.h" #include "digital/costas_loop_cc.h" @@ -66,45 +65,54 @@ #include "digital/framer_sink_1.h" #include "digital/glfsr_source_b.h" #include "digital/glfsr_source_f.h" +#include "digital/header_payload_demux.h" #include "digital/kurtotic_equalizer_cc.h" +#include "digital/lfsr.h" #include "digital/lms_dd_equalizer_cc.h" #include "digital/map_bb.h" +#include "digital/metric_type.h" #include "digital/mpsk_receiver_cc.h" +#include "digital/mpsk_snr_est.h" #include "digital/mpsk_snr_est_cc.h" -#include "digital/ofdm_cyclic_prefixer.h" #include "digital/ofdm_frame_acquisition.h" +#include "digital/ofdm_frame_equalizer_vcvc.h" #include "digital/ofdm_frame_sink.h" #include "digital/ofdm_insert_preamble.h" #include "digital/ofdm_mapper_bcv.h" #include "digital/ofdm_sampler.h" +#include "digital/ofdm_serializer_vcc.h" +#include "digital/packet_header_default.h" +#include "digital/packet_header_ofdm.h" +#include "digital/packet_headergenerator_bb.h" +#include "digital/packet_headerparser_b.h" #include "digital/packet_sink.h" #include "digital/pfb_clock_sync_ccf.h" #include "digital/pfb_clock_sync_fff.h" #include "digital/pn_correlator_cc.h" #include "digital/probe_density_b.h" #include "digital/probe_mpsk_snr_est_c.h" +#include "digital/scale_tags.h" #include "digital/scrambler_bb.h" -#include "digital/simple_framer.h" #include "digital/simple_correlator.h" +#include "digital/simple_framer.h" +#include "digital/tagged_stream_check.h" +#include "digital/ts_insert_zeros_cc.h" %} -%include "digital/metric_type.h" -%include "digital/mpsk_snr_est.h" -%include "digital/lfsr.h" %include "digital/additive_scrambler_bb.h" %include "digital/binary_slicer_fb.h" -%include "digital/chunks_to_symbols_bf.h" %include "digital/chunks_to_symbols_bc.h" -%include "digital/chunks_to_symbols_sf.h" -%include "digital/chunks_to_symbols_sc.h" -%include "digital/chunks_to_symbols_if.h" +%include "digital/chunks_to_symbols_bf.h" %include "digital/chunks_to_symbols_ic.h" +%include "digital/chunks_to_symbols_if.h" +%include "digital/chunks_to_symbols_sc.h" +%include "digital/chunks_to_symbols_sf.h" %include "digital/clock_recovery_mm_cc.h" %include "digital/clock_recovery_mm_ff.h" %include "digital/cma_equalizer_cc.h" %include "digital/constellation.h" -%include "digital/constellation_receiver_cb.h" %include "digital/constellation_decoder_cb.h" +%include "digital/constellation_receiver_cb.h" %include "digital/correlate_access_code_bb.h" %include "digital/correlate_access_code_tag_bb.h" %include "digital/costas_loop_cc.h" @@ -118,43 +126,57 @@ %include "digital/framer_sink_1.h" %include "digital/glfsr_source_b.h" %include "digital/glfsr_source_f.h" +%include "digital/header_payload_demux.h" %include "digital/kurtotic_equalizer_cc.h" +%include "digital/lfsr.h" %include "digital/lms_dd_equalizer_cc.h" %include "digital/map_bb.h" +%include "digital/metric_type.h" %include "digital/mpsk_receiver_cc.h" +%include "digital/mpsk_snr_est.h" %include "digital/mpsk_snr_est_cc.h" -%include "digital/ofdm_cyclic_prefixer.h" +//%include "digital/ofdm_cyclic_prefixer.h" %include "digital/ofdm_frame_acquisition.h" +%include "digital/ofdm_frame_equalizer_vcvc.h" %include "digital/ofdm_frame_sink.h" %include "digital/ofdm_insert_preamble.h" %include "digital/ofdm_mapper_bcv.h" %include "digital/ofdm_sampler.h" +%include "digital/ofdm_serializer_vcc.h" +%include "digital/packet_header_default.h" +%include "digital/packet_header_ofdm.h" +%include "digital/packet_headergenerator_bb.h" +%include "digital/packet_headerparser_b.h" %include "digital/packet_sink.h" %include "digital/pfb_clock_sync_ccf.h" %include "digital/pfb_clock_sync_fff.h" %include "digital/pn_correlator_cc.h" %include "digital/probe_density_b.h" %include "digital/probe_mpsk_snr_est_c.h" +%include "digital/scale_tags.h" %include "digital/scrambler_bb.h" -%include "digital/simple_framer.h" %include "digital/simple_correlator.h" +%include "digital/simple_framer.h" +%include "digital/tagged_stream_check.h" +%include "digital/ts_insert_zeros_cc.h" GR_SWIG_BLOCK_MAGIC2(digital, additive_scrambler_bb); GR_SWIG_BLOCK_MAGIC2(digital, binary_slicer_fb); -GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_bf); GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_bc); -GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_sf); -GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_sc); -GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_if); +GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_bf); GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_ic); +GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_if); +GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_sc); +GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_sf); GR_SWIG_BLOCK_MAGIC2(digital, clock_recovery_mm_cc); GR_SWIG_BLOCK_MAGIC2(digital, clock_recovery_mm_ff); GR_SWIG_BLOCK_MAGIC2(digital, cma_equalizer_cc); -GR_SWIG_BLOCK_MAGIC2(digital, constellation_receiver_cb); GR_SWIG_BLOCK_MAGIC2(digital, constellation_decoder_cb); +GR_SWIG_BLOCK_MAGIC2(digital, constellation_receiver_cb); GR_SWIG_BLOCK_MAGIC2(digital, correlate_access_code_bb); GR_SWIG_BLOCK_MAGIC2(digital, correlate_access_code_tag_bb); GR_SWIG_BLOCK_MAGIC2(digital, costas_loop_cc); +//GR_SWIG_BLOCK_MAGIC2(digital, ofdm_cyclic_prefixer); GR_SWIG_BLOCK_MAGIC2(digital, cpmmod_bc); GR_SWIG_BLOCK_MAGIC2(digital, descrambler_bb); GR_SWIG_BLOCK_MAGIC2(digital, diff_decoder_bb); @@ -164,28 +186,59 @@ GR_SWIG_BLOCK_MAGIC2(digital, fll_band_edge_cc); GR_SWIG_BLOCK_MAGIC2(digital, framer_sink_1); GR_SWIG_BLOCK_MAGIC2(digital, glfsr_source_b); GR_SWIG_BLOCK_MAGIC2(digital, glfsr_source_f); +GR_SWIG_BLOCK_MAGIC2(digital, header_payload_demux); GR_SWIG_BLOCK_MAGIC2(digital, kurtotic_equalizer_cc); GR_SWIG_BLOCK_MAGIC2(digital, lms_dd_equalizer_cc); GR_SWIG_BLOCK_MAGIC2(digital, map_bb); GR_SWIG_BLOCK_MAGIC2(digital, mpsk_receiver_cc); GR_SWIG_BLOCK_MAGIC2(digital, mpsk_snr_est_cc); -GR_SWIG_BLOCK_MAGIC2(digital, ofdm_cyclic_prefixer); GR_SWIG_BLOCK_MAGIC2(digital, ofdm_frame_acquisition); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_frame_equalizer_vcvc); GR_SWIG_BLOCK_MAGIC2(digital, ofdm_frame_sink); GR_SWIG_BLOCK_MAGIC2(digital, ofdm_insert_preamble); GR_SWIG_BLOCK_MAGIC2(digital, ofdm_mapper_bcv); GR_SWIG_BLOCK_MAGIC2(digital, ofdm_sampler); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_serializer_vcc); +GR_SWIG_BLOCK_MAGIC2(digital, packet_headergenerator_bb); +GR_SWIG_BLOCK_MAGIC2(digital, packet_headerparser_b); GR_SWIG_BLOCK_MAGIC2(digital, packet_sink); GR_SWIG_BLOCK_MAGIC2(digital, pfb_clock_sync_ccf); GR_SWIG_BLOCK_MAGIC2(digital, pfb_clock_sync_fff); GR_SWIG_BLOCK_MAGIC2(digital, pn_correlator_cc); GR_SWIG_BLOCK_MAGIC2(digital, probe_density_b); GR_SWIG_BLOCK_MAGIC2(digital, probe_mpsk_snr_est_c); +GR_SWIG_BLOCK_MAGIC2(digital, scale_tags); GR_SWIG_BLOCK_MAGIC2(digital, scrambler_bb); -GR_SWIG_BLOCK_MAGIC2(digital, simple_framer); GR_SWIG_BLOCK_MAGIC2(digital, simple_correlator); +GR_SWIG_BLOCK_MAGIC2(digital, simple_framer); +GR_SWIG_BLOCK_MAGIC2(digital, tagged_stream_check); +GR_SWIG_BLOCK_MAGIC2(digital, ts_insert_zeros_cc); GR_SWIG_BLOCK_MAGIC_FACTORY(digital, cpmmod_bc, gmskmod_bc); // Properly package up constellation objects %include "constellation.i" + +%include "packet_header.i" + +// Old-style blocks to be converted to 3.7 +%{ +#include <digital_crc32_bb.h> +#include <digital_ofdm_carrier_allocator_cvc.h> +#include <digital_ofdm_cyclic_prefixer.h> +#include <digital_ofdm_chanest_vcvc.h> +#include <digital_ofdm_cyclic_prefixer.h> +#include <digital_ofdm_equalizer_base.h> +#include <digital_ofdm_equalizer_simpledfe.h> +#include <digital_ofdm_equalizer_static.h> +#include <digital_ofdm_sync_sc_cfb.h> +%} + +%include "digital_crc32_bb.i" +%include "digital_ofdm_carrier_allocator_cvc.i" +%include "digital_ofdm_chanest_vcvc.i" +%include "digital_ofdm_cyclic_prefixer.i" +%include "digital_ofdm_equalizer_base.i" +%include "digital_ofdm_equalizer_simpledfe.i" +%include "digital_ofdm_equalizer_static.i" +%include "digital_ofdm_sync_sc_cfb.i" diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.i b/gr-digital/swig/packet_header.i index 3ca082522..7c06d19f7 100644 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.i +++ b/gr-digital/swig/packet_header.i @@ -1,35 +1,34 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. - * + * 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(gr,file_descriptor_source) +%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; +%} -gr_file_descriptor_source_sptr -gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat=false); +%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; +%} -class gr_file_descriptor_source : public gr_sync_block -{ - protected: - gr_file_descriptor_source (size_t itemsize, int fd, bool repeat); - - public: - ~gr_file_descriptor_source (); -}; diff --git a/gr-fcd/examples/grc/fcd_apt_rx.grc b/gr-fcd/examples/grc/fcd_apt_rx.grc index c4d3e64d1..41a806a10 100644 --- a/gr-fcd/examples/grc/fcd_apt_rx.grc +++ b/gr-fcd/examples/grc/fcd_apt_rx.grc @@ -270,7 +270,7 @@ </param> </block> <block> - <key>gr_wavfile_sink</key> + <key>blocks_wavfile_sink</key> <param> <key>id</key> <value>wavfile_sink</value> diff --git a/gr-fcd/lib/CMakeLists.txt b/gr-fcd/lib/CMakeLists.txt index 12d14b4f7..35cefedff 100644 --- a/gr-fcd/lib/CMakeLists.txt +++ b/gr-fcd/lib/CMakeLists.txt @@ -45,8 +45,8 @@ if(ENABLE_GR_CTRLPORT) include_directories(${ICE_INCLUDE_DIR}) endif(ENABLE_GR_CTRLPORT) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Setup library @@ -92,7 +92,7 @@ add_library(gnuradio-fcd SHARED ${gr_fcd_sources}) if (LINUX) list(APPEND fcd_libs rt) endif() -target_link_libraries(gnuradio-fcd ${fcd_libs} ${LOG4CXX_LIBRARIES}) +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-fec/lib/CMakeLists.txt b/gr-fec/lib/CMakeLists.txt index f012c8d2e..566bb3707 100644 --- a/gr-fec/lib/CMakeLists.txt +++ b/gr-fec/lib/CMakeLists.txt @@ -46,7 +46,7 @@ list(APPEND gnuradio_fec_sources #Add Windows DLL resource file if using MSVC if(MSVC) - include(${CMAKE_INSTALL_PREFIX}/cmake/Modules/GrVersion.cmake) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-fec.rc.in diff --git a/gr-filter/grc/filter_pfb_arb_resampler.xml b/gr-filter/grc/filter_pfb_arb_resampler.xml index 5629adabf..b3418b9f2 100644 --- a/gr-filter/grc/filter_pfb_arb_resampler.xml +++ b/gr-filter/grc/filter_pfb_arb_resampler.xml @@ -15,7 +15,8 @@ $nfilts, $atten) </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/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt index c85588157..5fa06701d 100644 --- a/gr-filter/lib/CMakeLists.txt +++ b/gr-filter/lib/CMakeLists.txt @@ -97,13 +97,13 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${VOLK_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories( ${Boost_LIBRARY_DIRS} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) if(ENABLE_GR_CTRLPORT) diff --git a/gr-howto-write-a-block/CMakeLists.txt b/gr-howto-write-a-block/CMakeLists.txt index cd7e447f6..760a7b62e 100644 --- a/gr-howto-write-a-block/CMakeLists.txt +++ b/gr-howto-write-a-block/CMakeLists.txt @@ -110,7 +110,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/include ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${CPPUNIT_INCLUDE_DIRS} ) @@ -118,7 +118,7 @@ include_directories( link_directories( ${GNURADIO_CORE_LIBRARY_DIRS} ${GRUEL_LIBRARY_DIRS} - ${LOG4CXX_LIBRARY_DIRS} + ${LOG4CPP_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${CPPUNIT_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 000000000..0b7208630 --- /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/FindLog4cxx.cmake b/gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake deleted file mode 100644 index b1e4f6f1f..000000000 --- a/gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# CMake module to find LOG4CXX library - -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_LOG4CXX liblog4cxx) - -FIND_PATH( - LOG4CXX_INCLUDE_DIRS - NAMES log4cxx/log4cxx.h - HINTS $ENV{LOG4CXX_DIR}/include - ${PC_LOG4CXX_INCLUDE_DIRS} - PATHS /usr/local/include - /usr/include -) - -FIND_LIBRARY( - LOG4CXX_LIBRARIES - NAMES log4cxx - HINTS $ENV{LOG4CXX_DIR}/lib - ${PC_LOG4CXX_LIBRARIES} - PATHS /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 -) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LOG4CXX DEFAULT_MSG LOG4CXX_LIBRARIES LOG4CXX_INCLUDE_DIRS) -MARK_AS_ADVANCED(LOG4CXX_LIBRARIES LOG4CXX_INCLUDE_DIRS) diff --git a/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake b/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake index 685ac3c87..876e71687 100644 --- a/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake +++ b/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake @@ -219,35 +219,35 @@ endfunction(GR_GEN_TARGET_DEPS) # Can manually set with -DENABLE_GR_LOG=0|1 ######################################################################## function(GR_LOGGING) - find_package(Log4cxx) + 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 LOG4CXX; if we have it, use this version of the logger + # also test LOG4CPP; if we have it, use this version of the logger # otherwise, default to the stdout/stderr model. - if(LOG4CXX_FOUND) - SET(HAVE_LOG4CXX True) - add_definitions( -DHAVE_LOG4CXX ) - else(LOG4CXX_FOUND) - SET(HAVE_LOG4CXX False) - SET(LOG4CXX_INCLUDE_DIRS "") - SET(LOG4CXX_LIBRARY_DIRS "") - SET(LOG4CXX_LIBRARIES "") - endif(LOG4CXX_FOUND) + 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_LOG4CXX False) - SET(LOG4CXX_INCLUDE_DIRS) - SET(LOG4CXX_LIBRARY_DIRS) - SET(LOG4CXX_LIBRARIES) + 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_LOG4CXX set to ${HAVE_LOG4CXX}.") + 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 2c995b868..826138bf9 100644 --- a/gr-howto-write-a-block/lib/CMakeLists.txt +++ b/gr-howto-write-a-block/lib/CMakeLists.txt @@ -25,13 +25,12 @@ include(GrPlatform) #define LIB_SUFFIX include_directories(${Boost_INCLUDE_DIR}) link_directories(${Boost_LIBRARY_DIRS}) -add_library(gnuradio-howto SHARED square_ff_impl.cc square2_ff_impl.cc) -target_link_libraries(gnuradio-howto - ${Boost_LIBRARIES} - ${GRUEL_LIBRARIES} - ${GNURADIO_CORE_LIBRARIES} - ${LOG4CXX_LIBRARIES} -) +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} + ${LOG4CPP_LIBRARIES}) set_target_properties(gnuradio-howto PROPERTIES DEFINE_SYMBOL "gnuradio_howto_EXPORTS") diff --git a/gr-noaa/examples/file_rx_hrpt.grc b/gr-noaa/examples/file_rx_hrpt.grc index 0b490269b..3a7caaed7 100644 --- a/gr-noaa/examples/file_rx_hrpt.grc +++ b/gr-noaa/examples/file_rx_hrpt.grc @@ -318,7 +318,7 @@ </param> </block> <block> - <key>gr_file_sink</key> + <key>blocks_file_sink</key> <param> <key>id</key> <value>frame_sink</value> @@ -469,10 +469,10 @@ </param> </block> <block> - <key>gr_file_source</key> + <key>blocks_file_source</key> <param> <key>id</key> - <value>gr_file_source_0</value> + <value>blocks_file_source_0</value> </param> <param> <key>_enabled</key> @@ -883,7 +883,7 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_file_source_0</source_block_id> + <source_block_id>blocks_file_source_0</source_block_id> <sink_block_id>throttle</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> diff --git a/gr-noaa/examples/hrpt_decode.grc b/gr-noaa/examples/hrpt_decode.grc index 39fe195d1..2fb57746e 100644 --- a/gr-noaa/examples/hrpt_decode.grc +++ b/gr-noaa/examples/hrpt_decode.grc @@ -323,7 +323,7 @@ </param> </block> <block> - <key>gr_file_source</key> + <key>blocks_file_source</key> <param> <key>id</key> <value>file_source</value> diff --git a/gr-noaa/examples/hrpt_demod.grc b/gr-noaa/examples/hrpt_demod.grc index feb352d9d..1400f5ed1 100644 --- a/gr-noaa/examples/hrpt_demod.grc +++ b/gr-noaa/examples/hrpt_demod.grc @@ -196,7 +196,7 @@ </param> </block> <block> - <key>gr_file_source</key> + <key>blocks_file_source</key> <param> <key>id</key> <value>file_source</value> @@ -521,10 +521,10 @@ </param> </block> <block> - <key>gr_file_sink</key> + <key>blocks_file_sink</key> <param> <key>id</key> - <value>gr_file_sink_0</value> + <value>blocks_file_sink_0</value> </param> <param> <key>_enabled</key> @@ -720,7 +720,7 @@ </connection> <connection> <source_block_id>noaa_hrpt_deframer_0</source_block_id> - <sink_block_id>gr_file_sink_0</sink_block_id> + <sink_block_id>blocks_file_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-noaa/examples/usrp_rx_hrpt.grc b/gr-noaa/examples/usrp_rx_hrpt.grc index 2cf2a7fe0..1f61a8880 100644 --- a/gr-noaa/examples/usrp_rx_hrpt.grc +++ b/gr-noaa/examples/usrp_rx_hrpt.grc @@ -1872,7 +1872,7 @@ </param> </block> <block> - <key>gr_file_sink</key> + <key>blocks_file_sink</key> <param> <key>id</key> <value>frame_sink</value> diff --git a/gr-noaa/examples/usrp_rx_hrpt_nogui.grc b/gr-noaa/examples/usrp_rx_hrpt_nogui.grc index cfaa8c631..3594ca035 100644 --- a/gr-noaa/examples/usrp_rx_hrpt_nogui.grc +++ b/gr-noaa/examples/usrp_rx_hrpt_nogui.grc @@ -1250,7 +1250,7 @@ </param> </block> <block> - <key>gr_file_sink</key> + <key>blocks_file_sink</key> <param> <key>id</key> <value>frame_sink</value> diff --git a/gr-noaa/lib/CMakeLists.txt b/gr-noaa/lib/CMakeLists.txt index baa4c732a..df0eafb0f 100644 --- a/gr-noaa/lib/CMakeLists.txt +++ b/gr-noaa/lib/CMakeLists.txt @@ -24,12 +24,12 @@ include_directories( ${GR_NOAA_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories(${Boost_LIBRARY_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) if(ENABLE_GR_CTRLPORT) ADD_DEFINITIONS(-DGR_CTRLPORT) @@ -62,7 +62,7 @@ endif(MSVC) list(APPEND noaa_libs gnuradio-core ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-noaa SHARED ${noaa_sources}) diff --git a/gr-pager/apps/usrp_flex b/gr-pager/apps/usrp_flex index 33877ea4e..811c6e95c 100755 --- a/gr-pager/apps/usrp_flex +++ b/gr-pager/apps/usrp_flex @@ -21,6 +21,7 @@ # from gnuradio import gr, gru, uhd, optfir, eng_notation, pager +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import time, os, sys @@ -65,12 +66,12 @@ class app_top_block(gr.top_block): else: # Use supplied file as source of samples - self.u = gr.file_source(gr.sizeof_gr_complex, options.from_file) + self.u = blocks.file_source(gr.sizeof_gr_complex, options.from_file) if options.verbose: print "Reading samples from", options.from_file if options.log and not options.from_file: - usrp_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') + usrp_sink = blocks.file_sink(gr.sizeof_gr_complex, 'usrp.dat') self.connect(self.u, usrp_sink) # Set up 22KHz-wide bandpass about center frequency. Decimate by 10 @@ -91,7 +92,7 @@ class app_top_block(gr.top_block): 250e3) # Sample rate if options.log: - chan_sink = gr.file_sink(gr.sizeof_gr_complex, 'chan.dat') + chan_sink = blocks.file_sink(gr.sizeof_gr_complex, 'chan.dat') self.connect(self.chan, chan_sink) # FLEX protocol demodulator diff --git a/gr-pager/apps/usrp_flex_all b/gr-pager/apps/usrp_flex_all index 06b5eb7e3..58fcc0af4 100755 --- a/gr-pager/apps/usrp_flex_all +++ b/gr-pager/apps/usrp_flex_all @@ -21,6 +21,7 @@ # from gnuradio import gr, uhd, eng_notation, pager +from gnuradio import blocks from gnuradio import filter from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -32,7 +33,7 @@ class app_top_block(gr.top_block): gr.top_block.__init__(self, "usrp_flex_all") if options.from_file is not None: - self.u = gr.file_source(gr.sizeof_gr_complex, options.from_file) + self.u = blocks.file_source(gr.sizeof_gr_complex, options.from_file) self.nchan = options.nchan if options.verbose: print "Reading samples from file", options.from_file @@ -93,7 +94,7 @@ class app_top_block(gr.top_block): self.connect(self.u, self.bank) if options.log and options.from_file == None: - src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') + src_sink = blocks.file_sink(gr.sizeof_gr_complex, 'usrp.dat') self.connect(self.u, src_sink) mid_chan = int(self.nchan/2) @@ -108,7 +109,7 @@ class app_top_block(gr.top_block): else: self.connect((self.bank, i), pager.flex_demod(queue, freq, options.verbose, options.log)) if options.log: - self.connect((self.bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat')) + self.connect((self.bank, i), blocks.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat')) def get_options(): diff --git a/gr-pager/apps/usrp_flex_band b/gr-pager/apps/usrp_flex_band index 78b87aaba..3a24d6cd5 100755 --- a/gr-pager/apps/usrp_flex_band +++ b/gr-pager/apps/usrp_flex_band @@ -21,6 +21,7 @@ # from gnuradio import gr, uhd, eng_notation, pager +from gnuradio import blocks from gnuradio import filter from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -31,7 +32,7 @@ class app_top_block(gr.top_block): gr.top_block.__init__(self, "usrp_flex_all") if options.from_file is not None: - self.u = gr.file_source(gr.sizeof_gr_complex, options.from_file) + self.u = blocks.file_source(gr.sizeof_gr_complex, options.from_file) if options.verbose: print "Reading samples from file", options.from_file else: @@ -78,7 +79,7 @@ class app_top_block(gr.top_block): self.connect(self.u, bank) if options.log and options.from_file == None: - src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') + src_sink = blocks.file_sink(gr.sizeof_gr_complex, 'usrp.dat') self.connect(self.u, src_sink) for i in range(40): @@ -89,7 +90,7 @@ class app_top_block(gr.top_block): self.connect((bank, i), pager.flex_demod(queue, freq, options.verbose, options.log)) if options.log: - self.connect((bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat')) + self.connect((bank, i), blocks.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat')) def get_options(): diff --git a/gr-pager/include/pager/CMakeLists.txt b/gr-pager/include/pager/CMakeLists.txt index 57b96199b..6577e7f4e 100644 --- a/gr-pager/include/pager/CMakeLists.txt +++ b/gr-pager/include/pager/CMakeLists.txt @@ -27,6 +27,6 @@ install(FILES flex_deinterleave.h flex_parse.h flex_sync.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/noaa - COMPONENT "noaa_devel" + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/pager + COMPONENT "pager_devel" ) diff --git a/gr-pager/lib/CMakeLists.txt b/gr-pager/lib/CMakeLists.txt index 3c5ffc817..3349d2d78 100644 --- a/gr-pager/lib/CMakeLists.txt +++ b/gr-pager/lib/CMakeLists.txt @@ -30,8 +30,8 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Setup library @@ -65,7 +65,7 @@ list(APPEND pager_libs gnuradio-core gnuradio-blocks ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-pager SHARED ${pager_sources}) diff --git a/gr-pager/python/flex_demod.py b/gr-pager/python/flex_demod.py index 85797f370..3ed469886 100644 --- a/gr-pager/python/flex_demod.py +++ b/gr-pager/python/flex_demod.py @@ -21,6 +21,7 @@ from gnuradio import gr from gnuradio import analog +from gnuradio import blocks from gnuradio import filter from math import pi import pager_swig @@ -54,9 +55,9 @@ class flex_demod(gr.hier_block2): if log: suffix = '_'+ "%3.3f" % (freq/1e6,) + '.dat' - quad_sink = gr.file_sink(gr.sizeof_float, 'quad'+suffix) - rsamp_sink = gr.file_sink(gr.sizeof_float, 'rsamp'+suffix) - slicer_sink = gr.file_sink(gr.sizeof_char, 'slicer'+suffix) + quad_sink = blocks.file_sink(gr.sizeof_float, 'quad'+suffix) + rsamp_sink = blocks.file_sink(gr.sizeof_float, 'rsamp'+suffix) + slicer_sink = blocks.file_sink(gr.sizeof_char, 'slicer'+suffix) self.connect(rsamp, rsamp_sink) self.connect(quad, quad_sink) self.connect(self.slicer, slicer_sink) diff --git a/gr-qtgui/apps/uhd_display.py b/gr-qtgui/apps/uhd_display.py index 81950b99a..0e0c8a177 100755 --- a/gr-qtgui/apps/uhd_display.py +++ b/gr-qtgui/apps/uhd_display.py @@ -235,7 +235,7 @@ class my_top_block(gr.top_block): self.lock() # Add file sink to save data - self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) + self.file_sink = blocks.file_sink(gr.sizeof_gr_complex, name) self.connect(self.amp, self.file_sink) self.unlock() diff --git a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml b/gr-qtgui/grc/qtgui_waterfall_sink_x.xml index 5a17f7d51..176a907e9 100644 --- a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml +++ b/gr-qtgui/grc/qtgui_waterfall_sink_x.xml @@ -18,6 +18,7 @@ qtgui.$(type.fcn)( $fc, \#fc $bw, \#bw $name, \#name + $nconnections \#number of inputs ) self.$(id).set_update_time($update_time) self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget) @@ -90,6 +91,13 @@ $(gui_hint()($win))</make> <type>real</type> </param> <param> + <name>Number of Inputs</name> + <key>nconnections</key> + <value>1</value> + <type>int</type> + <hide>part</hide> + </param> + <param> <name>Update Period</name> <key>update_time</key> <value>0.10</value> @@ -106,7 +114,7 @@ $(gui_hint()($win))</make> <sink> <name>in</name> <type>$type</type> - <nports>1</nports> + <nports>$nconnections</nports> </sink> <doc> The GUI hint can be used to position the widget within the application. \ diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt index 2395136e0..ff1e64ce3 100644 --- a/gr-qtgui/lib/CMakeLists.txt +++ b/gr-qtgui/lib/CMakeLists.txt @@ -109,7 +109,7 @@ include_directories( ${QWT_INCLUDE_DIRS} ${QT_INCLUDE_DIRS} ${FFTW3F_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ) @@ -117,7 +117,7 @@ include_directories( link_directories( ${QWT_LIBRARY_DIRS} ${FFTW3F_LIBRARY_DIRS} - ${LOG4CXX_LIBRARY_DIRS} + ${LOG4CPP_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ) @@ -140,7 +140,7 @@ list(APPEND qtgui_libs ${QT_LIBRARIES} ${PYTHON_LIBRARIES} ${FFTW3F_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_definitions(-DQWT_DLL) #setup QWT library linkage diff --git a/gr-shd/apps/shd_rx_cfile b/gr-shd/apps/shd_rx_cfile index 5b4178cf7..ceae85834 100755 --- a/gr-shd/apps/shd_rx_cfile +++ b/gr-shd/apps/shd_rx_cfile @@ -27,6 +27,7 @@ outputs single precision complex float values or complex short values """ from gnuradio import gr, eng_notation +from gnuradio import blocks from gnuradio import shd from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -44,12 +45,12 @@ class rx_cfile_block(gr.top_block): self._src = shd.smini_source(device_addr=options.address, io_type=shd.io_type.COMPLEX_INT16, num_channels=1) - self._sink = gr.file_sink(gr.sizeof_short*2, filename) + self._sink = blocks.file_sink(gr.sizeof_short*2, filename) else: self._src = shd.smini_source(device_addr=options.address, io_type=shd.io_type.COMPLEX_FLOAT32, num_channels=1) - self._sink = gr.file_sink(gr.sizeof_gr_complex, filename) + self._sink = blocks.file_sink(gr.sizeof_gr_complex, filename) # Set receiver sample rate self._src.set_samp_rate(options.samp_rate) diff --git a/gr-shd/lib/CMakeLists.txt b/gr-shd/lib/CMakeLists.txt index c5691a61c..0f75726ad 100644 --- a/gr-shd/lib/CMakeLists.txt +++ b/gr-shd/lib/CMakeLists.txt @@ -31,8 +31,8 @@ include_directories( link_directories(${SHD_LIBRARY_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # Setup library @@ -60,7 +60,7 @@ list(APPEND shd_libs gnuradio-core ${Boost_LIBRARIES} ${SHD_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-shd SHARED ${gr_shd_sources}) diff --git a/gr-trellis/src/lib/CMakeLists.txt b/gr-trellis/src/lib/CMakeLists.txt index 8515aa21a..d2e5fb19f 100644 --- a/gr-trellis/src/lib/CMakeLists.txt +++ b/gr-trellis/src/lib/CMakeLists.txt @@ -32,8 +32,8 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) -include_directories(${LOG4CXX_INCLUDE_DIRS}) -link_directories(${LOG4CXX_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # generate the python helper script which calls into the build utils @@ -167,7 +167,7 @@ endif(MSVC) list(APPEND trellis_libs gnuradio-core ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-trellis SHARED ${gr_trellis_sources}) diff --git a/gr-uhd/apps/hf_explorer/hfx.py b/gr-uhd/apps/hf_explorer/hfx.py index 9e0080513..93d34c097 100755 --- a/gr-uhd/apps/hf_explorer/hfx.py +++ b/gr-uhd/apps/hf_explorer/hfx.py @@ -255,7 +255,7 @@ class MyFrame(wx.Frame): self.tune_offset = 0 else: - self.src = gr.file_source (gr.sizeof_short,options.input_file) + self.src = blocks.file_source (gr.sizeof_short,options.input_file) self.tune_offset = 2200 # 2200 works for 3.5-4Mhz band # convert rf data in interleaved short int form to complex @@ -271,7 +271,7 @@ class MyFrame(wx.Frame): # save radio data to a file if SAVE_RADIO_TO_FILE: - radio_file = gr.file_sink(gr.sizeof_short, options.radio_file) + radio_file = blocks.file_sink(gr.sizeof_short, options.radio_file) self.tb.connect (self.src, radio_file) # 2nd DDC @@ -375,7 +375,7 @@ class MyFrame(wx.Frame): self.tb.connect(agc,dst) if SAVE_AUDIO_TO_FILE: - f_out = gr.file_sink(gr.sizeof_short,options.audio_file) + f_out = blocks.file_sink(gr.sizeof_short,options.audio_file) sc1 = blocks.multiply_const_ff(64000) f2s1 = blocks.float_to_short() self.tb.connect(agc,sc1,f2s1,f_out) diff --git a/gr-uhd/apps/uhd_rx_cfile b/gr-uhd/apps/uhd_rx_cfile index 62874771c..f9ed39256 100755 --- a/gr-uhd/apps/uhd_rx_cfile +++ b/gr-uhd/apps/uhd_rx_cfile @@ -27,6 +27,7 @@ outputs single precision complex float values or complex short values """ from gnuradio import gr, gru, eng_notation +from gnuradio import blocks from gnuradio import uhd from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -43,11 +44,11 @@ class rx_cfile_block(gr.top_block): if options.output_shorts: self._u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('sc16', options.wire_format, args=options.stream_args)) - self._sink = gr.file_sink(gr.sizeof_short*2, filename) + self._sink = blocks.file_sink(gr.sizeof_short*2, filename) else: self._u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32', options.wire_format, args=options.stream_args)) - self._sink = gr.file_sink(gr.sizeof_gr_complex, filename) + self._sink = blocks.file_sink(gr.sizeof_gr_complex, filename) # Set the subdevice spec if(options.spec): diff --git a/gr-uhd/examples/python/fm_tx4.py b/gr-uhd/examples/python/fm_tx4.py index e4cf3ded2..fefa67861 100755 --- a/gr-uhd/examples/python/fm_tx4.py +++ b/gr-uhd/examples/python/fm_tx4.py @@ -56,7 +56,7 @@ class pipeline(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_gr_complex)) try: - src = gr.file_source (gr.sizeof_float, filename, True) + src = blocks.file_source (gr.sizeof_float, filename, True) except RuntimeError: sys.stderr.write(("\nError: Could not open file '%s'\n\n" % \ filename)) diff --git a/gr-uhd/examples/python/usrp_tv_rcv.py b/gr-uhd/examples/python/usrp_tv_rcv.py index 3e612f6a0..d94b65166 100755 --- a/gr-uhd/examples/python/usrp_tv_rcv.py +++ b/gr-uhd/examples/python/usrp_tv_rcv.py @@ -124,7 +124,7 @@ class tv_rx_block (stdgui2.std_top_block): if not ((filename is None) or (filename=="usrp")): # file is data source - self.filesource = gr.file_source(gr.sizeof_short,filename,options.repeat) + self.filesource = blocks.file_source(gr.sizeof_short,filename,options.repeat) self.istoc = blocks.interleaved_short_to_complex() self.connect(self.filesource,self.istoc) self.src=self.istoc @@ -193,7 +193,7 @@ class tv_rx_block (stdgui2.std_top_block): + " gray:" + options.out_filename print "(Use the spacebar to advance to next frames)" options.repeat=False - file_sink=gr.file_sink(gr.sizeof_char, options.out_filename) + file_sink = blocks.file_sink(gr.sizeof_char, options.out_filename) self.dst =file_sink self.agc = analog.agc_cc(1e-7,1.0,1.0) #1e-7 diff --git a/gr-uhd/examples/python/usrp_tv_rcv_nogui.py b/gr-uhd/examples/python/usrp_tv_rcv_nogui.py index 5eef4a00f..13395cef4 100755 --- a/gr-uhd/examples/python/usrp_tv_rcv_nogui.py +++ b/gr-uhd/examples/python/usrp_tv_rcv_nogui.py @@ -120,9 +120,9 @@ class my_top_block(gr.top_block): if not (options.in_filename=="usrp"): # file is data source, capture with usr_rx_csfile.py - self.filesource = gr.file_source(gr.sizeof_short, - options.in_filename, - options.repeat) + self.filesource = blocks.file_source(gr.sizeof_short, + options.in_filename, + options.repeat) self.istoc = blocks.interleaved_short_to_complex() self.connect(self.filesource,self.istoc) self.src=self.istoc @@ -196,7 +196,7 @@ class my_top_block(gr.top_block): print "use the following line to show the demodulated TV-signal:" print "display -depth 8 -size " +str(width)+ "x" + str(height) + " gray:" +filename print "(Use the spacebar to advance to next frames)" - file_sink=gr.file_sink(gr.sizeof_char, filename) + file_sink = blocks.file_sink(gr.sizeof_char, filename) self.dst =file_sink if options.nframes is None: diff --git a/gr-uhd/lib/CMakeLists.txt b/gr-uhd/lib/CMakeLists.txt index a6bd4e98b..07ea65709 100644 --- a/gr-uhd/lib/CMakeLists.txt +++ b/gr-uhd/lib/CMakeLists.txt @@ -41,6 +41,9 @@ if(ENABLE_GR_CTRLPORT) include_directories(${ICE_INCLUDE_DIR}) endif(ENABLE_GR_CTRLPORT) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -68,7 +71,7 @@ list(APPEND uhd_libs gnuradio-core ${Boost_LIBRARIES} ${UHD_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-uhd SHARED ${gr_uhd_sources}) diff --git a/gr-utils/python/modtool/templates.py b/gr-utils/python/modtool/templates.py index 706017cc2..87eb9f470 100644 --- a/gr-utils/python/modtool/templates.py +++ b/gr-utils/python/modtool/templates.py @@ -275,7 +275,7 @@ ${str_to_python_comment($license)} #if $blocktype in ('sync', 'sink', 'source') #set $parenttype = 'gr.sync_block' #else -#set $parenttype = {'hier': 'gr.hier_block2', 'interpolator': 'gr.interp_block', 'decimator': 'gr.decim_block', 'general': 'gr.block'}[$blocktype] +#set $parenttype = {'hier': 'gr.hier_block2', 'interpolator': 'gr.interp_block', 'decimator': 'gr.decim_block', 'general': 'gr.basic_block'}[$blocktype] #end if #if $blocktype != 'hier' import numpy @@ -338,7 +338,7 @@ class ${blockname}(${parenttype}): def general_work(self, input_items, output_items): output_items[0][:] = input_items[0] - consume(0, len(input_items[0]) + consume(0, len(input_items[0])) \#self.consume_each(len(input_items[0])) return len(output_items[0]) #stop diff --git a/gr-video-sdl/src/CMakeLists.txt b/gr-video-sdl/src/CMakeLists.txt index 1e37505ac..805318223 100644 --- a/gr-video-sdl/src/CMakeLists.txt +++ b/gr-video-sdl/src/CMakeLists.txt @@ -25,7 +25,7 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} - ${LOG4CXX_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${SDL_INCLUDE_DIR} ) @@ -57,7 +57,7 @@ list(APPEND video_sdl_libs gnuradio-core ${Boost_LIBRARIES} ${SDL_LIBRARY} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-video-sdl SHARED ${gr_video_sdl_sources}) diff --git a/gr-vocoder/examples/cvsd_audio_loopback.py b/gr-vocoder/examples/cvsd_audio_loopback.py index ef4c6ded2..b9385b7dc 100755 --- a/gr-vocoder/examples/cvsd_audio_loopback.py +++ b/gr-vocoder/examples/cvsd_audio_loopback.py @@ -50,15 +50,15 @@ def build_graph(): tb.connect(enc, dec, s2f, decim, sink_scale, sink) if 0: # debug - tb.conect(src, gr.file_sink(gr.sizeof_float, "source.dat")) - tb.conect(src_scale, gr.file_sink(gr.sizeof_float, "src_scale.dat")) - tb.conect(interp, gr.file_sink(gr.sizeof_float, "interp.dat")) - tb.conect(f2s, gr.file_sink(gr.sizeof_short, "f2s.dat")) - tb.conect(enc, gr.file_sink(gr.sizeof_char, "enc.dat")) - tb.conect(dec, gr.file_sink(gr.sizeof_short, "dec.dat")) - tb.conect(s2f, gr.file_sink(gr.sizeof_float, "s2f.dat")) - tb.conect(decim, gr.file_sink(gr.sizeof_float, "decim.dat")) - tb.conect(sink_scale, gr.file_sink(gr.sizeof_float, "sink_scale.dat")) + tb.conect(src, blocks.file_sink(gr.sizeof_float, "source.dat")) + tb.conect(src_scale, blocks.file_sink(gr.sizeof_float, "src_scale.dat")) + tb.conect(interp, blocks.file_sink(gr.sizeof_float, "interp.dat")) + tb.conect(f2s, blocks.file_sink(gr.sizeof_short, "f2s.dat")) + tb.conect(enc, blocks.file_sink(gr.sizeof_char, "enc.dat")) + tb.conect(dec, blocks.file_sink(gr.sizeof_short, "dec.dat")) + tb.conect(s2f, blocks.file_sink(gr.sizeof_float, "s2f.dat")) + tb.conect(decim, blocks.file_sink(gr.sizeof_float, "decim.dat")) + tb.conect(sink_scale, blocks.file_sink(gr.sizeof_float, "sink_scale.dat")) return tb diff --git a/gr-vocoder/lib/CMakeLists.txt b/gr-vocoder/lib/CMakeLists.txt index 3b4fb859b..32f1ef0fb 100644 --- a/gr-vocoder/lib/CMakeLists.txt +++ b/gr-vocoder/lib/CMakeLists.txt @@ -36,6 +36,9 @@ if(ENABLE_GR_CTRLPORT) include_directories(${ICE_INCLUDE_DIR}) endif(ENABLE_GR_CTRLPORT) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -82,7 +85,7 @@ GR_INCLUDE_SUBDIRECTORY(gsm) list(APPEND vocoder_libs gnuradio-core ${Boost_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-vocoder SHARED ${gr_vocoder_sources}) diff --git a/gr-wavelet/lib/CMakeLists.txt b/gr-wavelet/lib/CMakeLists.txt index 090392f58..a78a24e22 100644 --- a/gr-wavelet/lib/CMakeLists.txt +++ b/gr-wavelet/lib/CMakeLists.txt @@ -44,6 +44,10 @@ if(ENABLE_GR_CTRLPORT) include_directories(${ICE_INCLUDE_DIR}) endif(ENABLE_GR_CTRLPORT) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + + ######################################################################## # Setup library ######################################################################## @@ -73,7 +77,7 @@ list(APPEND wavelet_libs ${Boost_LIBRARIES} ${WAVELET_LIBRARIES} ${GSL_LIBRARIES} - ${LOG4CXX_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-wavelet SHARED ${gr_wavelet_sources}) diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index ab8489f7d..e9da1ec88 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -11,10 +11,7 @@ <block>gr_vector_source_x</block> <block>random_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>pad_source</block> <block>virtual_source</block> </cat> @@ -22,10 +19,7 @@ <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>pad_sink</block> <block>virtual_sink</block> </cat> diff --git a/grc/blocks/gr_vector_source_x.xml b/grc/blocks/gr_vector_source_x.xml index 7a6a3aeff..992a6a787 100644 --- a/grc/blocks/gr_vector_source_x.xml +++ b/grc/blocks/gr_vector_source_x.xml @@ -8,7 +8,8 @@ <name>Vector Source</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> @@ -48,7 +49,13 @@ <name>Vector</name> <key>vector</key> <value>0, 0, 0</value> - <type>$type.vec_type</type> + <type>raw</type> + </param> + <param> + <name>Tags</name> + <key>tags</key> + <value>[]</value> + <type>raw</type> </param> <param> <name>Repeat</name> |