diff options
192 files changed, 11411 insertions, 107 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b81d76ce84..64eccbbeb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,8 +120,10 @@ set(GR_PREFSDIR ${SYSCONFDIR}/${CMAKE_PROJECT_NAME}/conf.d) OPTION(ENABLE_PERFORMANCE_COUNTERS "Enable block performance counters" OFF) if(ENABLE_PERFORMANCE_COUNTERS) message(STATUS "ADDING PERF COUNTERS") + SET(GR_PERFORMANCE_COUNTERS True) add_definitions(-DGR_PERFORMANCE_COUNTERS) else(ENABLE_PERFORMANCE_COUNTERS) + SET(GR_PERFORMANCE_COUNTERS False) message(STATUS "NO PERF COUNTERS") endif(ENABLE_PERFORMANCE_COUNTERS) @@ -226,6 +228,9 @@ CPACK_COMPONENT("volk_devel" add_subdirectory(volk) endif(ENABLE_VOLK) +# Handle gr_log enable/disable +GR_LOGGING() + ######################################################################## # Distribute the README file ######################################################################## @@ -275,6 +280,28 @@ add_subdirectory(gr-wavelet) add_subdirectory(gr-wxgui) add_subdirectory(gr-blocks) +# Create a config.h with some definitions to export to other projects. +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/config.h +) + +# Install config.h in include/gnuradio +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/config.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_devel" +) + +# Install our Cmake modules into ${GR_PKG_DATA_DIR}/cmake/Modules +file(GLOB cmake_modules "cmake/Modules/*.cmake") +install( + FILES ${cmake_modules} + DESTINATION ${GR_PKG_DATA_DIR}/cmake/Modules + COMPONENT "core_devel" +) + #finalize cpack after subdirs processed include(GrPackage) CPACK_FINALIZE() diff --git a/cmake/Modules/FindLog4cxx.cmake b/cmake/Modules/FindLog4cxx.cmake new file mode 100644 index 0000000000..b1e4f6f1f7 --- /dev/null +++ b/cmake/Modules/FindLog4cxx.cmake @@ -0,0 +1,28 @@ +# 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 3e80846d62..c7fe77bc88 100644 --- a/cmake/Modules/GrMiscUtils.cmake +++ b/cmake/Modules/GrMiscUtils.cmake @@ -209,6 +209,47 @@ function(GR_GEN_TARGET_DEPS name var) endif() endfunction(GR_GEN_TARGET_DEPS) +######################################################################## +# Control use of gr_logger +# Usage: +# GR_LOGGING() +# +# Will set ENABLE_GR_LOG to 1 by default. +# Can manually set with -DENABLE_GR_LOG=0|1 +######################################################################## +function(GR_LOGGING) + find_package(Log4cxx) + + 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 + # 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) + + 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) + endif(ENABLE_GR_LOG) + + message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.") + message(STATUS "HAVE_LOG4CXX set to ${HAVE_LOG4CXX}.") + +endfunction(GR_LOGGING) ######################################################################## # Run GRCC to compile .grc files into .py files. diff --git a/cmake/Modules/GrVersion.cmake b/cmake/Modules/GrVersion.cmake index 9199a702bb..bafd0a7326 100644 --- a/cmake/Modules/GrVersion.cmake +++ b/cmake/Modules/GrVersion.cmake @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -54,6 +54,8 @@ if("${MINOR_VERSION}" STREQUAL "git") set(VERSION "${GIT_DESCRIBE}") set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") + set(RC_MINOR_VERSION "0") + set(RC_MAINT_VERSION "0") elseif("${MAINT_VERSION}" STREQUAL "git") # VERSION: 3.3.1git-xxx-gxxxxxxxx # DOCVER: 3.3.1git @@ -61,6 +63,8 @@ elseif("${MAINT_VERSION}" STREQUAL "git") set(VERSION "${GIT_DESCRIBE}") set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") + math(EXPR RC_MINOR_VERSION "${MINOR_VERSION} - 1") + set(RC_MAINT_VERSION "0") else() # This is a numbered release. # VERSION: 3.3.1{.x} @@ -73,4 +77,6 @@ else() endif() set(DOCVER "${VERSION}") set(LIBVER "${VERSION}") + set(RC_MINOR_VERSION ${MINOR_VERSION}) + set(RC_MAINT_VERSION ${MAINT_VERSION}) endif() diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000000..325cb838ef --- /dev/null +++ b/config.h.in @@ -0,0 +1,30 @@ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef GNURADIO_CONFIG_H +#define GNURADIO_CONFIG_H + +#cmakedefine TRY_SHM_VMCIRCBUF +#cmakedefine GR_PERFORMANCE_COUNTERS +#cmakedefine ENABLE_GR_LOG +#cmakedefine HAVE_LOG4CXX + +#endif /* GNURADIO_CONFIG_H */ diff --git a/docs/doxygen/other/extra_pages.dox b/docs/doxygen/other/extra_pages.dox index d40c692e03..44cdf9d483 100644 --- a/docs/doxygen/other/extra_pages.dox +++ b/docs/doxygen/other/extra_pages.dox @@ -79,6 +79,8 @@ audio-osx and audio-windows to be either satisfied or built. \subsection dep_gr_comedi gr-comedi: Comedi hardware interface \li comedilib (>= 0.8) http://www.comedi.org/ +\subsection dep_gr_log gr-log: Logging Tools (Optional) +\li log4cxx (>= 0.10.0) http://logging.apache.org/log4cxx \section build_gr_cmake Building GNU Radio diff --git a/docs/doxygen/other/logger.dox b/docs/doxygen/other/logger.dox new file mode 100644 index 0000000000..f98a64657b --- /dev/null +++ b/docs/doxygen/other/logger.dox @@ -0,0 +1,202 @@ +/*! \page page_logger Logging + +\section logging Logging + +GNU Radio has a logging interface to enable various levels of logging +information to be printed to the console or a file. The logger derives +from log4cxx (http://logging.apache.org/log4cxx) 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 +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 + +The order here determines the level of output. These levels are +hierarchical in that specifying any level also includes any level +above it. For example, when using the Debug level, all Debug and +higher messages are logged and Trace is ignored. + +\subsection configfile Logging Configuration + +The logging configuration can be found in the gnuradio-core.conf file +under the [LOG] section. This allows us fairly complete control over +the logging facilities. The main configuration functions are to set up +the level of the loggers and set the default output behavior of the +loggers. + +There are two default loggers that all gr_block's have access to: +d_logger and d_debug_logger. The first is a standard logger meant to +output simple information about the block while it is running. The +debug logger is meant for debugging purposes and is added to make it +convenient to use a secondary logger that outputs to a different +stream or file. + +The four main configure options are: + +<pre> + log_level = all + debug_level = all + 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 +use files but instead output to the console. The standard logger will +output to standard out while the debug logger outputs to standard +error. + +Changing these last two lines to another value will create files that +are used to store the log messages. All messages are appended to the +file. + +When using either standard error or standard out, the messages for the +two different loggers will look like: + +<pre> + gr::log :\<level\>: \<block alias\> - \<message\> + gr::debug :\<level\>: \<block alias\> - \<message\> +</pre> + +When using a file, the only difference in the format is that the +message prefix of "gr::log" or "gr::debug" is not used. Instead, the +time in milliseconds from the start of the program is inserted. + +Remember that a local "~/.gnuradio/config.conf" file can be used to +override any parameter in the global file (see \ref prefs for more +details). + +To use these loggers inside of a GNU Radio block, we use the protected +data members of d_logger and d_debug_logger of gr_block and pass them +to our pre-defined macros: + +\code + GR_LOG_<level>(<logger>, "<Message to print>"); +\endcode + +Where \<level\> is one of the levels as mentioned above, \<logger\> is +either d_logger or d_debug_logger, and \<Message to print\> is the +message we want to output. If we wanted to output an INFO level +message to the standard logger and a WARN level message to the debug +logger, it would look like this: + +\code + GR_LOG_INFO(d_logger, "Some info about the block"); + GR_LOG_WARN(d_debug_logger, "Some warning about the block"); +\endcode + +When this is printed to wherever you are directing the output of the +logger, it will look like: + +<pre> + gr::log :INFO: <block's alias> - Some info about the block + gr::debug :WARN: <block's alias> - Some warning about the block +</pre> + +This provides us information about where the message came from, the +level of the message, and the block that generated the message. We use +the concept of the block's alias which by default (i.e., unless +otherwise set by the user) includes the name of the block and a unique +ID to distinguish it from other blocks of the same type. + +The various logging macros are defined in gr_logger.h. Here are some +simple examples of using them: + +\code + GR_LOG_TRACE(LOG, "TRACE message"); + GR_LOG_DEBUG(LOG, "DEBUG message"); + GR_LOG_INFO(LOG, "INFO 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"); +\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. + + +\subsection adv_config Advanced Configuration Options + +If not using the simplified settings discussed above, where we can +direct the logger messages to either a file or one of the standard +outputs, we must use a more complicated configuration file. We do this +by specifying the "log_config" option in the [LOG] section. The +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: + +<pre> + $prefix/etc/gnuradio/gr_log_default.xml +</pre> + +For the following examples, we will assume that our local +"~/.gnuradio/config.conf" looks like this: + +\code +[LOG] +log_config = /opt/gr/etc/gnuadio/gr_log_default.xml +log_level = All +debug_level = Off +\endcode + +Inside of the XML default configuration file, we define the parameters +for the two logger's, the standard logger the separate debug logger. + +If the levels of the two loggers are specified in our configuration +file, as in the above example, these levels override any levels +specified in the XML file. Here, we have turned on the standard logger +(d_logger) to all levels and turned off the debug logger +(d_debug_logger). So even if the debug logger is used in the code, it +will not actually output any information. Conversely, any level of +output passed to the standard logger will output because we have +turned this value to "all." + +If both an XML configuration file is set and the "log_file" or +"debug_file" options are set at the same time, both systems are +actually used. So you can configure file access and the pattern +through the XML file while also still outputting to stdout or stderr. + + +\section advlog Advanced Usage + +The description above for using the logging facilities is specific to +GNU Radio blocks. We have put the code necessary to access the +debugger into the gr_block parent class to simplify access and make +sure all blocks have the ability to quickly and easily use the logger. + +For non gr_block-based code, we have to get some information about the +logger in order to properly access it. Each logger only exists once as +a singleton in the system, but we need to get a pointer to the right +logger and then set it up for our local use. The following code +snippet shows how to do this to get access to the standard logger, +which has a root of "gr_log." (access to the debug logger is similar +except we would use "gr_log_debug." in the GR_LOG_GETLOGGER call): + +\code + gr_prefs *p = gr_prefs::singleton(); + std::string log_file = p->get_string("LOG", "log_config", ""); + std::string log_level = p->get_string("LOG", "log_level", "off"); + GR_CONFIG_LOGGER(log_file); + GR_LOG_GETLOGGER(LOG, "gr_log." + "my_logger_name"); + GR_LOG_SET_LEVEL(LOG, log_level); +\endcode + +This creates a pointer called LOG (which is instantiated as a +log4cxx:LoggerPtr in the macro) that we can now use locally as the +input to our logging macros like 'GR_LOG_TRACE(LOG, "message")'. + +*/ diff --git a/docs/doxygen/other/main_page.dox b/docs/doxygen/other/main_page.dox index e7d4685f75..8895cd552d 100644 --- a/docs/doxygen/other/main_page.dox +++ b/docs/doxygen/other/main_page.dox @@ -39,6 +39,7 @@ More details on packages in GNU Radio: \li \ref page_vocoder More details on GNU Radio concepts: +\li \ref page_logger \li \ref page_pmt \li \ref page_msg_passing \li \ref page_metadata diff --git a/gnuradio-core/CMakeLists.txt b/gnuradio-core/CMakeLists.txt index b277103547..1138bcc453 100644 --- a/gnuradio-core/CMakeLists.txt +++ b/gnuradio-core/CMakeLists.txt @@ -107,12 +107,26 @@ CPACK_COMPONENT("core_swig" DEPENDS "gruel_swig;core_python;core_devel" ) +# Setup configure file +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-core.conf.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.conf +@ONLY) + install( - FILES gnuradio-core.conf + FILES ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.conf DESTINATION ${GR_PREFSDIR} COMPONENT "core_runtime" ) +if(ENABLE_GR_LOG AND HAVE_LOG4CXX) +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) + ######################################################################## # Add subdirectories ######################################################################## diff --git a/gnuradio-core/gnuradio-core.conf b/gnuradio-core/gnuradio-core.conf deleted file mode 100644 index d575d1dc8a..0000000000 --- a/gnuradio-core/gnuradio-core.conf +++ /dev/null @@ -1,14 +0,0 @@ -# This file contains system wide configuration data for GNU Radio. -# You may override any setting on a per-user basis by editing -# ~/.gnuradio/config.conf - -[DEFAULT] - -verbose = False - -# The maximum number of messages a block will store up before pruning -# the queue by popping messages from the front. -max_messages = 100 - -[PerfCounters] -on = False diff --git a/gnuradio-core/gnuradio-core.conf.in b/gnuradio-core/gnuradio-core.conf.in new file mode 100644 index 0000000000..741525e642 --- /dev/null +++ b/gnuradio-core/gnuradio-core.conf.in @@ -0,0 +1,26 @@ +# This file contains system wide configuration data for GNU Radio. +# You may override any setting on a per-user basis by editing +# ~/.gnuradio/config.conf + +[DEFAULT] +verbose = False + +[LOG] +# Levels can be (case insensitive): +# trace, debug, info, warn, error, fatal +log_level = all +debug_level = all + +# These file names can either be 'stdout' to output to standard output +# or 'stderr' to output to standard error. Any other string will +# create a file in which to output the logging information. An empty +# string or no value here will ignore this level of configuration +# completely. +log_file = stdout +debug_file = stderr + +# Used for advanced configuration of the logger +#log_config = @CMAKE_INSTALL_PREFIX@/etc/gnuradio/gr_log_default.xml + +[PerfCounters] +on = False diff --git a/gnuradio-core/gr_log_default.xml b/gnuradio-core/gr_log_default.xml new file mode 100644 index 0000000000..13b854c7e8 --- /dev/null +++ b/gnuradio-core/gr_log_default.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + * Copyright 2006,2010,2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +--> + + <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> + + <appender name="RootConsoleAppender" class="org.apache.log4j.ConsoleAppender"> + <param name="Target" value="System.out"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="Root :%p: %c{1} - %m%n"/> + </layout> + </appender> + + <!--Add appender to root to log ALL msgs in one place--> + <root> + <priority value="all" /> + </root> + + <appender name="errLogRootConsoleAppender" class="org.apache.log4j.ConsoleAppender"> + <param name="Target" value="System.out"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="gr::log :%p: %c{1} - %m%n"/> + </layout> + </appender> + + <!-- Specify the level for some specific loggers--> + <category name="gr_log" > + <priority value ="all" /> + <appender-ref ref="errLogRootConsoleAppender"/> + </category> + + <appender name="errConsoleAppender" class="org.apache.log4j.ConsoleAppender"> + <param name="Target" value="System.out"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="gr::debug :%p: %c{1} - %m%n"/> + </layout> + </appender> + + <category name="gr_log_debug" > + <priority value ="DEBUG" /> + <appender-ref ref="errConsoleAppender"/> + </category> + + </log4j:configuration> + diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt index 89a1bad88b..fe3e530869 100644 --- a/gnuradio-core/src/lib/CMakeLists.txt +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. +# Copyright 2010-2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -39,6 +39,21 @@ list(APPEND gnuradio_core_sources bug_work_around_6.cc) list(APPEND test_gnuradio_core_sources bug_work_around_6.cc) ######################################################################## +# Set up Windows DLL resource files +######################################################################## + +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-core.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.rc + @ONLY) + + list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.rc) +ENDIF(MSVC) + +######################################################################## # Setup the include and linker paths ######################################################################## include_directories( @@ -54,13 +69,25 @@ link_directories( ${FFTW3F_LIBRARY_DIRS} ) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## + +# Only use if log4cxx is installed +# Define ENABLE_GR_LOG so .h and .cc files can turn actual +# logging and insert dummy functions. +#if(LOG4CXX_FOUND) +# add_definitions(-DENABLE_GR_LOG) +#endif(LOG4CXX_FOUND) + list(APPEND gnuradio_core_libs gruel ${Boost_LIBRARIES} ${FFTW3F_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) if(FFTW3F_THREADS_LIBRARIES) @@ -101,6 +128,6 @@ include_directories(${CPPUNIT_INCLUDE_DIRS}) link_directories(${CPPUNIT_LIBRARY_DIRS}) add_library(test-gnuradio-core SHARED ${test_gnuradio_core_sources}) -target_link_libraries(test-gnuradio-core gnuradio-core ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(test-gnuradio-core gnuradio-core ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES} ${LOG4CXX_LIBRARIES}) endif(ENABLE_TESTING) diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc index 97b8106994..95e17123c8 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc +++ b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc @@ -48,6 +48,7 @@ // #include <gr_fir_sss_mmx.h> // #include <gr_fir_sss_sse2.h> + #include <iostream> using std::cerr; @@ -207,7 +208,7 @@ gr_fir_sysconfig_x86::create_gr_fir_fcc (const std::vector<gr_complex> &taps) if (gr_cpu::has_3dnow ()){ if (first){ - cerr << ">>> gr_fir_fcc: using 3DNow!\n"; + cerr << ">>> gr_fir_fcc: gr_fir_fcc: using 3DNow!\n"; first = false; } return make_gr_fir_fcc_3dnow (taps); @@ -215,7 +216,7 @@ gr_fir_sysconfig_x86::create_gr_fir_fcc (const std::vector<gr_complex> &taps) if (gr_cpu::has_sse ()){ if (first){ - cerr << ">>> gr_fir_fcc: using SSE\n"; + cerr << ">>> gr_fir_fcc: gr_fir_fcc: using SSE\n"; first = false; } return make_gr_fir_fcc_sse (taps); @@ -326,19 +327,26 @@ gr_fir_sysconfig_x86::create_gr_fir_sss (const std::vector<short> &taps) { // FIXME -- probably want to figure out best answer for Athlon and code // add code to select it here... + static bool first = true; if (gr_cpu::has_sse2 ()){ - cerr << ">>> gr_fir_sss: using SSE2\n"; - return make_gr_fir_sss_sse2 (taps); + if(first) { + cerr << ">>> gr_fir_sss: using SSE2\n"; + return make_gr_fir_sss_sse2 (taps); + } } if (gr_cpu::has_mmx ()){ - cerr << ">>> gr_fir_sss: using MMX\n"; - return make_gr_fir_sss_mmx (taps); + if(first) { + cerr << ">>> gr_fir_sss: using MMX\n"; + return make_gr_fir_sss_mmx (taps); + } } - cerr << ">>> gr_fir_sss: handing off to parent class\n"; - return gr_fir_sysconfig_generic::create_gr_fir_sss (taps); + if(first) { + cerr << ">>> gr_fir_sss: handing off to parent class\n"; + return gr_fir_sysconfig_generic::create_gr_fir_sss (taps); + } } #endif diff --git a/gnuradio-core/src/lib/gnuradio-core.rc.in b/gnuradio-core/src/lib/gnuradio-core.rc.in new file mode 100644 index 0000000000..a5579ce4ed --- /dev/null +++ b/gnuradio-core/src/lib/gnuradio-core.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-core" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-core.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-core.dll" + VALUE "ProductName", "gnuradio-core" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gnuradio-core/src/lib/io/gr_pdu.h b/gnuradio-core/src/lib/io/gr_pdu.h index a5ae87db7f..53058ccb6c 100644 --- a/gnuradio-core/src/lib/io/gr_pdu.h +++ b/gnuradio-core/src/lib/io/gr_pdu.h @@ -23,17 +23,18 @@ #ifndef GR_PDU_H #define GR_PDU_H +#include <gr_core_api.h> #include <gr_complex.h> #include <gruel/pmt.h> -#define pdu_port_id pmt::mp("pdus") -#define pdu_length_tag pmt::mp("pdu_length") +#define PDU_PORT_ID pmt::mp("pdus") +#define PDU_LENGTH_TAG pmt::mp("pdu_length") enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex }; -size_t gr_pdu_itemsize(gr_pdu_vector_type type); -bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v); -pmt::pmt_t gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items); -gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector); +GR_CORE_API size_t gr_pdu_itemsize(gr_pdu_vector_type type); +GR_CORE_API bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v); +GR_CORE_API pmt::pmt_t gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items); +GR_CORE_API gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector); #endif diff --git a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc index 5c319dc39d..a702b66a2b 100644 --- a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc +++ b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc @@ -49,7 +49,7 @@ gr_pdu_to_tagged_stream::gr_pdu_to_tagged_stream (gr_pdu_vector_type t) gr_make_io_signature(1, 1, gr_pdu_itemsize(t))), d_vectortype(t), d_itemsize(gr_pdu_itemsize(t)) { - message_port_register_in(pdu_port_id); + message_port_register_in(PDU_PORT_ID); } gr_pdu_to_tagged_stream::~gr_pdu_to_tagged_stream() @@ -77,8 +77,8 @@ gr_pdu_to_tagged_stream::work(int noutput_items, if(noutput_items > 0){ // grab a message if one exists - //pmt::pmt_t msg( delete_head_nowait( pdu_port_id ) ); - pmt::pmt_t msg( delete_head_blocking( pdu_port_id ) ); + //pmt::pmt_t msg( delete_head_nowait( PDU_PORT_ID ) ); + pmt::pmt_t msg( delete_head_blocking( PDU_PORT_ID ) ); if(msg.get() == NULL ){ return nout; } @@ -99,7 +99,7 @@ gr_pdu_to_tagged_stream::work(int noutput_items, uint64_t offset = nitems_written(0) + nout; // add a tag for pdu length - add_item_tag(0, offset, pdu_length_tag, pmt::pmt_from_long( pmt::pmt_length(vect) ), pmt::mp(alias())); + add_item_tag(0, offset, PDU_LENGTH_TAG, pmt::pmt_from_long( pmt::pmt_length(vect) ), pmt::mp(alias())); // if we recieved metadata add it as tags if( !pmt_eq(meta, pmt::PMT_NIL) ){ diff --git a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc index 8211b7672d..1b869edfab 100644 --- a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc +++ b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc @@ -49,7 +49,7 @@ gr_tagged_stream_to_pdu::gr_tagged_stream_to_pdu (gr_pdu_vector_type t) d_vectortype(t), d_itemsize(gr_pdu_itemsize(t)), d_inpdu(false), d_pdu_meta(pmt::PMT_NIL), d_pdu_vector(pmt::PMT_NIL) { - message_port_register_out(pdu_port_id); + message_port_register_out(PDU_PORT_ID); } gr_tagged_stream_to_pdu::~gr_tagged_stream_to_pdu() @@ -70,7 +70,7 @@ gr_tagged_stream_to_pdu::work(int noutput_items, get_tags_in_range(d_tags, 0, abs_N, abs_N+1); bool found_length_tag(false); for(d_tags_itr = d_tags.begin(); (d_tags_itr != d_tags.end()) && (!found_length_tag); d_tags_itr++){ - if( pmt::pmt_equal( (*d_tags_itr).key, pdu_length_tag ) ){ + if( pmt::pmt_equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){ if( (*d_tags_itr).offset != abs_N ){ throw std::runtime_error("expected next pdu length tag on a different item..."); } @@ -91,7 +91,7 @@ gr_tagged_stream_to_pdu::work(int noutput_items, // copy any tags in this range into our meta object get_tags_in_range(d_tags, 0, abs_N, abs_N+ncopy); for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++){ - if( ! pmt_equal( (*d_tags_itr).key, pdu_length_tag ) ){ + if( ! pmt_equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){ d_pdu_meta = pmt_dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value); } } @@ -127,7 +127,7 @@ void gr_tagged_stream_to_pdu::send_message(){ } pmt::pmt_t msg = pmt::pmt_cons( d_pdu_meta, d_pdu_vector ); - message_port_pub( pdu_port_id, msg ); + message_port_pub( PDU_PORT_ID, msg ); d_pdu_meta = pmt::PMT_NIL; d_pdu_vector = pmt::PMT_NIL; diff --git a/gnuradio-core/src/lib/runtime/CMakeLists.txt b/gnuradio-core/src/lib/runtime/CMakeLists.txt index 70938a0f17..6772f7a26d 100644 --- a/gnuradio-core/src/lib/runtime/CMakeLists.txt +++ b/gnuradio-core/src/lib/runtime/CMakeLists.txt @@ -62,6 +62,7 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_local_sighandler.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_logger.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_message.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_accepter.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.cc @@ -105,6 +106,7 @@ list(APPEND test_gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/qa_block_tags.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_runtime.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_set_msg_handler.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_logger.cc ) ######################################################################## @@ -126,6 +128,7 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_local_sighandler.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_logger.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_message.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_accepter.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.h @@ -170,6 +173,7 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_dispatcher.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_logger.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_message.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_queue.i @@ -184,4 +188,5 @@ install(FILES DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig" ) + endif(ENABLE_PYTHON) diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc index 54d2676203..6c2ec4c539 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_block.cc @@ -29,6 +29,7 @@ #include <stdexcept> #include <iostream> #include <gr_block_registry.h> +#include <gr_prefs.h> gr_block::gr_block (const std::string &name, gr_io_signature_sptr input_signature, @@ -49,6 +50,52 @@ gr_block::gr_block (const std::string &name, d_min_output_buffer(std::max(output_signature->max_streams(),1), -1) { global_block_registry.register_primitive(alias(), this); + +#ifdef ENABLE_GR_LOG +#ifdef HAVE_LOG4CXX + gr_prefs *p = gr_prefs::singleton(); + std::string config_file = p->get_string("LOG", "log_config", ""); + std::string log_level = p->get_string("LOG", "log_level", "off"); + std::string log_file = p->get_string("LOG", "log_file", ""); + std::string debug_level = p->get_string("LOG", "debug_level", "off"); + std::string debug_file = p->get_string("LOG", "debug_file", ""); + + GR_CONFIG_LOGGER(config_file); + + GR_LOG_GETLOGGER(LOG, "gr_log." + alias()); + GR_LOG_SET_LEVEL(LOG, log_level); + if(log_file.size() > 0) { + if(log_file == "stdout") { + GR_LOG_ADD_CONSOLE_APPENDER(LOG, "gr::log :%p: %c{1} - %m%n", "System.out"); + } + else if(log_file == "stderr") { + GR_LOG_ADD_CONSOLE_APPENDER(LOG, "gr::log :%p: %c{1} - %m%n", "System.err"); + } + else { + GR_LOG_ADD_FILE_APPENDER(LOG, "%r :%p: %c{1} - %m%n", log_file, ""); + } + } + d_logger = LOG; + + GR_LOG_GETLOGGER(DLOG, "gr_log_debug." + alias()); + GR_LOG_SET_LEVEL(DLOG, debug_level); + if(debug_file.size() > 0) { + if(debug_file == "stdout") { + GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "gr::debug :%p: %c{1} - %m%n", "System.out"); + } + else if(debug_file == "stderr") { + GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "gr::debug :%p: %c{1} - %m%n", "System.err"); + } + else { + GR_LOG_ADD_FILE_APPENDER(DLOG, "%r :%p: %c{1} - %m%n", debug_file, ""); + } + } + d_debug_logger = DLOG; +#endif /* HAVE_LOG4CXX */ +#else /* ENABLE_GR_LOG */ + d_logger = NULL; + d_debug_logger = NULL; +#endif /* ENABLE_GR_LOG */ } gr_block::~gr_block () diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index 0783e86848..e4b30267e6 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -26,6 +26,7 @@ #include <gr_core_api.h> #include <gr_basic_block.h> #include <gr_tags.h> +#include <gr_logger.h> /*! * \brief The abstract base class for all 'terminal' processing blocks. @@ -616,6 +617,11 @@ class GR_CORE_API gr_block : public gr_basic_block { */ gruel::mutex d_setlock; + /*! Used by blocks to access the logger system. + */ + gr_logger_ptr d_logger; + gr_logger_ptr d_debug_logger; + // These are really only for internal use, but leaving them public avoids // having to work up an ever-varying list of friend GR_CORE_APIs diff --git a/gnuradio-core/src/lib/runtime/gr_logger.cc b/gnuradio-core/src/lib/runtime/gr_logger.cc new file mode 100644 index 0000000000..e337920a33 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_logger.cc @@ -0,0 +1,189 @@ +/* -*- 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. + */ + +/******************************************************************************* +* Copyright 2011 Johns Hopkins University Applied Physics Lab +* Author: Mark Plett +* Description: +* The gr_log module wraps the log4cxx library for logging in gnuradio. +*******************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_logger.h> +#include <stdexcept> +#include <algorithm> + +#ifdef ENABLE_GR_LOG +#ifdef HAVE_LOG4CXX + +bool gr_logger_configured(false); + +void +logger_load_config(const std::string &config_filename) +{ + if(!gr_logger_configured) { + gr_logger_configured = true; + if(config_filename.size() > 0) { + if(config_filename.find(".xml") != std::string::npos) { + log4cxx::xml::DOMConfigurator::configure(config_filename); + } + else { + log4cxx::PropertyConfigurator::configure(config_filename); + } + } + } +} + +void +logger_load_config_and_watch(const std::string &config_filename, + unsigned int watch_period) +{ + 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); + } + } + } +} + +void +logger_reset_config(void) +{ + log4cxx::LogManager::resetConfiguration(); + gr_logger_configured=false; +} + +void +logger_set_level(gr_logger_ptr logger, const std::string &level) +{ + std::string nocase = level; + std::transform(level.begin(), level.end(), nocase.begin(), ::tolower); + + if(nocase == "off") + 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()); + else if(nocase == "debug") + logger_set_level(logger, log4cxx::Level::getDebug()); + else if(nocase == "info") + logger_set_level(logger, log4cxx::Level::getInfo()); + else if(nocase == "warn") + logger_set_level(logger, log4cxx::Level::getWarn()); + else if(nocase == "error") + logger_set_level(logger, log4cxx::Level::getError()); + else if(nocase == "fatal") + logger_set_level(logger, log4cxx::Level::getFatal()); + else + throw std::runtime_error("logger_set_level: Bad level type.\n"); +} + +void +logger_set_level(gr_logger_ptr logger, log4cxx::LevelPtr level) +{ + logger->setLevel(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"; +}; + +void +logger_get_level(gr_logger_ptr logger, log4cxx::LevelPtr level) +{ + level = logger->getLevel(); +} + +void +logger_add_console_appender(gr_logger_ptr logger, std::string layout, + std::string target) +{ + 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); +} + +void +logger_add_file_appender(gr_logger_ptr logger, std::string layout, + std::string filename, bool append) +{ + 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); +} + +void +logger_add_rollingfile_appender(gr_logger_ptr logger, std::string layout, + std::string filename, bool append, + int bkup_index, std::string filesize) +{ + 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); +} + +void +logger_get_logger_names(std::vector<std::string>& names) +{ + log4cxx::LoggerList list = log4cxx::LogManager::getCurrentLoggers(); + log4cxx::LoggerList::iterator logger = list.begin(); + names.clear(); + for(; logger != list.end(); logger++) { + names.push_back((*logger)->getName()); + } +} + +#endif /* HAVE_LOG4CXX */ +#endif /* ENABLE_GR_LOGGER */ diff --git a/gnuradio-core/src/lib/runtime/gr_logger.h b/gnuradio-core/src/lib/runtime/gr_logger.h new file mode 100644 index 0000000000..40684ec9d0 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_logger.h @@ -0,0 +1,498 @@ +/* -*- 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. + */ + +/******************************************************************************* +* Copyright 2011 Johns Hopkins University Applied Physics Lab +* Author: Mark Plett +* Description: +* The gr_logger module wraps the log4cxx library for logging in gnuradio +*******************************************************************************/ + +#ifndef INCLUDED_GR_LOGGER_H +#define INCLUDED_GR_LOGGER_H + +/*! +* \file gr_logger.h +* \ingroup logging +* \brief GNURADIO logging wrapper for log4cxx library (C++ port of log4j) +* +*/ + +#include <gr_core_api.h> +#include <assert.h> +#include <iostream> + +#ifdef ENABLE_GR_LOG + +// We have three configurations... first logging to stdout/stderr +#ifndef HAVE_LOG4CXX +//#warning GR logging Enabled and using std::cout + +typedef std::string gr_logger_ptr; + +#define GR_LOG_DECLARE_LOGPTR(logger) +#define GR_LOG_ASSIGN_LOGPTR(logger,name) +#define GR_CONFIG_LOGGER(config) +#define GR_CONFIG_AND_WATCH_LOGGER(config) +#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_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> + +/*! + * \brief GR_LOG macros + * \ingroup logging + * + * These macros wrap the standard LOG4CXX_LEVEL macros. The availablie macros + * are: + * GR_LOG_TRACE + * GR_LOG_DEBUG + * GR_LOG_INFO + * GR_LOG_WARN + * GR_LOG_ERROR + * GR_LOG_FATAL + */ + +typedef log4cxx::LoggerPtr gr_logger_ptr; + +/* Macros for Programmatic Configuration */ +#define GR_LOG_DECLARE_LOGPTR(logger) \ + gr_logger_ptr logger; + +#define GR_LOG_ASSIGN_LOGPTR(logger,name) \ + logger = gr_logger::getLogger(name); + +#define GR_CONFIG_LOGGER(config) \ + logger_load_config(config) + +#define GR_CONFIG_AND_WATCH_LOGGER(config,period) \ + logger_load_config_and_watch(config,period) + +#define GR_LOG_GETLOGGER(logger, name) \ + log4cxx::LoggerPtr logger = gr_logger::getLogger(name); + +#define GR_SET_LEVEL(name, level){ \ + log4cxx::LoggerPtr logger = log4cxx::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); \ + 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_LOG_ADD_CONSOLE_APPENDER(logger,layout,target){ \ + logger_add_console_appender(logger,layout,target);} + +#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_LOG_ADD_FILE_APPENDER(logger,layout,filename,append){\ + logger_add_file_appender(logger,layout,filename,append);} + +#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_LOG_ADD_ROLLINGFILE_APPENDER(logger,layout,filename,append,bkup_index,filesize){\ + logger_add_rollingfile_appender(logger,layout,filename,append,bkup_index,filesize);} + +#define GR_GET_LOGGER_NAMES(names){ \ + logger_get_logger_names(names);} + +#define GR_RESET_CONFIGURATION(){ \ + 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);} + +#define GR_INFO(name, msg) { \ + log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ + LOG4CXX_INFO(logger, msg);} + +#define GR_WARN(name, msg) { \ + log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ + LOG4CXX_WARN(logger, msg);} + +#define GR_ERROR(name, msg) { \ + log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ + LOG4CXX_ERROR(logger, msg);} + +#define GR_FATAL(name, msg) { \ + log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ + LOG4CXX_FATAL(logger, msg);} + +#define GR_ERRORIF(name, cond, msg) { \ + log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ + LOG4CXX_ASSERT(logger, !(cond), msg);} + +#define GR_ASSERT(name, cond, msg) { \ + log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(name); \ + LOG4CXX_ASSERT(logger, (cond), msg); \ + assert((cond));} + +/* LoggerPtr Referenced Macros */ +#define GR_LOG_TRACE(logger, msg) { \ + LOG4CXX_TRACE(logger, msg);} + +#define GR_LOG_DEBUG(logger, msg) { \ + LOG4CXX_DEBUG(logger, msg);} + +#define GR_LOG_INFO(logger, msg) { \ + LOG4CXX_INFO(logger, msg);} + +#define GR_LOG_WARN(logger, msg) { \ + LOG4CXX_WARN(logger, msg);} + +#define GR_LOG_ERROR(logger, msg) { \ + LOG4CXX_ERROR(logger, msg);} + +#define GR_LOG_FATAL(logger, msg) { \ + LOG4CXX_FATAL(logger, msg);} + +#define GR_LOG_ERRORIF(logger,cond, msg) { \ + LOG4CXX_ASSERT(logger, !(cond), msg);} + +#define GR_LOG_ASSERT(logger, cond, msg) { \ + LOG4CXX_ASSERT(logger, (cond), msg); \ + assert((cond));} + +/*! + * \brief Load logger's configuration file. + * + * Initialize the GNU Radio logger by loading the configuration file + * \p config_filename. + * + * \param config_filename The configuration file. Set to "" for the + * basic logger that outputs to the console. + */ +GR_CORE_API void logger_load_config(const std::string &config_filename=""); + + +GR_CORE_API void logger_load_config_and_watch(const std::string &config_filename, + unsigned int watch_period); + +GR_CORE_API void logger_reset_config(void); + +/*! + * \brief Set the logger's output level. + * + * Sets the level of the logger. This takes a string that is + * translated to the standard levels and can be (case insensitive): + * + * \li off + * \li all + * \li trace + * \li debug + * \li info + * \li warn + * \li error + * \li fatal + * + * \param logger the logger to set the level of. + * \param level string to set the level to. + */ +GR_CORE_API void logger_set_level(gr_logger_ptr logger, const std::string &level); + +/*! + * \brief Set the logger's output level. + * + * Sets the level of the logger. This takes the actual Log4cxx::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() + * + * \param logger the logger to set the level of. + * \param level new logger level of type Log4cxx::Level + */ +GR_CORE_API void logger_set_level(gr_logger_ptr logger, log4cxx::LevelPtr level); + + +/*! + * \brief Get the logger's output level. + * + * Gets the level of the logger. This returns a string that + * corresponds to the standard levels and can be (case insensitive): + * + * \li off + * \li all + * \li trace + * \li debug + * \li info + * \li warn + * \li error + * \li fatal + * + * \param logger the logger to get the level of. + * \param level string to get the level into. + */ +GR_CORE_API void logger_get_level(gr_logger_ptr logger, std::string &level); + +/*! + * \brief Get the logger's output level. + * + * Gets the level of the logger. This returns the actual Log4cxx::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() + * + * \param logger the logger to get the level of. + */ +GR_CORE_API void logger_get_level(gr_logger_ptr logger, log4cxx::LevelPtr level); + + +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 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_get_logger_names(std::vector<std::string>& names); + +/*! + * \brief instantiate (configure) logger. + * \ingroup logging + * + */ +class gr_logger +{ + public: + /*! + * \brief contructor take log configuration file and configures loggers. + */ + gr_logger(std::string config_filename) + { + // Load configuration file + logger_load_config(config_filename); + }; + + /*! + * \brief contructor take log configuration file and watchtime and configures + */ + gr_logger(std::string config_filename, int watchPeriodSec) + { + // Load configuration file + if(config_filename.find(".xml")!=std::string::npos) { + log4cxx::xml::DOMConfigurator::configureAndWatch(config_filename, watchPeriodSec); + } + else { + log4cxx::PropertyConfigurator::configureAndWatch(config_filename, watchPeriodSec); + } + }; + + static log4cxx::LoggerPtr 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; + }; + }; + + // Wrappers for logging macros + /*! \brief inline function, wrapper to set the logger level */ + void set_level(std::string name,std::string level){GR_SET_LEVEL(name,level);} + + /*! \brief inline function, wrapper to get the logger level */ + void get_level(std::string name,std::string &level){GR_GET_LEVEL(name,level);} + + /*! \brief inline function, wrapper for 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 */ + void debug(std::string name,std::string msg){GR_DEBUG(name,msg);}; + + /*! \brief inline function, wrapper for LOG4CXX_INFO 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 */ + void warn(std::string name,std::string msg){GR_WARN(name,msg);}; + + /*! \brief inline function, wrapper for LOG4CXX_ERROR 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 */ + void fatal(std::string name,std::string msg){GR_FATAL(name,msg);}; + + /*! \brief inline function, wrapper for LOG4CXX_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 */ + 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);} + + /*! \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);} + + /*! \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 LOG4CXX_DEBUG for DEBUG message */ + void log_debug(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_DEBUG(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 LOG4CXX_WARN for WARN message */ + void log_warn(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_WARN(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 LOG4CXX_FATAL for FATAL message */ + void log_fatal(log4cxx::LoggerPtr logger,std::string msg){GR_LOG_FATAL(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 LOG4CXX_ASSERT for conditional ERROR message */ + void log_assert(log4cxx::LoggerPtr logger,bool cond,std::string msg){GR_LOG_ASSERT(logger,cond,msg);}; +}; + + +#endif /* HAVE_LOG4CXX */ + +// If Logger disable do nothing +#else /* ENABLE_GR_LOG */ + +typedef void* gr_logger_ptr; + +#define GR_LOG_DECLARE_LOGPTR(logger) +#define GR_LOG_ASSIGN_LOGPTR(logger,name) +#define GR_CONFIG_LOGGER(config) +#define GR_CONFIG_AND_WATCH_LOGGER(config) +#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_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_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_ERRORIF(logger, cond, msg) +#define GR_LOG_ASSERT(logger, cond, msg) + +#endif /* ENABLE_GR_LOG */ +#endif /* INCLUDED_GR_LOGGER_H */ diff --git a/gnuradio-core/src/lib/runtime/gr_logger.i b/gnuradio-core/src/lib/runtime/gr_logger.i new file mode 100644 index 0000000000..1eedf3d60d --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_logger.i @@ -0,0 +1,96 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/******************************************************************************* +* Copyright 2011 Johns Hopkins University Applied Physics Lab +* Author: Mark Plett +* Description: +* SWIG interface generator file for gr_logger module. gr_logger wraps log4cxx logging +* for gnuradio. +*******************************************************************************/ + +%feature("autodoc", "1"); // generate python docstrings + +%include "exception.i" +%import "gnuradio.i" // the common stuff + +%{ +#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix +#include <stdexcept> +%} + +//----------------------------------- + +#ifdef ENABLE_GR_LOG +#ifdef HAVE_LOG4CXX + +%{ +// The .h files +#include <gr_logger.h> +#include <log4cxx/logger.h> +#include <log4cxx/logmanager.h> +%} + +namespace log4cxx{ +class LoggerPtr { +public: + ~LoggerPtr(); +}; +}; +void logger_load_config(const std::string &config_filename); +void logger_set_level(log4cxx::LoggerPtr logger, const std::string &level); + +%rename(log) gr_logger; + +class gr_logger +{ +private: + +public: + //gr_logger(std::string config_filename); + gr_logger(std::string config_filename,int watchPeriodSec); + void set_level(std::string name,std::string level); + void get_level(std::string name,std::string &level); + void trace(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 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); +}; + +#endif /* HAVE_LOG4CXX */ +#endif /* ENABLE_GR_LOG */ diff --git a/gnuradio-core/src/lib/runtime/qa_gr_logger.cc b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc new file mode 100644 index 0000000000..3d21c1f305 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc @@ -0,0 +1,51 @@ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +/* + * This class gathers together all the test cases for the example + * directory into a single test suite. As you create new test cases, + * add them here. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <qa_gr_logger.h> +#include <gr_logger.h> + +void +qa_gr_logger::t1() +{ +#ifdef ENABLE_GR_LOG + // This doesn't really test anything, more just + // making sure nothing's gone horribly wrong. + GR_LOG_GETLOGGER(LOG,"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"); + CPPUNIT_ASSERT(true); +#endif +} diff --git a/gnuradio-core/src/lib/runtime/qa_gr_logger.h b/gnuradio-core/src/lib/runtime/qa_gr_logger.h new file mode 100644 index 0000000000..b0d3711523 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/qa_gr_logger.h @@ -0,0 +1,42 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU Example Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Example Public License for more details. + * + * You should have received a copy of the GNU Example Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QA_GR_LOG_H +#define INCLUDED_QA_GR_LOG_H + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestSuite.h> + +//! collect all the tests for the example directory + +class qa_gr_logger : public CppUnit::TestCase { + public: + CPPUNIT_TEST_SUITE(qa_gr_logger); + CPPUNIT_TEST(t1); + CPPUNIT_TEST_SUITE_END(); + + private: + void t1(); + +}; + +#endif /* INCLUDED_QA_GR_LOG_H */ diff --git a/gnuradio-core/src/lib/runtime/qa_runtime.cc b/gnuradio-core/src/lib/runtime/qa_runtime.cc index 5e62c79915..62c95ef5c4 100644 --- a/gnuradio-core/src/lib/runtime/qa_runtime.cc +++ b/gnuradio-core/src/lib/runtime/qa_runtime.cc @@ -34,6 +34,7 @@ #include <qa_gr_io_signature.h> #include <qa_gr_block.h> #include <qa_gr_flowgraph.h> +#include <qa_gr_logger.h> #include <qa_gr_top_block.h> #include <qa_gr_hier_block2.h> #include <qa_gr_hier_block2_derived.h> @@ -50,6 +51,7 @@ qa_runtime::suite () s->addTest (qa_gr_io_signature::suite ()); s->addTest (qa_gr_block::suite ()); s->addTest (qa_gr_flowgraph::suite ()); + s->addTest (qa_gr_logger::suite ()); s->addTest (qa_gr_top_block::suite ()); s->addTest (qa_gr_hier_block2::suite ()); s->addTest (qa_gr_hier_block2_derived::suite ()); diff --git a/gnuradio-core/src/lib/runtime/runtime.i b/gnuradio-core/src/lib/runtime/runtime.i index 8e35df8342..8902c6103f 100644 --- a/gnuradio-core/src/lib/runtime/runtime.i +++ b/gnuradio-core/src/lib/runtime/runtime.i @@ -40,6 +40,7 @@ #include <gr_sync_decimator.h> #include <gr_sync_interpolator.h> #include <gr_top_block.h> +#include <gr_logger.h> %} %constant int sizeof_char = sizeof(char); @@ -67,3 +68,4 @@ %include <gr_sync_decimator.i> %include <gr_sync_interpolator.i> %include <gr_top_block.i> +%include <gr_logger.i> diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt index d8a64cc0f6..de42cf2a49 100644 --- a/gnuradio-core/src/lib/swig/CMakeLists.txt +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -25,9 +25,19 @@ set(GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} + ${LOG4CXX_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) -set(GR_SWIG_LIBRARIES gnuradio-core) +set(GR_SWIG_LIBRARIES + gnuradio-core + ${LOG4CXX_LIBRARIES} +) + +# Only use if log4cxx is installed +# Define ENABLE_GR_LOG for the .i file to ignore it. +if(ENABLE_GR_LOG) + SET(GR_SWIG_FLAGS "-DENABLE_GR_LOG") +endif(ENABLE_GR_LOG) link_directories(${Boost_LIBRARY_DIRS}) diff --git a/gnuradio-core/src/tests/CMakeLists.txt b/gnuradio-core/src/tests/CMakeLists.txt index dbd52f05c7..f09c0bbe8f 100644 --- a/gnuradio-core/src/tests/CMakeLists.txt +++ b/gnuradio-core/src/tests/CMakeLists.txt @@ -36,6 +36,9 @@ link_directories( ${CPPUNIT_LIBRARY_DIRS} ) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # Build benchmarks and non-registered tests ######################################################################## diff --git a/gr-analog/lib/CMakeLists.txt b/gr-analog/lib/CMakeLists.txt index f7d6723b4e..e90bef5015 100644 --- a/gr-analog/lib/CMakeLists.txt +++ b/gr-analog/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -135,6 +135,21 @@ list(APPEND analog_sources sincos.cc ) +#Add Windows DLL resource file if using MSVC +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-analog.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-analog.rc + @ONLY) + + list(APPEND analog_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-analog.rc + ) + +ENDIF(MSVC) + list(APPEND analog_libs volk gnuradio-core diff --git a/gr-analog/lib/gnuradio-analog.rc.in b/gr-analog/lib/gnuradio-analog.rc.in new file mode 100644 index 0000000000..7c8c1919f0 --- /dev/null +++ b/gr-analog/lib/gnuradio-analog.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-analog" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-analog.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-analog.dll" + VALUE "ProductName", "gnuradio-analog" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-atsc/src/lib/CMakeLists.txt b/gr-atsc/src/lib/CMakeLists.txt index 3d2b84a03c..43e372b34a 100644 --- a/gr-atsc/src/lib/CMakeLists.txt +++ b/gr-atsc/src/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011-212 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -30,6 +30,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # Generate viterbi mux source # http://www.vtk.org/Wiki/CMake_Cross_Compiling#Using_executables_in_the_build_created_during_the_build @@ -95,9 +98,24 @@ list(APPEND gr_atsc_sources plinfo.cc ) +#Add Windows DLL resource file under MSVC +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-atsc.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-atsc.rc + @ONLY) + + list(APPEND gr_atsc_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-atsc.rc + ) +ENDIF(MSVC) + list(APPEND atsc_libs gnuradio-core ${Boost_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) add_library(gnuradio-atsc SHARED ${gr_atsc_sources}) diff --git a/gr-atsc/src/lib/gnuradio-atsc.rc.in b/gr-atsc/src/lib/gnuradio-atsc.rc.in new file mode 100644 index 0000000000..f0d7699f00 --- /dev/null +++ b/gr-atsc/src/lib/gnuradio-atsc.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-atsc" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-atsc.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-atsc.dll" + VALUE "ProductName", "gnuradio-atsc" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-audio/lib/CMakeLists.txt b/gr-audio/lib/CMakeLists.txt index f39264d5d2..b68e1fea4b 100644 --- a/gr-audio/lib/CMakeLists.txt +++ b/gr-audio/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -30,7 +30,10 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) -list(APPEND gr_audio_libs gnuradio-core ${Boost_LIBRARIES}) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + +list(APPEND gr_audio_libs gnuradio-core ${Boost_LIBRARIES} ${LOG4CXX_LIBRARIES}) list(APPEND gr_audio_sources gr_audio_registry.cc) list(APPEND gr_audio_confs ${CMAKE_CURRENT_SOURCE_DIR}/gr-audio.conf) @@ -142,6 +145,20 @@ if(WIN32) ${CMAKE_CURRENT_SOURCE_DIR}/windows/audio_windows_sink.cc ) + #Add Windows DLL resource file if using MSVC + IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-audio.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-audio.rc + @ONLY) + + list(APPEND gr_audio_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-audio.rc + ) + ENDIF() + endif(WIN32) ######################################################################## diff --git a/gr-audio/lib/gnuradio-audio.rc.in b/gr-audio/lib/gnuradio-audio.rc.in new file mode 100644 index 0000000000..5173278a0a --- /dev/null +++ b/gr-audio/lib/gnuradio-audio.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-audio" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-audio.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-audio.dll" + VALUE "ProductName", "gnuradio-audio" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-blocks/grc/blocks_argmax_xx.xml b/gr-blocks/grc/blocks_argmax_xx.xml new file mode 100644 index 0000000000..7adfa75973 --- /dev/null +++ b/gr-blocks/grc/blocks_argmax_xx.xml @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<!-- +################################################### +##ArgMax: +## 1 output, 2 to inf inputs +################################################### + --> +<block> + <name>Argmax</name> + <key>blocks_argmax_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.argmax_$(type.fcn)($vlen)</make> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:fs</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:is</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:dd</opt> + </option> + </param> + <param> + <name>Num Inputs</name> + <key>num_inputs</key> + <value>2</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$num_inputs >= 1</check> + <check>$vlen >= 1</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + <nports>$num_inputs</nports> + </sink> + <source> + <name>max_vec</name> + <type>short</type> + </source> + <source> + <name>max_inp</name> + <type>short</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml index 0077ec9484..40061dd663 100644 --- a/gr-blocks/grc/blocks_block_tree.xml +++ b/gr-blocks/grc/blocks_block_tree.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!-- - Copyright 2012 Free Software Foundation, Inc. + Copyright 2012,2013 Free Software Foundation, Inc. This file is part of GNU Radio @@ -32,10 +32,16 @@ <name>Sources (New)</name> <block>blocks_file_source</block> <block>blocks_file_meta_source</block> + <block>blocks_pdu_to_tagged_stream</block> + <block>blocks_message_source</block> + <block>blocks_message_burst_source</block> </cat> <cat> <name>Sinks (New)</name> <block>blocks_file_meta_sink</block> + <block>blocks_tagged_stream_to_pdu</block> + <block>blocks_tag_debug</block> + <block>blocks_message_sink</block> </cat> <cat> <name>Math Operations (New) </name> @@ -51,6 +57,8 @@ <block>blocks_nlog10_ff</block> <block>blocks_rms_xx</block> <block>blocks_transcendental</block> + <block>blocks_argmax_xx</block> + <block>blocks_max_xx</block> </cat> <cat> <name>Boolean Operations (New) </name> @@ -85,8 +93,6 @@ <cat> <name>Stream Operations (New) </name> <block>blocks_delay</block> - <block>blocks_packed_to_unpacked_xx</block> - <block>blocks_unpacked_to_packed_xx</block> <block>blocks_deinterleave</block> <block>blocks_interleave</block> <block>blocks_keep_m_in_n</block> @@ -99,13 +105,43 @@ <block>blocks_streams_to_vector</block> <block>blocks_vector_to_stream</block> <block>blocks_vector_to_streams</block> + <block>blocks_peak_detector_xb</block> <block>blocks_peak_detector2_fb</block> <block>blocks_regenerate_bb</block> <block>blocks_stretch_ff</block> <block>blocks_threshold_ff</block> + <block>blocks_burst_tagger</block> </cat> <cat> + <name>Misc Conversions (New) </name> + <block>blocks_packed_to_unpacked_xx</block> + <block>blocks_unpacked_to_packed_xx</block> + <block>blocks_pack_k_bits_bb</block> + <block>blocks_unpack_k_bits_bb</block> + </cat> + <cat> <name>Misc (New) </name> <block>blocks_throttle</block> </cat> + <cat> + <name>Networking</name> + <block>blocks_tuntap_pdu</block> + <block>blocks_socket_pdu</block> + </cat> + <cat> + <name>Level Controls (New)</name> + <block>blocks_mute_xx</block> + <block>blocks_sample_and_hold_xx</block> + <block>blocks_moving_average_xx</block> + </cat> + <cat> + <name>Probes (New)</name> + <block>blocks_probe_signal_x</block> + <block>blocks_probe_signal_vx</block> + </cat> + <cat> + <name>Message Tools (New)</name> + <block>blocks_message_strobe</block> + <block>blocks_message_debug</block> + </cat> </cat> diff --git a/gr-blocks/grc/blocks_burst_tagger.xml b/gr-blocks/grc/blocks_burst_tagger.xml new file mode 100644 index 0000000000..f603b53489 --- /dev/null +++ b/gr-blocks/grc/blocks_burst_tagger.xml @@ -0,0 +1,87 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Burst tagger: +## all types, 1 output, 2 input: stream & trigger (short) +################################################### + --> +<block> + <name>Burst Tagger</name> + <key>blocks_burst_tagger</key> + <import>from gnuradio import blocks</import> + <make>blocks.burst_tagger($type.size) +self.$(id).set_true_tag($true_key,$true_value) +self.$(id).set_false_tag($false_key,$false_value) + </make> + <callback>set_true_tag($true_key,$true_value)</callback> + <callback>set_false_tag($false_key,$false_value)</callback> + <param> + <name>Stream Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>True KeyID</name> + <key>true_key</key> + <value>burst</value> + <type>string</type> + </param> + <param> + <name>True Value</name> + <key>true_value</key> + <value>True</value> + <type>bool</type> + </param> + <param> + <name>False KeyID</name> + <key>false_key</key> + <value>burst</value> + <type>string</type> + </param> + <param> + <name>False Value</name> + <key>false_value</key> + <value>False</value> + <type>bool</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + <vlen>1</vlen> + </sink> + <sink> + <name>trigger</name> + <type>short</type> + <vlen>1</vlen> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>1</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_max_xx.xml b/gr-blocks/grc/blocks_max_xx.xml new file mode 100644 index 0000000000..afbcae93dc --- /dev/null +++ b/gr-blocks/grc/blocks_max_xx.xml @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Max: +## 1 output, 2 to inf inputs +################################################### + --> +<block> + <name>Max</name> + <key>blocks_max_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.max_$(type.fcn)($vlen)</make> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:ff</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:ii</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:dd</opt> + </option> + </param> + <param> + <name>Num Inputs</name> + <key>num_inputs</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$num_inputs >= 1</check> + <check>$vlen >= 1</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + <nports>$num_inputs</nports> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>1</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_message_burst_source.xml b/gr-blocks/grc/blocks_message_burst_source.xml new file mode 100644 index 0000000000..208955e557 --- /dev/null +++ b/gr-blocks/grc/blocks_message_burst_source.xml @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Message Burst Source (the sink port is a message) +################################################### + --> +<block> + <name>Message Burst Source</name> + <key>blocks_message_burst_source</key> + <import>from gnuradio import blocks</import> + <make>blocks.message_burst_source($type.size*$vlen, $(id)_msgq_in)</make> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>msg</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_message_debug.xml b/gr-blocks/grc/blocks_message_debug.xml new file mode 100644 index 0000000000..c547c7542d --- /dev/null +++ b/gr-blocks/grc/blocks_message_debug.xml @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Message Debug +################################################### + --> +<block> + <name>Message Debug</name> + <key>blocks_message_debug</key> + <import>from gnuradio import blocks</import> + <make>blocks.message_debug()</make> + <sink> + <name>print</name> + <type>message</type> + <optional>1</optional> + </sink> + <sink> + <name>store</name> + <type>message</type> + <optional>1</optional> + </sink> + <sink> + <name>print_pdu</name> + <type>message</type> + <optional>1</optional> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_message_sink.xml b/gr-blocks/grc/blocks_message_sink.xml new file mode 100644 index 0000000000..c1f21f6521 --- /dev/null +++ b/gr-blocks/grc/blocks_message_sink.xml @@ -0,0 +1,72 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Message Sink (the source port is a message) +################################################### + --> +<block> + <name>Message Sink</name> + <key>blocks_message_sink</key> + <import>from gnuradio import blocks</import> + <make>blocks.message_sink($type.size*$vlen, $(id)_msgq_out, $dont_block)</make> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Don't Block</name> + <key>dont_block</key> + <value>False</value> + <type>enum</type> + <option> + <name>Don't Block</name> + <key>True</key> + </option> + <option> + <name>Block</name> + <key>False</key> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> + <source> + <name>out</name> + <type>msg</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_message_source.xml b/gr-blocks/grc/blocks_message_source.xml new file mode 100644 index 0000000000..12c6569606 --- /dev/null +++ b/gr-blocks/grc/blocks_message_source.xml @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Message Source (the sink port is a message) +################################################### + --> +<block> + <name>Message Source</name> + <key>blocks_message_source</key> + <import>from gnuradio import blocks</import> + <make>blocks.message_source($type.size*$vlen, $(id)_msgq_in)</make> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>msg</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_message_strobe.xml b/gr-blocks/grc/blocks_message_strobe.xml new file mode 100644 index 0000000000..25c98cd01c --- /dev/null +++ b/gr-blocks/grc/blocks_message_strobe.xml @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Message Strobe +################################################### + --> +<block> + <name>Message Strobe</name> + <key>blocks_message_strobe</key> + <import>from gnuradio import blocks</import> + <import>from gruel import pmt</import> + <make>blocks.message_strobe($msg, $period)</make> + <param> + <name>Message PMT</name> + <key>msg</key> + <value>pmt.pmt_intern("TEST")</value> + <type>raw</type> + </param> + <param> + <name>Period (ms)</name> + <key>period</key> + <value>1000</value> + <type>real</type> + </param> + <sink> + <name>set_msg</name> + <type>message</type> + <optional>1</optional> + </sink> + <source> + <name>strobe</name> + <type>message</type> + <optional>1</optional> + </source> +</block> diff --git a/gr-blocks/grc/blocks_moving_average_xx.xml b/gr-blocks/grc/blocks_moving_average_xx.xml new file mode 100644 index 0000000000..e90903ad85 --- /dev/null +++ b/gr-blocks/grc/blocks_moving_average_xx.xml @@ -0,0 +1,68 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Moving Average +################################################### + --> +<block> + <name>Moving Average</name> + <key>blocks_moving_average_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.moving_average_$(type.fcn)($length, $scale, $max_iter)</make> + <callback>set_length_and_scale($length, $scale)</callback> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:cc</opt> + <opt>scale:complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:ff</opt> + <opt>scale:real</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:ii</opt> + <opt>scale:int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:ss</opt> + <opt>scale:int</opt> + </option> + </param> + <param> + <name>Length</name> + <key>length</key> + <value>1000</value> + <type>int</type> + </param> + <param> + <name>Scale</name> + <key>scale</key> + <value>1</value> + <type>$type.scale</type> + </param> + <param> + <name>Max Iter</name> + <key>max_iter</key> + <value>4000</value> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_mute_xx.xml b/gr-blocks/grc/blocks_mute_xx.xml new file mode 100644 index 0000000000..7023d32674 --- /dev/null +++ b/gr-blocks/grc/blocks_mute_xx.xml @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Mute Block: +## Cast input to bool. +################################################### + --> +<block> + <name>Mute</name> + <key>blocks_mute_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.mute_$(type.fcn)(bool($mute))</make> + <callback>set_mute(bool($mute))</callback> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:cc</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:ff</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:ii</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:ss</opt> + </option> + </param> + <param> + <name>Mute</name> + <key>mute</key> + <value>False</value> + <type>raw</type> + <option> + <name>True</name> + <key>True</key> + </option> + <option> + <name>False</name> + <key>False</key> + </option> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_pack_k_bits_bb.xml b/gr-blocks/grc/blocks_pack_k_bits_bb.xml new file mode 100644 index 0000000000..5400eb4af9 --- /dev/null +++ b/gr-blocks/grc/blocks_pack_k_bits_bb.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Pack K Bits +################################################### + --> +<block> + <name>Pack K Bits</name> + <key>blocks_pack_k_bits_bb</key> + <import>from gnuradio import blocks</import> + <make>blocks.pack_k_bits_bb($k)</make> + <param> + <name>K</name> + <key>k</key> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> + + <doc> + Pack K unpacked bits (one bit per byte) into a single packed byte containing k bits and 8 - k zeros. + </doc> + +</block> diff --git a/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml b/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml new file mode 100644 index 0000000000..2a7de84759 --- /dev/null +++ b/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +################################################### +## PDU Message to Tagged Stream +################################################### + --> +<block> + <name>PDU to Tagged Stream</name> + <key>blocks_pdu_to_tagged_stream</key> + <import>from gnuradio import blocks</import> + <make>blocks.pdu_to_tagged_stream($type.tv)</make> + <param> + <name>Item Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Byte</name> + <key>byte</key> + <opt>tv:blocks.byte_t</opt> + </option> + <option> + <name>Complex</name> + <key>complex</key> + <opt>tv:blocks.complex_t</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>tv:blocks.float_t</opt> + </option> + </param> + <sink> + <name>pdus</name> + <type>message</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_peak_detector_xb.xml b/gr-blocks/grc/blocks_peak_detector_xb.xml new file mode 100644 index 0000000000..1aabf89474 --- /dev/null +++ b/gr-blocks/grc/blocks_peak_detector_xb.xml @@ -0,0 +1,68 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Peak Detector +################################################### + --> +<block> + <name>Peak Detector</name> + <key>blocks_peak_detector_xb</key> + <import>from gnuradio import blocks</import> + <make>blocks.peak_detector_$(type.fcn)b($threshold_factor_rise, $threshold_factor_fall, $look_ahead, $alpha)</make> + <callback>set_threshold_factor_rise($threshold_factor_rise)</callback> + <callback>set_threshold_factor_fall($threshold_factor_fall)</callback> + <callback>set_look_ahead($look_ahead)</callback> + <callback>set_alpha($alpha)</callback> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:i</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:s</opt> + </option> + </param> + <param> + <name>TH Factor Rise</name> + <key>threshold_factor_rise</key> + <value>0.25</value> + <type>real</type> + </param> + <param> + <name>TH Factor Fall</name> + <key>threshold_factor_fall</key> + <value>0.40</value> + <type>real</type> + </param> + <param> + <name>Look Ahead</name> + <key>look_ahead</key> + <value>10</value> + <type>int</type> + </param> + <param> + <name>Alpha</name> + <key>alpha</key> + <value>0.001</value> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_probe_signal_vx.xml b/gr-blocks/grc/blocks_probe_signal_vx.xml new file mode 100644 index 0000000000..f8836f05c2 --- /dev/null +++ b/gr-blocks/grc/blocks_probe_signal_vx.xml @@ -0,0 +1,57 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Probe Signal +################################################### + --> +<block> + <name>Probe Signal</name> + <key>blocks_probe_signal_vx</key> + <import>from gnuradio import blocks</import> + <make>blocks.probe_signal_v$(type.fcn)($vlen)</make> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:c</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:i</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:s</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:b</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <doc> +Available functions to probe: level() + +Use with the function probe block. + </doc> +</block> diff --git a/gr-blocks/grc/blocks_probe_signal_x.xml b/gr-blocks/grc/blocks_probe_signal_x.xml new file mode 100644 index 0000000000..726f0fa747 --- /dev/null +++ b/gr-blocks/grc/blocks_probe_signal_x.xml @@ -0,0 +1,51 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Probe Signal +################################################### + --> +<block> + <name>Probe Signal</name> + <key>blocks_probe_signal_x</key> + <import>from gnuradio import blocks</import> + <make>blocks.probe_signal_$(type.fcn)()</make> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:c</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:i</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:s</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:b</opt> + </option> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <doc> +Available functions to probe: level() + +Use with the function probe block. + </doc> +</block> diff --git a/gr-blocks/grc/blocks_sample_and_hold_xx.xml b/gr-blocks/grc/blocks_sample_and_hold_xx.xml new file mode 100644 index 0000000000..1583204c02 --- /dev/null +++ b/gr-blocks/grc/blocks_sample_and_hold_xx.xml @@ -0,0 +1,49 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Sample and Hold +################################################### + --> +<block> + <name>Sample and Hold</name> + <key>blocks_sample_and_hold_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.sample_and_hold_$(type.fcn)()</make> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:ff</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:ii</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:ss</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:bb</opt> + </option> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <sink> + <name>ctrl</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_socket_pdu.xml b/gr-blocks/grc/blocks_socket_pdu.xml new file mode 100644 index 0000000000..1e897cfc4b --- /dev/null +++ b/gr-blocks/grc/blocks_socket_pdu.xml @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Socket PDU Message source/sink +################################################### + --> +<block> + <name>Socket PDU</name> + <key>blocks_socket_pdu</key> + <import>from gnuradio import blocks</import> + <make>blocks.socket_pdu($type, $host, $port, $mtu)</make> + <param> + <name>Type</name> + <key>type</key> + <value>TCP_SERVER</value> + <type>enum</type> + <option> + <name>TCP Server</name> + <key>"TCP_SERVER"</key> + </option> + <option> + <name>TCP Client</name> + <key>"TCP_CLIENT"</key> + </option> + <option> + <name>UDP Server</name> + <key>"UDP_SERVER"</key> + </option> + <option> + <name>UDP Client</name> + <key>"UDP_CLIENT"</key> + </option> + </param> + <param> + <name>Host</name> + <key>host</key> + <value></value> + <type>string</type> + </param> + <param> + <name>Port</name> + <key>port</key> + <value>52001</value> + <type>string</type> + </param> + <param> + <name>MTU</name> + <key>mtu</key> + <value>10000</value> + <type>int</type> + </param> + <sink> + <name>pdus</name> + <type>message</type> + <optional>1</optional> + </sink> + <source> + <name>pdus</name> + <type>message</type> + <optional>1</optional> + </source> +</block> diff --git a/gr-blocks/grc/blocks_tag_debug.xml b/gr-blocks/grc/blocks_tag_debug.xml new file mode 100644 index 0000000000..929e53afed --- /dev/null +++ b/gr-blocks/grc/blocks_tag_debug.xml @@ -0,0 +1,82 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Tag Debug +################################################### + --> +<block> + <name>Tag Debug</name> + <key>blocks_tag_debug</key> + <import>from gnuradio import blocks</import> + <make>blocks.tag_debug($type.size*$vlen, $name)</make> + <callback>set_display($display)</callback> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Name</name> + <key>name</key> + <type>string</type> + </param> + <param> + <name>Num Inputs</name> + <key>num_inputs</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Display</name> + <key>display</key> + <value>True</value> + <type>bool</type> + <option> + <name>On</name> + <key>True</key> + </option> + <option> + <name>Off</name> + <key>False</key> + </option> + </param> + <check>$num_inputs >= 1</check> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + <nports>$num_inputs</nports> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml b/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml new file mode 100644 index 0000000000..6dd7b9be30 --- /dev/null +++ b/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Tagged Stream to PDU Message +################################################### + --> +<block> + <name>Tagged Stream to PDU</name> + <key>blocks_tagged_stream_to_pdu</key> + <import>from gnuradio import blocks</import> + <make>blocks.tagged_stream_to_pdu($type.tv)</make> + <param> + <name>Item Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Byte</name> + <key>byte</key> + <opt>tv:blocks.byte_t</opt> + </option> + <option> + <name>Complex</name> + <key>complex</key> + <opt>tv:blocks.complex_t</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>tv:blocks.float_t</opt> + </option> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>pdus</name> + <type>message</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_tuntap_pdu.xml b/gr-blocks/grc/blocks_tuntap_pdu.xml new file mode 100644 index 0000000000..d9a63d4a7f --- /dev/null +++ b/gr-blocks/grc/blocks_tuntap_pdu.xml @@ -0,0 +1,34 @@ +<?xml version="1.0"?> +<!-- +################################################### +## TUNTAP PDU async message source/sink +################################################### + --> +<block> + <name>TUNTAP PDU</name> + <key>blocks_tuntap_pdu</key> + <import>from gnuradio import blocks</import> + <make>blocks.tuntap_pdu($ifn, $mtu)</make> + <param> + <name>Interface Name</name> + <key>ifn</key> + <value>tun0</value> + <type>string</type> + </param> + <param> + <name>MTU</name> + <key>mtu</key> + <value>10000</value> + <type>int</type> + </param> + <sink> + <name>pdus</name> + <type>message</type> + <optional>1</optional> + </sink> + <source> + <name>pdus</name> + <type>message</type> + <optional>1</optional> + </source> +</block> diff --git a/gr-blocks/grc/blocks_unpack_k_bits_bb.xml b/gr-blocks/grc/blocks_unpack_k_bits_bb.xml new file mode 100644 index 0000000000..90d7493af0 --- /dev/null +++ b/gr-blocks/grc/blocks_unpack_k_bits_bb.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Unpack K Bits +################################################### + --> +<block> + <name>Unpack K Bits</name> + <key>blocks_unpack_k_bits_bb</key> + <import>from gnuradio import blocks</import> + <make>blocks.unpack_k_bits_bb($k)</make> + <param> + <name>K</name> + <key>k</key> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt index d3c08f6e6d..684639e07e 100644 --- a/gr-blocks/include/blocks/CMakeLists.txt +++ b/gr-blocks/include/blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -69,13 +69,21 @@ expand_h(add_const_XX ss ii ff cc) expand_h(add_const_vXX ss ii ff cc) expand_h(and_XX bb ss ii) expand_h(and_const_XX bb ss ii) +expand_h(argmax_XX fs is ss) expand_h(divide_XX ss ii ff cc) expand_h(integrate_XX ss ii ff cc) +expand_h(max_XX ff ii ss) +expand_h(moving_average_XX ss ii ff cc) expand_h(multiply_XX ss ii) expand_h(multiply_const_XX ss ii) expand_h(multiply_const_vXX ss ii ff cc) +expand_h(mute_XX ss ii ff cc) expand_h(not_XX bb ss ii) expand_h(or_XX bb ss ii) +expand_h(peak_detector_XX fb ib sb) +expand_h(probe_signal_X b s i f c) +expand_h(probe_signal_vX b s i f c) +expand_h(sample_and_hold_XX bb ss ii ff) expand_h(sub_XX ss ii ff cc) expand_h(xor_XX bb ss ii) expand_h(packed_to_unpacked_XX bb ss ii) @@ -94,6 +102,8 @@ install(FILES count_bits.h log2_const.h add_ff.h + bin_statistics_f.h + burst_tagger.h char_to_float.h char_to_short.h complex_to_interleaved_short.h @@ -119,13 +129,21 @@ install(FILES interleaved_short_to_complex.h keep_m_in_n.h keep_one_in_n.h + message_debug.h + message_sink.h + message_source.h + message_strobe.h + message_burst_source.h multiply_cc.h multiply_ff.h multiply_conjugate_cc.h multiply_const_cc.h multiply_const_ff.h nlog10_ff.h + pack_k_bits_bb.h patterned_interleaver.h + pdu.h + pdu_to_tagged_stream.h peak_detector2_fb.h regenerate_bb.h repeat.h @@ -133,16 +151,21 @@ install(FILES rms_ff.h short_to_char.h short_to_float.h + socket_pdu.h stream_mux.h stream_to_streams.h stream_to_vector.h streams_to_stream.h streams_to_vector.h stretch_ff.h + tag_debug.h + tagged_stream_to_pdu.h threshold_ff.h throttle.h transcendental.h + tuntap_pdu.h uchar_to_float.h + unpack_k_bits_bb.h vector_to_stream.h vector_to_streams.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks diff --git a/gr-blocks/include/blocks/argmax_XX.h.t b/gr-blocks/include/blocks/argmax_XX.h.t new file mode 100644 index 0000000000..4c25c1c8c4 --- /dev/null +++ b/gr-blocks/include/blocks/argmax_XX.h.t @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Compares vectors from multiple streams and determines + * the index in the vector and stream number where the maximum + * value occurred. + * \ingroup math_blk + * + * Data is passed in as a vector of length \p vlen from multiple + * input sources. It will look through these streams of \p vlen + * data items and output two streams. + * Stream 0 will contain the index value in the vector where + * the maximum value occurred. + * Stream 1 will contain the number of the input stream that + * held the maximum value. + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(size_t vlen); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/bin_statistics_f.h b/gr-blocks/include/blocks/bin_statistics_f.h new file mode 100644 index 0000000000..a73afc82d6 --- /dev/null +++ b/gr-blocks/include/blocks/bin_statistics_f.h @@ -0,0 +1,76 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_BIN_STATISTICS_F_H +#define INCLUDED_GR_BIN_STATISTICS_F_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> +#include <gr_feval.h> + +namespace gr { + namespace blocks { + + /*! + * \brief control scanning and record frequency domain statistics + * \ingroup sink_blk + */ + class BLOCKS_API bin_statistics_f : virtual public gr_sync_block + { + protected: + std::vector<float> d_max; // per bin maxima + + virtual size_t vlen() const = 0; + virtual double center_freq() const = 0; + virtual gr_msg_queue_sptr msgq() const = 0; + + virtual void reset_stats() = 0; + virtual void accrue_stats(const float *input) = 0; + virtual void send_stats() = 0; + + public: + // gr::blocks::bin_statistics_f::sptr + typedef boost::shared_ptr<bin_statistics_f> sptr; + + /*! + * Build a bin statistics block. See qa_bin_statistics.py and + * gr-uhd/examples/python/usrp_spectrum_sense.py for examples of + * its use, specifically how to use the callback function. + * + * \param vlen vector length + * \param msgq message queue + * \param tune a gr_feval_dd callback function + * \param tune_delay number of samples for the tune delay + * \param dwell_delay number of samples for the dwell delay + */ + static sptr make(unsigned int vlen, // vector length + gr_msg_queue_sptr msgq, + gr_feval_dd *tune, // callback + size_t tune_delay, // samples + size_t dwell_delay); // samples + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_BIN_STATISTICS_F_H */ diff --git a/gr-blocks/include/blocks/burst_tagger.h b/gr-blocks/include/blocks/burst_tagger.h new file mode 100644 index 0000000000..408405f97b --- /dev/null +++ b/gr-blocks/include/blocks/burst_tagger.h @@ -0,0 +1,74 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_BURST_TAGGER_H +#define INCLUDED_GR_BURST_TAGGER_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Sets a burst on/off tag based on the value of the trigger input. + * \ingroup misc_blk + * + * This block takes two inputs, a signal stream on the input + * stream 0 and a trigger stream of shorts on input stream 1. If + * the trigger stream goes above 0, a tag with the key "burst" + * will be transmitted as a pmt::PMT_T. When the trigger signal + * falls below 0, the "burst" tag will be transmitted as + * pmt::PMT_F. + * + * The signal on stream 0 is retransmitted to output stream 0. + */ + class BLOCKS_API burst_tagger : virtual public gr_sync_block + { + public: + // gr::blocks::burst_tagger::sptr + typedef boost::shared_ptr<burst_tagger> sptr; + + /*! + * Build a burst tagger blocks. + * + * \param itemsize itemsize of the signal stream on input 0. + */ + static sptr make(size_t itemsize); + + /*! + * For the true burst tag, change the key name to \p key and a + * new value of \p value. + */ + virtual void set_true_tag(const std::string &key, bool value) = 0; + + /*! + * For the false burst tag, change the key name to \p key and a + * new value of \p value. + */ + virtual void set_false_tag(const std::string &key, bool value) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_BURST_TAGGER_H */ diff --git a/gr-blocks/include/blocks/max_XX.h.t b/gr-blocks/include/blocks/max_XX.h.t new file mode 100644 index 0000000000..9e74bf3cac --- /dev/null +++ b/gr-blocks/include/blocks/max_XX.h.t @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Compares vectors from multiple streams and determines + * the maximum value from each vector over all streams. + * \ingroup math_blk + * + * Data is passed in as a vector of length \p vlen from multiple + * input sources. It will look through these streams of \p vlen + * data items and output two streams. + * Stream 0 will contain the index value in the vector where + * the maximum value occurred. + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(size_t vlen); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ + diff --git a/gr-blocks/include/blocks/message_burst_source.h b/gr-blocks/include/blocks/message_burst_source.h new file mode 100644 index 0000000000..864d43452f --- /dev/null +++ b/gr-blocks/include/blocks/message_burst_source.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_MESSAGE_BURST_SOURCE_H +#define INCLUDED_GR_MESSAGE_BURST_SOURCE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Turn received messages into a stream and tag them for UHD to send. + * \ingroup source_blk + */ + class BLOCKS_API message_burst_source : virtual public gr_sync_block + { + public: + // gr::blocks::message_source::sptr + typedef boost::shared_ptr<message_burst_source> sptr; + + static sptr make(size_t itemsize, int msgq_limit); + static sptr make(size_t itemsize, gr_msg_queue_sptr msgq); + + virtual gr_msg_queue_sptr msgq() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_BURST_SOURCE_H */ diff --git a/gr-blocks/include/blocks/message_debug.h b/gr-blocks/include/blocks/message_debug.h new file mode 100644 index 0000000000..f0212331c2 --- /dev/null +++ b/gr-blocks/include/blocks/message_debug.h @@ -0,0 +1,85 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_MESSAGE_DEBUG_H +#define INCLUDED_GR_MESSAGE_DEBUG_H + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Debug block for the message passing system. + * \ingroup sink_blk + * + * The message debug block is used to capture and print or store + * messages as they are received. Any block that generates a + * message may connect that message port to one or more of the + * three message input ports of this debug block. The message + * ports are: + * + * \li print: prints the message directly to standard out. + * \li store: stores the message in an internal vector. May be + * access using the get_message function. + * \li print_pdu: specifically designed to handle formatted PDUs + * (see pdu.h). + */ + class BLOCKS_API message_debug : virtual public gr_block + { + public: + // gr::blocks::message_debug::sptr + typedef boost::shared_ptr<message_debug> sptr; + + /*! + * \brief Build the message debug block. It takes no parameters + * and has three message ports: print, store, and + * print_pdu. + */ + static sptr make(); + + /*! + * \brief Reports the number of messages received by this block. + */ + virtual int num_messages() = 0; + + /*! + * \brief Get a message (as a PMT) from the message vector at index \p i. + * + * Messages passed to the 'store' port will be stored in a + * vector. This function retrieves those messages by index. They + * are index in order of when they were received (all messages + * are just pushed onto the back of a vector). This is mostly + * useful in debugging message passing graphs and in QA code. + * + * \param i The index in the vector for the message to retrieve. + * + * \return a message at index \p i as a pmt_t. + */ + virtual pmt::pmt_t get_message(int i) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_DEBUG_H */ diff --git a/gr-blocks/include/blocks/message_sink.h b/gr-blocks/include/blocks/message_sink.h new file mode 100644 index 0000000000..5d14836dd4 --- /dev/null +++ b/gr-blocks/include/blocks/message_sink.h @@ -0,0 +1,49 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_MESSAGE_SINK_H +#define INCLUDED_GR_MESSAGE_SINK_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Gather received items into messages and insert into msgq + * \ingroup sink_blk + */ + class BLOCKS_API message_sink : virtual public gr_sync_block + { + public: + // gr::blocks::message_sink::sptr + typedef boost::shared_ptr<message_sink> sptr; + + static sptr make (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_SINK_H */ diff --git a/gr-blocks/include/blocks/message_source.h b/gr-blocks/include/blocks/message_source.h new file mode 100644 index 0000000000..5b55191880 --- /dev/null +++ b/gr-blocks/include/blocks/message_source.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_MESSAGE_SOURCE_H +#define INCLUDED_GR_MESSAGE_SOURCE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Turn received messages into a stream + * \ingroup source_blk + */ + class BLOCKS_API message_source : virtual public gr_sync_block + { + public: + // gr::blocks::message_source::sptr + typedef boost::shared_ptr<message_source> sptr; + + static sptr make(size_t itemsize, int msgq_limit=0); + static sptr make(size_t itemsize, gr_msg_queue_sptr msgq); + + virtual gr_msg_queue_sptr msgq() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_SOURCE_H */ diff --git a/gr-blocks/include/blocks/message_strobe.h b/gr-blocks/include/blocks/message_strobe.h new file mode 100644 index 0000000000..6b427d539c --- /dev/null +++ b/gr-blocks/include/blocks/message_strobe.h @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_MESSAGE_STROBE_H +#define INCLUDED_GR_MESSAGE_STROBE_H + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Send message at defined interval + * \ingroup msg_blk + * + * Takes a PMT message and sends it out every \p period_ms + * milliseconds. Useful for testing/debugging the message system. + */ + class BLOCKS_API message_strobe : virtual public gr_block + { + public: + // gr::blocks::message_strobe::sptr + typedef boost::shared_ptr<message_strobe> sptr; + + /*! + * Make a message stobe block to send message \p msg every \p + * period_ms milliseconds. + * + * \param msg The message to send as a PMT. + * \param period_ms the time period in milliseconds in which to + * send \p msg. + */ + static sptr make(pmt::pmt_t msg, float period_ms); + + /*! + * Reset the message being sent. + * \param msg The message to send as a PMT. + */ + virtual void set_msg(pmt::pmt_t msg) = 0; + + /*! + * Get the value of the message being sent. + */ + virtual pmt::pmt_t msg() const = 0; + + /*! + * Reset the sending interval. + * \param period_ms the time period in milliseconds. + */ + virtual void set_period(float period_ms) = 0; + + /*! + * Get the time interval of the strobe. + */ + virtual float period() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_STROBE_H */ diff --git a/gr-blocks/include/blocks/moving_average_XX.h.t b/gr-blocks/include/blocks/moving_average_XX.h.t new file mode 100644 index 0000000000..6b7883fdd4 --- /dev/null +++ b/gr-blocks/include/blocks/moving_average_XX.h.t @@ -0,0 +1,84 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief output is the moving sum of the last N samples, scaled by the scale factor + * \ingroup filter_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + /*! + * Create a moving average block. + * + * \param length Number of samples to use in the average. + * \param scale scale factor for the result. + * \param max_iter limits how long we go without flushing the accumulator + * This is necessary to avoid numerical instability for float and complex. + */ + static sptr make(int length, @O_TYPE@ scale, + int max_iter = 4096); + + /*! + * Get the length used in the avaraging calculation. + */ + virtual int length() const = 0; + + /*! + * Get the scale factor being used. + */ + virtual @O_TYPE@ scale() const = 0; + + /*! + * Set both the length and the scale factor together. + */ + virtual void set_length_and_scale(int length, @O_TYPE@ scale) = 0; + + /*! + * Set the length. + */ + virtual void set_length(int length) = 0; + + /*! + * Set the scale factor. + */ + virtual void set_scale(@O_TYPE@ scale) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/mute_XX.h.t b/gr-blocks/include/blocks/mute_XX.h.t new file mode 100644 index 0000000000..3033248c4e --- /dev/null +++ b/gr-blocks/include/blocks/mute_XX.h.t @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief output = input or zero if muted. + * \ingroup level_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(bool mute); + + virtual bool mute() const = 0; + virtual void set_mute(bool mute) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ + diff --git a/gr-blocks/include/blocks/pack_k_bits_bb.h b/gr-blocks/include/blocks/pack_k_bits_bb.h new file mode 100644 index 0000000000..5bf71c9c3e --- /dev/null +++ b/gr-blocks/include/blocks/pack_k_bits_bb.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_PACK_K_BITS_BB_H +#define INCLUDED_GR_PACK_K_BITS_BB_H + +#include <blocks/api.h> +#include <gr_sync_decimator.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Converts a stream of bytes with 1 bit in the LSB to a + * byte with k relevent bits. + * \ingroup converter_blk + */ + class BLOCKS_API pack_k_bits_bb : virtual public gr_sync_decimator + { + public: + // gr::blocks::pack_k_bits_bb::sptr + typedef boost::shared_ptr<pack_k_bits_bb> sptr; + + /*! + * \brief Make a pack_k_bits block. + * \param k number of bits to be packed. + */ + static sptr make(unsigned k); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PACK_K_BITS_BB_H */ diff --git a/gr-blocks/include/blocks/pdu.h b/gr-blocks/include/blocks/pdu.h new file mode 100644 index 0000000000..de0999c574 --- /dev/null +++ b/gr-blocks/include/blocks/pdu.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_BLOCKS_PDU_H +#define INCLUDED_BLOCKS_PDU_H + +#include <blocks/api.h> +#include <gr_complex.h> +#include <gruel/pmt.h> + +#define PDU_PORT_ID pmt::mp("pdus") +#define PDU_LENGTH_TAG pmt::mp("pdu_length") + +namespace gr { + namespace blocks { + namespace pdu { + + enum vector_type { byte_t, float_t, complex_t }; + + BLOCKS_API size_t itemsize(vector_type type); + BLOCKS_API bool type_matches(vector_type type, pmt::pmt_t v); + BLOCKS_API pmt::pmt_t make_vector(vector_type type, const uint8_t* buf, size_t items); + BLOCKS_API vector_type type_from_pmt(pmt::pmt_t vector); + + } /* namespace pdu */ + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_PDU_H */ diff --git a/gr-blocks/include/blocks/pdu_to_tagged_stream.h b/gr-blocks/include/blocks/pdu_to_tagged_stream.h new file mode 100644 index 0000000000..cf64f41dc2 --- /dev/null +++ b/gr-blocks/include/blocks/pdu_to_tagged_stream.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H +#define INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H + +#include <blocks/api.h> +#include <blocks/pdu.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Turns received PDUs into a tagged stream of items + * \ingroup source_blk + */ + class BLOCKS_API pdu_to_tagged_stream : virtual public gr_sync_block + { + public: + // gr::blocks::pdu_to_tagged_stream::sptr + typedef boost::shared_ptr<pdu_to_tagged_stream> sptr; + + /*! + * \brief Construct a pdu_to_tagged_stream block + * \param type PDU type of pdu::vector_type + */ + static sptr make(pdu::vector_type type); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H */ diff --git a/gr-blocks/include/blocks/peak_detector_XX.h.t b/gr-blocks/include/blocks/peak_detector_XX.h.t new file mode 100644 index 0000000000..1c8ba0652f --- /dev/null +++ b/gr-blocks/include/blocks/peak_detector_XX.h.t @@ -0,0 +1,117 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Detect the peak of a signal + * \ingroup level_blk + * + * 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 + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + /*! + * Make a peak detector block. + * + * \param threshold_factor_rise The threshold factor determins + * when a peak has started. An average of the signal is + * calculated and when the value of the signal goes over + * threshold_factor_rise*average, we start looking for a + * peak. + * \param threshold_factor_fall The threshold factor determins + * when a peak has ended. An average of the signal is + * calculated and when the value of the signal goes + * bellow threshold_factor_fall*average, we stop looking + * for a peak. + * \param look_ahead The look-ahead value is used when the + * threshold is found to look if there another peak + * within this step range. If there is a larger value, + * we set that as the peak and look ahead again. This is + * continued until the highest point is found with This + * look-ahead range. + * \param alpha The gain value of a moving average filter + */ + static sptr make(float threshold_factor_rise = 0.25, + float threshold_factor_fall = 0.40, + int look_ahead = 10, + float alpha = 0.001); + + /*! \brief Set the threshold factor value for the rise time + * \param thr new threshold factor + */ + virtual void set_threshold_factor_rise(float thr) = 0; + + /*! \brief Set the threshold factor value for the fall time + * \param thr new threshold factor + */ + virtual void set_threshold_factor_fall(float thr) = 0; + + /*! \brief Set the look-ahead factor + * \param look new look-ahead factor + */ + virtual void set_look_ahead(int look) = 0; + + /*! \brief Set the running average alpha + * \param alpha new alpha for running average + */ + virtual void set_alpha(int alpha) = 0; + + /*! \brief Get the threshold factor value for the rise time + * \return threshold factor + */ + virtual float threshold_factor_rise() = 0; + + /*! \brief Get the threshold factor value for the fall time + * \return threshold factor + */ + virtual float threshold_factor_fall() = 0; + + /*! \brief Get the look-ahead factor value + * \return look-ahead factor + */ + virtual int look_ahead() = 0; + + /*! \brief Get the alpha value of the running average + * \return alpha + */ + virtual float alpha() = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/probe_signal_X.h.t b/gr-blocks/include/blocks/probe_signal_X.h.t new file mode 100644 index 0000000000..01b7bad0c4 --- /dev/null +++ b/gr-blocks/include/blocks/probe_signal_X.h.t @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Sink that allows a sample to be grabbed from Python. + * \ingroup sink_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(); + + virtual @TYPE@ level() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/probe_signal_vX.h.t b/gr-blocks/include/blocks/probe_signal_vX.h.t new file mode 100644 index 0000000000..487f280db4 --- /dev/null +++ b/gr-blocks/include/blocks/probe_signal_vX.h.t @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <vector> +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Sink that allows a vector of samples to be grabbed from Python. + * \ingroup sink_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(size_t size); + + virtual std::vector<@TYPE@> level() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/sample_and_hold_XX.h.t b/gr-blocks/include/blocks/sample_and_hold_XX.h.t new file mode 100644 index 0000000000..3266523efb --- /dev/null +++ b/gr-blocks/include/blocks/sample_and_hold_XX.h.t @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief sample and hold circuit + * \ingroup level_blk + * + * Samples the data stream (input stream 0) and holds the value if + * the control signal is 1 (intput stream 1). + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/socket_pdu.h b/gr-blocks/include/blocks/socket_pdu.h new file mode 100644 index 0000000000..1a67f8358c --- /dev/null +++ b/gr-blocks/include/blocks/socket_pdu.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_BLOCKS_SOCKET_PDU_H +#define INCLUDED_BLOCKS_SOCKET_PDU_H + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Creates socket interface and translates traffic to PDUs + * \ingroup net_blk + */ + class BLOCKS_API socket_pdu : virtual public gr_block + { + public: + // gr::blocks::socket_pdu::sptr + typedef boost::shared_ptr<socket_pdu> sptr; + + /*! + * \brief Construct a SOCKET PDU interface + * \param dev Device name to create + * \param MTU Maximum Transmission Unit size + */ + static sptr make(std::string type, std::string addr, std::string port, int MTU=10000); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_SOCKET_PDU_H */ diff --git a/gr-blocks/include/blocks/tag_debug.h b/gr-blocks/include/blocks/tag_debug.h new file mode 100644 index 0000000000..9d27a26ecd --- /dev/null +++ b/gr-blocks/include/blocks/tag_debug.h @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_TAG_DEBUG_H +#define INCLUDED_GR_TAG_DEBUG_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Bit bucket that prints out any tag received. + * \ingroup sink_blk + * + * This block collects all tags sent to it on all input ports and + * displays them to stdout in a formatted way. The \p name + * parameter is used to identify which debug sink generated the + * tag, so when connecting a block to this debug sink, an + * appropriate name is something that identifies the input block. + * + * This block otherwise acts as a NULL sink in that items from the + * input stream are ignored. It is designed to be able to attach + * to any block and watch all tags streaming out of that block for + * debugging purposes. + * + * The tags from the last call to this work function are stored + * and can be retrieved using the function 'current_tags'. + */ + class BLOCKS_API tag_debug : virtual public gr_sync_block + { + public: + // gr::blocks::tag_debug::sptr + typedef boost::shared_ptr<tag_debug> sptr; + + /*! + * Build a tag debug block + * + * \param sizeof_stream_item size of the items in the incoming stream. + * \param name name to identify which debug sink generated the info. + */ + static sptr make(size_t sizeof_stream_item, + const std::string &name); + + /*! + * \brief Returns a vector of gr_tag_t items as of the last call to + * work. + */ + virtual std::vector<gr_tag_t> current_tags() = 0; + + /*! + * \brief Set the display of tags to stdout on/off. + */ + virtual void set_display(bool d) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_TAG_DEBUG_H */ diff --git a/gr-blocks/include/blocks/tagged_stream_to_pdu.h b/gr-blocks/include/blocks/tagged_stream_to_pdu.h new file mode 100644 index 0000000000..32e72a7879 --- /dev/null +++ b/gr-blocks/include/blocks/tagged_stream_to_pdu.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H +#define INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H + +#include <blocks/api.h> +#include <blocks/pdu.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Turns received stream data and tags into PDUs + * \ingroup source_blk + */ + class BLOCKS_API tagged_stream_to_pdu : virtual public gr_sync_block + { + public: + // gr::blocks::tagged_stream_to_pdu::sptr + typedef boost::shared_ptr<tagged_stream_to_pdu> sptr; + + /*! + * \brief Construct a tagged_stream_to_pdu block + * \param type PDU type of pdu::vector_type + */ + static sptr make(pdu::vector_type type); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H */ diff --git a/gr-blocks/include/blocks/tuntap_pdu.h b/gr-blocks/include/blocks/tuntap_pdu.h new file mode 100644 index 0000000000..70abb0bd5b --- /dev/null +++ b/gr-blocks/include/blocks/tuntap_pdu.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_BLOCKS_TUNTAP_PDU_H +#define INCLUDED_BLOCKS_TUNTAP_PDU_H + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Creates TUNTAP interface and translates traffic to PDUs + * \ingroup net_blk + */ + class BLOCKS_API tuntap_pdu : virtual public gr_block + { + public: + // gr::blocks::tuntap_pdu::sptr + typedef boost::shared_ptr<tuntap_pdu> sptr; + + /*! + * \brief Construct a TUNTAP PDU interface + * \param dev Device name to create + * \param MTU Maximum Transmission Unit size + */ + static sptr make(std::string dev, int MTU=10000); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_TUNTAP_PDU_H */ diff --git a/gr-blocks/include/blocks/unpack_k_bits_bb.h b/gr-blocks/include/blocks/unpack_k_bits_bb.h new file mode 100644 index 0000000000..b716ded1d3 --- /dev/null +++ b/gr-blocks/include/blocks/unpack_k_bits_bb.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_UNPACK_K_BITS_BB_H +#define INCLUDED_GR_UNPACK_K_BITS_BB_H + +#include <blocks/api.h> +#include <gr_sync_interpolator.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Converts a byte with k relevent bits to k output bytes with 1 bit in the LSB. + * \ingroup converter_blk + */ + class BLOCKS_API unpack_k_bits_bb : virtual public gr_sync_interpolator + { + public: + // gr::blocks::unpack_k_bits_bb::sptr + typedef boost::shared_ptr<unpack_k_bits_bb> sptr; + + /*! + * \brief Make an unpack_k_bits block. + * \param k number of bits to unpack. + */ + static sptr make(unsigned k); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_UNPACK_K_BITS_BB_H */ diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index 20e3ae4aa6..ac5e3056d8 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -95,13 +95,21 @@ expand_cc_h_impl(add_const_XX ss ii ff cc) expand_cc_h_impl(add_const_vXX ss ii ff cc) expand_cc_h_impl(and_XX bb ss ii) expand_cc_h_impl(and_const_XX bb ss ii) +expand_cc_h_impl(argmax_XX fs is ss) expand_cc_h_impl(divide_XX ss ii ff cc) expand_cc_h_impl(integrate_XX ss ii ff cc) +expand_cc_h_impl(max_XX ff ii ss) +expand_cc_h_impl(moving_average_XX ss ii ff cc) expand_cc_h_impl(multiply_XX ss ii) expand_cc_h_impl(multiply_const_XX ss ii) expand_cc_h_impl(multiply_const_vXX ss ii ff cc) +expand_cc_h_impl(mute_XX ss ii ff cc) expand_cc_h_impl(not_XX bb ss ii) expand_cc_h_impl(or_XX bb ss ii) +expand_cc_h_impl(peak_detector_XX fb ib sb) +expand_cc_h_impl(probe_signal_X b s i f c) +expand_cc_h_impl(probe_signal_vX b s i f c) +expand_cc_h_impl(sample_and_hold_XX bb ss ii ff) expand_cc_h_impl(sub_XX ss ii ff cc) expand_cc_h_impl(xor_XX bb ss ii) expand_cc_h_impl(packed_to_unpacked_XX bb ss ii) @@ -130,6 +138,8 @@ list(APPEND gr_blocks_sources ${generated_sources} count_bits.cc add_ff_impl.cc + bin_statistics_f_impl.cc + burst_tagger_impl.cc char_to_float_impl.cc char_to_short_impl.cc complex_to_interleaved_short_impl.cc @@ -158,13 +168,22 @@ list(APPEND gr_blocks_sources interleaved_short_to_complex_impl.cc keep_m_in_n_impl.cc keep_one_in_n_impl.cc + message_debug_impl.cc + message_sink_impl.cc + message_source_impl.cc + message_strobe_impl.cc + message_burst_source_impl.cc multiply_cc_impl.cc multiply_ff_impl.cc multiply_conjugate_cc_impl.cc multiply_const_cc_impl.cc multiply_const_ff_impl.cc nlog10_ff_impl.cc + pack_k_bits_bb_impl.cc patterned_interleaver_impl.cc + pdu.cc + tag_debug_impl.cc + pdu_to_tagged_stream_impl.cc peak_detector2_fb_impl.cc regenerate_bb_impl.cc repeat_impl.cc @@ -172,21 +191,41 @@ list(APPEND gr_blocks_sources rms_ff_impl.cc short_to_char_impl.cc short_to_float_impl.cc + socket_pdu_impl.cc stream_mux_impl.cc + stream_pdu_base.cc stream_to_streams_impl.cc stream_to_vector_impl.cc streams_to_stream_impl.cc streams_to_vector_impl.cc stretch_ff_impl.cc + tagged_stream_to_pdu_impl.cc threshold_ff_impl.cc throttle_impl.cc transcendental_impl.cc + tcp_connection.cc + tuntap_pdu_impl.cc uchar_array_to_float.cc uchar_to_float_impl.cc + unpack_k_bits_bb_impl.cc vector_to_stream_impl.cc vector_to_streams_impl.cc ) +#Add Windows DLL resource file if using MSVC +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-blocks.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-blocks.rc + @ONLY) + + list(APPEND gr_blocks_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-blocks.rc + ) +ENDIF(MSVC) + list(APPEND blocks_libs gnuradio-core volk diff --git a/gr-blocks/lib/ConfigChecks.cmake b/gr-blocks/lib/ConfigChecks.cmake index 72d6d1d8ab..7f60aed403 100644 --- a/gr-blocks/lib/ConfigChecks.cmake +++ b/gr-blocks/lib/ConfigChecks.cmake @@ -56,7 +56,7 @@ CHECK_INCLUDE_FILE_CXX(windows.h HAVE_WINDOWS_H) IF(HAVE_WINDOWS_H) ADD_DEFINITIONS(-DHAVE_WINDOWS_H -DUSING_WINSOCK) MESSAGE(STATUS "Adding windows libs to gr blocks libs...") - LIST(APPEND gnuradio_core_libs WS2_32.lib WSock32.lib) + LIST(APPEND blocks_libs WS2_32.lib WSock32.lib) ENDIF(HAVE_WINDOWS_H) ######################################################################## diff --git a/gr-blocks/lib/add_XX_impl.h.t b/gr-blocks/lib/add_XX_impl.h.t index a1c486b859..2e20ef5fe3 100644 --- a/gr-blocks/lib/add_XX_impl.h.t +++ b/gr-blocks/lib/add_XX_impl.h.t @@ -32,6 +32,7 @@ namespace gr { class BLOCKS_API @NAME_IMPL@ : public @NAME@ { + private: size_t d_vlen; public: diff --git a/gr-blocks/lib/argmax_XX_impl.cc.t b/gr-blocks/lib/argmax_XX_impl.cc.t new file mode 100644 index 0000000000..56673ef995 --- /dev/null +++ b/gr-blocks/lib/argmax_XX_impl.cc.t @@ -0,0 +1,86 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(size_t vlen) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(vlen)); + } + + @NAME_IMPL@::@NAME_IMPL@(size_t vlen) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, -1, vlen*sizeof(@I_TYPE@)), + gr_make_io_signature(2, 2, sizeof(@O_TYPE@))), + d_vlen(vlen) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int ninputs = input_items.size (); + + @O_TYPE@ *x_optr = (@O_TYPE@ *)output_items[0]; + @O_TYPE@ *y_optr = (@O_TYPE@ *)output_items[1]; + + for(int i = 0; i < noutput_items; i++) { + @I_TYPE@ max = ((@I_TYPE@ *)input_items[0])[i*d_vlen]; + int x = 0; + int y = 0; + + for(int j = 0; j < (int)d_vlen; j++ ) { + for(int k = 0; k < ninputs; k++) { + if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] > max) { + max = ((@I_TYPE@ *)input_items[k])[i*d_vlen + j]; + x = j; + y = k; + } + } + } + + *x_optr++ = (@O_TYPE@)x; + *y_optr++ = (@O_TYPE@)y; + } + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/argmax_XX_impl.h.t b/gr-blocks/lib/argmax_XX_impl.h.t new file mode 100644 index 0000000000..0f1643f6b9 --- /dev/null +++ b/gr-blocks/lib/argmax_XX_impl.h.t @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + size_t d_vlen; + + public: + @NAME_IMPL@(size_t vlen); + ~@NAME_IMPL@(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/bin_statistics_f_impl.cc b/gr-blocks/lib/bin_statistics_f_impl.cc new file mode 100644 index 0000000000..014222a63d --- /dev/null +++ b/gr-blocks/lib/bin_statistics_f_impl.cc @@ -0,0 +1,178 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "bin_statistics_f_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + bin_statistics_f::sptr + bin_statistics_f::make(unsigned int vlen, + gr_msg_queue_sptr msgq, + gr_feval_dd *tune, + size_t tune_delay, + size_t dwell_delay) + { + return gnuradio::get_initial_sptr + (new bin_statistics_f_impl(vlen, msgq, tune, + tune_delay, dwell_delay)); + } + + bin_statistics_f_impl::bin_statistics_f_impl(unsigned int vlen, + gr_msg_queue_sptr msgq, + gr_feval_dd *tune, + size_t tune_delay, + size_t dwell_delay) + : gr_sync_block("bin_statistics_f", + gr_make_io_signature(1, 1, sizeof(float) * vlen), + gr_make_io_signature(0, 0, 0)), + d_vlen(vlen), d_msgq(msgq), d_tune(tune), + d_tune_delay(tune_delay), d_dwell_delay(dwell_delay), + d_center_freq(0), d_delay(0), + d_max(vlen) + { + enter_init(); + } + + bin_statistics_f_impl::~bin_statistics_f_impl() + { + } + + void + bin_statistics_f_impl::enter_init() + { + d_state = ST_INIT; + d_delay = 0; + } + + void + bin_statistics_f_impl::enter_tune_delay() + { + d_state = ST_TUNE_DELAY; + d_delay = d_tune_delay; + d_center_freq = d_tune->calleval(0); + } + + void + bin_statistics_f_impl::enter_dwell_delay() + { + d_state = ST_DWELL_DELAY; + d_delay = d_dwell_delay; + reset_stats(); + } + + void + bin_statistics_f_impl::leave_dwell_delay() + { + send_stats(); + } + + int + bin_statistics_f_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *input = (const float*)input_items[0]; + size_t vlen = d_max.size(); + + int n = 0; + int t; + + while(n < noutput_items) { + switch(d_state) { + + case ST_INIT: + enter_tune_delay(); + break; + + case ST_TUNE_DELAY: + t = std::min(noutput_items - n, int(d_delay)); + n += t; + d_delay -= t; + assert(d_delay >= 0); + if(d_delay == 0) + enter_dwell_delay(); + break; + + case ST_DWELL_DELAY: + t = std::min(noutput_items - n, int(d_delay)); + for(int i = 0; i < t; i++) { + accrue_stats(&input[n * vlen]); + n++; + } + d_delay -= t; + assert(d_delay >= 0); + if(d_delay == 0) { + leave_dwell_delay(); + enter_tune_delay(); + } + break; + + default: + assert(0); + } + } + + return noutput_items; + } + + ////////////////////////////////////////////////////////////////////////// + // virtual methods for gathering stats + ////////////////////////////////////////////////////////////////////////// + + void + bin_statistics_f_impl::reset_stats() + { + for (size_t i = 0; i < vlen(); i++){ + d_max[i] = 0; + } + } + + void + bin_statistics_f_impl::accrue_stats(const float *input) + { + for(size_t i = 0; i < vlen(); i++) { + d_max[i] = std::max(d_max[i], input[i]); // compute per bin maxima + } + } + + void + bin_statistics_f_impl::send_stats() + { + if(msgq()->full_p()) // if the queue is full, don't block, drop the data... + return; + + // build & send a message + gr_message_sptr msg = gr_make_message(0, center_freq(), vlen(), vlen() * sizeof(float)); + memcpy(msg->msg(), &d_max[0], vlen() * sizeof(float)); + msgq()->insert_tail(msg); + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/bin_statistics_f_impl.h b/gr-blocks/lib/bin_statistics_f_impl.h new file mode 100644 index 0000000000..0abb60ed38 --- /dev/null +++ b/gr-blocks/lib/bin_statistics_f_impl.h @@ -0,0 +1,82 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_BIN_STATISTICS_F_IMPL_H +#define INCLUDED_GR_BIN_STATISTICS_F_IMPL_H + +#include <blocks/bin_statistics_f.h> +#include <gr_feval.h> +#include <gr_message.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace blocks { + + class bin_statistics_f_impl : public bin_statistics_f + { + private: + enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY }; + + size_t d_vlen; + gr_msg_queue_sptr d_msgq; + gr_feval_dd *d_tune; + size_t d_tune_delay; + size_t d_dwell_delay; + double d_center_freq; + + state_t d_state; + size_t d_delay; // nsamples remaining to state transition + + void enter_init(); + void enter_tune_delay(); + void enter_dwell_delay(); + void leave_dwell_delay(); + + protected: + std::vector<float> d_max; // per bin maxima + + size_t vlen() const { return d_vlen; } + double center_freq() const { return d_center_freq; } + gr_msg_queue_sptr msgq() const { return d_msgq; } + + virtual void reset_stats(); + virtual void accrue_stats(const float *input); + virtual void send_stats(); + + public: + bin_statistics_f_impl(unsigned int vlen, + gr_msg_queue_sptr msgq, + gr_feval_dd *tune, + size_t tune_delay, + size_t dwell_delay); + ~bin_statistics_f_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_BIN_STATISTICS_F_IMPL_H */ diff --git a/gr-blocks/lib/burst_tagger_impl.cc b/gr-blocks/lib/burst_tagger_impl.cc new file mode 100644 index 0000000000..5d0691bde6 --- /dev/null +++ b/gr-blocks/lib/burst_tagger_impl.cc @@ -0,0 +1,116 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "burst_tagger_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + burst_tagger::sptr + burst_tagger::make(size_t itemsize) + { + return gnuradio::get_initial_sptr + (new burst_tagger_impl(itemsize)); + } + + burst_tagger_impl::burst_tagger_impl(size_t itemsize) + : gr_sync_block("burst_tagger", + gr_make_io_signature2(2, 2, itemsize, sizeof(short)), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_state(false) + { + std::stringstream str; + str << name() << unique_id(); + + d_true_key = pmt::pmt_string_to_symbol("burst"); + d_true_value = pmt::PMT_T; + + d_false_key = pmt::pmt_string_to_symbol("burst"); + d_false_value = pmt::PMT_F; + + d_id = pmt::pmt_string_to_symbol(str.str()); + } + + burst_tagger_impl::~burst_tagger_impl() + { + } + + void + burst_tagger_impl::set_true_tag(const std::string &key, bool value) + { + d_true_key = pmt::pmt_string_to_symbol(key); + if(value == true) { + d_true_value = pmt::PMT_T; + } + else { + d_true_value = pmt::PMT_F; + } + } + + void + burst_tagger_impl::set_false_tag (const std::string &key, bool value) + { + d_false_key = pmt::pmt_string_to_symbol(key); + if(value == true) { + d_false_value = pmt::PMT_T; + } + else { + d_false_value = pmt::PMT_F; + } + } + + int + burst_tagger_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *signal = (const char*)input_items[0]; + const short *trigger = (const short*)input_items[1]; + char *out = (char*)output_items[0]; + + memcpy(out, signal, noutput_items * d_itemsize); + + for(int i = 0; i < noutput_items; i++) { + if(trigger[i] > 0) { + if(d_state == false) { + d_state = true; + add_item_tag(0, nitems_written(0)+i, d_true_key, d_true_value, d_id); + } + } + else { + if(d_state == true) { + d_state = false; + add_item_tag(0, nitems_written(0)+i, d_false_key, d_false_value, d_id); + } + } + } + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/burst_tagger_impl.h b/gr-blocks/lib/burst_tagger_impl.h new file mode 100644 index 0000000000..80bdec12fb --- /dev/null +++ b/gr-blocks/lib/burst_tagger_impl.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_BURST_TAGGER_IMPL_H +#define INCLUDED_GR_BURST_TAGGER_IMPL_H + +#include <blocks/burst_tagger.h> + +namespace gr { + namespace blocks { + + class burst_tagger_impl : public burst_tagger + { + private: + size_t d_itemsize; + bool d_state; + pmt::pmt_t d_true_key; + pmt::pmt_t d_true_value; + + pmt::pmt_t d_false_key; + pmt::pmt_t d_false_value; + + pmt::pmt_t d_id; + + public: + burst_tagger_impl(size_t itemsize); + ~burst_tagger_impl(); + + void set_true_tag(const std::string &key, bool value); + void set_false_tag(const std::string &key, bool value); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_BURST_TAGGER_IMPL_H */ diff --git a/gr-blocks/lib/gnuradio-blocks.rc.in b/gr-blocks/lib/gnuradio-blocks.rc.in new file mode 100644 index 0000000000..126db75091 --- /dev/null +++ b/gr-blocks/lib/gnuradio-blocks.rc.in @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-blocks" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-blocks.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-blocks.dll" + VALUE "ProductName", "gnuradio-blocks" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-blocks/lib/max_XX_impl.cc.t b/gr-blocks/lib/max_XX_impl.cc.t new file mode 100644 index 0000000000..669e2fd30d --- /dev/null +++ b/gr-blocks/lib/max_XX_impl.cc.t @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(size_t vlen) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(vlen)); + } + + @NAME_IMPL@::@NAME_IMPL@(size_t vlen) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, -1, vlen*sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_vlen(vlen) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; + + int ninputs = input_items.size(); + + for(int i = 0; i < noutput_items; i++) { + @I_TYPE@ max = ((@I_TYPE@ *)input_items[0])[i*d_vlen]; + + for(int j = 0; j < (int)d_vlen; j++ ) { + for(int k = 0; k < ninputs; k++) { + if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] > max) { + max = ((@I_TYPE@*)input_items[k])[i*d_vlen + j]; + } + } + } + + *optr++ = (@O_TYPE@)max; + } + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/max_XX_impl.h.t b/gr-blocks/lib/max_XX_impl.h.t new file mode 100644 index 0000000000..0f1643f6b9 --- /dev/null +++ b/gr-blocks/lib/max_XX_impl.h.t @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + size_t d_vlen; + + public: + @NAME_IMPL@(size_t vlen); + ~@NAME_IMPL@(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/message_burst_source_impl.cc b/gr-blocks/lib/message_burst_source_impl.cc new file mode 100644 index 0000000000..f3c90eda31 --- /dev/null +++ b/gr-blocks/lib/message_burst_source_impl.cc @@ -0,0 +1,149 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "message_burst_source_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <string.h> +#include <gr_tags.h> + +namespace gr { + namespace blocks { + + message_burst_source::sptr + message_burst_source::make(size_t itemsize, int msgq_limit) + { + return gnuradio::get_initial_sptr + (new message_burst_source_impl(itemsize, msgq_limit)); + } + + message_burst_source::sptr + message_burst_source::make(size_t itemsize, gr_msg_queue_sptr msgq) + { + return gnuradio::get_initial_sptr + (new message_burst_source_impl(itemsize, msgq)); + } + + message_burst_source_impl::message_burst_source_impl(size_t itemsize, int msgq_limit) + : gr_sync_block("message_burst_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), + d_msg_offset(0), d_eof(false) + { + std::stringstream id; + id << name() << unique_id(); + d_me = pmt::pmt_string_to_symbol(id.str()); + } + + message_burst_source_impl::message_burst_source_impl(size_t itemsize, gr_msg_queue_sptr msgq) + : gr_sync_block("message_burst_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_msgq(msgq), + d_msg_offset(0), d_eof(false) + { + std::stringstream id; + id << name() << unique_id(); + d_me = pmt::pmt_string_to_symbol(id.str()); + } + + message_burst_source_impl::~message_burst_source_impl() + { + } + + int + message_burst_source_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + char *out = (char*)output_items[0]; + int nn = 0; + + uint64_t abs_sample_count = nitems_written(0); + + while(nn < noutput_items) { + if(d_msg) { + // + // Consume whatever we can from the current message + // + + int mm = std::min(noutput_items - nn, + (int)((d_msg->length() - d_msg_offset) / d_itemsize)); + memcpy(out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize); + + nn += mm; + out += mm * d_itemsize; + d_msg_offset += mm * d_itemsize; + assert(d_msg_offset <= d_msg->length()); + + if(d_msg_offset == d_msg->length()) { + if(d_msg->type() == 1) // type == 1 sets EOF + d_eof = true; + d_msg.reset(); + //tag end of burst + add_item_tag(0, //stream ID + abs_sample_count+nn-1, //sample number + pmt::pmt_string_to_symbol("tx_eob"), + pmt::pmt_from_bool(1), + d_me); //block src id + } + } + else { + // + // No current message + // + if(d_msgq->empty_p() && nn > 0) { // no more messages in the queue, return what we've got + break; + } + + if(d_eof) + return -1; + + d_msg = d_msgq->delete_head(); // block, waiting for a message + d_msg_offset = 0; + //tag start of burst + add_item_tag(0, //stream ID + abs_sample_count+nn, //sample number + pmt::pmt_string_to_symbol("tx_sob"), + pmt::pmt_from_bool(1), + d_me); //block src id + + if((d_msg->length() % d_itemsize) != 0) + throw std::runtime_error("msg length is not a multiple of d_itemsize"); + } + } + + return nn; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/message_burst_source_impl.h b/gr-blocks/lib/message_burst_source_impl.h new file mode 100644 index 0000000000..2d5e6a974f --- /dev/null +++ b/gr-blocks/lib/message_burst_source_impl.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_MESSAGE_BURST_SOURCE_IMPL_H +#define INCLUDED_GR_MESSAGE_BURST_SOURCE_IMPL_H + +#include <blocks/message_burst_source.h> +#include <gr_message.h> + +namespace gr { + namespace blocks { + + class message_burst_source_impl : public message_burst_source + { + private: + size_t d_itemsize; + gr_msg_queue_sptr d_msgq; + gr_message_sptr d_msg; + unsigned d_msg_offset; + bool d_eof; + + pmt::pmt_t d_me; + + public: + message_burst_source_impl(size_t itemsize, int msgq_limit); + message_burst_source_impl(size_t itemsize, gr_msg_queue_sptr msgq); + ~message_burst_source_impl(); + + gr_msg_queue_sptr msgq() const { return d_msgq; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_BURST_SOURCE_IMPL_H */ diff --git a/gr-blocks/lib/message_debug_impl.cc b/gr-blocks/lib/message_debug_impl.cc new file mode 100644 index 0000000000..d7b1e5db09 --- /dev/null +++ b/gr-blocks/lib/message_debug_impl.cc @@ -0,0 +1,120 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "message_debug_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <iostream> + +namespace gr { + namespace blocks { + + message_debug::sptr + message_debug::make() + { + return gnuradio::get_initial_sptr + (new message_debug_impl()); + } + + void + message_debug_impl::print(pmt::pmt_t msg) + { + std::cout << "******* MESSAGE DEBUG PRINT ********\n"; + pmt::pmt_print(msg); + std::cout << "************************************\n"; + } + + void + message_debug_impl::store(pmt::pmt_t msg) + { + gruel::scoped_lock guard(d_mutex); + d_messages.push_back(msg); + } + + void + message_debug_impl::print_pdu(pmt::pmt_t pdu) + { + pmt::pmt_t meta = pmt::pmt_car(pdu); + pmt::pmt_t vector = pmt::pmt_cdr(pdu); + std::cout << "* MESSAGE DEBUG PRINT PDU VERBOSE *\n"; + pmt::pmt_print(meta); + size_t len = pmt::pmt_length(vector); + std::cout << "pdu_length = " << len << std::endl; + std::cout << "contents = " << std::endl; + size_t offset(0); + const uint8_t* d = (const uint8_t*) pmt_uniform_vector_elements(vector, offset); + for(size_t i=0; i<len; i+=16){ + printf("%04x: ", ((unsigned int)i)); + for(size_t j=i; j<std::min(i+16,len); j++){ + printf("%02x ",d[j] ); + } + + std::cout << std::endl; + } + + std::cout << "***********************************\n"; + } + + int + message_debug_impl::num_messages() + { + return (int)d_messages.size(); + } + + pmt::pmt_t + message_debug_impl::get_message(int i) + { + gruel::scoped_lock guard(d_mutex); + + if((size_t)i >= d_messages.size()) { + throw std::runtime_error("message_debug: index for message out of bounds.\n"); + } + + return d_messages[i]; + } + + message_debug_impl::message_debug_impl() + : gr_block("message_debug", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(0, 0, 0)) + { + message_port_register_in(pmt::mp("print")); + set_msg_handler(pmt::mp("print"), boost::bind(&message_debug_impl::print, this, _1)); + + message_port_register_in(pmt::mp("store")); + set_msg_handler(pmt::mp("store"), boost::bind(&message_debug_impl::store, this, _1)); + + message_port_register_in(pmt::mp("print_pdu")); + set_msg_handler(pmt::mp("print_pdu"), boost::bind(&message_debug_impl::print_pdu, this, _1)); + } + + message_debug_impl::~message_debug_impl() + { + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/message_debug_impl.h b/gr-blocks/lib/message_debug_impl.h new file mode 100644 index 0000000000..c9d82bd561 --- /dev/null +++ b/gr-blocks/lib/message_debug_impl.h @@ -0,0 +1,89 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_MESSAGE_DEBUG_IMPL_H +#define INCLUDED_GR_MESSAGE_DEBUG_IMPL_H + +#include <blocks/message_debug.h> +#include <gr_block.h> +#include <gruel/thread.h> +#include <gruel/pmt.h> + +namespace gr { + namespace blocks { + + class message_debug_impl : public message_debug + { + private: + + /*! + * \brief Messages received in this port are printed to stdout. + * + * This port receives messages from the scheduler's message + * handling mechanism and prints it to stdout. This message + * handler function is only meant to be used by the scheduler to + * handle messages posted to port 'print'. + * + * \param msg A pmt message passed from the scheduler's message handling. + */ + void print(pmt::pmt_t msg); + + /*! + * \brief PDU formatted messages received in this port are printed to stdout. + * + * This port receives messages from the scheduler's message + * handling mechanism and prints it to stdout. This message + * handler function is only meant to be used by the scheduler to + * handle messages posted to port 'print'. + * + * \param pdu A PDU message passed from the scheduler's message handling. + */ + void print_pdu(pmt::pmt_t pdu); + + /*! + * \brief Messages received in this port are stored in a vector. + * + * This port receives messages from the scheduler's message + * handling mechanism and stores it in a vector. Messages can be + * retrieved later using the 'get_message' function. This + * message handler function is only meant to be used by the + * scheduler to handle messages posted to port 'store'. + * + * \param msg A pmt message passed from the scheduler's message handling. + */ + void store(pmt::pmt_t msg); + + gruel::mutex d_mutex; + std::vector<pmt::pmt_t> d_messages; + + public: + message_debug_impl(); + ~message_debug_impl(); + + int num_messages(); + pmt::pmt_t get_message(int i); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_DEBUG_IMPL_H */ diff --git a/gr-blocks/lib/message_sink_impl.cc b/gr-blocks/lib/message_sink_impl.cc new file mode 100644 index 0000000000..a8dbfb4c71 --- /dev/null +++ b/gr-blocks/lib/message_sink_impl.cc @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "message_sink_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <string.h> + +namespace gr { + namespace blocks { + + message_sink::sptr + message_sink::make(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block) + { + return gnuradio::get_initial_sptr + (new message_sink_impl(itemsize, msgq, dont_block)); + } + + message_sink_impl::message_sink_impl(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block) + : gr_sync_block("message_sink", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(0, 0, 0)), + d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block) + { + } + + message_sink_impl::~message_sink_impl() + { + } + + int + message_sink_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *in = (const char*)input_items[0]; + + // if we'd block, drop the data on the floor and say everything is OK + if(d_dont_block && d_msgq->full_p()) + return noutput_items; + + // build a message to hold whatever we've got + gr_message_sptr msg = gr_make_message(0, // msg type + d_itemsize, // arg1 for other end + noutput_items, // arg2 for other end (redundant) + noutput_items * d_itemsize); // len of msg + memcpy(msg->msg(), in, noutput_items * d_itemsize); + + d_msgq->handle(msg); // send it + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/message_sink_impl.h b/gr-blocks/lib/message_sink_impl.h new file mode 100644 index 0000000000..a3106bc058 --- /dev/null +++ b/gr-blocks/lib/message_sink_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_MESSAGE_SINK_IMPL_H +#define INCLUDED_GR_MESSAGE_SINK_IMPL_H + +#include <blocks/message_sink.h> + +namespace gr { + namespace blocks { + + class message_sink_impl : public message_sink + { + private: + size_t d_itemsize; + gr_msg_queue_sptr d_msgq; + bool d_dont_block; + + public: + message_sink_impl(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); + ~message_sink_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_SINK_IMPL_H */ diff --git a/gr-blocks/lib/message_source_impl.cc b/gr-blocks/lib/message_source_impl.cc new file mode 100644 index 0000000000..cda4fc16c0 --- /dev/null +++ b/gr-blocks/lib/message_source_impl.cc @@ -0,0 +1,127 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "message_source_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <string.h> + +namespace gr { + namespace blocks { + + message_source::sptr + message_source::make(size_t itemsize, int msgq_limit) + { + return gnuradio::get_initial_sptr + (new message_source_impl(itemsize, msgq_limit)); + } + + message_source::sptr + message_source::make(size_t itemsize, gr_msg_queue_sptr msgq) + { + return gnuradio::get_initial_sptr + (new message_source_impl(itemsize, msgq)); + } + + message_source_impl::message_source_impl(size_t itemsize, int msgq_limit) + : gr_sync_block("message_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), + d_msg_offset(0), d_eof(false) + { + } + + message_source_impl::message_source_impl(size_t itemsize, gr_msg_queue_sptr msgq) + : gr_sync_block("message_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_msgq(msgq), + d_msg_offset(0), d_eof(false) + { + } + + message_source_impl::~message_source_impl() + { + } + + int + message_source_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + char *out = (char*)output_items[0]; + int nn = 0; + + while(nn < noutput_items) { + if(d_msg) { + // + // Consume whatever we can from the current message + // + int mm = std::min(noutput_items - nn, + (int)((d_msg->length() - d_msg_offset) / d_itemsize)); + memcpy(out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize); + + nn += mm; + out += mm * d_itemsize; + d_msg_offset += mm * d_itemsize; + assert(d_msg_offset <= d_msg->length()); + + if(d_msg_offset == d_msg->length()) { + if(d_msg->type() == 1) // type == 1 sets EOF + d_eof = true; + d_msg.reset(); + } + } + else { + // + // No current message + // + if(d_msgq->empty_p() && nn > 0) { // no more messages in the queue, return what we've got + break; + } + + if(d_eof) + return -1; + + d_msg = d_msgq->delete_head(); // block, waiting for a message + d_msg_offset = 0; + + if((d_msg->length() % d_itemsize) != 0) + throw std::runtime_error("msg length is not a multiple of d_itemsize"); + } + } + + return nn; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/message_source_impl.h b/gr-blocks/lib/message_source_impl.h new file mode 100644 index 0000000000..c420704478 --- /dev/null +++ b/gr-blocks/lib/message_source_impl.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_MESSAGE_SOURCE_IMPL_H +#define INCLUDED_GR_MESSAGE_SOURCE_IMPL_H + +#include <blocks/message_source.h> +#include <gr_message.h> + +namespace gr { + namespace blocks { + + class message_source_impl : public message_source + { + private: + size_t d_itemsize; + gr_msg_queue_sptr d_msgq; + gr_message_sptr d_msg; + unsigned d_msg_offset; + bool d_eof; + + public: + message_source_impl(size_t itemsize, int msgq_limit); + message_source_impl(size_t itemsize, gr_msg_queue_sptr msgq); + ~message_source_impl(); + + gr_msg_queue_sptr msgq() const { return d_msgq; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_SOURCE_IMPL_H */ diff --git a/gr-blocks/lib/message_strobe_impl.cc b/gr-blocks/lib/message_strobe_impl.cc new file mode 100644 index 0000000000..c4b0e5d567 --- /dev/null +++ b/gr-blocks/lib/message_strobe_impl.cc @@ -0,0 +1,85 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "message_strobe_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <string.h> +#include <iostream> + +namespace gr { + namespace blocks { + + message_strobe::sptr + message_strobe::make(pmt::pmt_t msg, float period_ms) + { + return gnuradio::get_initial_sptr + (new message_strobe_impl(msg, period_ms)); + } + + message_strobe_impl::message_strobe_impl(pmt::pmt_t msg, float period_ms) + : gr_block("message_strobe", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(0, 0, 0)), + d_finished(false), + d_period_ms(period_ms), + d_msg(msg) + { + message_port_register_out(pmt::mp("strobe")); + d_thread = boost::shared_ptr<boost::thread> + (new boost::thread(boost::bind(&message_strobe_impl::run, this))); + + message_port_register_in(pmt::mp("set_msg")); + set_msg_handler(pmt::mp("set_msg"), + boost::bind(&message_strobe_impl::set_msg, this, _1)); + } + + message_strobe_impl::~message_strobe_impl() + { + d_finished = true; + d_thread->interrupt(); + d_thread->join(); + } + + void message_strobe_impl::run() + { + while(!d_finished) { + boost::this_thread::sleep(boost::posix_time::milliseconds(d_period_ms)); + if(d_finished) { + return; + } + + message_port_pub(pmt::mp("strobe"), d_msg); + } + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/message_strobe_impl.h b/gr-blocks/lib/message_strobe_impl.h new file mode 100644 index 0000000000..1b2edae593 --- /dev/null +++ b/gr-blocks/lib/message_strobe_impl.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_MESSAGE_STROBE_IMPL_H +#define INCLUDED_GR_MESSAGE_STROBE_IMPL_H + +#include <blocks/message_strobe.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API message_strobe_impl : public message_strobe + { + private: + boost::shared_ptr<boost::thread> d_thread; + bool d_finished; + float d_period_ms; + pmt::pmt_t d_msg; + + void run(); + + public: + message_strobe_impl(pmt::pmt_t msg, float period_ms); + ~message_strobe_impl(); + + void set_msg(pmt::pmt_t msg) { d_msg = msg; } + pmt::pmt_t msg() const { return d_msg; } + void set_period(float period_ms) { d_period_ms = period_ms; } + float period() const { return d_period_ms; } + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_STROBE_IMPL_H */ diff --git a/gr-blocks/lib/moving_average_XX_impl.cc.t b/gr-blocks/lib/moving_average_XX_impl.cc.t new file mode 100644 index 0000000000..566deff116 --- /dev/null +++ b/gr-blocks/lib/moving_average_XX_impl.cc.t @@ -0,0 +1,114 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "@NAME_IMPL@.h" +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(int length, @O_TYPE@ scale, int max_iter) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(length, scale, max_iter)); + } + + @NAME_IMPL@::@NAME_IMPL@(int length, @O_TYPE@ scale, int max_iter) + : gr_sync_block("@NAME@", + gr_make_io_signature(1, 1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_length(length), + d_scale(scale), + d_max_iter(max_iter), + d_new_length(length), + d_new_scale(scale), + d_updated(false) + { + set_history(length); + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + void + @NAME_IMPL@::set_length_and_scale(int length, @O_TYPE@ scale) + { + d_new_length = length; + d_new_scale = scale; + d_updated = true; + } + + void + @NAME_IMPL@::set_length(int length) + { + d_new_length = length; + d_updated = true; + } + + void + @NAME_IMPL@::set_scale(@O_TYPE@ scale) + { + d_new_scale = scale; + d_updated = true; + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + if(d_updated) { + d_length = d_new_length; + d_scale = d_new_scale; + set_history(d_length); + d_updated = false; + return 0; // history requirements might have changed + } + + const @I_TYPE@ *in = (const @I_TYPE@ *)input_items[0]; + @O_TYPE@ *out = (@O_TYPE@ *)output_items[0]; + + @I_TYPE@ sum = 0; + int num_iter = (noutput_items>d_max_iter) ? d_max_iter : noutput_items; + for(int i = 0; i < d_length-1; i++) { + sum += in[i]; + } + + for(int i = 0; i < num_iter; i++) { + sum += in[i+d_length-1]; + out[i] = sum * d_scale; + sum -= in[i]; + } + + return num_iter; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/moving_average_XX_impl.h.t b/gr-blocks/lib/moving_average_XX_impl.h.t new file mode 100644 index 0000000000..7234cbe139 --- /dev/null +++ b/gr-blocks/lib/moving_average_XX_impl.h.t @@ -0,0 +1,65 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + int d_length; + @O_TYPE@ d_scale; + int d_max_iter; + + int d_new_length; + @O_TYPE@ d_new_scale; + bool d_updated; + + public: + @NAME_IMPL@(int length, @O_TYPE@ scale, + int max_iter = 4096); + ~@NAME_IMPL@(); + + int length() const { return d_new_length; } + @O_TYPE@ scale() const { return d_new_scale; } + + void set_length_and_scale(int length, @O_TYPE@ scale); + void set_length(int length); + void set_scale(@O_TYPE@ scale); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/mute_XX_impl.cc.t b/gr-blocks/lib/mute_XX_impl.cc.t new file mode 100644 index 0000000000..b29e9edada --- /dev/null +++ b/gr-blocks/lib/mute_XX_impl.cc.t @@ -0,0 +1,89 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(bool mute) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(mute)); + } + + @NAME_IMPL@::@NAME_IMPL@(bool mute) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_mute(mute) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @I_TYPE@ *iptr = (@I_TYPE@ *)input_items[0]; + @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; + + int size = noutput_items; + + if(d_mute) { + memset(optr, 0, noutput_items * sizeof(@O_TYPE@)); + } + else { + while(size >= 8) { + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + size -= 8; + } + + while(size-- > 0) + *optr++ = *iptr++; + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/mute_XX_impl.h.t b/gr-blocks/lib/mute_XX_impl.h.t new file mode 100644 index 0000000000..de93c8eb82 --- /dev/null +++ b/gr-blocks/lib/mute_XX_impl.h.t @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + bool d_mute; + + public: + @NAME_IMPL@(bool mute); + ~@NAME_IMPL@(); + + bool mute() const { return d_mute; } + void set_mute(bool mute) { d_mute = mute; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/pack_k_bits_bb_impl.cc b/gr-blocks/lib/pack_k_bits_bb_impl.cc new file mode 100644 index 0000000000..2a7fcc04cb --- /dev/null +++ b/gr-blocks/lib/pack_k_bits_bb_impl.cc @@ -0,0 +1,76 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "pack_k_bits_bb_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> +#include <iostream> + +namespace gr { + namespace blocks { + + pack_k_bits_bb::sptr + pack_k_bits_bb::make(unsigned k) + { + return gnuradio::get_initial_sptr + (new pack_k_bits_bb_impl(k)); + } + + pack_k_bits_bb_impl::pack_k_bits_bb_impl(unsigned k) + : gr_sync_decimator("pack_k_bits_bb", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(unsigned char)), + k), + d_k(k) + { + if(d_k == 0) + throw std::out_of_range("interpolation must be > 0"); + } + + pack_k_bits_bb_impl::~pack_k_bits_bb_impl() + { + } + + int + pack_k_bits_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *)input_items[0]; + unsigned char *out = (unsigned char *)output_items[0]; + + for(int i = 0; i < noutput_items; i++) { + out[i] = 0x00; + for(unsigned int j = 0; j < d_k; j++) { + out[i] |= (0x01 & in[i*d_k+j])<<(d_k-j-1); + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/pack_k_bits_bb_impl.h b/gr-blocks/lib/pack_k_bits_bb_impl.h new file mode 100644 index 0000000000..668d438a46 --- /dev/null +++ b/gr-blocks/lib/pack_k_bits_bb_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_PACK_K_BITS_BB_IMPL_H +#define INCLUDED_GR_PACK_K_BITS_BB_IMPL_H + +#include <blocks/pack_k_bits_bb.h> + +namespace gr { + namespace blocks { + + class pack_k_bits_bb_impl : public pack_k_bits_bb + { + private: + unsigned d_k; // number of relevent bits to pack from k input bytes + + public: + pack_k_bits_bb_impl(unsigned k); + ~pack_k_bits_bb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PACK_K_BITS_BB_IMPL_H */ diff --git a/gr-blocks/lib/pdu.cc b/gr-blocks/lib/pdu.cc new file mode 100644 index 0000000000..41a2d88c3a --- /dev/null +++ b/gr-blocks/lib/pdu.cc @@ -0,0 +1,92 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <blocks/pdu.h> + +namespace gr { + namespace blocks { + namespace pdu { + + size_t + itemsize(vector_type type) + { + switch(type) { + case byte_t: + return sizeof(char); + case float_t: + return sizeof(float); + case complex_t: + return sizeof(gr_complex); + default: + throw std::runtime_error("bad PDU type"); + } + } + + bool + type_matches(vector_type type, pmt::pmt_t v) + { + switch(type) { + case byte_t: + return pmt::pmt_is_u8vector(v); + case float_t: + return pmt::pmt_is_f32vector(v); + case complex_t: + return pmt::pmt_is_c32vector(v); + default: + throw std::runtime_error("bad PDU type"); + } + } + + pmt::pmt_t + make_vector(vector_type type, const uint8_t *buf, size_t items) + { + switch(type) { + case byte_t: + return pmt::pmt_init_u8vector(items, buf); + case float_t: + return pmt::pmt_init_f32vector(items, (const float *)buf); + case complex_t: + return pmt::pmt_init_c32vector(items, (const gr_complex *)buf); + default: + throw std::runtime_error("bad PDU type"); + } + } + + vector_type + type_from_pmt(pmt::pmt_t vector) + { + if(pmt_is_u8vector(vector)) + return byte_t; + if(pmt_is_f32vector(vector)) + return float_t; + if(pmt_is_c32vector(vector)) + return complex_t; + throw std::runtime_error("bad PDU type"); + } + + } /* namespace pdu */ + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc new file mode 100644 index 0000000000..80785b4781 --- /dev/null +++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc @@ -0,0 +1,120 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "pdu_to_tagged_stream_impl.h" +#include <blocks/pdu.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + pdu_to_tagged_stream::sptr + pdu_to_tagged_stream::make(pdu::vector_type type) + { + return gnuradio::get_initial_sptr(new pdu_to_tagged_stream_impl(type)); + } + + pdu_to_tagged_stream_impl::pdu_to_tagged_stream_impl(pdu::vector_type type) + : gr_sync_block("pdu_to_tagged_stream", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, pdu::itemsize(type))), + d_itemsize(pdu::itemsize(type)), + d_type(type) + { + message_port_register_in(PDU_PORT_ID); + } + + int + pdu_to_tagged_stream_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + char *out = (char *)output_items[0]; + int nout = 0; + + // if we have remaining output, send it + if (d_remain.size() > 0) { + nout = std::min((size_t)d_remain.size()/d_itemsize, (size_t)noutput_items); + memcpy(out, &d_remain[0], nout*d_itemsize); + d_remain.erase(d_remain.begin(), d_remain.begin()+nout); + noutput_items -= nout; + out += nout*d_itemsize; + } + + // if we have space for at least one item output as much as we can + if (noutput_items > 0) { + + // grab a message if one exists + pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID)); + if (msg.get() == NULL) + return nout; + + // make sure type is valid + if (!pmt::pmt_is_pair(msg)) // TODO: implement pdu::is_valid() + throw std::runtime_error("received a malformed pdu message"); + + // grab the components of the pdu message + pmt::pmt_t meta(pmt::pmt_car(msg)); + pmt::pmt_t vect(pmt::pmt_cdr(msg)); + + // compute offset for output tag + uint64_t offset = nitems_written(0) + nout; + + // add a tag for pdu length + add_item_tag(0, offset, PDU_LENGTH_TAG, pmt::pmt_from_long(pmt::pmt_length(vect)), pmt::mp(alias())); + + // if we recieved metadata add it as tags + if (!pmt_eq(meta, pmt::PMT_NIL) ) { + pmt::pmt_t pair(pmt::pmt_dict_keys(meta)); + + while (!pmt_eq(pair, pmt::PMT_NIL) ) { + pmt::pmt_t k(pmt::pmt_cdr(pair)); + pmt::pmt_t v(pmt::pmt_dict_ref(meta, k, pmt::PMT_NIL)); + add_item_tag(0, offset, k, v, pmt::mp(alias())); + } + } + + // copy vector output + size_t ncopy = std::min((size_t)noutput_items, (size_t)pmt::pmt_length(vect)); + size_t nsave = pmt::pmt_length(vect) - ncopy; + + // copy output + size_t io(0); + nout += ncopy; + memcpy(out, pmt_uniform_vector_elements(vect,io), ncopy*d_itemsize); + + // save leftover items if needed for next work call + if (nsave > 0) { + d_remain.resize(nsave*d_itemsize, 0); + memcpy(&d_remain[0], pmt_uniform_vector_elements(vect,ncopy), nsave*d_itemsize); + } + } + + return nout; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.h b/gr-blocks/lib/pdu_to_tagged_stream_impl.h new file mode 100644 index 0000000000..ca1c6437bd --- /dev/null +++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_PDU_TO_TAGGED_STREAM_IMPL_H +#define INCLUDED_PDU_TO_TAGGED_STREAM_IMPL_H + +#include <blocks/pdu_to_tagged_stream.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API pdu_to_tagged_stream_impl : public pdu_to_tagged_stream + { + size_t d_itemsize; + pdu::vector_type d_type; + std::vector<uint8_t> d_remain; + + public: + pdu_to_tagged_stream_impl(pdu::vector_type type); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif diff --git a/gr-blocks/lib/peak_detector_XX_impl.cc.t b/gr-blocks/lib/peak_detector_XX_impl.cc.t new file mode 100644 index 0000000000..27518962f5 --- /dev/null +++ b/gr-blocks/lib/peak_detector_XX_impl.cc.t @@ -0,0 +1,122 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "@NAME_IMPL@.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(float threshold_factor_rise, + float threshold_factor_fall, + int look_ahead, float alpha) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(threshold_factor_rise, + threshold_factor_fall, + look_ahead, alpha)); + } + + @NAME_IMPL@::@NAME_IMPL@(float threshold_factor_rise, + float threshold_factor_fall, + int look_ahead, float alpha) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(char))), + d_threshold_factor_rise(threshold_factor_rise), + d_threshold_factor_fall(threshold_factor_fall), + d_look_ahead(look_ahead), d_avg_alpha(alpha), d_avg(0), d_found(0) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @I_TYPE@ *iptr = (@I_TYPE@*)input_items[0]; + char *optr = (char*)output_items[0]; + + memset(optr, 0, noutput_items*sizeof(char)); + + @I_TYPE@ peak_val = -(@I_TYPE@)INFINITY; + int peak_ind = 0; + unsigned char state = 0; + int i = 0; + + //printf("noutput_items %d\n",noutput_items); + while(i < noutput_items) { + if(state == 0) { // below threshold + if(iptr[i] > d_avg*d_threshold_factor_rise) { + state = 1; + } + else { + d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg; + i++; + } + } + else if(state == 1) { // above threshold, have not found peak + //printf("Entered State 1: %f i: %d noutput_items: %d\n", iptr[i], i, noutput_items); + if(iptr[i] > peak_val) { + peak_val = iptr[i]; + peak_ind = i; + d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg; + i++; + } + else if(iptr[i] > d_avg*d_threshold_factor_fall) { + d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg; + i++; + } + else { + optr[peak_ind] = 1; + state = 0; + peak_val = -(@I_TYPE@)INFINITY; + //printf("Leaving State 1: Peak: %f Peak Ind: %d i: %d noutput_items: %d\n", + //peak_val, peak_ind, i, noutput_items); + } + } + } + + if(state == 0) { + //printf("Leave in State 0, produced %d\n",noutput_items); + return noutput_items; + } + else { // only return up to passing the threshold + //printf("Leave in State 1, only produced %d of %d\n",peak_ind,noutput_items); + return peak_ind+1; + } + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/peak_detector_XX_impl.h.t b/gr-blocks/lib/peak_detector_XX_impl.h.t new file mode 100644 index 0000000000..ef52f0f744 --- /dev/null +++ b/gr-blocks/lib/peak_detector_XX_impl.h.t @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + float d_threshold_factor_rise; + float d_threshold_factor_fall; + int d_look_ahead; + float d_avg_alpha; + float d_avg; + unsigned char d_found; + + public: + @NAME_IMPL@(float threshold_factor_rise, + float threshold_factor_fall, + int look_ahead, float alpha); + ~@NAME_IMPL@(); + + void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; } + void set_threshold_factor_fall(float thr) { d_threshold_factor_fall = thr; } + void set_look_ahead(int look) { d_look_ahead = look; } + void set_alpha(int alpha) { d_avg_alpha = alpha; } + float threshold_factor_rise() { return d_threshold_factor_rise; } + float threshold_factor_fall() { return d_threshold_factor_fall; } + int look_ahead() { return d_look_ahead; } + float alpha() { return d_avg_alpha; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/probe_signal_X_impl.cc.t b/gr-blocks/lib/probe_signal_X_impl.cc.t new file mode 100644 index 0000000000..4cda4e5273 --- /dev/null +++ b/gr-blocks/lib/probe_signal_X_impl.cc.t @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @BASE_NAME@::make() + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@()); + } + + @NAME_IMPL@::@NAME_IMPL@() + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@TYPE@)), + gr_make_io_signature(0, 0, 0)), + d_level(0) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const @TYPE@ *in = (const @TYPE@ *)input_items[0]; + + if(noutput_items > 0) + d_level = in[noutput_items-1]; + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/probe_signal_X_impl.h.t b/gr-blocks/lib/probe_signal_X_impl.h.t new file mode 100644 index 0000000000..9c3d05becd --- /dev/null +++ b/gr-blocks/lib/probe_signal_X_impl.h.t @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + @TYPE@ d_level; + + public: + @NAME_IMPL@(); + ~@NAME_IMPL@(); + + @TYPE@ level() const { return d_level; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/probe_signal_vX_impl.cc.t b/gr-blocks/lib/probe_signal_vX_impl.cc.t new file mode 100644 index 0000000000..bd520b0bc8 --- /dev/null +++ b/gr-blocks/lib/probe_signal_vX_impl.cc.t @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @BASE_NAME@::make(size_t size) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(size)); + } + + @NAME_IMPL@::@NAME_IMPL@(size_t size) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, 1, size*sizeof(@TYPE@)), + gr_make_io_signature(0, 0, 0)), + d_level(size, 0), d_size(size) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const @TYPE@ *in = (const @TYPE@ *)input_items[0]; + + for(size_t i=0; i<d_size; i++) + d_level[i] = in[(noutput_items-1)*d_size+i]; + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/probe_signal_vX_impl.h.t b/gr-blocks/lib/probe_signal_vX_impl.h.t new file mode 100644 index 0000000000..1424334a7f --- /dev/null +++ b/gr-blocks/lib/probe_signal_vX_impl.h.t @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <vector> +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + std::vector<@TYPE@> d_level; + size_t d_size; + + public: + @NAME_IMPL@(size_t size); + ~@NAME_IMPL@(); + + std::vector<@TYPE@> level() const { return d_level; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/sample_and_hold_XX_impl.cc.t b/gr-blocks/lib/sample_and_hold_XX_impl.cc.t new file mode 100644 index 0000000000..617b2d6ee5 --- /dev/null +++ b/gr-blocks/lib/sample_and_hold_XX_impl.cc.t @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make() + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@()); + } + + @NAME_IMPL@::@NAME_IMPL@() + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature2(2, 2, sizeof(@I_TYPE@), sizeof(char)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_data(0) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @I_TYPE@ *iptr = (@I_TYPE@ *)input_items[0]; + const char *ctrl = (const char *)input_items[1]; + @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; + + for(int i = 0; i < noutput_items; i++) { + if(ctrl[i]) { + d_data = iptr[i]; + } + optr[i] = d_data; + } + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/sample_and_hold_XX_impl.h.t b/gr-blocks/lib/sample_and_hold_XX_impl.h.t new file mode 100644 index 0000000000..048bf0d0e7 --- /dev/null +++ b/gr-blocks/lib/sample_and_hold_XX_impl.h.t @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + @O_TYPE@ d_data; + + public: + @NAME_IMPL@(); + ~@NAME_IMPL@(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/socket_pdu_impl.cc b/gr-blocks/lib/socket_pdu_impl.cc new file mode 100644 index 0000000000..0a48c2b9f4 --- /dev/null +++ b/gr-blocks/lib/socket_pdu_impl.cc @@ -0,0 +1,198 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "socket_pdu_impl.h" +#include "tcp_connection.h" +#include <gr_io_signature.h> +#include <gr_pdu.h> + +namespace gr { + namespace blocks { + + socket_pdu::sptr + socket_pdu::make(std::string type, std::string addr, std::string port, int MTU) + { + return gnuradio::get_initial_sptr(new socket_pdu_impl(type, addr, port, MTU)); + } + + socket_pdu_impl::socket_pdu_impl(std::string type, std::string addr, std::string port, int MTU) + : gr_block("socket_pdu", + gr_make_io_signature (0, 0, 0), + gr_make_io_signature (0, 0, 0)) + { + message_port_register_in(PDU_PORT_ID); + message_port_register_out(PDU_PORT_ID); + + if ((type == "TCP_SERVER") || (type == "TCP_CLIENT")) { + boost::asio::ip::tcp::resolver resolver(d_io_service); + boost::asio::ip::tcp::resolver::query query(boost::asio::ip::tcp::v4(), addr, port); + d_tcp_endpoint = *resolver.resolve(query); + } + + if ((type == "UDP_SERVER") || (type == "UDP_CLIENT")) { + boost::asio::ip::udp::resolver resolver(d_io_service); + boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(), addr, port); + + if (type == "UDP_SERVER") + d_udp_endpoint = *resolver.resolve(query); + else + d_udp_endpoint_other = *resolver.resolve(query); + } + + if (type == "TCP_SERVER") { + d_acceptor_tcp.reset(new boost::asio::ip::tcp::acceptor(d_io_service, d_tcp_endpoint)); + d_acceptor_tcp->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); + start_tcp_accept(); + set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::tcp_server_send, this, _1)); + + } + else if (type =="TCP_CLIENT") { + boost::system::error_code error = boost::asio::error::host_not_found; + d_tcp_socket.reset(new boost::asio::ip::tcp::socket(d_io_service)); + d_tcp_socket->connect(d_tcp_endpoint, error); + if (error) + throw boost::system::system_error(error); + + set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::tcp_client_send, this, _1)); + + d_tcp_socket->async_read_some( + boost::asio::buffer(d_rxbuf), + boost::bind(&socket_pdu_impl::handle_tcp_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred) + ); + } + else if (type =="UDP_SERVER") { + d_udp_socket.reset(new boost::asio::ip::udp::socket(d_io_service, d_udp_endpoint)); + d_udp_socket->async_receive_from(boost::asio::buffer(d_rxbuf), d_udp_endpoint_other, + boost::bind(&socket_pdu_impl::handle_udp_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::udp_send, this, _1)); + } + else if (type =="UDP_CLIENT") { + d_udp_socket.reset(new boost::asio::ip::udp::socket(d_io_service, d_udp_endpoint)); + d_udp_socket->async_receive_from(boost::asio::buffer(d_rxbuf), d_udp_endpoint_other, + boost::bind(&socket_pdu_impl::handle_udp_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::udp_send, this, _1)); + } + else + throw std::runtime_error("gr::blocks:socket_pdu: unknown socket type"); + + d_thread = gruel::thread(boost::bind(&socket_pdu_impl::run_io_service, this)); + d_started = true; + } + + void + socket_pdu_impl::handle_tcp_read(const boost::system::error_code& error, size_t bytes_transferred) + { + if (!error) { + pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t *)&d_rxbuf[0]); + pmt::pmt_t pdu = pmt::pmt_cons(pmt::PMT_NIL, vector); + message_port_pub(PDU_PORT_ID, pdu); + + d_tcp_socket->async_read_some(boost::asio::buffer(d_rxbuf), + boost::bind(&socket_pdu_impl::handle_tcp_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + } + else + throw boost::system::system_error(error); + } + + void + socket_pdu_impl::start_tcp_accept() + { + tcp_connection::sptr new_connection = tcp_connection::make(d_acceptor_tcp->get_io_service()); + + d_acceptor_tcp->async_accept(new_connection->socket(), + boost::bind(&socket_pdu_impl::handle_tcp_accept, this, + new_connection, boost::asio::placeholders::error)); + } + + void + socket_pdu_impl::tcp_server_send(pmt::pmt_t msg) + { + pmt::pmt_t vector = pmt::pmt_cdr(msg); + for(size_t i = 0; i < d_tcp_connections.size(); i++) + d_tcp_connections[i]->send(vector); + } + + void + socket_pdu_impl::handle_tcp_accept(tcp_connection::sptr new_connection, const boost::system::error_code& error) + { + if (!error) { + new_connection->start(this); + d_tcp_connections.push_back(new_connection); + start_tcp_accept(); + } + else + std::cout << error << std::endl; + } + + void + socket_pdu_impl::tcp_client_send(pmt::pmt_t msg) + { + pmt::pmt_t vector = pmt::pmt_cdr(msg); + size_t len = pmt::pmt_length(vector); + size_t offset(0); + boost::array<char, 10000> txbuf; + memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len); + d_tcp_socket->send(boost::asio::buffer(txbuf,len)); + } + + void + socket_pdu_impl::udp_send(pmt::pmt_t msg) + { + pmt::pmt_t vector = pmt::pmt_cdr(msg); + size_t len = pmt::pmt_length(vector); + size_t offset(0); + boost::array<char, 10000> txbuf; + memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len); + if (d_udp_endpoint_other.address().to_string() != "0.0.0.0") + d_udp_socket->send_to(boost::asio::buffer(txbuf,len), d_udp_endpoint_other); + } + + void + socket_pdu_impl::handle_udp_read(const boost::system::error_code& error, size_t bytes_transferred) + { + if (!error) { + pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&d_rxbuf[0]); + pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector); + + message_port_pub(PDU_PORT_ID, pdu); + + d_udp_socket->async_receive_from(boost::asio::buffer(d_rxbuf), d_udp_endpoint_other, + boost::bind(&socket_pdu_impl::handle_udp_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + } + } + + } /* namespace blocks */ +}/* namespace gr */ diff --git a/gr-blocks/lib/socket_pdu_impl.h b/gr-blocks/lib/socket_pdu_impl.h new file mode 100644 index 0000000000..78602754c7 --- /dev/null +++ b/gr-blocks/lib/socket_pdu_impl.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H +#define INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H + +#include <blocks/socket_pdu.h> +#include "stream_pdu_base.h" +#include "tcp_connection.h" + +namespace gr { + namespace blocks { + + class socket_pdu_impl : public socket_pdu, public stream_pdu_base + { + private: + boost::asio::io_service d_io_service; + boost::array<char, 10000> d_rxbuf; + void run_io_service() { d_io_service.run(); } + + // TCP specific + boost::asio::ip::tcp::endpoint d_tcp_endpoint; + std::vector<tcp_connection::sptr> d_tcp_connections; + void handle_tcp_read(const boost::system::error_code& error, size_t bytes_transferred); + + // TCP server specific + boost::shared_ptr<boost::asio::ip::tcp::acceptor> d_acceptor_tcp; + void start_tcp_accept(); + void tcp_server_send(pmt::pmt_t msg); + void handle_tcp_accept(tcp_connection::sptr new_connection, const boost::system::error_code& error); + + // TCP client specific + boost::shared_ptr<boost::asio::ip::tcp::socket> d_tcp_socket; + void tcp_client_send(pmt::pmt_t msg); + + // UDP specific + boost::asio::ip::udp::endpoint d_udp_endpoint; + boost::asio::ip::udp::endpoint d_udp_endpoint_other; + boost::shared_ptr<boost::asio::ip::udp::socket> d_udp_socket; + void handle_udp_read(const boost::system::error_code& error, size_t bytes_transferred); + void udp_send(pmt::pmt_t msg); + + public: + socket_pdu_impl(std::string type, std::string addr, std::string port, int MTU); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H */ diff --git a/gr-blocks/lib/stream_pdu_base.cc b/gr-blocks/lib/stream_pdu_base.cc new file mode 100644 index 0000000000..21fbb5eabe --- /dev/null +++ b/gr-blocks/lib/stream_pdu_base.cc @@ -0,0 +1,130 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_IO_H +#include <io.h> +#endif + +#ifdef HAVE_WINDOWS_H +#include <winsock2.h> +#endif + +#include <blocks/pdu.h> +#include <gr_basic_block.h> +#include "stream_pdu_base.h" +#include <boost/format.hpp> + +static const long timeout_us = 100*1000; //100ms + +namespace gr { + namespace blocks { + + stream_pdu_base::stream_pdu_base(int MTU) + : d_fd(-1), + d_started(false), + d_finished(false) + { + // reserve space for rx buffer + d_rxbuf.resize(MTU,0); + } + + stream_pdu_base::~stream_pdu_base() + { + stop_rxthread(); + } + + void + stream_pdu_base::start_rxthread(gr_basic_block *blk, pmt::pmt_t port) + { + d_blk = blk; + d_port = port; + d_thread = gruel::thread(boost::bind(&stream_pdu_base::run, this)); + d_started = true; + } + + void + stream_pdu_base::stop_rxthread() + { + d_finished = true; + + if (d_started) { + d_thread.interrupt(); + d_thread.join(); + } + } + + void + stream_pdu_base::run() + { + while(!d_finished) { + if (!wait_ready()) + continue; + + const int result = read(d_fd, &d_rxbuf[0], d_rxbuf.size()); + if (result <= 0) + throw std::runtime_error("stream_pdu_base, bad socket read!"); + + pmt::pmt_t vector = pmt::pmt_init_u8vector(result, &d_rxbuf[0]); + pmt::pmt_t pdu = pmt::pmt_cons(pmt::PMT_NIL, vector); + + d_blk->message_port_pub(d_port, pdu); + } + } + + bool + stream_pdu_base::wait_ready() + { + //setup timeval for timeout + timeval tv; + tv.tv_sec = 0; + tv.tv_usec = timeout_us; + + //setup rset for timeout + fd_set rset; + FD_ZERO(&rset); + FD_SET(d_fd, &rset); + + //call select with timeout on receive socket + return ::select(d_fd+1, &rset, NULL, NULL, &tv) > 0; + } + + void + stream_pdu_base::send(pmt::pmt_t msg) + { + pmt::pmt_t vector = pmt::pmt_cdr(msg); + size_t offset(0); + size_t itemsize(pdu::itemsize(pdu::type_from_pmt(vector))); + int len(pmt::pmt_length(vector)*itemsize); + + const int rv = write(d_fd, pmt::pmt_uniform_vector_elements(vector, offset), len); + if (rv != len) { + std::cerr << boost::format("WARNING: stream_pdu_base::send(pdu) write failed! (d_fd=%d, len=%d, rv=%d)") + % d_fd % len % rv << std::endl; + } + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/stream_pdu_base.h b/gr-blocks/lib/stream_pdu_base.h new file mode 100644 index 0000000000..66eaaf0c04 --- /dev/null +++ b/gr-blocks/lib/stream_pdu_base.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_STREAM_PDU_BASE_H +#define INCLUDED_STREAM_PDU_BASE_H + +#include <gruel/thread.h> +#include <gruel/pmt.h> + +class gr_basic_block; + +namespace gr { + namespace blocks { + + class stream_pdu_base + { + public: + stream_pdu_base(int MTU=10000); + ~stream_pdu_base(); + + protected: + int d_fd; + bool d_started; + bool d_finished; + std::vector<uint8_t> d_rxbuf; + gruel::thread d_thread; + + pmt::pmt_t d_port; + gr_basic_block *d_blk; + + void run(); + void send(pmt::pmt_t msg); + bool wait_ready(); + void start_rxthread(gr_basic_block *blk, pmt::pmt_t rxport); + void stop_rxthread(); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_STREAM_PDU_BASE_H */ diff --git a/gr-blocks/lib/tag_debug_impl.cc b/gr-blocks/lib/tag_debug_impl.cc new file mode 100644 index 0000000000..a216879637 --- /dev/null +++ b/gr-blocks/lib/tag_debug_impl.cc @@ -0,0 +1,118 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tag_debug_impl.h" +#include <gr_io_signature.h> +#include <iostream> +#include <iomanip> + +namespace gr { + namespace blocks { + + tag_debug::sptr + tag_debug::make(size_t sizeof_stream_item, + const std::string &name) + { + return gnuradio::get_initial_sptr + (new tag_debug_impl(sizeof_stream_item, name)); + } + + tag_debug_impl::tag_debug_impl(size_t sizeof_stream_item, + const std::string &name) + : gr_sync_block("tag_debug", + gr_make_io_signature(1, -1, sizeof_stream_item), + gr_make_io_signature(0, 0, 0)), + d_name(name), d_display(true) + { + } + + tag_debug_impl::~tag_debug_impl() + { + } + + std::vector<gr_tag_t> + tag_debug_impl::current_tags() + { + gruel::scoped_lock l(d_mutex); + return d_tags; + } + + void + tag_debug_impl::set_display(bool d) + { + gruel::scoped_lock l(d_mutex); + d_display = d; + } + + int + tag_debug_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gruel::scoped_lock l(d_mutex); + + std::stringstream sout; + if(d_display) { + sout << std::endl + << "----------------------------------------------------------------------"; + sout << std::endl << "Tag Debug: " << d_name << std::endl; + } + + uint64_t abs_N, end_N; + for(size_t i = 0; i < input_items.size(); i++) { + abs_N = nitems_read(i); + end_N = abs_N + (uint64_t)(noutput_items); + + d_tags.clear(); + get_tags_in_range(d_tags, i, abs_N, end_N); + + if(d_display) { + sout << "Input Stream: " << std::setw(2) << std::setfill('0') + << i << std::setfill(' ') << std::endl; + for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { + sout << std::setw(10) << "Offset: " << d_tags_itr->offset + << std::setw(10) << "Source: " + << (pmt::pmt_is_symbol(d_tags_itr->srcid) ? pmt::pmt_symbol_to_string(d_tags_itr->srcid) : "n/a") + << std::setw(10) << "Key: " << pmt::pmt_symbol_to_string(d_tags_itr->key) + << std::setw(10) << "Value: "; + sout << d_tags_itr->value << std::endl; + } + } + } + + if(d_display) { + sout << "----------------------------------------------------------------------"; + sout << std::endl; + + if(d_tags.size() > 0) + std::cout << sout.str(); + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/tag_debug_impl.h b/gr-blocks/lib/tag_debug_impl.h new file mode 100644 index 0000000000..988d0e1103 --- /dev/null +++ b/gr-blocks/lib/tag_debug_impl.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_TAG_DEBUG_IMPL_H +#define INCLUDED_GR_TAG_DEBUG_IMPL_H + +#include <blocks/tag_debug.h> +#include <gruel/thread.h> +#include <stddef.h> + +namespace gr { + namespace blocks { + + class tag_debug_impl : public tag_debug + { + private: + std::string d_name; + std::vector<gr_tag_t> d_tags; + std::vector<gr_tag_t>::iterator d_tags_itr; + bool d_display; + gruel::mutex d_mutex; + + public: + tag_debug_impl(size_t sizeof_stream_item, const std::string &name); + ~tag_debug_impl(); + + std::vector<gr_tag_t> current_tags(); + + void set_display(bool d); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_TAG_DEBUG_IMPL_H */ diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc new file mode 100644 index 0000000000..acd07292f4 --- /dev/null +++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc @@ -0,0 +1,136 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tagged_stream_to_pdu_impl.h" +#include <blocks/pdu.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + tagged_stream_to_pdu::sptr + tagged_stream_to_pdu::make(pdu::vector_type type) + { + return gnuradio::get_initial_sptr(new tagged_stream_to_pdu_impl(type)); + } + + tagged_stream_to_pdu_impl::tagged_stream_to_pdu_impl(pdu::vector_type type) + : gr_sync_block("tagged_stream_to_pdu", + gr_make_io_signature(1, 1, pdu::itemsize(type)), + gr_make_io_signature(0, 0, 0)), + d_itemsize(pdu::itemsize(type)), + d_inpdu(false), + d_type(type), + d_pdu_meta(pmt::PMT_NIL), + d_pdu_vector(pmt::PMT_NIL) + { + message_port_register_out(PDU_PORT_ID); + } + + int + tagged_stream_to_pdu_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const uint8_t *in = (const uint8_t*) input_items[0]; + uint64_t abs_N = nitems_read(0); + + // if we are not in a pdu already, start a new one + if (!d_inpdu) { + bool found_length_tag(false); + + get_tags_in_range(d_tags, 0, abs_N, abs_N+1); + + for (d_tags_itr = d_tags.begin(); (d_tags_itr != d_tags.end()) && (!found_length_tag); d_tags_itr++) { + if (pmt::pmt_equal((*d_tags_itr).key, PDU_LENGTH_TAG )) { + + if ((*d_tags_itr).offset != abs_N ) + throw std::runtime_error("expected next pdu length tag on a different item..."); + + found_length_tag = true; + d_pdu_length = pmt::pmt_to_long((*d_tags_itr).value); + d_pdu_remain = d_pdu_length; + d_pdu_meta = pmt::pmt_make_dict(); + break; + } // if have length tag + } // iter over tags + + if (!found_length_tag) + throw std::runtime_error("tagged stream does not contain a pdu_length tag"); + } + + size_t ncopy = std::min((size_t)noutput_items, d_pdu_remain); + + // copy any tags in this range into our meta object + get_tags_in_range(d_tags, 0, abs_N, abs_N+ncopy); + for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) + if(!pmt_equal((*d_tags_itr).key, PDU_LENGTH_TAG )) + d_pdu_meta = pmt_dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value); + + // copy samples for this vector into either a pmt or our save buffer + if (ncopy == d_pdu_remain) { // we will send this pdu + if (d_save.size() == 0) { + d_pdu_vector = pdu::make_vector(d_type, in, ncopy); + send_message(); + } + else { + size_t oldsize = d_save.size(); + d_save.resize((oldsize + ncopy)*d_itemsize, 0); + memcpy(&d_save[oldsize*d_itemsize], in, ncopy*d_itemsize); + d_pdu_vector = pdu::make_vector(d_type, &d_save[0], d_pdu_length); + send_message(); + d_save.clear(); + } + } + else { + d_inpdu = true; + size_t oldsize = d_save.size(); + d_save.resize((oldsize+ncopy)*d_itemsize); + memcpy(&d_save[oldsize*d_itemsize], in, ncopy*d_itemsize); + d_pdu_remain -= ncopy; + } + + return ncopy; + } + + void + tagged_stream_to_pdu_impl::send_message() + { + if (pmt::pmt_length(d_pdu_vector) != d_pdu_length) + throw std::runtime_error("msg length not correct"); + + pmt::pmt_t msg = pmt::pmt_cons(d_pdu_meta, d_pdu_vector); + message_port_pub(PDU_PORT_ID, msg); + + d_pdu_meta = pmt::PMT_NIL; + d_pdu_vector = pmt::PMT_NIL; + d_pdu_length = 0; + d_pdu_remain = 0; + d_inpdu = false; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.h b/gr-blocks/lib/tagged_stream_to_pdu_impl.h new file mode 100644 index 0000000000..84d7f6c3cb --- /dev/null +++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_TAGGED_STREAM_TO_PDU_IMPL_H +#define INCLUDED_TAGGED_STREAM_TO_PDU_IMPL_H + +#include <blocks/tagged_stream_to_pdu.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API tagged_stream_to_pdu_impl : public tagged_stream_to_pdu + { + size_t d_itemsize; + size_t d_pdu_length; + size_t d_pdu_remain; + bool d_inpdu; + pdu::vector_type d_type; + std::vector<uint8_t> d_save; + pmt::pmt_t d_pdu_meta; + pmt::pmt_t d_pdu_vector; + + std::vector<gr_tag_t>::iterator d_tags_itr; + std::vector<gr_tag_t> d_tags; + + public: + tagged_stream_to_pdu_impl(pdu::vector_type type); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + void send_message(); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif diff --git a/gr-blocks/lib/tcp_connection.cc b/gr-blocks/lib/tcp_connection.cc new file mode 100644 index 0000000000..4ead6442d8 --- /dev/null +++ b/gr-blocks/lib/tcp_connection.cc @@ -0,0 +1,87 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tcp_connection.h" +#include <gr_basic_block.h> +#include <gr_pdu.h> +//#include <boost/asio.hpp> +//#include <boost/bind.hpp> + +namespace gr { + namespace blocks { + + tcp_connection::sptr tcp_connection::make(boost::asio::io_service& io_service) + { + return sptr(new tcp_connection(io_service)); + } + + tcp_connection::tcp_connection(boost::asio::io_service& io_service) + : d_socket(io_service) + { + } + + void + tcp_connection::send(pmt::pmt_t vector) + { + size_t len = pmt::pmt_length(vector); + size_t offset(0); + boost::array<char, 10000> txbuf; + memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len); + boost::asio::async_write(d_socket, boost::asio::buffer(txbuf, len), + boost::bind(&tcp_connection::handle_write, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + } + + void + tcp_connection::start(gr_basic_block *block) + { + d_block = block; + d_socket.async_read_some(boost::asio::buffer(d_buf), + boost::bind(&tcp_connection::handle_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + } + + void + tcp_connection::handle_read(const boost::system::error_code& error, size_t bytes_transferred) + { + if (!error) { + pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&d_buf[0]); + pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector); + + d_block->message_port_pub(PDU_PORT_ID, pdu); + + d_socket.async_read_some(boost::asio::buffer(d_buf), + boost::bind(&tcp_connection::handle_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + + } + } + + } /* namespace blocks */ +}/* namespace gr */ diff --git a/gr-blocks/lib/tcp_connection.h b/gr-blocks/lib/tcp_connection.h new file mode 100644 index 0000000000..ba57de0783 --- /dev/null +++ b/gr-blocks/lib/tcp_connection.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_TCP_CONNECTION_H +#define INCLUDED_TCP_CONNECTION_H + +#include <boost/array.hpp> +#include <boost/asio.hpp> +#include <gruel/pmt.h> + +class gr_basic_block; + +namespace gr { + namespace blocks { + + class tcp_connection + { + private: + boost::asio::ip::tcp::socket d_socket; + boost::array<char, 10000> d_buf; + std::string d_message; + gr_basic_block *d_block; + + tcp_connection(boost::asio::io_service& io_service); + + public: + typedef boost::shared_ptr<tcp_connection> sptr; + + static sptr make(boost::asio::io_service& io_service); + + boost::asio::ip::tcp::socket& socket() { return d_socket; }; + + void start(gr_basic_block *block); + void send(pmt::pmt_t vector); + void handle_read(const boost::system::error_code& error, size_t bytes_transferred); + void handle_write(const boost::system::error_code& error, size_t bytes_transferred) { } + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_TCP_CONNECTION_H */ diff --git a/gr-blocks/lib/tuntap_pdu_impl.cc b/gr-blocks/lib/tuntap_pdu_impl.cc new file mode 100644 index 0000000000..8de817738f --- /dev/null +++ b/gr-blocks/lib/tuntap_pdu_impl.cc @@ -0,0 +1,139 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tuntap_pdu_impl.h" +#include <gr_io_signature.h> +#include <blocks/pdu.h> +#include <boost/format.hpp> + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#if (defined(linux) || defined(__linux) || defined(__linux__)) +#include <sys/ioctl.h> +#include <arpa/inet.h> +#include <linux/if.h> +#endif + +namespace gr { + namespace blocks { + + tuntap_pdu::sptr + tuntap_pdu::make(std::string dev, int MTU) + { +#if (defined(linux) || defined(__linux) || defined(__linux__)) + return gnuradio::get_initial_sptr(new tuntap_pdu_impl(dev, MTU)); +#else + throw std::runtime_error("tuntap_pdu not implemented on this platform"); +#endif + } + +#if (defined(linux) || defined(__linux) || defined(__linux__)) + tuntap_pdu_impl::tuntap_pdu_impl(std::string dev, int MTU) + : gr_block("tuntap_pdu", + gr_make_io_signature (0, 0, 0), + gr_make_io_signature (0, 0, 0)), + stream_pdu_base(MTU), + d_dev(dev) + { + // make the tuntap + char dev_cstr[1024]; + memset(dev_cstr, 0x00, 1024); + strncpy(dev_cstr, dev.c_str(), std::min(sizeof(dev_cstr), dev.size())); + + d_fd = tun_alloc(dev_cstr); + if (d_fd <= 0) + throw std::runtime_error("gr::tuntap_pdu::make: tun_alloc failed (are you running as root?)"); + + std::cout << boost::format( + "Allocated virtual ethernet interface: %s\n" + "You must now use ifconfig to set its IP address. E.g.,\n" + " $ sudo ifconfig %s 192.168.200.1\n" + "Be sure to use a different address in the same subnet for each machine.\n" + ) % dev % dev << std::endl; + + // set up output message port + message_port_register_out(PDU_PORT_ID); + start_rxthread(this, PDU_PORT_ID); + + // set up input message port + message_port_register_in(PDU_PORT_ID); + set_msg_handler(PDU_PORT_ID, boost::bind(&tuntap_pdu_impl::send, this, _1)); + } + + int + tuntap_pdu_impl::tun_alloc(char *dev, int flags) + { + struct ifreq ifr; + int fd, err; + const char *clonedev = "/dev/net/tun"; + + /* Arguments taken by the function: + * + * char *dev: the name of an interface (or '\0'). MUST have enough + * space to hold the interface name if '\0' is passed + * int flags: interface flags (eg, IFF_TUN etc.) + */ + + /* open the clone device */ + if ((fd = open(clonedev, O_RDWR)) < 0) + return fd; + + /* preparation of the struct ifr, of type "struct ifreq" */ + memset(&ifr, 0, sizeof(ifr)); + + ifr.ifr_flags = flags; /* IFF_TUN or IFF_TAP, plus maybe IFF_NO_PI */ + + /* if a device name was specified, put it in the structure; otherwise, + * the kernel will try to allocate the "next" device of the + * specified type + */ + if (*dev) + strncpy(ifr.ifr_name, dev, IFNAMSIZ); + + /* try to create the device */ + if ((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0) { + close(fd); + return err; + } + + /* if the operation was successful, write back the name of the + * interface to the variable "dev", so the caller can know + * it. Note that the caller MUST reserve space in *dev (see calling + * code below) + */ + strcpy(dev, ifr.ifr_name); + + /* this is the special file descriptor that the caller will use to talk + * with the virtual interface + */ + return fd; + } +#endif + + } /* namespace blocks */ +}/* namespace gr */ diff --git a/gr-blocks/lib/tuntap_pdu_impl.h b/gr-blocks/lib/tuntap_pdu_impl.h new file mode 100644 index 0000000000..396d9d51c8 --- /dev/null +++ b/gr-blocks/lib/tuntap_pdu_impl.h @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H +#define INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H + +#include <blocks/tuntap_pdu.h> +#include "stream_pdu_base.h" + +#if (defined(linux) || defined(__linux) || defined(__linux__)) +#include <linux/if_tun.h> +#endif + +namespace gr { + namespace blocks { + + class tuntap_pdu_impl : public tuntap_pdu, public stream_pdu_base + { +#if (defined(linux) || defined(__linux) || defined(__linux__)) + private: + std::string d_dev; + int tun_alloc(char *dev, int flags = IFF_TAP | IFF_NO_PI); + + public: + tuntap_pdu_impl(std::string dev, int MTU); +#endif + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H */ diff --git a/gr-blocks/lib/unpack_k_bits_bb_impl.cc b/gr-blocks/lib/unpack_k_bits_bb_impl.cc new file mode 100644 index 0000000000..367100be84 --- /dev/null +++ b/gr-blocks/lib/unpack_k_bits_bb_impl.cc @@ -0,0 +1,77 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "unpack_k_bits_bb_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> +#include <iostream> + +namespace gr { + namespace blocks { + + unpack_k_bits_bb::sptr + unpack_k_bits_bb::make(unsigned k) + { + return gnuradio::get_initial_sptr + (new unpack_k_bits_bb_impl(k)); + } + + unpack_k_bits_bb_impl::unpack_k_bits_bb_impl(unsigned k) + : gr_sync_interpolator("unpack_k_bits_bb", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(unsigned char)), + k), + d_k(k) + { + if(d_k == 0) + throw std::out_of_range("interpolation must be > 0"); + } + + unpack_k_bits_bb_impl::~unpack_k_bits_bb_impl() + { + } + + int + unpack_k_bits_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *)input_items[0]; + unsigned char *out = (unsigned char *)output_items[0]; + + int n = 0; + for(unsigned int i = 0; i < noutput_items/d_k; i++) { + unsigned int t = in[i]; + for(int j = d_k - 1; j >= 0; j--) + out[n++] = (t >> j) & 0x01; + } + + assert(n == noutput_items); + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/unpack_k_bits_bb_impl.h b/gr-blocks/lib/unpack_k_bits_bb_impl.h new file mode 100644 index 0000000000..c72d16ebf8 --- /dev/null +++ b/gr-blocks/lib/unpack_k_bits_bb_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H +#define INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H + +#include <blocks/unpack_k_bits_bb.h> + +namespace gr { + namespace blocks { + + class unpack_k_bits_bb_impl : public unpack_k_bits_bb + { + private: + unsigned d_k; // number of relevent bits to unpack into k output bytes + + public: + unpack_k_bits_bb_impl(unsigned k); + ~unpack_k_bits_bb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H */ diff --git a/gr-blocks/python/qa_argmax.py b/gr-blocks/python/qa_argmax.py new file mode 100644 index 0000000000..ec82b71cd4 --- /dev/null +++ b/gr-blocks/python/qa_argmax.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# +# Copyright 2007,2010,2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import math + +class test_arg_max(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + tb = self.tb + + src1_data = (0,0.2,-0.3,0,12,0) + src2_data = (0,0.0,3.0,0,10,0) + src3_data = (0,0.0,3.0,0,1,0) + + src1 = gr.vector_source_f(src1_data) + s2v1 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) + tb.connect(src1, s2v1) + + src2 = gr.vector_source_f(src2_data) + s2v2 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) + tb.connect(src2, s2v2) + + src3 = gr.vector_source_f(src3_data) + s2v3 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) + tb.connect(src3, s2v3) + + dst1 = gr.vector_sink_s() + dst2 = gr.vector_sink_s() + argmax = blocks.argmax_fs(len(src1_data)) + + tb.connect(s2v1, (argmax, 0)) + tb.connect(s2v2, (argmax, 1)) + tb.connect(s2v3, (argmax, 2)) + + tb.connect((argmax,0), dst1) + tb.connect((argmax,1), dst2) + + tb.run() + index = dst1.data() + source = dst2.data() + self.assertEqual(index, (4,)) + self.assertEqual(source, (0,)) + +if __name__ == '__main__': + gr_unittest.run(test_arg_max, "test_arg_max.xml") + diff --git a/gr-blocks/python/qa_bin_statistics.py b/gr-blocks/python/qa_bin_statistics.py new file mode 100755 index 0000000000..c1b3072530 --- /dev/null +++ b/gr-blocks/python/qa_bin_statistics.py @@ -0,0 +1,227 @@ +#!/usr/bin/env python +# +# Copyright 2006,2007,2010,2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import random +import struct + +""" +Note: There has been an issue with this block in the past, see Issue +#199. This looks like it might have fixed itself over the years. I am +leaving these tests disabled on our master branch for v3.6 for now, +though, just in case. TWR. +""" + +class counter(gr.feval_dd): + def __init__(self, step_size=1): + gr.feval_dd.__init__(self) + self.step_size = step_size + self.count = 0 + + def eval(self, input): + #print "eval: self.count =", self.count + t = self.count + self.count = self.count + self.step_size + return t + + +class counter3(gr.feval_dd): + def __init__(self, f, step_size): + gr.feval_dd.__init__(self) + self.f = f + self.step_size = step_size + self.count = 0 + + def eval(self, input): + try: + #print "eval: self.count =", self.count + t = self.count + self.count = self.count + self.step_size + self.f(self.count) + except Exception, e: + print "Exception: ", e + return t + +def foobar3(new_t): + #print "foobar3: new_t =", new_t + pass + + +class counter4(gr.feval_dd): + def __init__(self, obj_instance, step_size): + gr.feval_dd.__init__(self) + self.obj_instance = obj_instance + self.step_size = step_size + self.count = 0 + + def eval(self, input): + try: + #print "eval: self.count =", self.count + t = self.count + self.count = self.count + self.step_size + self.obj_instance.foobar4(self.count) + except Exception, e: + print "Exception: ", e + return t + + +class parse_msg(object): + def __init__(self, msg): + self.center_freq = msg.arg1() + self.vlen = int(msg.arg2()) + assert(msg.length() == self.vlen * gr.sizeof_float) + self.data = struct.unpack('%df' % (self.vlen,), msg.to_string()) + +class test_bin_statistics(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block () + + def tearDown(self): + self.tb = None + + def xtest_001(self): + vlen = 4 + tune = counter(1) + tune_delay = 0 + dwell_delay = 1 + msgq = gr.msg_queue() + + src_data = tuple([float(x) for x in + ( 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16 + )]) + + expected_results = tuple([float(x) for x in + ( 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16 + )]) + + src = gr.vector_source_f(src_data, False) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) + stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) + self.tb.connect(src, s2v, stats) + self.tb.run() + self.assertEqual(4, msgq.count()) + for i in range(4): + m = parse_msg(msgq.delete_head()) + #print "m =", m.center_freq, m.data + self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data) + + def xtest_002(self): + vlen = 4 + tune = counter(1) + tune_delay = 1 + dwell_delay = 2 + msgq = gr.msg_queue() + + src_data = tuple([float(x) for x in + ( 1, 2, 3, 4, + 9, 6, 11, 8, + 5, 10, 7, 12, + 13, 14, 15, 16 + )]) + + expected_results = tuple([float(x) for x in + ( 9, 10, 11, 12)]) + + src = gr.vector_source_f(src_data, False) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) + stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) + self.tb.connect(src, s2v, stats) + self.tb.run() + self.assertEqual(1, msgq.count()) + for i in range(1): + m = parse_msg(msgq.delete_head()) + #print "m =", m.center_freq, m.data + self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data) + + + + def xtest_003(self): + vlen = 4 + tune = counter3(foobar3, 1) + tune_delay = 1 + dwell_delay = 2 + msgq = gr.msg_queue() + + src_data = tuple([float(x) for x in + ( 1, 2, 3, 4, + 9, 6, 11, 8, + 5, 10, 7, 12, + 13, 14, 15, 16 + )]) + + expected_results = tuple([float(x) for x in + ( 9, 10, 11, 12)]) + + src = gr.vector_source_f(src_data, False) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) + stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) + self.tb.connect(src, s2v, stats) + self.tb.run() + self.assertEqual(1, msgq.count()) + for i in range(1): + m = parse_msg(msgq.delete_head()) + #print "m =", m.center_freq, m.data + self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data) + + def foobar4(self, new_t): + #print "foobar4: new_t =", new_t + pass + + def xtest_004(self): + vlen = 4 + tune = counter4(self, 1) + tune_delay = 1 + dwell_delay = 2 + msgq = gr.msg_queue() + + src_data = tuple([float(x) for x in + ( 1, 2, 3, 4, + 9, 6, 11, 8, + 5, 10, 7, 12, + 13, 14, 15, 16 + )]) + + expected_results = tuple([float(x) for x in + ( 9, 10, 11, 12)]) + + src = gr.vector_source_f(src_data, False) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) + stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) + self.tb.connect(src, s2v, stats) + self.tb.run() + self.assertEqual(1, msgq.count()) + for i in range(1): + m = parse_msg(msgq.delete_head()) + #print "m =", m.center_freq, m.data + self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data) + + +if __name__ == '__main__': + gr_unittest.run(test_bin_statistics, "test_bin_statistics.xml") diff --git a/gr-blocks/python/qa_burst_tagger.py b/gr-blocks/python/qa_burst_tagger.py new file mode 100644 index 0000000000..5e249cb8b9 --- /dev/null +++ b/gr-blocks/python/qa_burst_tagger.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# Copyright 2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import pmt + +class test_burst_tagger(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + # 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) + trg = gr.vector_source_s(trg_data) + op = blocks.burst_tagger(gr.sizeof_int) + snk = blocks.tag_debug(gr.sizeof_int, "burst tagger QA") + self.tb.connect(src, (op,0)) + self.tb.connect(trg, (op,1)) + self.tb.connect(op, snk) + self.tb.run() + + x = snk.current_tags() + self.assertEqual(2, x[0].offset) + self.assertEqual(4, x[1].offset) + self.assertEqual(6, x[2].offset) + self.assertEqual(8, x[3].offset) + + self.assertEqual(True, pmt.pmt_to_bool(x[0].value)) + self.assertEqual(False, pmt.pmt_to_bool(x[1].value)) + self.assertEqual(True, pmt.pmt_to_bool(x[2].value)) + self.assertEqual(False, pmt.pmt_to_bool(x[3].value)) + +if __name__ == '__main__': + gr_unittest.run(test_burst_tagger, "test_burst_tagger.xml") diff --git a/gr-blocks/python/qa_max.py b/gr-blocks/python/qa_max.py new file mode 100755 index 0000000000..4af70bd4be --- /dev/null +++ b/gr-blocks/python/qa_max.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +# +# Copyright 2007,2010,2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import math + +class test_max(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = (0,0.2,-0.3,0,12,0) + expected_result = (float(max(src_data)),) + + src = gr.vector_source_f(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) + op = blocks.max_ff(len(src_data)) + dst = gr.vector_sink_f() + + self.tb.connect(src, s2v, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def test_002(self): + src_data=(-100,-99,-98,-97,-96,-1) + expected_result = (float(max(src_data)),) + + src = gr.vector_source_f(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) + op = blocks.max_ff(len(src_data)) + dst = gr.vector_sink_f() + + self.tb.connect(src, s2v, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + +if __name__ == '__main__': + gr_unittest.run(test_max, "test_max.xml") + diff --git a/gr-blocks/python/qa_message.py b/gr-blocks/python/qa_message.py new file mode 100755 index 0000000000..551fdd6259 --- /dev/null +++ b/gr-blocks/python/qa_message.py @@ -0,0 +1,149 @@ +#!/usr/bin/env python +# +# Copyright 2004,2010,2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import pmt +import time + +def all_counts(): + return (gr.block_ncurrently_allocated(), + gr.block_detail_ncurrently_allocated(), + gr.buffer_ncurrently_allocated(), + gr.buffer_reader_ncurrently_allocated(), + gr.message_ncurrently_allocated()) + + +class test_message(gr_unittest.TestCase): + + def setUp(self): + self.msgq = gr.msg_queue() + + def tearDown(self): + self.msgq = None + + def leak_check(self, fct): + begin = all_counts() + fct() + # tear down early so we can check for leaks + self.tearDown() + end = all_counts() + self.assertEqual(begin, end) + + def test_100(self): + msg = gr.message(0, 1.5, 2.3) + self.assertEquals(0, msg.type()) + self.assertAlmostEqual(1.5, msg.arg1()) + self.assertAlmostEqual(2.3, msg.arg2()) + self.assertEquals(0, msg.length()) + + def test_101(self): + s = 'This is a test' + msg = gr.message_from_string(s) + self.assertEquals(s, msg.to_string()) + + def test_200(self): + self.leak_check(self.body_200) + + def body_200(self): + self.msgq.insert_tail(gr.message(0)) + self.assertEquals(1, self.msgq.count()) + self.msgq.insert_tail(gr.message(1)) + self.assertEquals(2, self.msgq.count()) + msg0 = self.msgq.delete_head() + self.assertEquals(0, msg0.type()) + msg1 = self.msgq.delete_head() + self.assertEquals(1, msg1.type()) + self.assertEquals(0, self.msgq.count()) + + def test_201(self): + self.leak_check(self.body_201) + + def body_201(self): + self.msgq.insert_tail(gr.message(0)) + self.assertEquals(1, self.msgq.count()) + self.msgq.insert_tail(gr.message(1)) + self.assertEquals(2, self.msgq.count()) + + def test_202(self): + self.leak_check(self.body_202) + + def body_202(self): + # global msg + msg = gr.message(666) + + def test_300(self): + input_data = (0,1,2,3,4,5,6,7,8,9) + src = gr.vector_source_b(input_data) + dst = gr.vector_sink_b() + tb = gr.top_block() + tb.connect(src, dst) + tb.run() + self.assertEquals(input_data, dst.data()) + + def test_301(self): + # Use itemsize, limit constructor + src = blocks.message_source(gr.sizeof_char) + dst = gr.vector_sink_b() + tb = gr.top_block() + tb.connect(src, dst) + src.msgq().insert_tail(gr.message_from_string('01234')) + src.msgq().insert_tail(gr.message_from_string('5')) + src.msgq().insert_tail(gr.message_from_string('')) + src.msgq().insert_tail(gr.message_from_string('6789')) + src.msgq().insert_tail(gr.message(1)) # send EOF + tb.run() + self.assertEquals(tuple(map(ord, '0123456789')), dst.data()) + + def test_302(self): + # Use itemsize, msgq constructor + msgq = gr.msg_queue() + src = blocks.message_source(gr.sizeof_char, msgq) + dst = gr.vector_sink_b() + tb = gr.top_block() + tb.connect(src, dst) + src.msgq().insert_tail(gr.message_from_string('01234')) + src.msgq().insert_tail(gr.message_from_string('5')) + src.msgq().insert_tail(gr.message_from_string('')) + src.msgq().insert_tail(gr.message_from_string('6789')) + src.msgq().insert_tail(gr.message(1)) # send EOF + tb.run() + self.assertEquals(tuple(map(ord, '0123456789')), dst.data()) + + def test_debug_401(self): + msg = pmt.pmt_intern("TESTING") + src = blocks.message_strobe(msg, 500) + snk = blocks.message_debug() + + tb = gr.top_block() + tb.msg_connect(src, "strobe", snk, "store") + tb.start() + time.sleep(1) + tb.stop() + tb.wait() + + rec_msg = snk.get_message(0) + self.assertTrue(pmt.pmt_eqv(rec_msg, msg)) + + +if __name__ == '__main__': + gr_unittest.run(test_message, "test_message.xml") diff --git a/gr-blocks/python/qa_moving_average.py b/gr-blocks/python/qa_moving_average.py new file mode 100644 index 0000000000..169b4746c2 --- /dev/null +++ b/gr-blocks/python/qa_moving_average.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python +# +# Copyright 2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import math, random + +def make_random_complex_tuple(L, scale=1): + result = [] + for x in range(L): + result.append(scale*complex(2*random.random()-1, + 2*random.random()-1)) + return tuple(result) + +def make_random_float_tuple(L, scale=1): + result = [] + for x in range(L): + result.append(scale*(2*random.random()-1)) + return tuple(result) + +class test_moving_average(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_01(self): + tb = self.tb + + N = 10000 + seed = 0 + data = make_random_float_tuple(N, 1) + expected_result = N*[0,] + + src = gr.vector_source_f(data, False) + op = blocks.moving_average_ff(100, 0.001) + dst = gr.vector_sink_f() + + tb.connect(src, op) + tb.connect(op, dst) + tb.run() + + dst_data = dst.data() + + # make sure result is close to zero + self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 1) + + def test_02(self): + tb = self.tb + + N = 10000 + seed = 0 + data = make_random_complex_tuple(N, 1) + expected_result = N*[0,] + + src = gr.vector_source_c(data, False) + op = blocks.moving_average_cc(100, 0.001) + dst = gr.vector_sink_c() + + tb.connect(src, op) + tb.connect(op, dst) + tb.run() + + dst_data = dst.data() + + # make sure result is close to zero + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1) + +if __name__ == '__main__': + gr_unittest.run(test_moving_average, "test_moving_average.xml") diff --git a/gr-blocks/python/qa_mute.py b/gr-blocks/python/qa_mute.py new file mode 100755 index 0000000000..96c57b2ed1 --- /dev/null +++ b/gr-blocks/python/qa_mute.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python +# +# Copyright 2004,2005,2007,2010,2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_mute(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def help_ii(self, src_data, exp_data, op): + for s in zip(range(len(src_data)), src_data): + src = gr.vector_source_i(s[1]) + self.tb.connect(src, (op, s[0])) + dst = gr.vector_sink_i() + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(exp_data, result_data) + + def help_ff(self, src_data, exp_data, op): + for s in zip(range(len(src_data)), src_data): + src = gr.vector_source_f(s[1]) + self.tb.connect(src, (op, s[0])) + dst = gr.vector_sink_f() + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(exp_data, result_data) + + def help_cc(self, src_data, exp_data, op): + for s in zip(range(len(src_data)), src_data): + src = gr.vector_source_c(s[1]) + self.tb.connect(src, (op, s[0])) + dst = gr.vector_sink_c() + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(exp_data, result_data) + + def test_unmute_ii(self): + src_data = (1, 2, 3, 4, 5) + expected_result = (1, 2, 3, 4, 5) + op = blocks.mute_ii(False) + self.help_ii((src_data,), expected_result, op) + + def test_mute_ii(self): + src_data = (1, 2, 3, 4, 5) + expected_result = (0, 0, 0, 0, 0) + op = blocks.mute_ii(True) + self.help_ii((src_data,), expected_result, op) + + def test_unmute_cc(self): + src_data = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j) + expected_result = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j) + op = blocks.mute_cc(False) + self.help_cc((src_data,), expected_result, op) + + def test_unmute_cc(self): + src_data = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j) + expected_result =(0+0j, 0+0j, 0+0j, 0+0j, 0+0j) + op = blocks.mute_cc(True) + self.help_cc((src_data,), expected_result, op) + +if __name__ == '__main__': + gr_unittest.run(test_mute, "test_mute.xml") diff --git a/gr-blocks/python/qa_pack_k_bits.py b/gr-blocks/python/qa_pack_k_bits.py new file mode 100755 index 0000000000..cd55d2f200 --- /dev/null +++ b/gr-blocks/python/qa_pack_k_bits.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# +# Copyright 2006,2010,2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import random + +class test_pack(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = (1,0,1,1,0,1,1,0) + expected_results = (1,0,1,1,0,1,1,0) + src = gr.vector_source_b(src_data,False) + op = blocks.pack_k_bits_bb(1) + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + self.assertEqual(expected_results, dst.data()) + + def test_002(self): + src_data = (1,0,1,1,0,0,0,1) + expected_results = ( 2, 3, 0, 1) + src = gr.vector_source_b(src_data,False) + op = blocks.pack_k_bits_bb(2) + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + #self.assertEqual(expected_results, dst.data()) + self.assertEqual(expected_results, dst.data()) + + def test_003(self): + src_data = expected_results = map(lambda x: random.randint(0,3), range(10)); + src = gr.vector_source_b( src_data ); + pack = blocks.pack_k_bits_bb(2); + unpack = blocks.unpack_k_bits_bb(2); + snk = gr.vector_sink_b(); + self.tb.connect(src,unpack,pack,snk); + self.tb.run() + self.assertEqual(list(expected_results), list(snk.data())); + +if __name__ == '__main__': + gr_unittest.run(test_pack, "test_pack.xml") + diff --git a/gr-blocks/python/qa_pdu.py b/gr-blocks/python/qa_pdu.py new file mode 100755 index 0000000000..dc50b7c330 --- /dev/null +++ b/gr-blocks/python/qa_pdu.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python +# +# Copyright 2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import pmt +import time + +class test_pdu(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_000(self): + # Just run some data through and make sure it doesn't puke. + src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + + src = blocks.pdu_to_tagged_stream(blocks.byte_t) + snk3 = blocks.tagged_stream_to_pdu(blocks.byte_t) + snk2 = gr.vector_sink_b() + snk = gr.tag_debug(1, "test") + snk.set_display(False) + + dbg = gr.message_debug() + + # Test that the right number of ports exist. + pi = snk3.message_ports_in() + po = snk3.message_ports_out() + self.assertEqual(pmt.pmt_length(pi), 0) + self.assertEqual(pmt.pmt_length(po), 1) + + time.sleep(0.1) + self.tb.connect(src, snk) + self.tb.connect(src, snk2) + self.tb.connect(src, snk3) + self.tb.msg_connect(snk3, "pdus", dbg, "store") + self.tb.start() + + # make our reference and message pmts + port = pmt.pmt_intern("pdus") + msg = pmt.pmt_cons( pmt.PMT_NIL, pmt.pmt_make_u8vector(16, 0xFF)) + + # post the message + src.to_basic_block()._post(port, msg) # eww, what's that smell? + + while dbg.num_messages() < 1: + time.sleep(0.5) + self.tb.stop() + self.tb.wait() + + # Get the vector of data from the vector sink + result_data = snk2.data() + + # Get the vector of data from the message sink + # Convert the message PMT as a pair into its vector + result_msg = dbg.get_message(0) + msg_vec = pmt.pmt_cdr(result_msg) + #pmt.pmt_print(msg_vec) + + # Convert the PMT vector into a Python list + msg_data = [] + for i in xrange(16): + msg_data.append(pmt.pmt_u8vector_ref(msg_vec, i)) + + actual_data = 16*[0xFF,] + self.assertEqual(actual_data, list(result_data)) + self.assertEqual(actual_data, msg_data) + +if __name__ == '__main__': + gr_unittest.run(test_pdu, "test_pdu.xml") diff --git a/gr-blocks/python/qa_peak_detector.py b/gr-blocks/python/qa_peak_detector.py new file mode 100644 index 0000000000..c3ff2548c4 --- /dev/null +++ b/gr-blocks/python/qa_peak_detector.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# +# Copyright 2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_peak_detector(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_01(self): + tb = self.tb + + data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] + + expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + + src = gr.vector_source_f(data, False) + regen = blocks.peak_detector_fb() + dst = gr.vector_sink_b() + + tb.connect(src, regen) + tb.connect(regen, dst) + tb.run() + + dst_data = dst.data() + + self.assertEqual(expected_result, dst_data) + + def test_02(self): + tb = self.tb + + data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] + + expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + + src = gr.vector_source_i(data, False) + regen = blocks.peak_detector_ib() + dst = gr.vector_sink_b() + + tb.connect(src, regen) + tb.connect(regen, dst) + tb.run() + + dst_data = dst.data() + + self.assertEqual(expected_result, dst_data) + + def test_03(self): + tb = self.tb + + data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] + + expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + + src = gr.vector_source_s(data, False) + regen = blocks.peak_detector_sb() + dst = gr.vector_sink_b() + + tb.connect(src, regen) + tb.connect(regen, dst) + tb.run() + + dst_data = dst.data() + + self.assertEqual(expected_result, dst_data) + +if __name__ == '__main__': + gr_unittest.run(test_peak_detector, "test_peak_detector.xml") diff --git a/gr-blocks/python/qa_peak_detector2.py b/gr-blocks/python/qa_peak_detector2.py index 4b864e4d70..b2d8e318dd 100644 --- a/gr-blocks/python/qa_peak_detector2.py +++ b/gr-blocks/python/qa_peak_detector2.py @@ -50,7 +50,6 @@ class test_peak_detector2(gr_unittest.TestCase): tb.run() dst_data = dst.data() - print dst_data self.assertEqual(expected_result, dst_data) diff --git a/gr-blocks/python/qa_probe_signal.py b/gr-blocks/python/qa_probe_signal.py new file mode 100644 index 0000000000..a420df71e5 --- /dev/null +++ b/gr-blocks/python/qa_probe_signal.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +# +# Copyright 2012-2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +import time +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_probe_signal(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + value = 12.3 + repeats = 100 + src_data = [value] * repeats + + src = gr.vector_source_f(src_data) + dst = blocks.probe_signal_f() + + self.tb.connect(src, dst) + self.tb.run() + output = dst.level() + self.assertAlmostEqual(value, output, places=6) + + def test_002(self): + vector_length = 10 + repeats = 10 + value = [0.5+i for i in range(0, vector_length)] + src_data = value * repeats + + src = gr.vector_source_f(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_float, vector_length) + dst = blocks.probe_signal_vf(vector_length) + + self.tb.connect(src, s2v, dst) + self.tb.run() + output = dst.level() + self.assertEqual(len(output), vector_length) + self.assertAlmostEqual(value[3], output[3], places=6) + +if __name__ == '__main__': + gr_unittest.run(test_probe_signal, "test_probe_signal.xml") diff --git a/gr-blocks/python/qa_sample_and_hold.py b/gr-blocks/python/qa_sample_and_hold.py new file mode 100644 index 0000000000..59628090d1 --- /dev/null +++ b/gr-blocks/python/qa_sample_and_hold.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# Copyright 2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +import time +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_sample_and_hold(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = 10*[0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1] + ctrl_data = 10*[1,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0] + expected_result = 10*(0,0,0,0,4,5,6,7,8,9,9,9,9,9,9,9,9,9) + + src = gr.vector_source_f(src_data) + ctrl = gr.vector_source_b(ctrl_data) + op = blocks.sample_and_hold_ff() + dst = gr.vector_sink_f() + + self.tb.connect(src, (op,0)) + self.tb.connect(ctrl, (op,1)) + self.tb.connect(op, dst) + self.tb.run() + + result = dst.data() + self.assertFloatTuplesAlmostEqual(expected_result, result, places=6) + +if __name__ == '__main__': + gr_unittest.run(test_sample_and_hold, "test_sample_and_hold.xml") diff --git a/gr-blocks/python/qa_tag_debug.py b/gr-blocks/python/qa_tag_debug.py new file mode 100755 index 0000000000..ad85daebcc --- /dev/null +++ b/gr-blocks/python/qa_tag_debug.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# +# Copyright 2012-2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_tag_debug(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + # Just run some data through and make sure it doesn't puke. + src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + src = gr.vector_source_i(src_data) + op = blocks.tag_debug(gr.sizeof_int, "tag QA") + self.tb.connect(src, op) + self.tb.run() + x = op.current_tags() + +if __name__ == '__main__': + gr_unittest.run(test_tag_debug, "test_tag_debug.xml") diff --git a/gr-blocks/python/qa_unpack_k_bits.py b/gr-blocks/python/qa_unpack_k_bits.py new file mode 100755 index 0000000000..e038d5a03a --- /dev/null +++ b/gr-blocks/python/qa_unpack_k_bits.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# +# Copyright 2006,2010,2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import random + +class test_unpack(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block () + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = (1,0,1,1,0,1,1,0) + expected_results = (1,0,1,1,0,1,1,0) + src = gr.vector_source_b(src_data,False) + op = blocks.unpack_k_bits_bb(1) + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + self.assertEqual(expected_results, dst.data()) + + def test_002(self): + src_data = ( 2, 3, 0, 1) + expected_results = (1,0,1,1,0,0,0,1) + src = gr.vector_source_b(src_data,False) + op = blocks.unpack_k_bits_bb(2) + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + self.assertEqual(expected_results, dst.data()) + +if __name__ == '__main__': + gr_unittest.run(test_unpack, "test_unpack.xml") + diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i index db8af34368..1c0f49dfeb 100644 --- a/gr-blocks/swig/blocks_swig.i +++ b/gr-blocks/swig/blocks_swig.i @@ -23,6 +23,7 @@ #define BLOCKS_API %include "gnuradio.i" +%include "blocks/pdu.h" //load generated python docstrings %include "blocks_swig_doc.i" @@ -48,6 +49,11 @@ #include "blocks/and_const_bb.h" #include "blocks/and_const_ss.h" #include "blocks/and_const_ii.h" +#include "blocks/argmax_fs.h" +#include "blocks/argmax_is.h" +#include "blocks/argmax_ss.h" +#include "blocks/bin_statistics_f.h" +#include "blocks/burst_tagger.h" #include "blocks/char_to_float.h" #include "blocks/char_to_short.h" #include "blocks/complex_to_interleaved_short.h" @@ -81,6 +87,18 @@ #include "blocks/interleaved_short_to_complex.h" #include "blocks/keep_m_in_n.h" #include "blocks/keep_one_in_n.h" +#include "blocks/max_ff.h" +#include "blocks/max_ii.h" +#include "blocks/max_ss.h" +#include "blocks/message_debug.h" +#include "blocks/message_sink.h" +#include "blocks/message_source.h" +#include "blocks/message_strobe.h" +#include "blocks/message_burst_source.h" +#include "blocks/moving_average_cc.h" +#include "blocks/moving_average_ff.h" +#include "blocks/moving_average_ii.h" +#include "blocks/moving_average_ss.h" #include "blocks/multiply_ss.h" #include "blocks/multiply_ii.h" #include "blocks/multiply_ff.h" @@ -94,15 +112,34 @@ #include "blocks/multiply_const_vii.h" #include "blocks/multiply_const_vff.h" #include "blocks/multiply_const_vcc.h" +#include "blocks/mute_ss.h" +#include "blocks/mute_ii.h" +#include "blocks/mute_ff.h" +#include "blocks/mute_cc.h" #include "blocks/nlog10_ff.h" #include "blocks/not_bb.h" #include "blocks/not_ss.h" #include "blocks/not_ii.h" #include "blocks/patterned_interleaver.h" +#include "blocks/pack_k_bits_bb.h" #include "blocks/packed_to_unpacked_bb.h" #include "blocks/packed_to_unpacked_ss.h" #include "blocks/packed_to_unpacked_ii.h" +#include "blocks/pdu_to_tagged_stream.h" +#include "blocks/peak_detector_fb.h" +#include "blocks/peak_detector_ib.h" +#include "blocks/peak_detector_sb.h" #include "blocks/peak_detector2_fb.h" +#include "blocks/probe_signal_b.h" +#include "blocks/probe_signal_s.h" +#include "blocks/probe_signal_i.h" +#include "blocks/probe_signal_f.h" +#include "blocks/probe_signal_c.h" +#include "blocks/probe_signal_vb.h" +#include "blocks/probe_signal_vs.h" +#include "blocks/probe_signal_vi.h" +#include "blocks/probe_signal_vf.h" +#include "blocks/probe_signal_vc.h" #include "blocks/or_bb.h" #include "blocks/or_ss.h" #include "blocks/or_ii.h" @@ -110,8 +147,13 @@ #include "blocks/repeat.h" #include "blocks/rms_cf.h" #include "blocks/rms_ff.h" +#include "blocks/sample_and_hold_bb.h" +#include "blocks/sample_and_hold_ss.h" +#include "blocks/sample_and_hold_ii.h" +#include "blocks/sample_and_hold_ff.h" #include "blocks/short_to_char.h" #include "blocks/short_to_float.h" +#include "blocks/socket_pdu.h" #include "blocks/stream_mux.h" #include "blocks/stream_to_streams.h" #include "blocks/stream_to_vector.h" @@ -122,10 +164,14 @@ #include "blocks/sub_ss.h" #include "blocks/sub_ii.h" #include "blocks/sub_cc.h" +#include "blocks/tag_debug.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/unpack_k_bits_bb.h" #include "blocks/unpacked_to_packed_bb.h" #include "blocks/unpacked_to_packed_ss.h" #include "blocks/unpacked_to_packed_ii.h" @@ -154,7 +200,12 @@ %include "blocks/and_const_bb.h" %include "blocks/and_const_ss.h" %include "blocks/and_const_ii.h" +%include "blocks/argmax_fs.h" +%include "blocks/argmax_is.h" +%include "blocks/argmax_ss.h" %include "blocks/char_to_float.h" +%include "blocks/bin_statistics_f.h" +%include "blocks/burst_tagger.h" %include "blocks/char_to_short.h" %include "blocks/complex_to_interleaved_short.h" %include "blocks/complex_to_float.h" @@ -187,6 +238,18 @@ %include "blocks/interleaved_short_to_complex.h" %include "blocks/keep_m_in_n.h" %include "blocks/keep_one_in_n.h" +%include "blocks/max_ff.h" +%include "blocks/max_ii.h" +%include "blocks/max_ss.h" +%include "blocks/message_debug.h" +%include "blocks/message_sink.h" +%include "blocks/message_source.h" +%include "blocks/message_strobe.h" +%include "blocks/message_burst_source.h" +%include "blocks/moving_average_cc.h" +%include "blocks/moving_average_ff.h" +%include "blocks/moving_average_ii.h" +%include "blocks/moving_average_ss.h" %include "blocks/multiply_ss.h" %include "blocks/multiply_ii.h" %include "blocks/multiply_ff.h" @@ -200,24 +263,49 @@ %include "blocks/multiply_const_vii.h" %include "blocks/multiply_const_vff.h" %include "blocks/multiply_const_vcc.h" +%include "blocks/mute_ss.h" +%include "blocks/mute_ii.h" +%include "blocks/mute_ff.h" +%include "blocks/mute_cc.h" %include "blocks/nlog10_ff.h" %include "blocks/not_bb.h" %include "blocks/not_ss.h" %include "blocks/not_ii.h" -%include "blocks/patterned_interleaver.h" +%include "blocks/probe_signal_b.h" +%include "blocks/probe_signal_s.h" +%include "blocks/probe_signal_i.h" +%include "blocks/probe_signal_f.h" +%include "blocks/probe_signal_c.h" +%include "blocks/probe_signal_vb.h" +%include "blocks/probe_signal_vs.h" +%include "blocks/probe_signal_vi.h" +%include "blocks/probe_signal_vf.h" +%include "blocks/probe_signal_vc.h" +%include "blocks/or_bb.h" +%include "blocks/or_ss.h" +%include "blocks/or_ii.h" +%include "blocks/pack_k_bits_bb.h" %include "blocks/packed_to_unpacked_bb.h" %include "blocks/packed_to_unpacked_ss.h" %include "blocks/packed_to_unpacked_ii.h" +%include "blocks/patterned_interleaver.h" +%include "blocks/tag_debug.h" +%include "blocks/pdu_to_tagged_stream.h" +%include "blocks/peak_detector_fb.h" +%include "blocks/peak_detector_ib.h" +%include "blocks/peak_detector_sb.h" %include "blocks/peak_detector2_fb.h" -%include "blocks/or_bb.h" -%include "blocks/or_ss.h" -%include "blocks/or_ii.h" %include "blocks/regenerate_bb.h" %include "blocks/repeat.h" %include "blocks/rms_cf.h" %include "blocks/rms_ff.h" +%include "blocks/sample_and_hold_bb.h" +%include "blocks/sample_and_hold_ss.h" +%include "blocks/sample_and_hold_ii.h" +%include "blocks/sample_and_hold_ff.h" %include "blocks/short_to_char.h" %include "blocks/short_to_float.h" +%include "blocks/socket_pdu.h" %include "blocks/stream_mux.h" %include "blocks/stream_to_streams.h" %include "blocks/stream_to_vector.h" @@ -228,10 +316,13 @@ %include "blocks/sub_ss.h" %include "blocks/sub_ii.h" %include "blocks/sub_cc.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/unpack_k_bits_bb.h" %include "blocks/unpacked_to_packed_bb.h" %include "blocks/unpacked_to_packed_ss.h" %include "blocks/unpacked_to_packed_ii.h" @@ -259,6 +350,11 @@ GR_SWIG_BLOCK_MAGIC2(blocks, and_ii); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_bb); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_ss); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, argmax_fs); +GR_SWIG_BLOCK_MAGIC2(blocks, argmax_is); +GR_SWIG_BLOCK_MAGIC2(blocks, argmax_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, bin_statistics_f); +GR_SWIG_BLOCK_MAGIC2(blocks, burst_tagger); GR_SWIG_BLOCK_MAGIC2(blocks, char_to_float); GR_SWIG_BLOCK_MAGIC2(blocks, char_to_short); GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_interleaved_short); @@ -292,6 +388,18 @@ GR_SWIG_BLOCK_MAGIC2(blocks, interleave); GR_SWIG_BLOCK_MAGIC2(blocks, interleaved_short_to_complex); GR_SWIG_BLOCK_MAGIC2(blocks, keep_m_in_n); GR_SWIG_BLOCK_MAGIC2(blocks, keep_one_in_n); +GR_SWIG_BLOCK_MAGIC2(blocks, max_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, max_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, max_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, message_debug); +GR_SWIG_BLOCK_MAGIC2(blocks, message_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, message_source); +GR_SWIG_BLOCK_MAGIC2(blocks, message_strobe); +GR_SWIG_BLOCK_MAGIC2(blocks, message_burst_source); +GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_cc); +GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ss); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ss); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ii); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ff); @@ -305,24 +413,48 @@ GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vss); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vii); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vff); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vcc); +GR_SWIG_BLOCK_MAGIC2(blocks, mute_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, mute_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, mute_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, mute_cc); GR_SWIG_BLOCK_MAGIC2(blocks, nlog10_ff); GR_SWIG_BLOCK_MAGIC2(blocks, not_bb); GR_SWIG_BLOCK_MAGIC2(blocks, not_ss); GR_SWIG_BLOCK_MAGIC2(blocks, not_ii); GR_SWIG_BLOCK_MAGIC2(blocks, patterned_interleaver); +GR_SWIG_BLOCK_MAGIC2(blocks, pack_k_bits_bb); GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_bb); GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_ss); GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector_fb); +GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector_ib); +GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector_sb); GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector2_fb); +GR_SWIG_BLOCK_MAGIC2(blocks, pdu_to_tagged_stream); GR_SWIG_BLOCK_MAGIC2(blocks, or_bb); GR_SWIG_BLOCK_MAGIC2(blocks, or_ss); GR_SWIG_BLOCK_MAGIC2(blocks, or_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_b); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_s); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_i); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_f); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_c); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vb); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vs); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vi); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vf); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vc); GR_SWIG_BLOCK_MAGIC2(blocks, regenerate_bb); GR_SWIG_BLOCK_MAGIC2(blocks, repeat); GR_SWIG_BLOCK_MAGIC2(blocks, rms_cf); GR_SWIG_BLOCK_MAGIC2(blocks, rms_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_bb); +GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_ff); GR_SWIG_BLOCK_MAGIC2(blocks, short_to_char); GR_SWIG_BLOCK_MAGIC2(blocks, short_to_float); +GR_SWIG_BLOCK_MAGIC2(blocks, socket_pdu); GR_SWIG_BLOCK_MAGIC2(blocks, stream_mux); GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_streams); GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_vector); @@ -333,10 +465,14 @@ GR_SWIG_BLOCK_MAGIC2(blocks, sub_ff); GR_SWIG_BLOCK_MAGIC2(blocks, sub_ss); GR_SWIG_BLOCK_MAGIC2(blocks, sub_ii); GR_SWIG_BLOCK_MAGIC2(blocks, sub_cc); +GR_SWIG_BLOCK_MAGIC2(blocks, tag_debug); +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, unpack_k_bits_bb); GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_bb); GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_ss); GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_ii); diff --git a/gr-comedi/src/CMakeLists.txt b/gr-comedi/src/CMakeLists.txt index 1d9dac2c48..116f561394 100644 --- a/gr-comedi/src/CMakeLists.txt +++ b/gr-comedi/src/CMakeLists.txt @@ -33,6 +33,9 @@ link_directories( ${COMEDI_LIBRARY_DIRS} ) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -46,6 +49,7 @@ list(APPEND comedi_libs gnuradio-core ${Boost_LIBRARIES} ${COMEDI_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) add_library(gnuradio-comedi SHARED ${gr_comedi_sources}) diff --git a/gr-digital/include/digital_constellation.h b/gr-digital/include/digital_constellation.h index 76cd30b25f..b9c27bbc44 100644 --- a/gr-digital/include/digital_constellation.h +++ b/gr-digital/include/digital_constellation.h @@ -276,6 +276,80 @@ class DIGITAL_API digital_constellation_rect : public digital_constellation_sect }; +/************************************************************/ +/* digital_constellation_expl_rect */ +/************************************************************/ + +/*! + * \brief Rectangular digital constellation + * \ingroup digital + * + * Only implemented for 1-(complex)dimensional constellation. + * + * Constellation space is divided into rectangular sectors. Each + * sector is associated with the nearest constellation point. + * + * This class is different from constellation_rect in that the mapping + * from sector to constellation point is explicitly passed into the + * constructor as sector_values. Usually we do not need this, since + * we want each sector to be automatically mapped to the closest + * constellation point, however sometimes it's nice to have the + * flexibility. + */ + +class digital_constellation_expl_rect; +typedef boost::shared_ptr<digital_constellation_expl_rect> digital_constellation_expl_rect_sptr; + +// public constructor +DIGITAL_API digital_constellation_expl_rect_sptr +digital_make_constellation_expl_rect ( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values +); + +class DIGITAL_API digital_constellation_expl_rect : public digital_constellation_rect +{ + public: + + digital_constellation_expl_rect ( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values + ); + + protected: + unsigned int calc_sector_value (unsigned int sector) { + return d_sector_values[sector]; + } + + private: + std::vector<unsigned int> d_sector_values; + + friend DIGITAL_API digital_constellation_expl_rect_sptr + digital_make_constellation_expl_rect ( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values + ); + +}; + /************************************************************/ /* digital_constellation_psk */ diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index 7ac16602c7..c7f73f8505 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -26,10 +26,12 @@ include_directories( ${GR_ANALOG_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} + ${LOG4CXX_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories(${Boost_LIBRARY_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) ######################################################################## # generate helper scripts to expand templated files @@ -90,6 +92,7 @@ expand_cc(digital_chunks_to_symbols_XX bf bc sf sc if ic) ######################################################################## # Setup library ######################################################################## + list(APPEND gr_digital_sources ${generated_sources} digital_impl_glfsr.cc @@ -139,9 +142,24 @@ list(APPEND gr_digital_sources digital_simple_correlator.cc ) +#Add Windows DLL resource file if using MSVC +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-digital.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-digital.rc + @ONLY) + + list(APPEND gr_digital_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-digital.rc + ) +ENDIF(MSVC) + list(APPEND digital_libs gnuradio-core ${Boost_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) add_library(gnuradio-digital SHARED ${gr_digital_sources}) diff --git a/gr-digital/lib/digital_constellation.cc b/gr-digital/lib/digital_constellation.cc index da79f2caa4..0d4b88b047 100644 --- a/gr-digital/lib/digital_constellation.cc +++ b/gr-digital/lib/digital_constellation.cc @@ -345,6 +345,37 @@ digital_constellation_rect::calc_sector_value (unsigned int sector) return closest_point; } +digital_constellation_expl_rect_sptr +digital_make_constellation_expl_rect( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values +) +{ + return digital_constellation_expl_rect_sptr( + new digital_constellation_expl_rect( + constellation, pre_diff_code, rotational_symmetry, real_sectors, imag_sectors, + width_real_sectors, width_imag_sectors, sector_values)); +} + +digital_constellation_expl_rect::digital_constellation_expl_rect ( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values + ) : digital_constellation_rect( + constellation, pre_diff_code, rotational_symmetry, real_sectors, imag_sectors, + width_real_sectors, width_imag_sectors), + d_sector_values(sector_values) {}; digital_constellation_psk_sptr digital_make_constellation_psk(std::vector<gr_complex> constellation, diff --git a/gr-digital/lib/gnuradio-digital.rc.in b/gr-digital/lib/gnuradio-digital.rc.in new file mode 100644 index 0000000000..3b287f9d62 --- /dev/null +++ b/gr-digital/lib/gnuradio-digital.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-digital" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-digital.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-digital.dll" + VALUE "ProductName", "gnuradio-digital" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-digital/python/CMakeLists.txt b/gr-digital/python/CMakeLists.txt index 8f2af0664d..9be5e1ae75 100644 --- a/gr-digital/python/CMakeLists.txt +++ b/gr-digital/python/CMakeLists.txt @@ -43,6 +43,7 @@ GR_PYTHON_INSTALL( pkt.py psk.py qam.py + qamlike.py qpsk.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/digital COMPONENT "digital_python" diff --git a/gr-digital/python/qa_constellation.py b/gr-digital/python/qa_constellation.py index 6962ec6338..ddd8c71e64 100755 --- a/gr-digital/python/qa_constellation.py +++ b/gr-digital/python/qa_constellation.py @@ -30,6 +30,7 @@ import digital_swig # import from local folder import psk import qam +import qamlike tested_mod_codes = (mod_codes.NO_CODE, mod_codes.GRAY_CODE) @@ -64,14 +65,19 @@ def threed_constell(): dim = 3 return digital_swig.constellation_calcdist(points, [], rot_sym, dim) -tested_constellation_info = ( +# A list of tuples for constellation testing. The contents of the +# tuples are (constructor, poss_args, differential, diff_argname). + +# These constellations should lock on well. +easy_constellation_info = ( (psk.psk_constellation, - {'m': (2, 4, 8, 16, 32, 64), + {'m': (2, 4, 8, 16, ), 'mod_code': tested_mod_codes, }, True, None), (qam.qam_constellation, - {'constellation_points': (4, 16, 64), - 'mod_code': tested_mod_codes, }, + {'constellation_points': (4,), + 'mod_code': tested_mod_codes, + 'large_ampls_to_corners': [False],}, True, None), (digital_swig.constellation_bpsk, {}, True, None), (digital_swig.constellation_qpsk, {}, False, None), @@ -81,11 +87,44 @@ tested_constellation_info = ( (threed_constell, {}, True, None), ) -def tested_constellations(): +# These constellations don't work nicely. +# We have a lower required error rate. +medium_constellation_info = ( + (psk.psk_constellation, + {'m': (32, 64), + 'mod_code': tested_mod_codes, }, + True, None), + (qam.qam_constellation, + {'constellation_points': (16 ,), + 'mod_code': tested_mod_codes, + 'large_ampls_to_corners': [False, True],}, + True, None), + (qamlike.qam32_holeinside_constellation, + {'large_ampls_to_corners': [True]}, + True, None), +) + +# These constellation are basically broken in our test +difficult_constellation_info = ( + (qam.qam_constellation, + {'constellation_points': (64,), + 'mod_code': tested_mod_codes, + 'large_ampls_to_corners': [False, True],}, + True, None), +) + +def tested_constellations(easy=True, medium=True, difficult=True): """ Generator to produce (constellation, differential) tuples for testing purposes. """ - for constructor, poss_args, differential, diff_argname in tested_constellation_info: + constellation_info = [] + if easy: + constellation_info += easy_constellation_info + if medium: + constellation_info += medium_constellation_info + if difficult: + constellation_info += difficult_constellation_info + for constructor, poss_args, differential, diff_argname in constellation_info: if differential: diff_poss = (True, False) else: diff --git a/gr-digital/python/qa_constellation_receiver.py b/gr-digital/python/qa_constellation_receiver.py index 2d25433b92..37e56b4cf7 100755 --- a/gr-digital/python/qa_constellation_receiver.py +++ b/gr-digital/python/qa_constellation_receiver.py @@ -39,7 +39,9 @@ SEED = 1239 # We need this many to let the frequency recovery block converge. DATA_LENGTH = 2000 # Test fails if fraction of output that is correct is less than this. -REQ_CORRECT = 0.7 +EASY_REQ_CORRECT = 0.9 +# For constellations that aren't expected to work so well. +MEDIUM_REQ_CORRECT = 0.8 # CHANNEL PARAMETERS NOISE_VOLTAGE = 0.01 @@ -78,25 +80,33 @@ class test_constellation_receiver (gr_unittest.TestCase): self.indices = alignment.random_sample( self.max_data_length, self.max_num_samples, SEED) - for constellation, differential in tested_constellations(): - # The constellation_receiver doesn't work for constellations - # of multple dimensions (i.e. multiple complex numbers to a - # single symbol). - # That is not implemented since the receiver has no way of - # knowing where the beginning of a symbol is. - # It also doesn't work for non-differential modulation. - if constellation.dimensionality() != 1 or not differential: - continue - data_length = DATA_LENGTH * constellation.bits_per_symbol() - tb = rec_test_tb(constellation, differential, - src_data=self.src_data[:data_length]) - tb.run() - data = tb.dst.data() - d1 = tb.src_data[:int(len(tb.src_data)*self.ignore_fraction)] - d2 = data[:int(len(data)*self.ignore_fraction)] - correct, overlap, offset, indices = alignment.align_sequences( - d1, d2, indices=self.indices) - self.assertTrue(correct > REQ_CORRECT) + requirements = ( + (EASY_REQ_CORRECT, tested_constellations(easy=True, medium=False, difficult=False)), + (MEDIUM_REQ_CORRECT, tested_constellations(easy=False, medium=True, difficult=False)), + ) + for req_correct, tcs in requirements: + for constellation, differential in tcs: + # The constellation_receiver doesn't work for constellations + # of multple dimensions (i.e. multiple complex numbers to a + # single symbol). + # That is not implemented since the receiver has no way of + # knowing where the beginning of a symbol is. + # It also doesn't work for non-differential modulation. + if constellation.dimensionality() != 1 or not differential: + continue + data_length = DATA_LENGTH * constellation.bits_per_symbol() + tb = rec_test_tb(constellation, differential, + src_data=self.src_data[:data_length]) + tb.run() + data = tb.dst.data() + d1 = tb.src_data[:int(len(tb.src_data)*self.ignore_fraction)] + d2 = data[:int(len(data)*self.ignore_fraction)] + correct, overlap, offset, indices = alignment.align_sequences( + d1, d2, indices=self.indices) + if correct <= req_correct: + print("Constellation is {0}. Differential is {1}. Required correct is {2}. Correct is {3}. FAIL.". + format(constellation, differential, req_correct, correct)) + self.assertTrue(correct > req_correct) class rec_test_tb (gr.top_block): diff --git a/gr-digital/python/qam.py b/gr-digital/python/qam.py index 5b1f7683b8..6834e1945a 100644 --- a/gr-digital/python/qam.py +++ b/gr-digital/python/qam.py @@ -146,9 +146,17 @@ def make_non_differential_constellation(m, gray_coded): def qam_constellation(constellation_points=_def_constellation_points, differential=_def_differential, - mod_code=_def_mod_code): + mod_code=_def_mod_code, + large_ampls_to_corners=False): """ Creates a QAM constellation object. + + If large_ampls_to_corners=True then sectors that are probably + occupied due to a phase offset, are not mapped to the closest + constellation point. Rather we take into account the fact that a + phase offset is probably the problem and map them to the closest + corner point. It's a bit hackish but it seems to improve + frequency locking. """ if mod_code == mod_codes.GRAY_CODE: gray_coded = True @@ -165,10 +173,85 @@ def qam_constellation(constellation_points=_def_constellation_points, # No pre-diff code # Should add one so that we can gray-code the quadrant bits too. pre_diff_code = [] - constellation = digital_swig.constellation_rect(points, pre_diff_code, 4, - side, side, width, width) + if not large_ampls_to_corners: + constellation = digital_swig.constellation_rect(points, pre_diff_code, 4, + side, side, width, width) + else: + sector_values = large_ampls_to_corners_mapping(side, points, width) + constellation = digital_swig.constellation_expl_rect( + points, pre_diff_code, 4, side, side, width, width, sector_values) return constellation +def find_closest_point(p, qs): + """ + Return in index of the closest point in 'qs' to 'p'. + """ + min_dist = None + min_i = None + for i, q in enumerate(qs): + dist = abs(q-p) + if min_dist is None or dist < min_dist: + min_dist = dist + min_i = i + return min_i + +def large_ampls_to_corners_mapping(side, points, width): + """ + We have a grid that we use for decision making. One additional row/column + is placed on each side of the grid. Points in these additional rows/columns + are mapped to the corners rather than the closest constellation points. + + Args: + side: The number of rows/columns in the grid that we use to do + decision making. + points: The list of constellation points. + width: The width of the rows/columns. + + Returns: + sector_values maps the sector index to the constellation + point index. + """ + # First find the indices of the corner points. + # Assume the corner points are the 4 points with the largest magnitudes. + corner_indices = [] + corner_points = [] + max_mag = 0 + for i, p in enumerate(points): + if abs(p) > max_mag: + corner_indices = [i] + corner_points = [p] + max_mag = abs(p) + elif abs(p) == max_mag: + corner_indices.append(i) + corner_points.append(p) + if len(corner_indices) != 4: + raise ValueError("Found {0} corner indices. Expected 4." + .format(len(corner_indices))) + # We want an additional layer around the constellation + # Value in this extra layer will be mapped to the closest corner rather + # than the closest constellation point. + extra_layers = 1 + side = side + extra_layers*2 + # Calculate sector values + sector_values = [] + for real_x in range(side): + for imag_x in range(side): + sector = real_x * side + imag_x + # If this sector is a normal constellation sector then + # use the center point. + c = ((real_x-side/2.0+0.5)*width + + (imag_x-side/2.0+0.5)*width*1j) + if (real_x >= extra_layers and real_x < side-extra_layers + and imag_x >= extra_layers and imag_x < side-extra_layers): + # This is not an edge row/column. Find closest point. + index = find_closest_point(c, points) + else: + # This is an edge. Find closest corner point. + index = corner_indices[find_closest_point(c, corner_points)] + sector_values.append(index) + return sector_values + + # ///////////////////////////////////////////////////////////////////////////// # QAM modulator # ///////////////////////////////////////////////////////////////////////////// @@ -186,12 +269,19 @@ class qam_mod(generic_mod): The input is a byte stream (unsigned char) and the output is the complex modulated signal at baseband. - See generic_mod block for list of parameters. + Args: + constellation_points: Number of constellation points. + Must be a power of 4. + mod_code: Specifies an encoding to use (typically used to indicated + if we want gray coding, see digital.utils.mod_codes) + + See generic_mod block for list of additional parameters. """ - constellation = qam_constellation(constellation_points, differential, mod_code) - # We take care of the gray coding in the constellation generation so it doesn't - # need to be done in the block. + constellation = qam_constellation(constellation_points, differential, + mod_code) + # We take care of the gray coding in the constellation + # generation so it doesn't need to be done in the block. super(qam_mod, self).__init__(constellation, differential=differential, *args, **kwargs) @@ -205,6 +295,7 @@ class qam_demod(generic_demod): def __init__(self, constellation_points=_def_constellation_points, differential=_def_differential, mod_code=_def_mod_code, + large_ampls_to_corner = False, *args, **kwargs): """ @@ -213,11 +304,23 @@ class qam_demod(generic_demod): The input is a byte stream (unsigned char) and the output is the complex modulated signal at baseband. - See generic_demod block for list of parameters. + Args: + constellation_points: Number of constellation points. + Must be a power of 4. + mod_code: Specifies an encoding to use (typically used to indicated + if we want gray coding, see digital.utils.mod_codes) + large_ampls_to_corners: If this is set to True then when the + constellation is making decisions, points that are far outside + the constellation are mapped to the closest corner rather than + the closet constellation point. This can help with phase + locking. + + See generic_demod block for list of additional parameters. """ - constellation = qam_constellation(constellation_points, differential, mod_code) - # We take care of the gray coding in the constellation generation so it doesn't - # need to be done in the block. + constellation = qam_constellation(constellation_points, differential, + mod_code) + # We take care of the gray coding in the constellation + # generation so it doesn't need to be done in the block. super(qam_demod, self).__init__(constellation, differential=differential, *args, **kwargs) diff --git a/gr-digital/python/qamlike.py b/gr-digital/python/qamlike.py new file mode 100644 index 0000000000..2f8c855339 --- /dev/null +++ b/gr-digital/python/qamlike.py @@ -0,0 +1,75 @@ +# Copyright 2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +""" +This file contains constellations that are similar to QAM, but are not perfect squares. +""" + +import digital_swig +from qam import large_ampls_to_corners_mapping + +def qam32_holeinside_constellation(large_ampls_to_corners=False): + # First make constellation for one quadrant. + # 0 1 2 + # 2 - 010 111 110 + # 1 - 011 101 100 + # 0 - 000 001 + + # Have put hole in the side rather than corner. + # Corner point is helpful for frequency locking. + + # It has an attempt at some gray-coding, but not + # a very good one. + + # Indices are (horizontal, vertical). + indices_and_numbers = ( + ((0, 0), 0b000), + ((0, 1), 0b011), + ((0, 2), 0b010), + ((1, 0), 0b001), + ((1, 1), 0b101), + ((1, 2), 0b111), + ((2, 1), 0b100), + ((2, 2), 0b110), + ) + points = [None]*32 + for indices, number in indices_and_numbers: + p_in_quadrant = 0.5+indices[0] + 1j*(0.5+indices[1]) + for quadrant in range(4): + index = number + 8 * quadrant + rotation = pow(1j, quadrant) + p = p_in_quadrant * rotation + points[index] = p + side = 6 + width = 1 + # Double number of boxes on side + # This is so that points in the 'hole' get assigned correctly. + side = 12 + width = 0.5 + pre_diff_code = [] + if not large_ampls_to_corners: + constellation = digital_swig.constellation_rect(points, pre_diff_code, 4, + side, side, width, width) + else: + sector_values = large_ampls_to_corners_mapping(side, points, width) + constellation = digital_swig.constellation_expl_rect( + points, pre_diff_code, 4, side, side, width, width, sector_values) + return constellation + diff --git a/gr-digital/swig/digital_constellation.i b/gr-digital/swig/digital_constellation.i index 248f900149..4c4f8aa01d 100644 --- a/gr-digital/swig/digital_constellation.i +++ b/gr-digital/swig/digital_constellation.i @@ -102,6 +102,33 @@ public: float width_real_sectors, float width_imag_sectors); }; +class digital_constellation_expl_rect; +typedef boost::shared_ptr<digital_constellation_expl_rect> digital_constellation_expl_rect_sptr; +%template(digital_constellation_expl_rect_sptr) boost::shared_ptr<digital_constellation_expl_rect>; +%rename(constellation_expl_rect) digital_make_constellation_expl_rect; +digital_constellation_expl_rect_sptr digital_make_constellation_expl_rect( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors, + std::vector<unsigned int> sector_values +); +%ignore digital_constellation_expl_rect; + +class digital_constellation_expl_rect : public digital_constellation_rect +{ +public: + digital_constellation_expl_rect ( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors, + std::vector<unsigned int> sector_values + ); +}; + class digital_constellation_psk; typedef boost::shared_ptr<digital_constellation_psk> digital_constellation_psk_sptr; %template(digital_constellation_psk_sptr) boost::shared_ptr<digital_constellation_psk>; @@ -198,6 +225,7 @@ public: digital_constellation_calcdist_sptr.__repr__ = lambda self: '<constellation calcdist (m=%s)>' % str(len(self.points())) digital_constellation_rect_sptr.__repr__ = lambda self: '<constellation rect (m=%s)>' % str(len(self.points())) +digital_constellation_expl_rect_sptr.__repr__ = lambda self: '<constellation expl_rect (m=%s)>' % str(len(self.points())) digital_constellation_psk_sptr.__repr__ = lambda self: '<constellation psk (m=%s)>' % str(len(self.points())) digital_constellation_bpsk_sptr.__repr__ = lambda self: '<constellation bpsk>' digital_constellation_qpsk_sptr.__repr__ = lambda self: '<constellation qpsk>' diff --git a/gr-fcd/lib/CMakeLists.txt b/gr-fcd/lib/CMakeLists.txt index a5c95ceb7d..709b69cfdd 100644 --- a/gr-fcd/lib/CMakeLists.txt +++ b/gr-fcd/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -36,6 +36,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -51,6 +54,18 @@ list(APPEND fcd_libs if (WIN32) list(APPEND fcd_libs setupapi) + + #Add Windows DLL resource file if using MSVC + if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-fcd.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fcd.rc + @ONLY) + + list(APPEND gr_fcd_sources ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fcd.rc) + endif(MSVC) endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") @@ -67,7 +82,7 @@ add_library(gnuradio-fcd SHARED ${gr_fcd_sources}) if (LINUX) list(APPEND fcd_libs rt) endif() -target_link_libraries(gnuradio-fcd ${fcd_libs}) +target_link_libraries(gnuradio-fcd ${fcd_libs} ${LOG4CXX_LIBRARIES}) GR_LIBRARY_FOO(gnuradio-fcd RUNTIME_COMPONENT "fcd_runtime" DEVEL_COMPONENT "fcd_devel") diff --git a/gr-fcd/lib/gnuradio-fcd.rc.in b/gr-fcd/lib/gnuradio-fcd.rc.in new file mode 100644 index 0000000000..01c502c4dd --- /dev/null +++ b/gr-fcd/lib/gnuradio-fcd.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-fcd" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-fcd.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-fcd.dll" + VALUE "ProductName", "gnuradio-fcd" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-fft/lib/CMakeLists.txt b/gr-fft/lib/CMakeLists.txt index 26fcaa7cde..9382a48c3b 100644 --- a/gr-fft/lib/CMakeLists.txt +++ b/gr-fft/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -50,6 +50,20 @@ list(APPEND fft_libs ${FFTW3F_LIBRARIES} ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-fft.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fft.rc + @ONLY) + + list(APPEND fft_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fft.rc + ) +endif(MSVC) + if(FFTW3F_THREADS_LIBRARIES) list(APPEND fft_libs ${FFTW3F_THREADS_LIBRARIES}) add_definitions("-DFFTW3F_THREADS") diff --git a/gr-fft/lib/gnuradio-fft.rc.in b/gr-fft/lib/gnuradio-fft.rc.in new file mode 100644 index 0000000000..0c12bc91e7 --- /dev/null +++ b/gr-fft/lib/gnuradio-fft.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-fft" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-fft.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-fft.dll" + VALUE "ProductName", "gnuradio-fft" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-filter/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt index 626f5521f2..a89bb52dd6 100644 --- a/gr-filter/lib/CMakeLists.txt +++ b/gr-filter/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -97,10 +97,14 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${VOLK_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} + ${LOG4CXX_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) -link_directories(${Boost_LIBRARY_DIRS}) +link_directories( + ${Boost_LIBRARY_DIRS} + ${LOG4CXX_LIBRARIES} +) ######################################################################## # Setup library @@ -137,6 +141,20 @@ list(APPEND filter_sources channel_model_impl.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-filter.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-filter.rc + @ONLY) + + list(APPEND filter_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-filter.rc + ) +endif(MSVC) + list(APPEND filter_libs gnuradio-core gnuradio-fft diff --git a/gr-filter/lib/gnuradio-filter.rc.in b/gr-filter/lib/gnuradio-filter.rc.in new file mode 100644 index 0000000000..8fae9746e9 --- /dev/null +++ b/gr-filter/lib/gnuradio-filter.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-filter" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-filter.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-filter.dll" + VALUE "ProductName", "gnuradio-filter" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-howto-write-a-block/CMakeLists.txt b/gr-howto-write-a-block/CMakeLists.txt index 02b13c6b69..d5d04e24d0 100644 --- a/gr-howto-write-a-block/CMakeLists.txt +++ b/gr-howto-write-a-block/CMakeLists.txt @@ -94,6 +94,10 @@ if(NOT GNURADIO_CORE_FOUND) message(FATAL_ERROR "GnuRadio Core required to compile howto") endif() +# Handle gr_log enable/disable +include(GrMiscUtils) #define LIB_SUFFIX +GR_LOGGING() + ######################################################################## # Setup the include and linker paths ######################################################################## @@ -101,12 +105,14 @@ include_directories( ${CMAKE_SOURCE_DIR}/include ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} + ${LOG4CXX_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories( ${GNURADIO_CORE_LIBRARY_DIRS} ${GRUEL_LIBRARY_DIRS} + ${LOG4CXX_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ) diff --git a/gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake b/gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake new file mode 100644 index 0000000000..b1e4f6f1f7 --- /dev/null +++ b/gr-howto-write-a-block/cmake/Modules/FindLog4cxx.cmake @@ -0,0 +1,28 @@ +# 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 9331d5debc..685ac3c879 100644 --- a/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake +++ b/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake @@ -208,3 +208,46 @@ function(GR_GEN_TARGET_DEPS name var) set(${var} "DEPENDS;${name};COMMAND;${name}" PARENT_SCOPE) endif() endfunction(GR_GEN_TARGET_DEPS) + + +######################################################################## +# Control use of gr_logger +# Usage: +# GR_LOGGING() +# +# Will set ENABLE_GR_LOG to 1 by default. +# Can manually set with -DENABLE_GR_LOG=0|1 +######################################################################## +function(GR_LOGGING) + find_package(Log4cxx) + + 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 + # 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) + + 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) + endif(ENABLE_GR_LOG) + + message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.") + message(STATUS "HAVE_LOG4CXX set to ${HAVE_LOG4CXX}.") + +endfunction(GR_LOGGING) diff --git a/gr-howto-write-a-block/lib/CMakeLists.txt b/gr-howto-write-a-block/lib/CMakeLists.txt index 835ae02d60..a55bb1fa4a 100644 --- a/gr-howto-write-a-block/lib/CMakeLists.txt +++ b/gr-howto-write-a-block/lib/CMakeLists.txt @@ -23,7 +23,11 @@ include(GrPlatform) #define LIB_SUFFIX add_library(gnuradio-howto SHARED howto_square_ff.cc howto_square2_ff.cc) -target_link_libraries(gnuradio-howto ${Boost_LIBRARIES} ${GRUEL_LIBRARIES} ${GNURADIO_CORE_LIBRARIES}) +target_link_libraries(gnuradio-howto + ${Boost_LIBRARIES} + ${GRUEL_LIBRARIES} + ${GNURADIO_CORE_LIBRARIES} + ${LOG4CXX_LIBRARIES}) set_target_properties(gnuradio-howto PROPERTIES DEFINE_SYMBOL "gnuradio_howto_EXPORTS") ######################################################################## diff --git a/gr-noaa/lib/CMakeLists.txt b/gr-noaa/lib/CMakeLists.txt index 3f369f8aff..bded04b779 100644 --- a/gr-noaa/lib/CMakeLists.txt +++ b/gr-noaa/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -29,6 +29,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -38,9 +41,24 @@ list(APPEND gr_noaa_sources noaa_hrpt_pll_cf.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-noaa.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-noaa.rc + @ONLY) + + list(APPEND gr_noaa_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-noaa.rc + ) +endif(MSVC) + list(APPEND noaa_libs gnuradio-core ${Boost_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) add_library(gnuradio-noaa SHARED ${gr_noaa_sources}) diff --git a/gr-noaa/lib/gnuradio-noaa.rc.in b/gr-noaa/lib/gnuradio-noaa.rc.in new file mode 100644 index 0000000000..2f19f110b7 --- /dev/null +++ b/gr-noaa/lib/gnuradio-noaa.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-noaa" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-noaa.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-noaa.dll" + VALUE "ProductName", "gnuradio-noaa" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-pager/lib/CMakeLists.txt b/gr-pager/lib/CMakeLists.txt index cb62bcc752..711712375e 100644 --- a/gr-pager/lib/CMakeLists.txt +++ b/gr-pager/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -29,6 +29,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -43,9 +46,24 @@ list(APPEND gr_pager_sources pageri_util.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-pager.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-pager.rc + @ONLY) + + list(APPEND gr_pager_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-pager.rc + ) +endif(MSVC) + list(APPEND pager_libs gnuradio-core ${Boost_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) add_library(gnuradio-pager SHARED ${gr_pager_sources}) diff --git a/gr-pager/lib/gnuradio-pager.rc.in b/gr-pager/lib/gnuradio-pager.rc.in new file mode 100644 index 0000000000..cf9d85b24f --- /dev/null +++ b/gr-pager/lib/gnuradio-pager.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-pager" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-pager.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-pager.dll" + VALUE "ProductName", "gnuradio-pager" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt index 49fa525d7e..2203bf409b 100644 --- a/gr-qtgui/lib/CMakeLists.txt +++ b/gr-qtgui/lib/CMakeLists.txt @@ -58,6 +58,20 @@ set(qtgui_srcs qtgui_util.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-qtgui.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-qtgui.rc + @ONLY) + + list(APPEND qtgui_srcs + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-qtgui.rc + ) +endif(MSVC) + ######################################################################## # Setup the include and linker paths ######################################################################## @@ -67,12 +81,14 @@ include_directories( ${GRUEL_INCLUDE_DIRS} ${QWT_INCLUDE_DIRS} ${QT_INCLUDE_DIRS} + ${LOG4CXX_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ) link_directories( ${QWT_LIBRARY_DIRS} + ${LOG4CXX_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ) @@ -86,6 +102,7 @@ list(APPEND qtgui_libs ${QWT_LIBRARIES} ${QT_LIBRARIES} ${PYTHON_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) add_definitions(-DQWT_DLL) #setup QWT library linkage diff --git a/gr-qtgui/lib/gnuradio-qtgui.rc.in b/gr-qtgui/lib/gnuradio-qtgui.rc.in new file mode 100644 index 0000000000..1e1e0725e1 --- /dev/null +++ b/gr-qtgui/lib/gnuradio-qtgui.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-qtgui" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-qtgui.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-qtgui.dll" + VALUE "ProductName", "gnuradio-qtgui" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-shd/lib/CMakeLists.txt b/gr-shd/lib/CMakeLists.txt index 38154755c1..9f00c33488 100644 --- a/gr-shd/lib/CMakeLists.txt +++ b/gr-shd/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -31,6 +31,9 @@ include_directories( link_directories(${SHD_LIBRARY_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -39,10 +42,25 @@ list(APPEND gr_shd_sources gr_shd_smini_sink.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-shd.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-shd.rc + @ONLY) + + list(APPEND gr_shd_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-shd.rc + ) +endif(MSVC) + list(APPEND shd_libs gnuradio-core ${Boost_LIBRARIES} ${SHD_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) add_library(gnuradio-shd SHARED ${gr_shd_sources}) diff --git a/gr-shd/lib/gnuradio-shd.rc.in b/gr-shd/lib/gnuradio-shd.rc.in new file mode 100644 index 0000000000..4a3313b0ff --- /dev/null +++ b/gr-shd/lib/gnuradio-shd.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-shd" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-shd.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-shd.dll" + VALUE "ProductName", "gnuradio-shd" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-trellis/src/lib/CMakeLists.txt b/gr-trellis/src/lib/CMakeLists.txt index e2abf0238f..26ff108c8a 100644 --- a/gr-trellis/src/lib/CMakeLists.txt +++ b/gr-trellis/src/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -32,6 +32,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # generate the python helper script which calls into the build utils ######################################################################## @@ -147,9 +150,24 @@ list(APPEND gr_trellis_sources ${generated_trellis_sources} ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-trellis.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-trellis.rc + @ONLY) + + list(APPEND gr_trellis_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-trellis.rc + ) +endif(MSVC) + list(APPEND trellis_libs gnuradio-core ${Boost_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) add_library(gnuradio-trellis SHARED ${gr_trellis_sources}) diff --git a/gr-trellis/src/lib/gnuradio-trellis.rc.in b/gr-trellis/src/lib/gnuradio-trellis.rc.in new file mode 100644 index 0000000000..db9f187947 --- /dev/null +++ b/gr-trellis/src/lib/gnuradio-trellis.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-trellis" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-trellis.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-trellis.dll" + VALUE "ProductName", "gnuradio-trellis" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-uhd/lib/CMakeLists.txt b/gr-uhd/lib/CMakeLists.txt index c494fddad5..f23885aca5 100644 --- a/gr-uhd/lib/CMakeLists.txt +++ b/gr-uhd/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011-2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -34,6 +34,9 @@ link_directories( ${Boost_LIBRARY_DIRS} ) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -43,10 +46,25 @@ list(APPEND gr_uhd_sources gr_uhd_amsg_source.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-uhd.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-uhd.rc + @ONLY) + + list(APPEND gr_uhd_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-uhd.rc + ) +endif(MSVC) + list(APPEND uhd_libs gnuradio-core ${Boost_LIBRARIES} ${UHD_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) add_library(gnuradio-uhd SHARED ${gr_uhd_sources}) diff --git a/gr-uhd/lib/gnuradio-uhd.rc.in b/gr-uhd/lib/gnuradio-uhd.rc.in new file mode 100644 index 0000000000..80fb29b9fb --- /dev/null +++ b/gr-uhd/lib/gnuradio-uhd.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-uhd" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-uhd.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-uhd.dll" + VALUE "ProductName", "gnuradio-uhd" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-video-sdl/src/CMakeLists.txt b/gr-video-sdl/src/CMakeLists.txt index 3050926bd7..1e37505acc 100644 --- a/gr-video-sdl/src/CMakeLists.txt +++ b/gr-video-sdl/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011-2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -25,6 +25,7 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} + ${LOG4CXX_INCLUDE_DIRS} ${SDL_INCLUDE_DIR} ) @@ -38,10 +39,25 @@ list(APPEND gr_video_sdl_sources video_sdl_sink_s.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-video-sdl.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-video-sdl.rc + @ONLY) + + list(APPEND gr_uhd_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-video-sdl.rc + ) +endif(MSVC) + list(APPEND video_sdl_libs gnuradio-core ${Boost_LIBRARIES} ${SDL_LIBRARY} + ${LOG4CXX_LIBRARIES} ) add_library(gnuradio-video-sdl SHARED ${gr_video_sdl_sources}) diff --git a/gr-video-sdl/src/gnuradio-video-sdl.rc.in b/gr-video-sdl/src/gnuradio-video-sdl.rc.in new file mode 100644 index 0000000000..c876b0f08a --- /dev/null +++ b/gr-video-sdl/src/gnuradio-video-sdl.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-video-sdl" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-video-sdl.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-video-sdl.dll" + VALUE "ProductName", "gnuradio-video-sdl" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-vocoder/lib/CMakeLists.txt b/gr-vocoder/lib/CMakeLists.txt index 43a4156d06..930ec96eca 100644 --- a/gr-vocoder/lib/CMakeLists.txt +++ b/gr-vocoder/lib/CMakeLists.txt @@ -29,6 +29,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -51,6 +54,20 @@ list(APPEND gr_vocoder_sources vocoder_ulaw_encode_sb.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-vocoder.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-vocoder.rc + @ONLY) + + list(APPEND gr_uhd_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-vocoder.rc + ) +endif(MSVC) + ######################################################################## # Include subdirs rather to populate to the sources lists. ######################################################################## @@ -61,6 +78,7 @@ GR_INCLUDE_SUBDIRECTORY(gsm) list(APPEND vocoder_libs gnuradio-core ${Boost_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) add_library(gnuradio-vocoder SHARED ${gr_vocoder_sources}) diff --git a/gr-vocoder/lib/gnuradio-vocoder.rc.in b/gr-vocoder/lib/gnuradio-vocoder.rc.in new file mode 100644 index 0000000000..c80be446e3 --- /dev/null +++ b/gr-vocoder/lib/gnuradio-vocoder.rc.in @@ -0,0 +1,33 @@ +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-vocoder" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-vocoder.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-vocoder.dll" + VALUE "ProductName", "gnuradio-vocoder" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-wavelet/lib/CMakeLists.txt b/gr-wavelet/lib/CMakeLists.txt index f446adb9c2..66c31d7f6b 100644 --- a/gr-wavelet/lib/CMakeLists.txt +++ b/gr-wavelet/lib/CMakeLists.txt @@ -35,6 +35,9 @@ link_directories(${Boost_LIBRARY_DIRS}) link_directories(${GSL_LIBRARY_DIRS}) add_definitions(${GSL_DEFINITIONS}) +include_directories(${LOG4CXX_INCLUDE_DIRS}) +link_directories(${LOG4CXX_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -44,11 +47,26 @@ list(APPEND gr_wavelet_sources wavelet_wvps_ff_impl.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-wavelet.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-wavelet.rc + @ONLY) + + list(APPEND gr_wavelet_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-wavelet.rc + ) +endif(MSVC) + list(APPEND wavelet_libs gnuradio-core ${Boost_LIBRARIES} ${WAVELET_LIBRARIES} ${GSL_LIBRARIES} + ${LOG4CXX_LIBRARIES} ) add_library(gnuradio-wavelet SHARED ${gr_wavelet_sources}) diff --git a/gr-wavelet/lib/gnuradio-wavelet.rc.in b/gr-wavelet/lib/gnuradio-wavelet.rc.in new file mode 100644 index 0000000000..7c3c0674f9 --- /dev/null +++ b/gr-wavelet/lib/gnuradio-wavelet.rc.in @@ -0,0 +1,33 @@ +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-wavelet" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-wavelet.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-wavelet.dll" + VALUE "ProductName", "gnuradio-wavelet" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gruel/src/lib/CMakeLists.txt b/gruel/src/lib/CMakeLists.txt index 717d566601..a08e67d99a 100644 --- a/gruel/src/lib/CMakeLists.txt +++ b/gruel/src/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. +# Copyright 2010-2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -81,6 +81,20 @@ list(APPEND gruel_sources thread_group.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gruel.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gruel.rc + @ONLY) + + list(APPEND gruel_sources + ${CMAKE_CURRENT_BINARY_DIR}/gruel.rc + ) +endif(MSVC) + list(APPEND gruel_libs ${Boost_LIBRARIES}) if(HAVE_PTHREAD_SETSCHEDPARAM) diff --git a/gruel/src/lib/gruel.rc.in b/gruel/src/lib/gruel.rc.in new file mode 100644 index 0000000000..906b7d61c2 --- /dev/null +++ b/gruel/src/lib/gruel.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gruel" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gruel.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gruel.dll" + VALUE "ProductName", "gruel" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END |