diff options
290 files changed, 13800 insertions, 272 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9be8217eaa..5d0cbe2891 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) # Set the version information here set(VERSION_INFO_MAJOR_VERSION 3) set(VERSION_INFO_API_COMPAT 6) -set(VERSION_INFO_MINOR_VERSION 1) +set(VERSION_INFO_MINOR_VERSION 2) set(VERSION_INFO_MAINT_VERSION git) include(GrVersion) #setup version info @@ -107,6 +107,8 @@ set(GR_PKG_CONF_DIR ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d) set(GR_LIBEXEC_DIR libexec) set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME}) set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks) +set(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/${GR_CONF_DIR}" CACHE PATH "System configuration directory") +set(GR_PREFSDIR ${SYSCONFDIR}/${CMAKE_PROJECT_NAME}/conf.d) ######################################################################## # Variables replaced when configuring the package config files @@ -115,6 +117,8 @@ file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}" prefix) file(TO_NATIVE_PATH "\${prefix}" exec_prefix) file(TO_NATIVE_PATH "\${exec_prefix}/${GR_LIBRARY_DIR}" libdir) file(TO_NATIVE_PATH "\${prefix}/${GR_INCLUDE_DIR}" includedir) +file(TO_NATIVE_PATH "${SYSCONFDIR}" SYSCONFDIR) +file(TO_NATIVE_PATH "${GR_PREFSDIR}" GR_PREFSDIR) ######################################################################## # Create uninstall target diff --git a/cmake/Modules/FindSphinx.cmake b/cmake/Modules/FindSphinx.cmake new file mode 100644 index 0000000000..da12ee93de --- /dev/null +++ b/cmake/Modules/FindSphinx.cmake @@ -0,0 +1,37 @@ +# - This module looks for Sphinx +# Find the Sphinx documentation generator +# +# This modules defines +# SPHINX_EXECUTABLE +# SPHINX_FOUND + +#============================================================================= +# Copyright 2002-2009 Kitware, Inc. +# Copyright 2009-2011 Peter Colberg +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file COPYING-CMAKE-SCRIPTS for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +find_program(SPHINX_EXECUTABLE NAMES sphinx-build + HINTS + $ENV{SPHINX_DIR} + PATH_SUFFIXES bin + DOC "Sphinx documentation generator" +) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(Sphinx DEFAULT_MSG + SPHINX_EXECUTABLE +) + +mark_as_advanced( + SPHINX_EXECUTABLE +) diff --git a/cmake/Packaging/Fedora-15.cmake b/cmake/Packaging/Fedora-15.cmake index 278d68990a..2e9e78ee11 100644 --- a/cmake/Packaging/Fedora-15.cmake +++ b/cmake/Packaging/Fedora-15.cmake @@ -1,6 +1,6 @@ SET(PACKAGE_DEPENDS_GRUEL_RUNTIME "boost-python" "glibc") SET(PACKAGE_DEPENDS_GRUEL_PYTHON "python") -SET(PACKAGE_DEPENDS_CORE_RUNTIME "fftw-libs" "gsl") +SET(PACKAGE_DEPENDS_CORE_RUNTIME "fftw-libs") SET(PACKAGE_DEPENDS_QTGUI_RUNTIME "qt" "qwt") SET(PACKAGE_DEPENDS_QTGUI_PYTHON "PyQt4" "PyQwt") SET(PACKAGE_DEPENDS_GRC "python" "numpy" "gtk2" "python-lxml" "python-cheetah") @@ -8,3 +8,5 @@ SET(PACKAGE_DEPENDS_WXGUI "wxGTK" "python" "numpy") SET(PACKAGE_DEPENDS_VIDEO_SDL_RUNTIME "SDL") SET(PACKAGE_DEPENDS_UHD_RUNTIME "uhd") SET(PACKAGE_DEPENDS_AUDIO_RUNTIME "pulseaudio" "alsa-lib" "jack-audio-connection-kit") +SET(PACKAGE_DEPENDS_WAVELET_RUNTIME "gsl") +SET(PACKAGE_DEPENDS_WAVELET_PYTHON "python" "numpy") diff --git a/cmake/Packaging/Fedora-16.cmake b/cmake/Packaging/Fedora-16.cmake index 278d68990a..2e9e78ee11 100644 --- a/cmake/Packaging/Fedora-16.cmake +++ b/cmake/Packaging/Fedora-16.cmake @@ -1,6 +1,6 @@ SET(PACKAGE_DEPENDS_GRUEL_RUNTIME "boost-python" "glibc") SET(PACKAGE_DEPENDS_GRUEL_PYTHON "python") -SET(PACKAGE_DEPENDS_CORE_RUNTIME "fftw-libs" "gsl") +SET(PACKAGE_DEPENDS_CORE_RUNTIME "fftw-libs") SET(PACKAGE_DEPENDS_QTGUI_RUNTIME "qt" "qwt") SET(PACKAGE_DEPENDS_QTGUI_PYTHON "PyQt4" "PyQwt") SET(PACKAGE_DEPENDS_GRC "python" "numpy" "gtk2" "python-lxml" "python-cheetah") @@ -8,3 +8,5 @@ SET(PACKAGE_DEPENDS_WXGUI "wxGTK" "python" "numpy") SET(PACKAGE_DEPENDS_VIDEO_SDL_RUNTIME "SDL") SET(PACKAGE_DEPENDS_UHD_RUNTIME "uhd") SET(PACKAGE_DEPENDS_AUDIO_RUNTIME "pulseaudio" "alsa-lib" "jack-audio-connection-kit") +SET(PACKAGE_DEPENDS_WAVELET_RUNTIME "gsl") +SET(PACKAGE_DEPENDS_WAVELET_PYTHON "python" "numpy") diff --git a/cmake/Packaging/Fedora-17.cmake b/cmake/Packaging/Fedora-17.cmake new file mode 100644 index 0000000000..2e9e78ee11 --- /dev/null +++ b/cmake/Packaging/Fedora-17.cmake @@ -0,0 +1,12 @@ +SET(PACKAGE_DEPENDS_GRUEL_RUNTIME "boost-python" "glibc") +SET(PACKAGE_DEPENDS_GRUEL_PYTHON "python") +SET(PACKAGE_DEPENDS_CORE_RUNTIME "fftw-libs") +SET(PACKAGE_DEPENDS_QTGUI_RUNTIME "qt" "qwt") +SET(PACKAGE_DEPENDS_QTGUI_PYTHON "PyQt4" "PyQwt") +SET(PACKAGE_DEPENDS_GRC "python" "numpy" "gtk2" "python-lxml" "python-cheetah") +SET(PACKAGE_DEPENDS_WXGUI "wxGTK" "python" "numpy") +SET(PACKAGE_DEPENDS_VIDEO_SDL_RUNTIME "SDL") +SET(PACKAGE_DEPENDS_UHD_RUNTIME "uhd") +SET(PACKAGE_DEPENDS_AUDIO_RUNTIME "pulseaudio" "alsa-lib" "jack-audio-connection-kit") +SET(PACKAGE_DEPENDS_WAVELET_RUNTIME "gsl") +SET(PACKAGE_DEPENDS_WAVELET_PYTHON "python" "numpy") diff --git a/cmake/Packaging/Ubuntu-10.04.cmake b/cmake/Packaging/Ubuntu-10.04.cmake index a7a60f6b80..3320073c6b 100644 --- a/cmake/Packaging/Ubuntu-10.04.cmake +++ b/cmake/Packaging/Ubuntu-10.04.cmake @@ -1,6 +1,6 @@ SET(PACKAGE_DEPENDS_GRUEL_RUNTIME "libboost-all-dev" "libc6") SET(PACKAGE_DEPENDS_GRUEL_PYTHON "python") -SET(PACKAGE_DEPENDS_CORE_RUNTIME "libfftw3-3" "libgsl0ldbl") +SET(PACKAGE_DEPENDS_CORE_RUNTIME "libfftw3-3") SET(PACKAGE_DEPENDS_QTGUI_RUNTIME "libqtcore4" "libqwt5-qt4") SET(PACKAGE_DEPENDS_QTGUI_PYTHON "python-qt4" "python-qwt5-qt4") SET(PACKAGE_DEPENDS_GRC "python" "python-numpy" "python-gtk2" "python-lxml" "python-cheetah") @@ -8,3 +8,5 @@ SET(PACKAGE_DEPENDS_WXGUI "python-wxgtk2.8" "python" "python-numpy") SET(PACKAGE_DEPENDS_VIDEO_SDL_RUNTIME "libsdl1.2debian") SET(PACKAGE_DEPENDS_UHD_RUNTIME "uhd") SET(PACKAGE_DEPENDS_AUDIO_RUNTIME "libpulse0" "alsa-base" "libjack0") +SET(PACKAGE_DEPENDS_WAVELET_RUNTIME "libgsl0ldbl") +SET(PACKAGE_DEPENDS_WAVELET_PYTHON "python" "python-numpy") diff --git a/cmake/Packaging/Ubuntu-10.10.cmake b/cmake/Packaging/Ubuntu-10.10.cmake index a7a60f6b80..3320073c6b 100644 --- a/cmake/Packaging/Ubuntu-10.10.cmake +++ b/cmake/Packaging/Ubuntu-10.10.cmake @@ -1,6 +1,6 @@ SET(PACKAGE_DEPENDS_GRUEL_RUNTIME "libboost-all-dev" "libc6") SET(PACKAGE_DEPENDS_GRUEL_PYTHON "python") -SET(PACKAGE_DEPENDS_CORE_RUNTIME "libfftw3-3" "libgsl0ldbl") +SET(PACKAGE_DEPENDS_CORE_RUNTIME "libfftw3-3") SET(PACKAGE_DEPENDS_QTGUI_RUNTIME "libqtcore4" "libqwt5-qt4") SET(PACKAGE_DEPENDS_QTGUI_PYTHON "python-qt4" "python-qwt5-qt4") SET(PACKAGE_DEPENDS_GRC "python" "python-numpy" "python-gtk2" "python-lxml" "python-cheetah") @@ -8,3 +8,5 @@ SET(PACKAGE_DEPENDS_WXGUI "python-wxgtk2.8" "python" "python-numpy") SET(PACKAGE_DEPENDS_VIDEO_SDL_RUNTIME "libsdl1.2debian") SET(PACKAGE_DEPENDS_UHD_RUNTIME "uhd") SET(PACKAGE_DEPENDS_AUDIO_RUNTIME "libpulse0" "alsa-base" "libjack0") +SET(PACKAGE_DEPENDS_WAVELET_RUNTIME "libgsl0ldbl") +SET(PACKAGE_DEPENDS_WAVELET_PYTHON "python" "python-numpy") diff --git a/cmake/Packaging/Ubuntu-11.04.cmake b/cmake/Packaging/Ubuntu-11.04.cmake index 71882b2e1f..c166bcf427 100644 --- a/cmake/Packaging/Ubuntu-11.04.cmake +++ b/cmake/Packaging/Ubuntu-11.04.cmake @@ -1,7 +1,7 @@ #set the debian package dependencies (parsed by our deb component maker) SET(PACKAGE_DEPENDS_GRUEL_RUNTIME "libboost-all-dev" "libc6") SET(PACKAGE_DEPENDS_GRUEL_PYTHON "python") -SET(PACKAGE_DEPENDS_CORE_RUNTIME "libfftw3-3" "libgsl0ldbl") +SET(PACKAGE_DEPENDS_CORE_RUNTIME "libfftw3-3") SET(PACKAGE_DEPENDS_QTGUI_RUNTIME "libqtcore4" "libqwt5-qt4") SET(PACKAGE_DEPENDS_QTGUI_PYTHON "python-qt4" "python-qwt5-qt4") SET(PACKAGE_DEPENDS_GRC "python" "python-numpy" "python-gtk2" "python-lxml" "python-cheetah") @@ -9,3 +9,5 @@ SET(PACKAGE_DEPENDS_WXGUI "python-wxgtk2.8") SET(PACKAGE_DEPENDS_VIDEO_SDL_RUNTIME "libsdl1.2debian") SET(PACKAGE_DEPENDS_UHD_RUNTIME "uhd") SET(PACKAGE_DEPENDS_AUDIO_RUNTIME "libpulse0" "alsa-base" "libjack0") +SET(PACKAGE_DEPENDS_WAVELET_RUNTIME "libgsl0ldbl") +SET(PACKAGE_DEPENDS_WAVELET_PYTHON "python" "python-numpy") diff --git a/cmake/Packaging/Ubuntu-11.10.cmake b/cmake/Packaging/Ubuntu-11.10.cmake index dcb7b31783..702ce574f3 100644 --- a/cmake/Packaging/Ubuntu-11.10.cmake +++ b/cmake/Packaging/Ubuntu-11.10.cmake @@ -1,6 +1,6 @@ SET(PACKAGE_DEPENDS_GRUEL_RUNTIME "libboost-all-dev" "libc6") SET(PACKAGE_DEPENDS_GRUEL_PYTHON "python" "python-numpy") -SET(PACKAGE_DEPENDS_CORE_RUNTIME "libfftw3-3" "libgsl0ldbl") +SET(PACKAGE_DEPENDS_CORE_RUNTIME "libfftw3-3") SET(PACKAGE_DEPENDS_QTGUI_RUNTIME "libqtcore4" "libqwt6") SET(PACKAGE_DEPENDS_QTGUI_PYTHON "python-qt4" "python-qwt5-qt4") SET(PACKAGE_DEPENDS_GRC "python" "python-numpy" "python-gtk2" "python-lxml" "python-cheetah") @@ -8,3 +8,5 @@ SET(PACKAGE_DEPENDS_WXGUI "python-wxgtk2.8") SET(PACKAGE_DEPENDS_VIDEO_SDL_RUNTIME "libsdl1.2debian") SET(PACKAGE_DEPENDS_UHD_RUNTIME "uhd") SET(PACKAGE_DEPENDS_AUDIO_RUNTIME "libpulse0" "alsa-base" "libjack0") +SET(PACKAGE_DEPENDS_WAVELET_RUNTIME "libgsl0ldbl") +SET(PACKAGE_DEPENDS_WAVELET_PYTHON "python" "python-numpy") diff --git a/cmake/Packaging/Ubuntu-12.04.cmake b/cmake/Packaging/Ubuntu-12.04.cmake new file mode 100644 index 0000000000..702ce574f3 --- /dev/null +++ b/cmake/Packaging/Ubuntu-12.04.cmake @@ -0,0 +1,12 @@ +SET(PACKAGE_DEPENDS_GRUEL_RUNTIME "libboost-all-dev" "libc6") +SET(PACKAGE_DEPENDS_GRUEL_PYTHON "python" "python-numpy") +SET(PACKAGE_DEPENDS_CORE_RUNTIME "libfftw3-3") +SET(PACKAGE_DEPENDS_QTGUI_RUNTIME "libqtcore4" "libqwt6") +SET(PACKAGE_DEPENDS_QTGUI_PYTHON "python-qt4" "python-qwt5-qt4") +SET(PACKAGE_DEPENDS_GRC "python" "python-numpy" "python-gtk2" "python-lxml" "python-cheetah") +SET(PACKAGE_DEPENDS_WXGUI "python-wxgtk2.8") +SET(PACKAGE_DEPENDS_VIDEO_SDL_RUNTIME "libsdl1.2debian") +SET(PACKAGE_DEPENDS_UHD_RUNTIME "uhd") +SET(PACKAGE_DEPENDS_AUDIO_RUNTIME "libpulse0" "alsa-base" "libjack0") +SET(PACKAGE_DEPENDS_WAVELET_RUNTIME "libgsl0ldbl") +SET(PACKAGE_DEPENDS_WAVELET_PYTHON "python" "python-numpy") diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index f67fdd7a86..24bf2405ea 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -21,12 +21,14 @@ # Setup dependencies ######################################################################## find_package(Doxygen) +find_package(Sphinx) ######################################################################## # Register component ######################################################################## include(GrComponent) GR_REGISTER_COMPONENT("doxygen" ENABLE_DOXYGEN DOXYGEN_FOUND) +GR_REGISTER_COMPONENT("sphinx" ENABLE_SPHINX SPHINX_FOUND) ######################################################################## # Begin conditional configuration @@ -48,3 +50,25 @@ CPACK_COMPONENT("docs" add_subdirectory(doxygen) endif(ENABLE_DOXYGEN) + + +######################################################################## +# Begin conditional configuration +######################################################################## +if(ENABLE_SPHINX) + +######################################################################## +# Setup CPack components +######################################################################## +include(GrPackage) +CPACK_COMPONENT("docs" + DISPLAY_NAME "Documentation" + DESCRIPTION "Sphinx generated documentation" +) + +######################################################################## +# Add subdirectories +######################################################################## +add_subdirectory(sphinx) + +endif(ENABLE_SPHINX) diff --git a/docs/doxygen/Doxyfile.in b/docs/doxygen/Doxyfile.in index f3485316c4..ad3c2d01f4 100644 --- a/docs/doxygen/Doxyfile.in +++ b/docs/doxygen/Doxyfile.in @@ -628,7 +628,6 @@ EXCLUDE = @abs_top_builddir@/docs/doxygen/html \ @abs_top_builddir@/gr-gsm-fr-vocoder/src/lib/gsm_full_rate.py \ @abs_top_builddir@/gr-gsm-fr-vocoder/src/python/encdec.py \ @abs_top_builddir@/gr-howto-write-a-block \ - @abs_top_builddir@/gr-howto-write-a-block-cmake \ @abs_top_builddir@/gr-pager/src/pager_swig.py \ @abs_top_builddir@/gr-trellis/doc \ @abs_top_builddir@/gr-trellis/src/lib/generate_all.py \ @@ -640,7 +639,7 @@ EXCLUDE = @abs_top_builddir@/docs/doxygen/html \ @abs_top_builddir@/_CPack_Packages \ @abs_top_srcdir@/cmake \ @abs_top_srcdir@/gr-qtgui/lib \ - @abs_top_srcdir@/gr-howto-write-a-block-cmake + @abs_top_srcdir@/gr-howto-write-a-block # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded diff --git a/docs/doxygen/doxyxml/doxyindex.py b/docs/doxygen/doxyxml/doxyindex.py index 0132ab86fd..304109a8e5 100644 --- a/docs/doxygen/doxyxml/doxyindex.py +++ b/docs/doxygen/doxyxml/doxyindex.py @@ -1,23 +1,23 @@ # # Copyright 2010 Free Software Foundation, Inc. -# +# # This file is part of GNU Radio -# +# # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. -# +# # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -# +# """ Classes providing more user-friendly interfaces to the doxygen xml docs than the generated classes provide. @@ -40,7 +40,7 @@ class DoxyIndex(Base): if self._parsed: return super(DoxyIndex, self)._parse() - self._root = index.parse(os.path.join(self._xml_path, 'index.xml')) + self._root = index.parse(os.path.join(self._xml_path, 'index.xml')) for mem in self._root.compound: converted = self.convert_mem(mem) # For files we want the contents to be accessible directly @@ -78,7 +78,24 @@ class DoxyCompMem(Base): bd = description(getattr(parse_data, 'briefdescription', None)) dd = description(getattr(parse_data, 'detaileddescription', None)) self._data['brief_description'] = bd - self._data['detailed_description'] = dd + self._data['detailed_description'] = dd + + def set_parameters(self, data): + vs = [ddc.value for ddc in data.detaileddescription.content_] + pls = [] + for v in vs: + if hasattr(v, 'parameterlist'): + pls += v.parameterlist + pis = [] + for pl in pls: + pis += pl.parameteritem + dpis = [] + for pi in pis: + dpi = DoxyParameterItem(pi) + dpi._parse() + dpis.append(dpi) + self._data['params'] = dpis + class DoxyCompound(DoxyCompMem): pass @@ -86,7 +103,6 @@ class DoxyCompound(DoxyCompMem): class DoxyMember(DoxyCompMem): pass - class DoxyFunction(DoxyMember): __module__ = "gnuradio.utils.doxyxml" @@ -98,10 +114,13 @@ class DoxyFunction(DoxyMember): return super(DoxyFunction, self)._parse() self.set_descriptions(self._parse_data) - self._data['params'] = [] - prms = self._parse_data.param - for prm in prms: - self._data['params'].append(DoxyParam(prm)) + self.set_parameters(self._parse_data) + if not self._data['params']: + # If the params weren't set by a comment then just grab the names. + self._data['params'] = [] + prms = self._parse_data.param + for prm in prms: + self._data['params'].append(DoxyParam(prm)) brief_description = property(lambda self: self.data()['brief_description']) detailed_description = property(lambda self: self.data()['detailed_description']) @@ -111,7 +130,7 @@ Base.mem_classes.append(DoxyFunction) class DoxyParam(DoxyMember): - + __module__ = "gnuradio.utils.doxyxml" def _parse(self): @@ -121,16 +140,46 @@ class DoxyParam(DoxyMember): self.set_descriptions(self._parse_data) self._data['declname'] = self._parse_data.declname + @property + def description(self): + descriptions = [] + if self.brief_description: + descriptions.append(self.brief_description) + if self.detailed_description: + descriptions.append(self.detailed_description) + return '\n\n'.join(descriptions) + brief_description = property(lambda self: self.data()['brief_description']) detailed_description = property(lambda self: self.data()['detailed_description']) - declname = property(lambda self: self.data()['declname']) + name = property(lambda self: self.data()['declname']) -class DoxyClass(DoxyCompound): +class DoxyParameterItem(DoxyMember): + """A different representation of a parameter in Doxygen.""" + + def _parse(self): + if self._parsed: + return + super(DoxyParameterItem, self)._parse() + names = [] + for nl in self._parse_data.parameternamelist: + for pn in nl.parametername: + names.append(description(pn)) + # Just take first name + self._data['name'] = names[0] + # Get description + pd = description(self._parse_data.get_parameterdescription()) + self._data['description'] = pd + + description = property(lambda self: self.data()['description']) + name = property(lambda self: self.data()['name']) + +class DoxyClass(DoxyCompound): + __module__ = "gnuradio.utils.doxyxml" kind = 'class' - + def _parse(self): if self._parsed: return @@ -139,22 +188,24 @@ class DoxyClass(DoxyCompound): if self._error: return self.set_descriptions(self._retrieved_data.compounddef) + self.set_parameters(self._retrieved_data.compounddef) # Sectiondef.kind tells about whether private or public. # We just ignore this for now. self.process_memberdefs() brief_description = property(lambda self: self.data()['brief_description']) detailed_description = property(lambda self: self.data()['detailed_description']) + params = property(lambda self: self.data()['params']) Base.mem_classes.append(DoxyClass) - + class DoxyFile(DoxyCompound): - + __module__ = "gnuradio.utils.doxyxml" kind = 'file' - + def _parse(self): if self._parsed: return @@ -164,7 +215,7 @@ class DoxyFile(DoxyCompound): if self._error: return self.process_memberdefs() - + brief_description = property(lambda self: self.data()['brief_description']) detailed_description = property(lambda self: self.data()['detailed_description']) @@ -172,16 +223,16 @@ Base.mem_classes.append(DoxyFile) class DoxyNamespace(DoxyCompound): - + __module__ = "gnuradio.utils.doxyxml" kind = 'namespace' - + Base.mem_classes.append(DoxyNamespace) class DoxyGroup(DoxyCompound): - + __module__ = "gnuradio.utils.doxyxml" kind = 'group' @@ -209,7 +260,7 @@ class DoxyGroup(DoxyCompound): self.process_memberdefs() title = property(lambda self: self.data()['title']) - + Base.mem_classes.append(DoxyGroup) @@ -224,7 +275,7 @@ Base.mem_classes.append(DoxyFriend) class DoxyOther(Base): - + __module__ = "gnuradio.utils.doxyxml" kinds = set(['variable', 'struct', 'union', 'define', 'typedef', 'enum', 'dir', 'page']) @@ -232,6 +283,6 @@ class DoxyOther(Base): @classmethod def can_parse(cls, obj): return obj.kind in cls.kinds - + Base.mem_classes.append(DoxyOther) diff --git a/docs/doxygen/other/volk_guide.dox b/docs/doxygen/other/volk_guide.dox index 24882ed1a6..0e444ebbaf 100644 --- a/docs/doxygen/other/volk_guide.dox +++ b/docs/doxygen/other/volk_guide.dox @@ -63,7 +63,7 @@ calls with: \code const int alignment_multiple = volk_get_alignment() / output_item_size; - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); \endcode The Volk function 'volk_get_alignment' provides the alignment of the diff --git a/docs/doxygen/swig_doc.py b/docs/doxygen/swig_doc.py index bd35b8efdd..9277470984 100644 --- a/docs/doxygen/swig_doc.py +++ b/docs/doxygen/swig_doc.py @@ -1,23 +1,23 @@ # # Copyright 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. -# +# """ Creates the swig_doc.i SWIG interface file. Execute using: python swig_doc.py xml_path outputfilename @@ -29,11 +29,8 @@ python docstrings. import sys, time -try: - from doxyxml import DoxyIndex, DoxyClass, DoxyFriend, DoxyFunction, DoxyFile, base -except ImportError: - from gnuradio.doxyxml import DoxyIndex, DoxyClass, DoxyFriend, DoxyFunction, DoxyFile, base - +from doxyxml import DoxyIndex, DoxyClass, DoxyFriend, DoxyFunction, DoxyFile +from doxyxml import DoxyOther, base def py_name(name): bits = name.split('_') @@ -56,8 +53,29 @@ class Block(object): # Check for a parsing error. if item.error(): return False - return item.has_member(make_name(item.name()), DoxyFriend) - + friendname = make_name(item.name()) + is_a_block = item.has_member(friendname, DoxyFriend) + # But now sometimes the make function isn't a friend so check again. + if not is_a_block: + is_a_block = di.has_member(friendname, DoxyFunction) + return is_a_block + +class Block2(object): + """ + Checks if doxyxml produced objects correspond to a new style + gnuradio block. + """ + + @classmethod + def includes(cls, item): + if not isinstance(item, DoxyClass): + return False + # Check for a parsing error. + if item.error(): + return False + is_a_block2 = item.has_member('make', DoxyFunction) and item.has_member('sptr', DoxyOther) + return is_a_block2 + def utoascii(text): """ @@ -82,13 +100,19 @@ def combine_descriptions(obj): if dd: description.append(dd) return utoascii('\n\n'.join(description)).strip() - + +def format_params(parameteritems): + output = ['Args:'] + template = ' {0} : {1}' + for pi in parameteritems: + output.append(template.format(pi.name, pi.description)) + return '\n'.join(output) entry_templ = '%feature("docstring") {name} "{docstring}"' -def make_entry(obj, name=None, templ="{description}", description=None): +def make_entry(obj, name=None, templ="{description}", description=None, params=[]): """ Create a docstring entry for a swig interface file. - + obj - a doxyxml object from which documentation will be extracted. name - the name of the C object (defaults to obj.name()) templ - an optional template for the docstring containing only one @@ -102,6 +126,9 @@ def make_entry(obj, name=None, templ="{description}", description=None): return '' if description is None: description = combine_descriptions(obj) + if params: + description += '\n\n' + description += utoascii(format_params(params)) docstring = templ.format(description=description) if not docstring: return '' @@ -121,27 +148,31 @@ def make_func_entry(func, name=None, description=None, params=None): used as the description instead of extracting it from func. params - a parameter list that overrides using func.params. """ - if params is None: - params = func.params - params = [prm.declname for prm in params] - if params: - sig = "Params: (%s)" % ", ".join(params) - else: - sig = "Params: (NONE)" - templ = "{description}\n\n" + sig - return make_entry(func, name=name, templ=utoascii(templ), - description=description) - - -def make_class_entry(klass, description=None): + #if params is None: + # params = func.params + #params = [prm.declname for prm in params] + #if params: + # sig = "Params: (%s)" % ", ".join(params) + #else: + # sig = "Params: (NONE)" + #templ = "{description}\n\n" + sig + #return make_entry(func, name=name, templ=utoascii(templ), + # description=description) + return make_entry(func, name=name, description=description, params=params) + + +def make_class_entry(klass, description=None, ignored_methods=[], params=None): """ Create a class docstring for a swig interface file. """ + if params is None: + params = klass.params output = [] - output.append(make_entry(klass, description=description)) + output.append(make_entry(klass, description=description, params=params)) for func in klass.in_category(DoxyFunction): - name = klass.name() + '::' + func.name() - output.append(make_func_entry(func, name=name)) + if func.name() not in ignored_methods: + name = klass.name() + '::' + func.name() + output.append(make_func_entry(func, name=name)) return "\n\n".join(output) @@ -175,18 +206,56 @@ def make_block_entry(di, block): # the make function. output = [] output.append(make_class_entry(block, description=super_description)) - creator = block.get_member(block.name(), DoxyFunction) output.append(make_func_entry(make_func, description=super_description, - params=creator.params)) + params=block.params)) return "\n\n".join(output) +def make_block2_entry(di, block): + """ + Create class and function docstrings of a new style gnuradio block for a + swig interface file. + """ + descriptions = [] + # For new style blocks all the relevant documentation should be + # associated with the 'make' method. + make_func = block.get_member('make', DoxyFunction) + description = combine_descriptions(make_func) + # Associate the combined description with the class and + # the make function. + output = [] + #output.append(make_class_entry( + # block, description=description, + # ignored_methods=['make'], params=make_func.params)) + makename = block.name() + '::make' + output.append(make_func_entry( + make_func, name=makename, description=description, + params=make_func.params)) + return "\n\n".join(output) -def make_swig_interface_file(di, swigdocfilename, custom_output=None): +def wait_if_necessary(tries, swigdocfilename, item=None): + if item is not None: + extra = ', item {0}'.format(item.name()) + else: + extra = '' + if(tries < 3): + # May not be built just yet; sleep and try again + sys.stderr.write("XML parsing problem with file {0}{1}, retrying.\n".format( + swigdocfilename, extra)) + time.sleep(1) + tries += 1 + return tries, True + else: + # if we've given it three tries, give up and raise an error + sys.stderr.write("XML parsing error with file {0}{1}. giving up.\n".format( + swigdocfilename, extra)) + return tries, False +def make_swig_interface_file(di, swigdocfilename, custom_output=None, tries=0): + output = [""" /* * This file was automatically generated using swig_doc.py. - * + * * Any changes to it will be lost next time it is regenerated. */ """] @@ -195,67 +264,71 @@ def make_swig_interface_file(di, swigdocfilename, custom_output=None): output.append(custom_output) # Create docstrings for the blocks. - tries = 0 while(1): try: blocks = di.in_category(Block) + blocks2 = di.in_category(Block2) except: - if(tries < 3): - # May not be built just yet; sleep and try again - sys.stderr.write("XML parsing problem with file {0}, retrying.\n".format( - swigdocfilename)) - time.sleep(1) - tries += 1 - else: - # if we've given it three tries, give up and raise an error - sys.stderr.write("XML parsing error with file {0}. giving up.\n".format( - swigdocfilename)) + tries, try_again = wait_if_necessary(tries, swigdocfilename) + if not try_again: raise else: break - make_funcs = set([]) for block in blocks: - tries = 0 while(1): try: make_func = di.get_member(make_name(block.name()), DoxyFunction) - make_funcs.add(make_func.name()) - output.append(make_block_entry(di, block)) + # Don't want to risk writing to output twice. + if make_func.name() not in make_funcs: + make_funcs.add(make_func.name()) + output.append(make_block_entry(di, block)) except block.ParsingError: - sys.stderr.write('Parsing error for block {0}'.format(block.name())) + sys.stderr.write('Parsing error for block {0}\n'.format(block.name())) except: - if(tries < 3): - # May not be built just yet; sleep and try again - sys.stderr.write("XML parsing problem with file {0}, retrying.\n".format( - swigdocfilename)) - time.sleep(1) - tries += 1 - else: - # if we've given it three tries, give up and raise an error - sys.stderr.write("XML parsing error with file {0}. giving up.\n".format( - swigdocfilename)) + tries, try_again = wait_if_necessary(tries, swigdocfilename, block) + if not try_again: raise else: break + for block in blocks2: + while(1): + try: + make_func = block.get_member('make', DoxyFunction) + make_func_name = block.name() +'::make' + # Don't want to risk writing to output twice. + if make_func_name not in make_funcs: + make_funcs.add(make_func_name) + output.append(make_block2_entry(di, block)) + except block.ParsingError: + sys.stderr.write('Parsing error for block {0}\n'.format(block.name())) + except: + tries, try_again = wait_if_necessary(tries, swigdocfilename, block) + if not try_again: + raise + else: + break # Create docstrings for functions # Don't include the make functions since they have already been dealt with. - funcs = [f for f in di.in_category(DoxyFunction) if f.name() not in make_funcs] + funcs = [f for f in di.in_category(DoxyFunction) + if f.name() not in make_funcs and not f.name().startswith('std::')] for f in funcs: try: output.append(make_func_entry(f)) except f.ParsingError: - sys.stderr.write('Parsing error for function {0}'.format(f.name())) + sys.stderr.write('Parsing error for function {0}\n'.format(f.name())) # Create docstrings for classes block_names = [block.name() for block in blocks] - klasses = [k for k in di.in_category(DoxyClass) if k.name() not in block_names] + block_names += [block.name() for block in blocks2] + klasses = [k for k in di.in_category(DoxyClass) + if k.name() not in block_names and not k.name().startswith('std::')] for k in klasses: try: output.append(make_class_entry(k)) except k.ParsingError: - sys.stderr.write('Parsing error for class {0}'.format(k.name())) + sys.stderr.write('Parsing error for class {0}\n'.format(k.name())) # Docstrings are not created for anything that is not a function or a class. # If this excludes anything important please add it here. @@ -291,19 +364,11 @@ if __name__ == "__main__": tries = 0 while(1): try: - make_swig_interface_file(di, swigdocfilename, custom_output=custom_output) + make_swig_interface_file(di, swigdocfilename, custom_output=custom_output, tries=tries) except: - if(tries < 3): - # May not be built just yet; sleep and try again - sys.stderr.write("XML parsing problem with file {0}, retrying.\n".format( - swigdocfilename)) - time.sleep(1) - tries += 1 - else: - # if we've given it three tries, give up and raise an error - sys.stderr.write("XML parsing error with file {0}. giving up.\n".format( - swigdocfilename)) + tries, try_again = wait_if_necessary(tries, swigdocfilename) + if not try_again: raise else: break - + diff --git a/docs/sphinx/CMakeLists.txt b/docs/sphinx/CMakeLists.txt new file mode 100644 index 0000000000..38d77fb3aa --- /dev/null +++ b/docs/sphinx/CMakeLists.txt @@ -0,0 +1,35 @@ +# 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. + +include(GrPython) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/source/conf.py.in + ${CMAKE_CURRENT_BINARY_DIR}/conf.py +@ONLY) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/run_sphinx_build.sh.in + ${CMAKE_BINARY_DIR}/run_sphinx_build.sh +@ONLY) + +if(UNIX) + #make the shell file executable + execute_process(COMMAND chmod +x ${CMAKE_BINARY_DIR}/run_sphinx_build.sh) +endif(UNIX) diff --git a/docs/sphinx/README b/docs/sphinx/README new file mode 100644 index 0000000000..0ae3a43f84 --- /dev/null +++ b/docs/sphinx/README @@ -0,0 +1,72 @@ +INTRODUCTION +The Sphinx documentation system uses the fully installed Python tree +to build a set of documents (generally in HTML). In GNU Radio, the +documentation system is done through Doxygen in the public header +(/include/foo.h) files. Doxygen first builds its documentation files, +then the swig_docs program uses Doxygen's XML output and smashed the +documentation from each header file into the SWIG'd Python +block. Basically, using a single documentation markup, Doxygen, we +expose the documentation strings in both the Doxygen-built manual and +within the Python blocks themselves. + +Sphinx takes this process one step farther by reading the docstrings +of all Python blocks and creating its own manual. This has two +benefits. First, the Sphinx documentation looks nice and is formatted +in such a way that Python users of GNU Radio can easy see the module +structure and hierarchy. It also not only takes the Doxygen +documentation from C++, but it also allows us to take any Python files +and include their documentation. + +The end result is two manuals: one for Python and one for C++ users +without having to duplicate comments, markup, or documentation. + + +BUILDING THE SPHINX MANUAL +Building the Sphinx docs takes some manual intervention as it +requires GNU Radio to already be installed. So first follow the steps +to build and install GNU Radio. + +In the build directory, a helper file is created called +run_sphinx_build.sh. This is a Linux shell script that runs the +sphinx-build command with all of the normal settings and important +directories preloaded. For non Linux systems, it should be easy to +pull out the executable and options to run it by hand. + +The run_sphinx_build.sh outputs the manual into +$builddir/docs/sphinx/sphinx_out. Open up the index.html file in a +browser to view it. + +ADDING NEW CONTENT TO THE SPHINX MANUAL +Although the content of the sphinx manual is automatically generated, +new blocks are not automatically added to the generated documentation. +The procedure for adding new content is best illustrated with two +examples. + +1) Adding a new C++ signal processing block gnuradio.gr.myslicer + Edit file gnuradio/docs/sphinx/source/gr/index.rst and add the line + > gnuradio.gr.myslicer + under the "Slicing and Dicing Streams" subheading. + Edit file gnuradio/docs/sphinx/source/gr/slicedice_blk.rst and add + the line + >.. autooldblock:: gnuradio.gr.myslicer + +2) Adding a new python hierarchical block gnuradio.digital.mymod + Edit file gnruadio/docs/sphinx/source/digital/index.rst and add the + line + > gnuradio.digital.mymod + under the "Signal Processing Blocks" subheading. + Edit file gnuradio/docs/sphinx/source/digital/blocks.rst and add + the line + >.. autopyblock:: gnuradio.digital.mymod + Notice that the 'autopyblock' directive is used rather than the + 'autoblock' directive. This lets sphinx know that it is displaying + a python hierarchical signal processing block so that it can format + it appropriately. + +The process for documenting objects that are not signal processing +blocks is similar but rather than using the 'autooldblock', and +'autopyblock' directives the standard sphinx directives such as +'autofunction' and 'autoclass' can be used. + +Finally for signal processing blocks using the 3.7 style the directive +'autoblock' rather than 'autooldblock' can be used.
\ No newline at end of file diff --git a/docs/sphinx/gnuradio_sphinx.py b/docs/sphinx/gnuradio_sphinx.py new file mode 100644 index 0000000000..e8ca867f8c --- /dev/null +++ b/docs/sphinx/gnuradio_sphinx.py @@ -0,0 +1,183 @@ +""" +Customizations of sphinx for gnuradio use. +""" + +from sphinx.ext.autodoc import py_ext_sig_re +from sphinx.ext.autodoc import ClassDocumenter, FunctionDocumenter, members_option +from sphinx.ext.autodoc import bool_option, members_set_option, identity +from sphinx.ext.autodoc import ALL + +# A dictionary of the number of lines to delete from the beginning of docstrings +lines_to_delete = {} + +def setup(sp): + # Fix line-breaks in signature. + sp.connect('autodoc-process-signature', fix_signature) + sp.connect('autodoc-process-docstring', remove_lines) + # Add node to autodocument signal-processing blocks. + sp.add_autodocumenter(OldBlockDocumenter) + sp.add_autodocumenter(BlockDocumenter) + sp.add_autodocumenter(PyBlockDocumenter) + +def remove_lines(app, what, name, obj, options, lines): + del_lines = lines_to_delete.get(name, 0) + # Don't delete any lines if this is called again. + lines_to_delete[name] = 0 + lines[:] = lines[del_lines:] + +def fix_signature(app, what, name, obj, options, signature, return_annotation): + """ + SWIG produces signature at the top of docstrings of the form + 'blah(int arg1, float arg2) -> return_type' + and if the string is long it breaks it over multiple lines. + + Sphinx gets confused if it is broken over multiple lines. + fix_signature and remove_lines get around this problem. + """ + if return_annotation is not None: + return + + if hasattr(obj, '__doc__'): + docs = obj.__doc__ + else: + docs = None + if not docs: + return None + doclines = docs.split('\n') + del_lines = remove_linebreaks_in_signature(doclines) + # match first line of docstring against signature RE + match = py_ext_sig_re.match(doclines[0]) + if not match: + return None + exmod, path, base, args, retann = match.groups() + # ok, now jump over remaining empty lines and set the remaining + # lines as the new doclines + i = 1 + while i < len(doclines) and not doclines[i].strip(): + i += 1 + lines_to_delete[name] = i - 1 + del_lines + # format args + signature = "({0})".format(args) + return signature, retann + +def remove_linebreaks_in_signature(lines): + alllines = '\n'.join(lines) + alllines = alllines.lstrip() + bits = alllines.split('->') + if len(bits) == 1: + return 0 + after = '->'.join(bits[1:]) + after_lines = after.split('\n') + ending = None + remainder = [] + for line in after_lines: + if line and ending is None: + ending = line + elif ending is not None: + remainder.append(line) + first_line = ' '.join([a.strip() for a in bits[0].split('\n') if a.strip()]) + ' -> ' + ending.strip() + match = py_ext_sig_re.match(first_line) + # If it is a signature, make the change to lines. + if match: + new_lines = [first_line] + remainder + lines[:] = new_lines + return len(bits[0].split('\n')) + else: + return 0 + +# These methods are not displayed in the documentation of blocks to +# avoid redundancy. +common_block_members =[ + 'check_topology', + 'detail', + 'history', + 'input_signature', + 'name', + 'nitems_read', + 'nitems_written', + 'nthreads', + 'output_multiple', + 'output_signature', + 'relative_rate', + 'set_detail', + 'set_nthreads', + 'start', + 'stop', + 'thisown', + 'to_basic_block', + 'unique_id', + 'make', + ] + +class OldBlockDocumenter(FunctionDocumenter): + """ + Specialized Documenter subclass for gnuradio blocks. + + It merges together the documentation for the generator function (e.g. gr.head) + with the wrapped sptr (e.g. gr.gr_head_sptr) to keep the documentation + tidier. + """ + objtype = 'oldblock' + directivetype = 'function' + # Don't want to use this for generic functions for give low priority. + priority = -10 + + def __init__(self, *args, **kwargs): + super(OldBlockDocumenter, self).__init__(*args, **kwargs) + # Get class name + bits = self.name.split('.') + if len(bits) != 3 or bits[0] != 'gnuradio': + raise ValueError("expected name to be of form gnuradio.x.y but it is {0}".format(self.name)) + sptr_name = 'gnuradio.{0}.{0}_{1}_sptr'.format(bits[1], bits[2]) + # Create a Class Documenter to create documentation for the classes members. + self.classdoccer = ClassDocumenter(self.directive, sptr_name, indent=self.content_indent) + self.classdoccer.doc_as_attr = False + self.classdoccer.real_modname = self.classdoccer.get_real_modname() + self.classdoccer.options.members = ALL + self.classdoccer.options.exclude_members = common_block_members + self.classdoccer.parse_name() + self.classdoccer.import_object() + + def document_members(self, *args, **kwargs): + return self.classdoccer.document_members(*args, **kwargs) + +class BlockDocumenter(FunctionDocumenter): + """ + Specialized Documenter subclass for new style gnuradio blocks. + + It merges together the documentation for the generator function (e.g. wavelet.squash_ff) + with the wrapped sptr (e.g. wavelet.squash_ff_sptr) to keep the documentation + tidier. + """ + objtype = 'block' + directivetype = 'function' + # Don't want to use this for generic functions for give low priority. + priority = -10 + + def __init__(self, *args, **kwargs): + super(BlockDocumenter, self).__init__(*args, **kwargs) + # Get class name + sptr_name = self.name + '_sptr' + # Create a Class Documenter to create documentation for the classes members. + self.classdoccer = ClassDocumenter(self.directive, sptr_name, indent=self.content_indent) + self.classdoccer.doc_as_attr = False + self.classdoccer.real_modname = self.classdoccer.get_real_modname() + self.classdoccer.options.members = ALL + self.classdoccer.options.exclude_members = common_block_members + self.classdoccer.parse_name() + self.classdoccer.import_object() + + def document_members(self, *args, **kwargs): + return self.classdoccer.document_members(*args, **kwargs) + +class PyBlockDocumenter(ClassDocumenter): + """ + Specialized Documenter subclass for hierarchical python gnuradio blocks. + """ + objtype = 'pyblock' + directivetype = 'class' + + def __init__(self, *args, **kwargs): + super(PyBlockDocumenter, self).__init__(*args, **kwargs) + self.options.members = ALL + self.options.exclude_members = common_block_members diff --git a/docs/sphinx/hieroglyph/LICENSE.txt b/docs/sphinx/hieroglyph/LICENSE.txt new file mode 100644 index 0000000000..3f7a638305 --- /dev/null +++ b/docs/sphinx/hieroglyph/LICENSE.txt @@ -0,0 +1,26 @@ +Copyright (c) 2011, Robert Smallshire +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Robert Smallshire nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/docs/sphinx/hieroglyph/README.txt b/docs/sphinx/hieroglyph/README.txt new file mode 100644 index 0000000000..c26409d896 --- /dev/null +++ b/docs/sphinx/hieroglyph/README.txt @@ -0,0 +1,10 @@ +Sphinx is a popular tool for documenting Python APIs which uses reStructuredText +as a its lightweight markup language. Sphinx extends restructured text with +semantic markup elements for documenting Python APIs but once these are used the +ratio of markup to content becomes too high and readability is compromised +enough that the docstring becomes unsuitable for use with standard Python +introspection mechanisms like help() or IDEs. + +Hieroglyph is an a Sphinx extension which automatically converts a highly +readable docstring format suitable for use with help() and IDEs to the +reStructuredText hieroglyphics required by Sphinx.
\ No newline at end of file diff --git a/docs/sphinx/hieroglyph/__init__.py b/docs/sphinx/hieroglyph/__init__.py new file mode 100644 index 0000000000..25dea27fba --- /dev/null +++ b/docs/sphinx/hieroglyph/__init__.py @@ -0,0 +1,6 @@ +# We only need to expose the setup function to Sphinx + +from .hieroglyph import setup +from .version import __version__ + +__author__ = 'Robert Smallshire'
\ No newline at end of file diff --git a/docs/sphinx/hieroglyph/errors.py b/docs/sphinx/hieroglyph/errors.py new file mode 100644 index 0000000000..334b097d8a --- /dev/null +++ b/docs/sphinx/hieroglyph/errors.py @@ -0,0 +1,10 @@ +
+from sphinx.errors import ExtensionError
+
+__author__ = 'rjs'
+
+class HieroglyphError(ExtensionError):
+ '''
+ An exception type specific to the Hieroglyph Sphinx extension.
+ '''
+ pass
\ No newline at end of file diff --git a/docs/sphinx/hieroglyph/hieroglyph.py b/docs/sphinx/hieroglyph/hieroglyph.py new file mode 100644 index 0000000000..0056d9ab8a --- /dev/null +++ b/docs/sphinx/hieroglyph/hieroglyph.py @@ -0,0 +1,404 @@ +from __future__ import print_function + +import re + +from errors import HieroglyphError +from nodes import (Node, Raises, Except, Note, Warning, Returns, Arg, + ensure_terminal_blank) + +__author__ = 'Robert Smallshire' + +def parse_hieroglyph_text(lines): + '''Parse text in hieroglyph format and return a reStructuredText equivalent + + Args: + lines: A sequence of strings representing the lines of a single + docstring as read from the source by Sphinx. This string should be + in a format that can be parsed by hieroglyph. + + Returns: + A list of lines containing the transformed docstring as + reStructuredText as produced by hieroglyph. + + Raises: + RuntimeError: If the docstring cannot be parsed. + ''' + indent_lines = unindent(lines) + indent_lines = pad_blank_lines(indent_lines) + indent_lines = first_paragraph_indent(indent_lines) + indent_paragraphs = gather_lines(indent_lines) + parse_tree = group_paragraphs(indent_paragraphs) + syntax_tree = extract_structure(parse_tree) + result = syntax_tree.render_rst() + ensure_terminal_blank(result) + return result + + +def unindent(lines): + '''Convert an iterable of indented lines into a sequence of tuples. + + The first element of each tuple is the indent in number of characters, and + the second element is the unindented string. + + Args: + lines: A sequence of strings representing the lines of text in a docstring. + + Returns: + A list of tuples where each tuple corresponds to one line of the input + list. Each tuple has two entries - the first is an integer giving the + size of the indent in characters, the second is the unindented text. + ''' + unindented_lines = [] + for line in lines: + unindented_line = line.lstrip() + indent = len(line) - len(unindented_line) + unindented_lines.append((indent, unindented_line)) + return unindented_lines + + +def pad_blank_lines(indent_texts): + '''Give blank (empty) lines the same indent level as the preceding line. + + Args: + indent_texts: An iterable of tuples each containing an integer in the + first element and a string in the second element. + + Returns: + A list of tuples each containing an integer in the first element and a + string in the second element. + ''' + current_indent = 0 + result = [] + for indent, text in indent_texts: + if len(text) > 0: + current_indent = indent + result.append((current_indent, text)) + return result + + +def extract_structure(parse_tree): + '''Create an Abstract Syntax Tree representing the semantics of a parse tree. + + Args: + parse_tree: TODO + + Returns: + A Node with is the result of an Abstract Syntax Tree representing the + docstring. + + Raises: + HieroglyphError: In the event that the parse tree cannot be understood. + ''' + return convert_node(parse_tree) + + +def convert_node(node): + if node.indent == 0 and len(node.lines) == 0: + return convert_children(node) + if node.lines[0].startswith('Args:'): + return convert_args(node) + if node.lines[0].startswith('Returns:'): + return convert_returns(node) + if node.lines[0].startswith('Raises:'): + return convert_raises(node) + if node.lines[0].startswith('Note:'): + return convert_note(node) + if node.lines[0].startswith('Warning:'): + return convert_warning(node) + result = convert_children(node) + result.lines = node.lines + result.indent = node.indent + return result + + +def convert_children(node): + converted_children = [convert_node(child) for child in node.children] + result = Node() + result.children = converted_children + return result + + +ARG_REGEX = re.compile(r'(\*{0,2}\w+)(\s+\((\w+)\))?\s*:\s*(.*)') + +def append_child_to_args_group_node(child, group_node, indent): + arg = None + non_empty_lines = (line for line in child.lines if line) + for line in non_empty_lines: + m = ARG_REGEX.match(line) + if m is None: + raise HieroglyphError("Invalid hieroglyph argument syntax: {0}".format(line)) + param_name = m.group(1) + param_type = m.group(3) + param_text = m.group(4) + + arg = Arg(indent, child.indent, param_name) + group_node.children.append(arg) + arg.type = param_type + + if param_text is not None: + arg.children.append(Node(indent, [param_text], arg)) + if arg is not None: + last_child = arg.children[-1] if len(arg.children) != 0 else arg + for grandchild in child.children: + last_child.children.append(grandchild) + + +def convert_args(node): + assert node.lines[0].startswith('Args:') + group_node = Node() + for child in node.children: + append_child_to_args_group_node(child, group_node, node.indent) + return group_node + + +def convert_returns(node): + assert node.lines[0].startswith('Returns:') + returns = Returns(node.indent) + returns.line = node.lines[0][8:].strip() + returns.children = node.children + return returns + + +def convert_note(node): + assert node.lines[0].startswith('Note:') + note = Note(node.indent) + note.line = node.lines[0][5:].strip() + note.children = node.children + return note + + +def convert_warning(node): + assert node.lines[0].startswith('Warning:') + warning = Warning(node.indent) + warning.line = node.lines[0][8:].strip() + warning.children = node.children + return warning + + +def convert_raises(node): + assert node.lines[0].startswith('Raises:') + group_node = Raises(node.indent) + for child in node.children: + append_child_to_raise_node(child, group_node) + return group_node + + +RAISE_REGEX = re.compile(r'(\w+)\s*:\s*(.*)') + +def extract_exception_type_and_text(line): + m = RAISE_REGEX.match(line) + if m is None: + raise HieroglyphError("Invalid hieroglyph exception syntax: {0}".format(line)) + return (m.group(2), m.group(1)) + + +def append_child_to_raise_node(child, group_node): + exception = None + non_empty_lines = (line for line in child.lines if line) + for line in non_empty_lines: + exception_text, exception_type = extract_exception_type_and_text(line) + + exception = Except(child.indent, exception_type) + group_node.children.append(exception) # TODO: Could use parent here. + + if exception_text is not None: + exception.children.append( Node(child.indent, + [exception_text], exception)) + if exception is not None: + last_child = exception.children[-1] if len(exception.children) != 0 else exception + for grandchild in child.children: + last_child.children.append(grandchild) + + +def group_paragraphs(indent_paragraphs): + ''' + Group paragraphs so that more indented paragraphs become children of less + indented paragraphs. + ''' + # The tree consists of tuples of the form (indent, [children]) where the + # children may be strings or other tuples + + root = Node(0, [], None) + current_node = root + + previous_indent = -1 + for indent, lines in indent_paragraphs: + if indent > previous_indent: + current_node = create_child_node(current_node, indent, lines) + elif indent == previous_indent: + current_node = create_sibling_node(current_node, indent, lines) + elif indent < previous_indent: + current_node = create_uncle_node(current_node, indent, lines) + previous_indent = indent + return root + + +def create_sibling_node(current_node, indent, lines): + sibling = Node(indent, lines, current_node.parent) + current_node.parent.add_child(sibling) + current_node = sibling + return current_node + + +def create_child_node(current_node, indent, lines): + child = Node(indent, lines, current_node) + current_node.add_child(child) + current_node = child + return current_node + + +def create_uncle_node(current_node, indent, lines): + ancestor = current_node + while ancestor.indent >= indent: + if ancestor.parent is None: + break + ancestor = ancestor.parent + uncle = Node(indent, lines, ancestor) + ancestor.add_child(uncle) + current_node = uncle + return current_node + + +def gather_lines(indent_lines): + '''Split the list of (int, str) tuples into a list of (int, [str]) tuples + to group the lines into paragraphs of consistent indent. + ''' + return remove_empty_paragraphs(split_separated_lines(gather_lines_by_indent(indent_lines))) + +def gather_lines_by_indent(indent_lines): + result = [] + previous_indent = -1 + for indent, line in indent_lines: + if indent != previous_indent: + paragraph = (indent, []) + result.append(paragraph) + else: + paragraph = result[-1] + paragraph[1].append(line) + previous_indent = indent + return result + +def split_separated_lines(indent_paragraphs): + result = [] + for indent, paragraph in indent_paragraphs: + result.append((indent, [])) + + if len(paragraph) > 0: + result[-1][1].append(paragraph[0]) + + if len(paragraph) > 2: + for line in paragraph[1: -1]: + result[-1][1].append(line) + if len(line) == 0: + result.append((indent, [])) + + if len(paragraph) > 1: + result[-1][1].append(paragraph[-1]) + + return result + +def remove_empty_paragraphs(indent_paragraphs): + return [(indent, paragraph) for indent, paragraph in indent_paragraphs if len(paragraph)] + +def first_paragraph_indent(indent_texts): + '''Fix the indentation on the first paragraph. + + This occurs because the first line of a multi-line docstring following the + opening quote usually has no indent. + + Args: + indent_texts: The lines of the docstring as an iterable over 2-tuples + each containing an integer indent level as the first element and + the text as the second element. + + Return: + A list of 2-tuples, each containing an integer indent level as the + first element and the text as the second element. + ''' + opening_indent = determine_opening_indent(indent_texts) + + result = [] + input = iter(indent_texts) + for indent, text in input: + if indent == 0: + result.append((opening_indent, text)) + else: + result.append((indent, text)) + break + + for indent, text in input: + result.append((indent, text)) + + return result + + +def determine_opening_indent(indent_texts): + '''Determine the opening indent level for a docstring. + + The opening indent level is the indent level is the first non-zero indent + level of a non-empty line in the docstring. + + Args: + indent_texts: The lines of the docstring as an iterable over 2-tuples + each containing an integer indent level as the first element and + the text as the second element. + + Returns: + The opening indent level as an integer. + ''' + num_lines = len(indent_texts) + + if num_lines < 1: + return 0 + + assert num_lines >= 1 + + first_line_indent = indent_texts[0][0] + + if num_lines == 1: + return first_line_indent + + assert num_lines >= 2 + + second_line_indent = indent_texts[1][0] + second_line_text = indent_texts[1][1] + + if len(second_line_text) == 0: + return first_line_indent + + return second_line_indent + + + +def rewrite_autodoc(app, what, name, obj, options, lines): + '''Convert lines from Hieroglyph to Sphinx format. + + The function to be called by the Sphinx autodoc extension when autodoc + has read and processed a docstring. This function modified its + ``lines`` argument *in place* replacing Hieroglyph syntax input into + Sphinx reStructuredText output. + + Args: + apps: The Sphinx application object. + + what: The type of object which the docstring belongs to. One of + 'module', 'class', 'exception', 'function', 'method', 'attribute' + + name: The fully qualified name of the object. + + obj: The object itself. + + options: The options given to the directive. An object with attributes + ``inherited_members``, ``undoc_members``, ``show_inheritance`` and + ``noindex`` that are ``True`` if the flag option of the same name + was given to the auto directive. + + lines: The lines of the docstring. Will be modified *in place*. + ''' + lines[:] = parse_hieroglyph_text(lines) + + +def setup(app): + app.connect('autodoc-process-docstring', rewrite_autodoc) + + diff --git a/docs/sphinx/hieroglyph/nodes.py b/docs/sphinx/hieroglyph/nodes.py new file mode 100644 index 0000000000..e583ce04d7 --- /dev/null +++ b/docs/sphinx/hieroglyph/nodes.py @@ -0,0 +1,267 @@ +__author__ = 'Robert Smallshire'
+
+class Node(object):
+
+ def __init__(self, indent=None, lines=None, parent=None):
+ if indent is not None:
+ self.indent = indent
+ else:
+ self.indent = 0
+
+ if lines is not None:
+ self.lines = lines
+ else:
+ self.lines = []
+
+ self._parent = parent
+
+ self.children = []
+
+ parent = property(lambda self: self._parent)
+
+ def add_child(self, child):
+ assert(child.parent is self)
+ self.children.append(child)
+
+
+ def __repr__(self):
+ return "Node(" + repr(self.indent) + ", " + repr(self.lines) + ", children=" + repr(self.children) + ")"
+
+
+ def render_rst(self, *args, **kwargs):
+ result = []
+ prefix = ' ' * self.indent
+ result.extend(prefix + line for line in self.lines)
+ for child in self.children:
+ result.extend(child.render_rst())
+ return result
+
+
+
+class Arg(Node):
+
+ def __init__(self, indent, child_indent, name):
+ super(Arg, self).__init__(indent)
+ self.child_indent = child_indent
+ self.name = name
+ self.type = None
+
+
+ def __repr__(self):
+ return "Arg(" + repr(self.name) + ", " + repr(self.type) + ", children=" + repr(self.children) + ")"
+
+
+ def render_rst(self, *args, **kwargs):
+ result = []
+ indent = ' ' * self.indent
+
+ # Render the param description
+ description = []
+ for child in self.children:
+ child_lines = child.render_rst()
+ description.extend(child_lines)
+
+ dedent = self.child_indent - self.indent
+
+ name = self.name.replace('*', r'\*')
+
+ first_description = description[0].lstrip() if len(description) else ''
+ if not first_description:
+ # TODO: Emit a warning about a missing argument description
+ pass
+
+ result.append("{indent}:param {name}: {first_description}".format(indent=indent, name=name,
+ first_description=first_description))
+
+ dedented_body = [line[dedent:] for line in description[1:]]
+
+ result.extend(dedented_body)
+
+ # If a type was specified render the type
+ if self.type is not None:
+ result.append("{indent}:type {name}: {type}".format(indent=indent, name=self.name, type=self.type))
+ result.append('')
+
+ ensure_terminal_blank(result)
+
+ return result
+
+
+
+class Raises(Node):
+
+ def __init__(self, indent=None):
+ super(Raises, self).__init__(indent=indent)
+
+ def __repr__(self):
+ return "Raises(" + repr(self.indent) + ", children=" + repr(self.children) + ")"
+
+
+ def render_rst(self, *args, **kwargs):
+ result = []
+ indent = ' ' * self.indent
+ result.append(indent + ':raises:')
+ for child in self.children:
+ result.extend(child.render_rst(only_child=len(self.children) == 1))
+
+ ensure_terminal_blank(result)
+
+ return result
+
+
+class Except(Node):
+
+ def __init__(self, indent, type):
+ super(Except, self).__init__(indent=indent)
+ #self.child_indent = child_indent
+ self.type = type
+
+
+ def __repr__(self):
+ return "Except(" + repr(self.type) + ", children=" + repr(self.children) + ")"
+
+
+ def render_rst(self, only_child=False, *args, **kwargs):
+ result = []
+ indent = ' ' * self.indent
+
+ # Render the param description
+ description = []
+ for child in self.children:
+ child_lines = child.render_rst()
+ description.extend(child_lines)
+
+ #dedent = self.child_indent - self.indent
+ bullet = '* ' if not only_child else ''
+
+ first_description = description[0].lstrip() if len(description) else ''
+ result.append("{indent}{bullet}{type} - {first_description}".format(indent=indent,
+ bullet=bullet, type=self.type,
+ first_description=first_description))
+
+ #dedented_body = [' ' * len(bullet) + line[dedent:] for line in description[1:]]
+ #result.extend(dedented_body)
+ result.extend(description[1:])
+ ensure_terminal_blank(result)
+
+ return result
+
+
+
+class Returns(Node):
+
+ def __init__(self, indent):
+ super(Returns, self).__init__(indent=indent)
+ self.title = 'Returns'
+ self.line = ''
+
+
+ def __repr__(self):
+ return "Returns(" + str(self.indent) + ", children=" + str(self.children) + ")"
+
+
+ def render_rst(self, *args, **kwargs):
+ result = []
+ indent = ' ' * self.indent
+
+ # Render the param description
+ description = [self.line] if self.line else []
+ for child in self.children:
+ child_lines = child.render_rst()
+ description.extend(child_lines)
+
+ self.render_title(description, indent, result)
+
+ result.extend(description[1:])
+
+ ensure_terminal_blank(result)
+ return result
+
+
+ def render_title(self, description, indent, result):
+ result.append(
+ "{indent}:returns: {first_description}".format(indent=indent,
+ first_description=description[0].lstrip()))
+
+
+
+class Warning(Node):
+
+ def __init__(self, indent):
+ super(Warning, self).__init__(indent=indent)
+
+ def __repr__(self):
+ return "Warning(" + repr(self.indent) + ", children=" + str(self.children) + ")"
+
+ def render_rst(self, *args, **kwargs):
+ # TODO: Factor out the commonality between this and Note below
+ result = []
+ indent = ' ' * self.indent
+
+ # Render the param description
+ description = [self.line] if self.line else []
+ for child in self.children:
+ child_lines = child.render_rst()
+ description.extend(child_lines)
+
+ # Fix the indent on the first line
+ if len(description) > 1 and len(description[1].strip()) != 0:
+ body_indent = len(description[1]) - len(description[1].strip())
+ else:
+ body_indent = self.indent + 4
+
+ if len(description) > 0:
+ description[0] = ' ' * body_indent + description[0]
+
+ result.append(indent + ".. warning::")
+ result.append(indent + '')
+ result.extend(description)
+
+ ensure_terminal_blank(result)
+ return result
+
+
+class Note(Node):
+
+ def __init__(self, indent):
+ super(Note, self).__init__(indent=indent)
+ self.line = ''
+
+
+ def __repr__(self):
+ return "Note(" + repr(self.indent) + ", children=" + str(self.children) + ")"
+
+
+ def render_rst(self, *args, **kwargs):
+ # TODO: Factor out the commonality between this and Warning above
+ result = []
+ indent = ' ' * self.indent
+
+ # Render the param description
+ description = [self.line] if self.line else []
+ for child in self.children:
+ child_lines = child.render_rst()
+ description.extend(child_lines)
+
+ # Fix the indent on the first line
+ if len(description) > 1 and len(description[1].strip()) != 0:
+ body_indent = len(description[1]) - len(description[1].strip())
+ else:
+ body_indent = self.indent + 4
+
+ if len(description) > 0:
+ description[0] = ' ' * body_indent + description[0]
+
+ result.append(indent + ".. note::")
+ result.append(indent + '')
+ result.extend(description)
+
+ ensure_terminal_blank(result)
+ return result
+
+
+def ensure_terminal_blank(result):
+ '''If the description didn't end with a blank line add one here.'''
+ if len(result) > 0:
+ if len(result[-1].strip()) != 0:
+ result.append('')
diff --git a/docs/sphinx/hieroglyph/test/__init__.py b/docs/sphinx/hieroglyph/test/__init__.py new file mode 100644 index 0000000000..fd249423f2 --- /dev/null +++ b/docs/sphinx/hieroglyph/test/__init__.py @@ -0,0 +1,2 @@ +__author__ = 'rjs' +
\ No newline at end of file diff --git a/docs/sphinx/hieroglyph/test/test_comments.py b/docs/sphinx/hieroglyph/test/test_comments.py new file mode 100644 index 0000000000..d1a1453ee1 --- /dev/null +++ b/docs/sphinx/hieroglyph/test/test_comments.py @@ -0,0 +1,586 @@ +import unittest + +from hieroglyph.hieroglyph import parse_hieroglyph_text +from hieroglyph.errors import HieroglyphError + +class CommentTests(unittest.TestCase): + + def test_comment1(self): + source = """Fetches rows from a Bigtable. + This is a continuation of the opening paragraph. + + Retrieves rows pertaining to the given keys from the Table instance + represented by big_table. Silly things may happen if + other_silly_variable is not None. + + Args: + big_table: An open Bigtable Table instance. + keys: A sequence of strings representing the key of each table row + to fetch. + other_silly_variable (str): Another optional variable, that has a much + longer name than the other args, and which does nothing. + + Returns: + A dict mapping keys to the corresponding table row data + fetched. Each row is represented as a tuple of strings. For + example: + + {'Serak': ('Rigel VII', 'Preparer'), + 'Zim': ('Irk', 'Invader'), + 'Lrrr': ('Omicron Persei 8', 'Emperor')} + + If a key from the keys argument is missing from the dictionary, + then that row was not found in the table. + + Raises: + IOError: An error occurred accessing the bigtable.Table object. + """ + + expected = """ Fetches rows from a Bigtable. + This is a continuation of the opening paragraph. + + Retrieves rows pertaining to the given keys from the Table instance + represented by big_table. Silly things may happen if + other_silly_variable is not None. + + :param big_table: An open Bigtable Table instance. + + :param keys: A sequence of strings representing the key of each table row + to fetch. + + :param other_silly_variable: Another optional variable, that has a much + longer name than the other args, and which does nothing. + + :type other_silly_variable: str + + :returns: A dict mapping keys to the corresponding table row data + fetched. Each row is represented as a tuple of strings. For + example: + + {'Serak': ('Rigel VII', 'Preparer'), + 'Zim': ('Irk', 'Invader'), + 'Lrrr': ('Omicron Persei 8', 'Emperor')} + + If a key from the keys argument is missing from the dictionary, + then that row was not found in the table. + + :raises: + IOError - An error occurred accessing the bigtable.Table object. + """ + source_lines = source.splitlines() + actual_lines = parse_hieroglyph_text(source_lines) + expected_lines = expected.splitlines() + self.assertEqual(len(actual_lines), len(expected_lines)) + for actual_line, result_line in zip(actual_lines, expected_lines): + if len(actual_line.strip()) == 0: + self.assertTrue(len(result_line.strip()) == 0) + else: + self.assertEqual(actual_line, result_line) + + def test_comment2(self): + source = """Determine if all elements in the source sequence satisfy a condition. + + All of the source sequence will be consumed. + + Note: This method uses immediate execution. + + Args: + predicate: An optional single argument function used to test each + elements. If omitted, the bool() function is used resulting in + the elements being tested directly. + + Returns: + True if all elements in the sequence meet the predicate condition, + otherwise False. + + Raises: + ValueError: If the Queryable is closed() + TypeError: If predicate is not callable. + """ + + expected = """Determine if all elements in the source sequence satisfy a condition. + + All of the source sequence will be consumed. + + .. note:: + + This method uses immediate execution. + + :param predicate: An optional single argument function used to test each + elements. If omitted, the bool() function is used resulting in + the elements being tested directly. + + :returns: True if all elements in the sequence meet the predicate condition, + otherwise False. + + :raises: + * ValueError - If the Queryable is closed() + + * TypeError - If predicate is not callable. + """ + source_lines = source.splitlines() + actual_lines = parse_hieroglyph_text(source_lines) + expected_lines = expected.splitlines() + self.assertEqual(len(actual_lines), len(expected_lines)) + for actual_line, result_line in zip(actual_lines, expected_lines): + if len(actual_line.strip()) == 0: + self.assertTrue(len(result_line.strip()) == 0) + else: + self.assertEqual(actual_line, result_line) + + def test_comment3(self): + source = """Determine if all elements in the source sequence satisfy a condition. + + All of the source sequence will be consumed. + + Note: This method uses immediate execution. + + Args: + predicate: An optional single argument function used to test each + elements. If omitted, the bool() function is used resulting in + the elements being tested directly. + + Returns: + True if all elements in the sequence meet the predicate condition, + otherwise False. + + Raises: + ValueError: If the Queryable is closed() + TypeError: If predicate is not callable. + """ + + expected = """Determine if all elements in the source sequence satisfy a condition. + + All of the source sequence will be consumed. + + .. note:: + + This method uses immediate execution. + + :param predicate: An optional single argument function used to test each + elements. If omitted, the bool() function is used resulting in + the elements being tested directly. + + :returns: True if all elements in the sequence meet the predicate condition, + otherwise False. + + :raises: + * ValueError - If the Queryable is closed() + + * TypeError - If predicate is not callable. + """ + source_lines = source.splitlines() + actual_lines = parse_hieroglyph_text(source_lines) + expected_lines = expected.splitlines() + self.assertEqual(len(actual_lines), len(expected_lines)) + for actual_line, result_line in zip(actual_lines, expected_lines): + if len(actual_line.strip()) == 0: + self.assertTrue(len(result_line.strip()) == 0) + else: + self.assertEqual(actual_line, result_line) + + def test_comment4(self): + source_lines = [u'Determine if all elements in the source sequence satisfy a condition.', + u'', + u'All of the source sequence will be consumed.', + u'', + u'Note: This method uses immediate execution.', + u'', + u'Args:', + u' predicate: An optional single argument function used to test each', + u' elements. If omitted, the bool() function is used resulting in', + u' the elements being tested directly.', + u'', + u'Returns:', + u' True if all elements in the sequence meet the predicate condition,', + u' otherwise False.', + u'', + u'Raises:', + u' ValueError: If the Queryable is closed()', + u' TypeError: If predicate is not callable.', + u''] + + expected = """Determine if all elements in the source sequence satisfy a condition. + +All of the source sequence will be consumed. + +.. note:: + + This method uses immediate execution. + +:param predicate: An optional single argument function used to test each + elements. If omitted, the bool() function is used resulting in + the elements being tested directly. + +:returns: True if all elements in the sequence meet the predicate condition, + otherwise False. + +:raises: + * ValueError - If the Queryable is closed() + + * TypeError - If predicate is not callable. + +""" + actual_lines = parse_hieroglyph_text(source_lines) + expected_lines = expected.splitlines() + self.assertEqual(len(actual_lines), len(expected_lines)) + for actual_line, result_line in zip(actual_lines, expected_lines): + if len(actual_line.strip()) == 0: + self.assertTrue(len(result_line.strip()) == 0) + else: + self.assertEqual(actual_line, result_line) + + def test_comment5(self): + source_lines = [u'An empty Queryable.', + u'', + u'Note: The same empty instance will be returned each time.', + u'', + u'Returns: A Queryable over an empty sequence.', + u''] + + expected = """An empty Queryable. + +.. note:: + + The same empty instance will be returned each time. + +:returns: A Queryable over an empty sequence. + +""" + actual_lines = parse_hieroglyph_text(source_lines) + expected_lines = expected.splitlines() + self.assertEqual(len(actual_lines), len(expected_lines)) + for actual_line, result_line in zip(actual_lines, expected_lines): + if len(actual_line.strip()) == 0: + self.assertTrue(len(result_line.strip()) == 0) + else: + self.assertEqual(actual_line, result_line) + + def test_comment6(self): + source_lines = [u'A convenience factory for creating Records.', + u'', + u'Args:', + u' **kwargs: Each keyword argument will be used to initialise an', + u' attribute with the same name as the argument and the given', + u' value.', + u'', + u'Returns:', + u' A Record which has a named attribute for each of the keyword arguments.', + u''] + + expected = """A convenience factory for creating Records. + +:param \*\*kwargs: Each keyword argument will be used to initialise an + attribute with the same name as the argument and the given + value. + +:returns: A Record which has a named attribute for each of the keyword arguments. + +""" + actual_lines = parse_hieroglyph_text(source_lines) + expected_lines = expected.splitlines() + self.assertEqual(len(actual_lines), len(expected_lines)) + for actual_line, result_line in zip(actual_lines, expected_lines): + if len(actual_line.strip()) == 0: + self.assertTrue(len(result_line.strip()) == 0) + else: + self.assertEqual(actual_line, result_line) + + def test_comment7(self): + source = """Projects each element of a sequence to an intermediate new sequence, + flattens the resulting sequences into one sequence and optionally + transforms the flattened sequence using a selector function. + + Note: This method uses deferred execution. + + Args: + collection_selector: A unary function mapping each element of the + source iterable into an intermediate sequence. The single + argument of the collection_selector is the value of an element + from the source sequence. The return value should be an + iterable derived from that element value. The default + collection_selector, which is the identity function, assumes + that each element of the source sequence is itself iterable. + + result_selector: An optional unary function mapping the elements in + the flattened intermediate sequence to corresponding elements + of the result sequence. The single argument of the + result_selector is the value of an element from the flattened + intermediate sequence. The return value should be the + corresponding value in the result sequence. The default + result_selector is the identity function. + + Returns: + A Queryable over a generated sequence whose elements are the result + of applying the one-to-many collection_selector to each element of + the source sequence, concatenating the results into an intermediate + sequence, and then mapping each of those elements through the + result_selector into the result sequence. + + Raises: + ValueError: If this Queryable has been closed. + TypeError: If either collection_selector or result_selector are not + callable. + """ + + expected = """ Projects each element of a sequence to an intermediate new sequence, + flattens the resulting sequences into one sequence and optionally + transforms the flattened sequence using a selector function. + + .. note:: + + This method uses deferred execution. + + :param collection_selector: A unary function mapping each element of the + source iterable into an intermediate sequence. The single + argument of the collection_selector is the value of an element + from the source sequence. The return value should be an + iterable derived from that element value. The default + collection_selector, which is the identity function, assumes + that each element of the source sequence is itself iterable. + + :param result_selector: An optional unary function mapping the elements in + the flattened intermediate sequence to corresponding elements + of the result sequence. The single argument of the + result_selector is the value of an element from the flattened + intermediate sequence. The return value should be the + corresponding value in the result sequence. The default + result_selector is the identity function. + + :returns: A Queryable over a generated sequence whose elements are the result + of applying the one-to-many collection_selector to each element of + the source sequence, concatenating the results into an intermediate + sequence, and then mapping each of those elements through the + result_selector into the result sequence. + + :raises: + * ValueError - If this Queryable has been closed. + + * TypeError - If either collection_selector or result_selector are not + callable. + """ + source_lines = source.splitlines() + actual_lines = parse_hieroglyph_text(source_lines) + expected_lines = expected.splitlines() + self.assertEqual(len(actual_lines), len(expected_lines)) + for actual_line, result_line in zip(actual_lines, expected_lines): + if len(actual_line.strip()) == 0: + self.assertTrue(len(result_line.strip()) == 0) + else: + self.assertEqual(actual_line, result_line) + + def test_comment8(self): + source = """A convenience factory for creating Records. + + Args: + **kwargs: Each keyword argument will be used to initialise an + attribute with the same name as the argument and the given + value. + + Returns: + A Record which has a named attribute for each of the keyword arguments. + """ + + expected = """A convenience factory for creating Records. + + :param \*\*kwargs: Each keyword argument will be used to initialise an + attribute with the same name as the argument and the given + value. + + :returns: A Record which has a named attribute for each of the keyword arguments. + +""" + source_lines = source.splitlines() + actual_lines = parse_hieroglyph_text(source_lines) + expected_lines = expected.splitlines() + self.assertEqual(len(actual_lines), len(expected_lines)) + for actual_line, result_line in zip(actual_lines, expected_lines): + if len(actual_line.strip()) == 0: + self.assertTrue(len(result_line.strip()) == 0) + else: + self.assertEqual(actual_line, result_line) + + def test_comment9(self): + source_lines = [u'Parse a single line of a tree to determine depth and node.', + u'', + u'Args:', + u' This line is missing an argument name.', + u' ', + u'Returns:', + u' A 2-tuple containing the tree 0 based tree depth as the first', + u' element and the node description as the second element.', + u'', + u'Raises:', + u' ValueError: If line does not have the expected form.', + u''] + + self.assertRaises(HieroglyphError, lambda: parse_hieroglyph_text(source_lines)) + + def test_comment10(self): + source = """ + Execute the command described by concatenating the string function arguments + with the p4 -s global scripting flag and return the results in a dictionary. + + For example, to run the command:: + + p4 -s fstat -T depotFile foo.h + + call:: + + p4('fstat', '-T', 'depotFile', 'foo.h') + + Args: + args: The arguments to the p4 command as a list of objects which will + be converted to strings. + + Returns: + A dictionary of lists where each key in the dictionary is the field name + from the command output, and each value is a list of output lines in + order. + + Raises: + PerforceError: If the command could not be run or if the command + reported an error. + """ + + expected = """ + Execute the command described by concatenating the string function arguments + with the p4 -s global scripting flag and return the results in a dictionary. + + For example, to run the command:: + + p4 -s fstat -T depotFile foo.h + + call:: + + p4('fstat', '-T', 'depotFile', 'foo.h') + + :param args: The arguments to the p4 command as a list of objects which will + be converted to strings. + + :returns: A dictionary of lists where each key in the dictionary is the field name + from the command output, and each value is a list of output lines in + order. + + :raises: + PerforceError - If the command could not be run or if the command + reported an error. + +""" + + source_lines = source.splitlines() + actual_lines = parse_hieroglyph_text(source_lines) + expected_lines = expected.splitlines() + self.assertEqual(len(actual_lines), len(expected_lines)) + for actual_line, result_line in zip(actual_lines, expected_lines): + if len(actual_line.strip()) == 0: + self.assertTrue(len(result_line.strip()) == 0) + else: + self.assertEqual(actual_line, result_line) + + def test_comment11(self): + source = """Projects each element of a sequence to an intermediate new sequence, + flattens the resulting sequences into one sequence and optionally + transforms the flattened sequence using a selector function. + + Warning: This method may explode at short notice. + + Args: + collection_selector: A unary function mapping each element of the + source iterable into an intermediate sequence. The single + argument of the collection_selector is the value of an element + from the source sequence. The return value should be an + iterable derived from that element value. The default + collection_selector, which is the identity function, assumes + that each element of the source sequence is itself iterable. + + result_selector: An optional unary function mapping the elements in + the flattened intermediate sequence to corresponding elements + of the result sequence. The single argument of the + result_selector is the value of an element from the flattened + intermediate sequence. The return value should be the + corresponding value in the result sequence. The default + result_selector is the identity function. + + Returns: + A Queryable over a generated sequence whose elements are the result + of applying the one-to-many collection_selector to each element of + the source sequence, concatenating the results into an intermediate + sequence, and then mapping each of those elements through the + result_selector into the result sequence. + + Raises: + ValueError: If this Queryable has been closed. + TypeError: If either collection_selector or result_selector are not + callable. + """ + + expected = """ Projects each element of a sequence to an intermediate new sequence, + flattens the resulting sequences into one sequence and optionally + transforms the flattened sequence using a selector function. + + .. warning:: + + This method may explode at short notice. + + :param collection_selector: A unary function mapping each element of the + source iterable into an intermediate sequence. The single + argument of the collection_selector is the value of an element + from the source sequence. The return value should be an + iterable derived from that element value. The default + collection_selector, which is the identity function, assumes + that each element of the source sequence is itself iterable. + + :param result_selector: An optional unary function mapping the elements in + the flattened intermediate sequence to corresponding elements + of the result sequence. The single argument of the + result_selector is the value of an element from the flattened + intermediate sequence. The return value should be the + corresponding value in the result sequence. The default + result_selector is the identity function. + + :returns: A Queryable over a generated sequence whose elements are the result + of applying the one-to-many collection_selector to each element of + the source sequence, concatenating the results into an intermediate + sequence, and then mapping each of those elements through the + result_selector into the result sequence. + + :raises: + * ValueError - If this Queryable has been closed. + + * TypeError - If either collection_selector or result_selector are not + callable. + """ + source_lines = source.splitlines() + actual_lines = parse_hieroglyph_text(source_lines) + expected_lines = expected.splitlines() + self.assertEqual(len(actual_lines), len(expected_lines)) + for actual_line, result_line in zip(actual_lines, expected_lines): + if len(actual_line.strip()) == 0: + self.assertTrue(len(result_line.strip()) == 0) + else: + self.assertEqual(actual_line, result_line) + + def test_comment12(self): + source = """Determine if all elements in the source sequence satisfy a condition. + + All of the source sequence will be consumed. + + Note: This method uses immediate execution. + + Args: + predicate: An optional single argument function used to test each + elements. If omitted, the bool() function is used resulting in + the elements being tested directly. + + Returns: + True if all elements in the sequence meet the predicate condition, + otherwise False. + + Raises: + This is not a proper exception description + """ + + source_lines = source.splitlines() + self.assertRaises(HieroglyphError, lambda: parse_hieroglyph_text(source_lines)) + diff --git a/docs/sphinx/hieroglyph/test/test_hierglyph.py b/docs/sphinx/hieroglyph/test/test_hierglyph.py new file mode 100644 index 0000000000..42947cb0c7 --- /dev/null +++ b/docs/sphinx/hieroglyph/test/test_hierglyph.py @@ -0,0 +1,264 @@ +import unittest
+from hieroglyph.hieroglyph import first_paragraph_indent, gather_lines, unindent
+
+__author__ = 'Robert Smallshire'
+
+class UnindentTests(unittest.TestCase):
+
+ def test_zero_lines(self):
+ source = []
+ expected = []
+ actual = unindent(source)
+ self.assertEqual(actual, expected)
+
+ def test_one_zero_indent_line(self):
+ source = ["First line"]
+ expected = [(0, "First line")]
+ actual = unindent(source)
+ self.assertEqual(actual, expected)
+
+ def test_two_zero_indent_lines(self):
+ source = ["First line",
+ "Second line"]
+ expected = [(0, "First line"),
+ (0, "Second line")]
+ actual = unindent(source)
+ self.assertEqual(actual, expected)
+
+ def test_two_indented_lines(self):
+ source = [" First line",
+ " Second line"]
+ expected = [(4, "First line"),
+ (6, "Second line")]
+ actual = unindent(source)
+ self.assertEqual(actual, expected)
+
+ def test_whitespace_line(self):
+ source = [" "]
+ expected = [(4, "")]
+ actual = unindent(source)
+ self.assertEqual(actual, expected)
+
+ def test_tab_line(self):
+ source = ["\tHello"]
+ expected = [(1, "Hello")]
+ actual = unindent(source)
+ self.assertEqual(actual, expected)
+
+
+class FirstParagraphIndentTests(unittest.TestCase):
+
+ def test_zero_lines(self):
+ source = []
+ expected = []
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+ def test_single_line_non_indented_comment(self):
+ source = [(0, "A single line comment")]
+ expected = [(0, "A single line comment")]
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+ def test_single_line_indented_comment(self):
+ source = [(4, "A single line comment")]
+ expected = [(4, "A single line comment")]
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+ def test_double_line_non_indented_comment(self):
+ source = [(0, "The first line"),
+ (0, "The second line")]
+ expected = [(0, "The first line"),
+ (0, "The second line")]
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+ def test_double_line_indented_comment(self):
+ source = [(4, "The first line"),
+ (4, "The second line")]
+ expected = [(4, "The first line"),
+ (4, "The second line")]
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+ def test_first_line_indent(self):
+ source = [(4, "The first line"),
+ (0, "The second line")]
+ expected = [(4, "The first line"),
+ (0, "The second line")]
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+ def test_first_line_non_indent(self):
+ source = [(0, "The first line"),
+ (4, "The second line")]
+ expected = [(4, "The first line"),
+ (4, "The second line")]
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+ def test_increasing_indent(self):
+ source = [(0, "The first line"),
+ (4, "The second line"),
+ (8, "The third line")]
+ expected = [(4, "The first line"),
+ (4, "The second line"),
+ (8, "The third line")]
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+ def test_separate_paragraphs(self):
+ source = [(0, "This is the first paragraph"),
+ (0, ""),
+ (4, "This is the second paragraph")]
+ expected = [(0, "This is the first paragraph"),
+ (0, ""),
+ (4, "This is the second paragraph")]
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+ def test_separate_paragraphs_indented(self):
+ source = [(4, "This is the first paragraph"),
+ (4, ""),
+ (8, "This is the second paragraph")]
+ expected = [(4, "This is the first paragraph"),
+ (4, ""),
+ (8, "This is the second paragraph")]
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+ def test_separated_lines_first_line_non_indented(self):
+ source = [(0, "The first line"),
+ (0, ""),
+ (4, "The third line")]
+ expected = [(0, "The first line"),
+ (0, ""),
+ (4, "The third line")]
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+ def test_separated_lines_first_line_indented(self):
+ source = [(4, "The first line"),
+ (4, ""),
+ (4, "The third line")]
+ expected = [(4, "The first line"),
+ (4, ""),
+ (4, "The third line")]
+ actual = first_paragraph_indent(source)
+ self.assertEqual(actual, expected)
+
+class GatherLinesTests(unittest.TestCase):
+
+ def test_empty(self):
+ source = []
+ expected = []
+ actual = gather_lines(source)
+ self.assertEqual(actual, expected)
+
+ def test_one_liner(self):
+ source = [(0, 'One liner')]
+ expected = [(0, ['One liner'])]
+ actual = gather_lines(source)
+ self.assertEqual(actual, expected)
+
+ def test_two_liner(self):
+ source = [(0, 'First line'),
+ (0, 'Second line')]
+ expected = [(0, ['First line',
+ 'Second line'])]
+ actual = gather_lines(source)
+ self.assertEqual(actual, expected)
+
+ def test_separated_lines(self):
+ source = [(0, 'First line'),
+ (0, ''),
+ (0, 'Third line')]
+ expected = [(0, ['First line',
+ '']),
+ (0, ['Third line'])]
+ actual = gather_lines(source)
+ self.assertEqual(actual, expected)
+
+ def test_separated_multi_lines(self):
+ source = [(0, 'First line'),
+ (0, 'Second line'),
+ (0, ''),
+ (0, 'Fourth line'),
+ (0, 'Fifth line')]
+ expected = [(0, ['First line',
+ 'Second line',
+ '']),
+ (0, ['Fourth line',
+ 'Fifth line'])]
+ actual = gather_lines(source)
+ self.assertEqual(actual, expected)
+
+
+ def test_indented_lines(self):
+ source = [(0, 'First line'),
+ (4, 'Second line')]
+ expected = [(0, ['First line']),
+ (4, ['Second line'])]
+ actual = gather_lines(source)
+ self.assertEqual(actual, expected)
+
+ def test_dedented_lines(self):
+ source = [(4, 'First line'),
+ (0, 'Second line')]
+ expected = [(4, ['First line']),
+ (0, ['Second line'])]
+ actual = gather_lines(source)
+ self.assertEqual(actual, expected)
+
+ def test_indented_multi_lines(self):
+ source = [(0, 'First line'),
+ (0, 'Second line'),
+ (4, 'Third line'),
+ (4, 'Fourth line')]
+ expected = [(0, ['First line',
+ 'Second line']),
+ (4, ['Third line',
+ 'Fourth line'])]
+ actual = gather_lines(source)
+ self.assertEqual(actual, expected)
+
+ def test_dedented_multi_lines(self):
+ source = [(4, 'First line'),
+ (4, 'Second line'),
+ (0, 'Third line'),
+ (0, 'Fourth line')]
+ expected = [(4, ['First line',
+ 'Second line']),
+ (0, ['Third line',
+ 'Fourth line'])]
+ actual = gather_lines(source)
+ self.assertEqual(actual, expected)
+
+ def test_indented_separated_multi_lines(self):
+ source = [(0, 'First line'),
+ (0, 'Second line'),
+ (0, ''),
+ (4, 'Fourth line'),
+ (4, 'Fifth line')]
+ expected = [(0, ['First line',
+ 'Second line',
+ '']),
+ (4, ['Fourth line',
+ 'Fifth line'])]
+ actual = gather_lines(source)
+ self.assertEqual(actual, expected)
+
+ def test_dedented_separated_multi_lines(self):
+ source = [(4, 'First line'),
+ (4, 'Second line'),
+ (4, ''),
+ (0, 'Fourth line'),
+ (0, 'Fifth line')]
+ expected = [(4, ['First line',
+ 'Second line',
+ '']),
+ (0, ['Fourth line',
+ 'Fifth line'])]
+ actual = gather_lines(source)
+ self.assertEqual(actual, expected)
diff --git a/docs/sphinx/hieroglyph/test/test_nodes.py b/docs/sphinx/hieroglyph/test/test_nodes.py new file mode 100644 index 0000000000..4cc17b4771 --- /dev/null +++ b/docs/sphinx/hieroglyph/test/test_nodes.py @@ -0,0 +1,386 @@ +import unittest
+from hieroglyph.nodes import Node, Arg, Raises, Except, Returns, Warning, Note
+
+__author__ = 'Robert Smallshire'
+
+class NodeTests(unittest.TestCase):
+
+ def test_create_default_node(self):
+ node = Node()
+ self.assertEqual(node.indent, 0)
+ self.assertEqual(node.lines, [])
+ self.assertIsNone(node.parent)
+
+ def test_create_with_indent(self):
+ node = Node(indent=4)
+ self.assertEqual(node.indent, 4)
+ self.assertEqual(node.lines, [])
+ self.assertIsNone(node.parent)
+
+ def test_create_with_lines(self):
+ node = Node(lines= ['First', 'Second', 'Third'])
+ self.assertEqual(node.indent, 0)
+ self.assertEqual(node.lines, ['First', 'Second', 'Third'])
+ self.assertIsNone(node.parent)
+
+ def test_repr(self):
+ node = Node(5, ['One', 'Two', 'Three'])
+ actual = repr(node)
+ expected = "Node(5, ['One', 'Two', 'Three'], children=[])"
+ self.assertEqual(expected, actual)
+
+ def test_add_one_child(self):
+ node = Node()
+ child = Node(parent=node)
+ node.add_child(child)
+ self.assertIs(node.children[0], child)
+
+ def test_add_two_children(self):
+ node = Node()
+ child0 = Node(parent=node)
+ child1 = Node(parent=node)
+ node.add_child(child0)
+ node.add_child(child1)
+ self.assertIs(node.children[0], child0)
+ self.assertIs(node.children[1], child1)
+
+ def test_render_rst_empty(self):
+ node = Node()
+ rst = node.render_rst()
+ self.assertEqual(len(rst), 0)
+
+ def test_render_rst_indent(self):
+ node = Node(indent=4)
+ rst = node.render_rst()
+ self.assertEqual(len(rst), 0)
+
+ def test_render_rst_lines(self):
+ node = Node(lines= ['First',
+ 'Second',
+ 'Third'])
+ rst = node.render_rst()
+ self.assertEqual(rst, ['First',
+ 'Second',
+ 'Third'])
+
+ def test_render_rst_indented_lines(self):
+ node = Node(indent=3, lines= ['First',
+ 'Second',
+ 'Third'])
+ rst = node.render_rst()
+ self.assertEqual(rst, [' First',
+ ' Second',
+ ' Third'])
+
+ def test_render_rst_with_child(self):
+ node = Node(indent=4, lines=["Parent"])
+ child = Node(indent=8, lines=["Child"], parent=node)
+ node.add_child(child)
+ rst = node.render_rst()
+ self.assertEqual(rst, [' Parent',
+ ' Child'])
+
+ def test_render_rst_with_children(self):
+ node = Node(indent=4, lines=["Parent"])
+ child_a = Node(indent=8, lines=["ChildA"], parent=node)
+ node.add_child(child_a)
+ child_b = Node(indent=6, lines=["ChildB"], parent=node)
+ node.add_child(child_b)
+ rst = node.render_rst()
+ self.assertEqual(rst, [' Parent',
+ ' ChildA',
+ ' ChildB'])
+
+
+class ArgTests(unittest.TestCase):
+
+ def test_create(self):
+ node = Arg(5, 10, 'foo')
+ self.assertEqual(node.indent, 5)
+ self.assertEqual(node.child_indent, 10)
+ self.assertEqual(node.name, 'foo')
+ self.assertEqual(node.lines, [])
+ self.assertIsNone(node.parent)
+
+ def test_set_type(self):
+ node = Arg(5, 10, 'foo')
+ node.type = 'str'
+ self.assertEqual(node.type, 'str')
+
+ def test_add_one_child(self):
+ node = Arg(5, 10, 'foo')
+ child = Node(parent=node)
+ node.add_child(child)
+ self.assertIs(node.children[0], child)
+
+ def test_add_two_children(self):
+ node = Arg(5, 10, 'foo')
+ child0 = Node(parent=node)
+ child1 = Node(parent=node)
+ node.add_child(child0)
+ node.add_child(child1)
+ self.assertIs(node.children[0], child0)
+ self.assertIs(node.children[1], child1)
+
+ def test_repr(self):
+ node = Arg(5, 10, 'foo')
+ actual = repr(node)
+ expected = "Arg('foo', None, children=[])"
+ self.assertEqual(expected, actual)
+
+ def test_render_rst_empty(self):
+ node = Arg(5, 10, 'bar')
+ rst = node.render_rst()
+ self.assertEqual(rst, [' :param bar: ',
+ ''])
+
+ def test_render_rst_with_child(self):
+ node = Arg(5, 10, 'bar')
+ child = Node(indent=10, lines=["Description"], parent=node)
+ node.add_child(child)
+ rst = node.render_rst()
+ self.assertEqual(rst, [' :param bar: Description',
+ ''])
+
+ def test_render_rst_with_children(self):
+ node = Arg(5, 10, 'bar')
+ child_a = Node(indent=10, lines=["ChildA"], parent=node)
+ node.add_child(child_a)
+ child_b = Node(indent=10, lines=["ChildB"], parent=node)
+ node.add_child(child_b)
+ rst = node.render_rst()
+ self.assertEqual(rst, [' :param bar: ChildA',
+ ' ChildB',
+ ''])
+
+ def test_render_rst_with_type(self):
+ node = Arg(5, 10, 'bar')
+ node.type = 'str'
+ rst = node.render_rst()
+ self.assertEqual(rst, [' :param bar: ',
+ ' :type bar: str',
+ ''])
+
+
+class RaisesTests(unittest.TestCase):
+
+ def test_create_default_node(self):
+ node = Raises()
+ self.assertEqual(node.indent, 0)
+ self.assertEqual(node.lines, [])
+ self.assertIsNone(node.parent)
+
+ def test_create_with_indent(self):
+ node = Raises(indent=4)
+ self.assertEqual(node.indent, 4)
+ self.assertEqual(node.lines, [])
+ self.assertIsNone(node.parent)
+
+ def test_repr(self):
+ node = Raises(5)
+ actual = repr(node)
+ expected = "Raises(5, children=[])"
+ self.assertEqual(expected, actual)
+
+ def test_add_one_child(self):
+ node = Raises()
+ child = Node(parent=node)
+ node.add_child(child)
+ self.assertIs(node.children[0], child)
+
+ def test_add_two_children(self):
+ node = Raises()
+ child0 = Node(parent=node)
+ child1 = Node(parent=node)
+ node.add_child(child0)
+ node.add_child(child1)
+ self.assertIs(node.children[0], child0)
+ self.assertIs(node.children[1], child1)
+
+ def test_render_rst_empty(self):
+ node = Raises()
+ rst = node.render_rst()
+ self.assertEqual(rst, [':raises:',
+ ''])
+
+ def test_render_rst_indent(self):
+ node = Raises(indent=5)
+ rst = node.render_rst()
+ self.assertEqual(rst, [' :raises:',
+ ''])
+
+ def test_render_rst_with_child(self):
+ node = Raises(5)
+ child = Node(indent=10, lines=["Description"], parent=node)
+ node.add_child(child)
+ rst = node.render_rst()
+ self.assertEqual(rst, [' :raises:',
+ ' Description',
+ ''])
+
+ def test_render_rst_with_children(self):
+ node = Raises(5)
+ child_a = Node(indent=10, lines=["ChildA"], parent=node)
+ node.add_child(child_a)
+ child_b = Node(indent=10, lines=["ChildB"], parent=node)
+ node.add_child(child_b)
+ rst = node.render_rst()
+ self.assertEqual(rst, [' :raises:',
+ ' ChildA',
+ ' ChildB',
+ ''])
+
+
+class ExceptTests(unittest.TestCase):
+
+ def test_create(self):
+ node = Except(5, 'FooError')
+ self.assertEqual(node.indent, 5)
+ self.assertEqual(node.type, 'FooError')
+ self.assertEqual(node.lines, [])
+ self.assertIsNone(node.parent)
+
+ def test_add_one_child(self):
+ node = Except(5, 'FooError')
+ child = Node(parent=node)
+ node.add_child(child)
+ self.assertIs(node.children[0], child)
+
+ def test_add_two_children(self):
+ node = Except(5, 'FooError')
+ child0 = Node(parent=node)
+ child1 = Node(parent=node)
+ node.add_child(child0)
+ node.add_child(child1)
+ self.assertIs(node.children[0], child0)
+ self.assertIs(node.children[1], child1)
+
+ def test_repr(self):
+ node = Except(5,'FooError')
+ actual = repr(node)
+ expected = "Except('FooError', children=[])"
+ self.assertEqual(expected, actual)
+
+ def test_render_rst_empty(self):
+ node = Except(5, 'FooError')
+ rst = node.render_rst()
+ self.assertEqual(rst, [' * FooError - ',
+ ''])
+
+ def test_render_rst_indent(self):
+ node = Except(5, 'FooError')
+ rst = node.render_rst()
+ self.assertEqual(rst, [' * FooError - ',
+ ''])
+
+ def test_render_rst_with_child(self):
+ node = Except(5, 'FooError')
+ child = Node(indent=10, lines=["Description"], parent=node)
+ node.add_child(child)
+ rst = node.render_rst()
+ self.assertEqual(rst, [' * FooError - Description',
+ ''])
+
+ def test_render_rst_with_children(self):
+ node = Except(5, 'FooError')
+ child_a = Node(indent=10, lines=["ChildA"], parent=node)
+ node.add_child(child_a)
+ child_b = Node(indent=10, lines=["ChildB"], parent=node)
+ node.add_child(child_b)
+ rst = node.render_rst()
+ self.assertEqual(rst, [' * FooError - ChildA',
+ ' ChildB',
+ ''])
+
+class ReturnsTests(unittest.TestCase):
+
+ def test_create(self):
+ node = Returns(5)
+ self.assertEqual(node.indent, 5)
+ self.assertEqual(node.lines, [])
+ self.assertIsNone(node.parent)
+
+ def test_add_one_child(self):
+ node = Returns(5)
+ child = Node(parent=node)
+ node.add_child(child)
+ self.assertIs(node.children[0], child)
+
+ def test_add_two_children(self):
+ node = Returns(5)
+ child0 = Node(parent=node)
+ child1 = Node(parent=node)
+ node.add_child(child0)
+ node.add_child(child1)
+ self.assertIs(node.children[0], child0)
+ self.assertIs(node.children[1], child1)
+
+ def test_repr(self):
+ node = Returns(5)
+ actual = repr(node)
+ expected = "Returns(5, children=[])"
+ self.assertEqual(expected, actual)
+
+ # TODO test_render_rst
+
+class WarningTests(unittest.TestCase):
+
+ def test_create(self):
+ node = Warning(5)
+ self.assertEqual(node.indent, 5)
+ self.assertEqual(node.lines, [])
+ self.assertIsNone(node.parent)
+
+ def test_add_one_child(self):
+ node = Warning(5)
+ child = Node(parent=node)
+ node.add_child(child)
+ self.assertIs(node.children[0], child)
+
+ def test_add_two_children(self):
+ node = Warning(5)
+ child0 = Node(parent=node)
+ child1 = Node(parent=node)
+ node.add_child(child0)
+ node.add_child(child1)
+ self.assertIs(node.children[0], child0)
+ self.assertIs(node.children[1], child1)
+
+ def test_repr(self):
+ node = Warning(5)
+ actual = repr(node)
+ expected = "Warning(5, children=[])"
+ self.assertEqual(expected, actual)
+
+ # TODO test_render_rst
+
+class NoteTests(unittest.TestCase):
+
+ def test_create(self):
+ node = Note(5)
+ self.assertEqual(node.indent, 5)
+ self.assertEqual(node.lines, [])
+ self.assertIsNone(node.parent)
+
+ def test_add_one_child(self):
+ node = Note(5)
+ child = Node(parent=node)
+ node.add_child(child)
+ self.assertIs(node.children[0], child)
+
+ def test_add_two_children(self):
+ node = Note(5)
+ child0 = Node(parent=node)
+ child1 = Node(parent=node)
+ node.add_child(child0)
+ node.add_child(child1)
+ self.assertIs(node.children[0], child0)
+ self.assertIs(node.children[1], child1)
+
+ def test_repr(self):
+ node = Note(5)
+ actual = repr(node)
+ expected = "Note(5, children=[])"
+ self.assertEqual(expected, actual)
+
+ # TODO test_render_rst
diff --git a/docs/sphinx/hieroglyph/version.py b/docs/sphinx/hieroglyph/version.py new file mode 100644 index 0000000000..d060125c0f --- /dev/null +++ b/docs/sphinx/hieroglyph/version.py @@ -0,0 +1,3 @@ +'''Specification of the hieroglyph version'''
+
+__version__ = '0.6'
diff --git a/docs/sphinx/run_sphinx_build.sh.in b/docs/sphinx/run_sphinx_build.sh.in new file mode 100644 index 0000000000..bc89f2de71 --- /dev/null +++ b/docs/sphinx/run_sphinx_build.sh.in @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "Creating Sphinx documentation in: @CMAKE_CURRENT_BINARY_DIR@/sphinx_out" + +LD_LIBRARY_PATH="@CMAKE_INSTALL_PREFIX@/lib" +@SPHINX_EXECUTABLE@ -b html -c @CMAKE_CURRENT_BINARY_DIR@/ @CMAKE_CURRENT_SOURCE_DIR@/source @CMAKE_CURRENT_BINARY_DIR@/sphinx_out + diff --git a/docs/sphinx/source/atsc/blks.rst b/docs/sphinx/source/atsc/blks.rst new file mode 100644 index 0000000000..6f51a22876 --- /dev/null +++ b/docs/sphinx/source/atsc/blks.rst @@ -0,0 +1,20 @@ +gnuradio.atsc: Signal Processing Blocks +======================================= + +.. autooldblock:: gnuradio.atsc.bit_timing_loop +.. autooldblock:: gnuradio.atsc.deinterleaver +.. autooldblock:: gnuradio.atsc.depad +.. autooldblock:: gnuradio.atsc.derandomizer +.. autooldblock:: gnuradio.atsc.ds_to_softds +.. autooldblock:: gnuradio.atsc.equalizer +.. autooldblock:: gnuradio.atsc.field_sync_demux +.. autooldblock:: gnuradio.atsc.field_sync_mux +.. autooldblock:: gnuradio.atsc.fpll +.. autooldblock:: gnuradio.atsc.fs_checker +.. autooldblock:: gnuradio.atsc.interleaver +.. autooldblock:: gnuradio.atsc.pad +.. autooldblock:: gnuradio.atsc.randomizer +.. autooldblock:: gnuradio.atsc.rs_decoder +.. autooldblock:: gnuradio.atsc.rs_encoder +.. autooldblock:: gnuradio.atsc.trellis_encoder +.. autooldblock:: gnuradio.atsc.viterbi_decoder diff --git a/docs/sphinx/source/atsc/index.rst b/docs/sphinx/source/atsc/index.rst new file mode 100644 index 0000000000..2371f24569 --- /dev/null +++ b/docs/sphinx/source/atsc/index.rst @@ -0,0 +1,62 @@ +gnuradio.atsc +============= + +.. automodule:: gnuradio.atsc + +Signal Processing Blocks +------------------------ + +.. autosummary:: + :nosignatures: + + gnuradio.atsc.bit_timing_loop + gnuradio.atsc.deinterleaver + gnuradio.atsc.depad + gnuradio.atsc.derandomizer + gnuradio.atsc.ds_to_softds + gnuradio.atsc.equalizer + gnuradio.atsc.field_sync_demux + gnuradio.atsc.field_sync_mux + gnuradio.atsc.fpll + gnuradio.atsc.fs_checker + gnuradio.atsc.interleaver + gnuradio.atsc.pad + gnuradio.atsc.randomizer + gnuradio.atsc.rs_decoder + gnuradio.atsc.rs_encoder + gnuradio.atsc.trellis_encoder + gnuradio.atsc.viterbi_decoder + +Constants +--------- + +.. autosummary:: + :nosignatures: + + gnuradio.atsc.ATSC_DATA_SEGMENT_LENGTH + gnuradio.atsc.ATSC_DATA_SEGMENT_RATE + gnuradio.atsc.ATSC_DSEGS_PER_FIELD + gnuradio.atsc.ATSC_MPEG_DATA_LENGTH + gnuradio.atsc.ATSC_MPEG_PKT_LENGTH + gnuradio.atsc.ATSC_MPEG_RS_ENCODED_LENGTH + gnuradio.atsc.ATSC_SYMBOL_RATE + gnuradio.atsc.MPEG_SYNC_BYTE + gnuradio.atsc.MPEG_TRANSPORT_ERROR_BIT + +Sizes +--------- + +.. autosummary:: + :nosignatures: + + gnuradio.atsc.sizeof_atsc_data_segment + gnuradio.atsc.sizeof_atsc_data_segment_pad + gnuradio.atsc.sizeof_atsc_mpeg_packet + gnuradio.atsc.sizeof_atsc_mpeg_packet_no_sync + gnuradio.atsc.sizeof_atsc_mpeg_packet_no_sync_pad + gnuradio.atsc.sizeof_atsc_mpeg_packet_pad + gnuradio.atsc.sizeof_atsc_mpeg_packet_rs_encoded + gnuradio.atsc.sizeof_atsc_mpeg_packet_rs_encoded_pad + gnuradio.atsc.sizeof_atsc_soft_data_segment + gnuradio.atsc.sizeof_atsc_soft_data_segment_pad + diff --git a/docs/sphinx/source/audio/index.rst b/docs/sphinx/source/audio/index.rst new file mode 100644 index 0000000000..d0bc4f3c08 --- /dev/null +++ b/docs/sphinx/source/audio/index.rst @@ -0,0 +1,7 @@ +gnuradio.audio +============== + +.. automodule:: gnuradio.audio + +.. autooldblock:: gnuradio.audio.source +.. autooldblock:: gnuradio.audio.sink diff --git a/docs/sphinx/source/blks2/blks.rst b/docs/sphinx/source/blks2/blks.rst new file mode 100644 index 0000000000..c28c7af0f8 --- /dev/null +++ b/docs/sphinx/source/blks2/blks.rst @@ -0,0 +1,31 @@ +gnuradio.blks2: Signal Processing Blocks +======================================== + +.. autopyblock:: gnuradio.blks2.am_demod_cf +.. autopyblock:: gnuradio.blks2.ctcss_gen_f +.. autopyblock:: gnuradio.blks2.demod_10k0a3e_cf +.. autopyblock:: gnuradio.blks2.demod_200kf3e_cf +.. autopyblock:: gnuradio.blks2.demod_20k0f3e_cf +.. autopyblock:: gnuradio.blks2.fm_demod_cf +.. autopyblock:: gnuradio.blks2.logpwrfft_c +.. autopyblock:: gnuradio.blks2.logpwrfft_f +.. autopyblock:: gnuradio.blks2.pfb_arb_resampler_ccf +.. autopyblock:: gnuradio.blks2.pfb_arb_resampler_fff +.. autopyblock:: gnuradio.blks2.pfb_channelizer_ccf +.. autopyblock:: gnuradio.blks2.pfb_decimator_ccf +.. autopyblock:: gnuradio.blks2.pfb_interpolator_ccf +.. autopyblock:: gnuradio.blks2.rational_resampler_ccc +.. autopyblock:: gnuradio.blks2.rational_resampler_ccf +.. autopyblock:: gnuradio.blks2.rational_resampler_fff +.. autopyblock:: gnuradio.blks2.analysis_filterbank +.. autopyblock:: gnuradio.blks2.fm_deemph +.. autopyblock:: gnuradio.blks2.fm_preemph +.. autopyblock:: gnuradio.blks2.nbfm_rx +.. autopyblock:: gnuradio.blks2.nbfm_tx +.. autopyblock:: gnuradio.blks2.stream_to_vector_decimator +.. autopyblock:: gnuradio.blks2.standard_squelch +.. autopyblock:: gnuradio.blks2.synthesis_filterbank +.. autopyblock:: gnuradio.blks2.wfm_rcv +.. autopyblock:: gnuradio.blks2.wfm_rcv_fmdet +.. autopyblock:: gnuradio.blks2.wfm_rcv_pll +.. autopyblock:: gnuradio.blks2.wfm_tx diff --git a/docs/sphinx/source/blks2/index.rst b/docs/sphinx/source/blks2/index.rst new file mode 100644 index 0000000000..4df8e5a796 --- /dev/null +++ b/docs/sphinx/source/blks2/index.rst @@ -0,0 +1,47 @@ +gnuradio.blks2 +============== + +.. automodule:: gnuradio.blks2 + +Signal Processing Blocks +------------------------ + +.. autosummary:: + :nosignatures: + + gnuradio.blks2.am_demod_cf + gnuradio.blks2.ctcss_gen_f + gnuradio.blks2.demod_10k0a3e_cf + gnuradio.blks2.demod_200kf3e_cf + gnuradio.blks2.demod_20k0f3e_cf + gnuradio.blks2.fm_demod_cf + gnuradio.blks2.logpwrfft_c + gnuradio.blks2.logpwrfft_f + gnuradio.blks2.pfb_arb_resampler_ccf + gnuradio.blks2.pfb_arb_resampler_fff + gnuradio.blks2.pfb_channelizer_ccf + gnuradio.blks2.pfb_decimator_ccf + gnuradio.blks2.pfb_interpolator_ccf + gnuradio.blks2.rational_resampler_ccc + gnuradio.blks2.rational_resampler_ccf + gnuradio.blks2.rational_resampler_fff + gnuradio.blks2.analysis_filterbank + gnuradio.blks2.fm_deemph + gnuradio.blks2.fm_preemph + gnuradio.blks2.nbfm_rx + gnuradio.blks2.nbfm_tx + gnuradio.blks2.stream_to_vector_decimator + gnuradio.blks2.standard_squelch + gnuradio.blks2.synthesis_filterbank + gnuradio.blks2.wfm_rcv + gnuradio.blks2.wfm_rcv_fmdet + gnuradio.blks2.wfm_rcv_pll + gnuradio.blks2.wfm_tx + +Utility Functions +----------------- + +.. autosummary:: + :nosignatures: + + gnuradio.blks2.design_filter diff --git a/docs/sphinx/source/blks2/utilities.rst b/docs/sphinx/source/blks2/utilities.rst new file mode 100644 index 0000000000..3ce068fb41 --- /dev/null +++ b/docs/sphinx/source/blks2/utilities.rst @@ -0,0 +1,4 @@ +gnuradio.blks2: Utility Functions +================================= + +.. autoclass:: gnuradio.blks2.design_filter diff --git a/docs/sphinx/source/conf.py.in b/docs/sphinx/source/conf.py.in new file mode 100644 index 0000000000..aa7b122cc9 --- /dev/null +++ b/docs/sphinx/source/conf.py.in @@ -0,0 +1,217 @@ +# -*- coding: utf-8 -*- +# +# GNU Radio documentation build configuration file, created by +# sphinx-quickstart on Sun Oct 16 22:27:51 2011. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath('@CMAKE_CURRENT_SOURCE_DIR@')) +sys.path.insert(0, '@CMAKE_INSTALL_PREFIX@/@GR_PYTHON_DIR@') + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.autosummary', 'sphinx.ext.mathjax', 'gnuradio_sphinx', 'hieroglyph'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'GNU Radio' +copyright = u'2012, Free Software Foundation' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '@VERSION@' +# The full version, including alpha/beta/rc tags. +release = '@VERSION@' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# "<project> v<release> documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'GNURadiodoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'GNURadio.tex', u'GNU Radio Documentation', + u'Free Software Foundation', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'gnuradio', u'GNU Radio Documentation', + [u'Free Software Foundation'], 1) +] diff --git a/docs/sphinx/source/digital/blocks.rst b/docs/sphinx/source/digital/blocks.rst new file mode 100644 index 0000000000..68ec8dad1c --- /dev/null +++ b/docs/sphinx/source/digital/blocks.rst @@ -0,0 +1,51 @@ +gnuradio.digital: Signal Processing Blocks +========================================== + +.. autooldblock:: gnuradio.digital.fll_band_edge_cc +.. autooldblock:: gnuradio.digital.kurtotic_equalizer_cc +.. autooldblock:: gnuradio.digital.lms_dd_equalizer_cc +.. autooldblock:: gnuradio.digital.mpsk_receiver_cc +.. autooldblock:: gnuradio.digital.mpsk_snr_est_cc +.. autooldblock:: gnuradio.digital.clock_recovery_mm_cc +.. autooldblock:: gnuradio.digital.clock_recovery_mm_ff +.. autooldblock:: gnuradio.digital.constellation_decoder_cb +.. autooldblock:: gnuradio.digital.constellation_receiver_cb +.. autooldblock:: gnuradio.digital.correlate_access_code_bb +.. autooldblock:: gnuradio.digital.costas_loop_cc +.. autooldblock:: gnuradio.digital.cma_equalizer_cc +.. autooldblock:: gnuradio.digital.binary_slicer_fb +.. autooldblock:: gnuradio.digital.gmskmod_bc +.. autooldblock:: gnuradio.digital.probe_mpsk_snr_est_c +.. autooldblock:: gnuradio.digital.cpmmod_bc +.. autopyblock:: gnuradio.digital.generic_demod +.. autopyblock:: gnuradio.digital.generic_mod +.. autopyblock:: gnuradio.digital.bpsk.dbpsk_demod +.. autopyblock:: gnuradio.digital.bpsk.dbpsk_mod +.. autopyblock:: gnuradio.digital.qpsk.dqpsk_demod +.. autopyblock:: gnuradio.digital.qpsk.dqpsk_mod +.. autopyblock:: gnuradio.digital.gmsk.gmsk_demod +.. autopyblock:: gnuradio.digital.gmsk.gmsk_mod +.. autopyblock:: gnuradio.digital.bpsk.bpsk_demod +.. autopyblock:: gnuradio.digital.bpsk.bpsk_mod +.. autopyblock:: gnuradio.digital.psk.psk_demod +.. autopyblock:: gnuradio.digital.psk.psk_mod +.. autopyblock:: gnuradio.digital.qam.qam_demod +.. autopyblock:: gnuradio.digital.qam.qam_mod +.. autopyblock:: gnuradio.digital.qpsk.qpsk_demod +.. autopyblock:: gnuradio.digital.qpsk.qpsk_mod +.. autopyblock:: gnuradio.digital.cpm.cpm_mod +.. autopyblock:: gnuradio.digital.pkt.mod_pkts +.. autopyblock:: gnuradio.digital.pkt.demod_pkts +.. autopyblock:: gnuradio.digital.ofdm_cyclic_prefixer +.. autopyblock:: gnuradio.digital.ofdm_frame_acquisition +.. autopyblock:: gnuradio.digital.ofdm_frame_sink +.. autopyblock:: gnuradio.digital.ofdm_insert_preamble +.. autopyblock:: gnuradio.digital.ofdm_mapper_bcv +.. autopyblock:: gnuradio.digital.ofdm_mod +.. autopyblock:: gnuradio.digital.ofdm_demod +.. autopyblock:: gnuradio.digital.ofdm_receiver +.. autopyblock:: gnuradio.digital.ofdm_sampler +.. autopyblock:: gnuradio.digital.ofdm_sync_fixed +.. autopyblock:: gnuradio.digital.ofdm_sync_ml +.. autopyblock:: gnuradio.digital.ofdm_sync_pn +.. autopyblock:: gnuradio.digital.ofdm_sync_pnac diff --git a/docs/sphinx/source/digital/constellations.rst b/docs/sphinx/source/digital/constellations.rst new file mode 100644 index 0000000000..3fa02613ae --- /dev/null +++ b/docs/sphinx/source/digital/constellations.rst @@ -0,0 +1,13 @@ +gnuradio.digital: Constellations +================================ + +.. autofunction:: gnuradio.digital.constellation_8psk +.. autofunction:: gnuradio.digital.constellation_bpsk +.. autofunction:: gnuradio.digital.constellation_calcdist +.. autofunction:: gnuradio.digital.constellation_dqpsk +.. autofunction:: gnuradio.digital.constellation_psk +.. autofunction:: gnuradio.digital.constellation_qpsk +.. autofunction:: gnuradio.digital.constellation_rect +.. autofunction:: gnuradio.digital.qpsk.qpsk_constellation +.. autofunction:: gnuradio.digital.psk.psk_constellation +.. autofunction:: gnuradio.digital.qam.qam_constellation diff --git a/docs/sphinx/source/digital/index.rst b/docs/sphinx/source/digital/index.rst new file mode 100644 index 0000000000..da5227e455 --- /dev/null +++ b/docs/sphinx/source/digital/index.rst @@ -0,0 +1,133 @@ +gnuradio.digital +================ + +.. automodule:: gnuradio.digital + +Signal Processing Blocks +------------------------ + +.. autosummary:: + :nosignatures: + + gnuradio.digital.fll_band_edge_cc + gnuradio.digital.kurtotic_equalizer_cc + gnuradio.digital.lms_dd_equalizer_cc + gnuradio.digital.mpsk_receiver_cc + gnuradio.digital.mpsk_snr_est_cc + gnuradio.digital.clock_recovery_mm_cc + gnuradio.digital.clock_recovery_mm_ff + gnuradio.digital.constellation_decoder_cb + gnuradio.digital.constellation_receiver_cb + gnuradio.digital.correlate_access_code_bb + gnuradio.digital.costas_loop_cc + gnuradio.digital.cma_equalizer_cc + gnuradio.digital.binary_slicer_fb + gnuradio.digital.gmskmod_bc + gnuradio.digital.probe_mpsk_snr_est_c + gnuradio.digital.cpmmod_bc + gnuradio.digital.generic_demod + gnuradio.digital.generic_mod + gnuradio.digital.bpsk.dbpsk_demod + gnuradio.digital.bpsk.dbpsk_mod + gnuradio.digital.qpsk.dqpsk_demod + gnuradio.digital.qpsk.dqpsk_mod + gnuradio.digital.gmsk.gmsk_demod + gnuradio.digital.gmsk.gmsk_mod + gnuradio.digital.bpsk.bpsk_demod + gnuradio.digital.bpsk.bpsk_mod + gnuradio.digital.psk.psk_demod + gnuradio.digital.psk.psk_mod + gnuradio.digital.qam.qam_demod + gnuradio.digital.qam.qam_mod + gnuradio.digital.qpsk.qpsk_demod + gnuradio.digital.qpsk.qpsk_mod + gnuradio.digital.cpm.cpm_mod + gnuradio.digital.pkt.mod_pkts + gnuradio.digital.pkt.demod_pkts + gnuradio.digital.ofdm_cyclic_prefixer + gnuradio.digital.ofdm_frame_acquisition + gnuradio.digital.ofdm_frame_sink + gnuradio.digital.ofdm_insert_preamble + gnuradio.digital.ofdm_mapper_bcv + gnuradio.digital.ofdm_mod + gnuradio.digital.ofdm_demod + gnuradio.digital.ofdm_receiver + gnuradio.digital.ofdm_sampler + gnuradio.digital.ofdm_sync_fixed + gnuradio.digital.ofdm_sync_ml + gnuradio.digital.ofdm_sync_pn + gnuradio.digital.ofdm_sync_pnac + +Constellations +-------------- + +.. autosummary:: + :nosignatures: + + gnuradio.digital.constellation_8psk + gnuradio.digital.constellation_bpsk + gnuradio.digital.constellation_calcdist + gnuradio.digital.constellation_dqpsk + gnuradio.digital.constellation_psk + gnuradio.digital.constellation_qpsk + gnuradio.digital.constellation_qpsk + gnuradio.digital.constellation_rect + gnuradio.digital.qpsk.qpsk_constellation + gnuradio.digital.psk.psk_constellation + gnuradio.digital.qam.qam_constellation + +Modulation Utilties +------------------- + +.. autosummary:: + :nosignatures: + + gnuradio.digital.utils.gray_code.gray_code + gnuradio.digital.utils.mod_codes.GRAY_CODE + gnuradio.digital.utils.mod_codes.NO_CODE + gnuradio.digital.modulation_utils.add_type_1_constellation + gnuradio.digital.modulation_utils.add_type_1_demod + gnuradio.digital.modulation_utils.add_type_1_mod + gnuradio.digital.modulation_utils.type_1_constellations + gnuradio.digital.modulation_utils.type_1_demods + gnuradio.digital.modulation_utils.type_1_mods + +Packet Utilities +---------------- + +.. autosummary:: + :nosignatures: + + gnuradio.digital.packet_utils.conv_1_0_string_to_packed_binary_string + gnuradio.digital.packet_utils.conv_packed_binary_string_to_1_0_string + gnuradio.digital.packet_utils.default_access_code + gnuradio.digital.packet_utils.dewhiten + gnuradio.digital.packet_utils.is_1_0_string + gnuradio.digital.packet_utils.make_header + gnuradio.digital.packet_utils.make_packet + gnuradio.digital.packet_utils.preamble + gnuradio.digital.packet_utils.random_mask_tuple + gnuradio.digital.packet_utils.random_mask_vec8 + gnuradio.digital.packet_utils.string_to_hex_list + gnuradio.digital.packet_utils.unmake_packet + gnuradio.digital.packet_utils.whiten + gnuradio.digital.crc.check_crc32 + gnuradio.digital.crc.gen_and_append_crc32 + +OFDM Packet Utilities +--------------------- + +.. autosummary:: + :nosignatures: + + gnuradio.digital.ofdm_packet_utils.conv_1_0_string_to_packed_binary_string + gnuradio.digital.ofdm_packet_utils.conv_packed_binary_string_to_1_0_string + gnuradio.digital.ofdm_packet_utils.dewhiten + gnuradio.digital.ofdm_packet_utils.is_1_0_string + gnuradio.digital.ofdm_packet_utils.make_header + gnuradio.digital.ofdm_packet_utils.make_packet + gnuradio.digital.ofdm_packet_utils.random_mask_tuple + gnuradio.digital.ofdm_packet_utils.random_mask_vec8 + gnuradio.digital.ofdm_packet_utils.string_to_hex_list + gnuradio.digital.ofdm_packet_utils.unmake_packet + gnuradio.digital.ofdm_packet_utils.whiten diff --git a/docs/sphinx/source/digital/ofdm.rst b/docs/sphinx/source/digital/ofdm.rst new file mode 100644 index 0000000000..8680503f26 --- /dev/null +++ b/docs/sphinx/source/digital/ofdm.rst @@ -0,0 +1,14 @@ +gnuradio.digital: OFDM Packet Utilities +======================================= + +.. autofunction:: gnuradio.digital.ofdm_packet_utils.conv_1_0_string_to_packed_binary_string +.. autofunction:: gnuradio.digital.ofdm_packet_utils.conv_packed_binary_string_to_1_0_string +.. autofunction:: gnuradio.digital.ofdm_packet_utils.dewhiten +.. autofunction:: gnuradio.digital.ofdm_packet_utils.is_1_0_string +.. autofunction:: gnuradio.digital.ofdm_packet_utils.make_header +.. autofunction:: gnuradio.digital.ofdm_packet_utils.make_packet +.. autofunction:: gnuradio.digital.ofdm_packet_utils.random_mask_tuple +.. autofunction:: gnuradio.digital.ofdm_packet_utils.random_mask_vec8 +.. autofunction:: gnuradio.digital.ofdm_packet_utils.string_to_hex_list +.. autofunction:: gnuradio.digital.ofdm_packet_utils.unmake_packet +.. autofunction:: gnuradio.digital.ofdm_packet_utils.whiten diff --git a/docs/sphinx/source/digital/pkt_utils.rst b/docs/sphinx/source/digital/pkt_utils.rst new file mode 100644 index 0000000000..112e103a2f --- /dev/null +++ b/docs/sphinx/source/digital/pkt_utils.rst @@ -0,0 +1,18 @@ +gnuradio.digital: Packet Utilities +================================== + +.. autofunction:: gnuradio.digital.packet_utils.conv_1_0_string_to_packed_binary_string +.. autofunction:: gnuradio.digital.packet_utils.conv_packed_binary_string_to_1_0_string +.. data:: gnuradio.digital.packet_utils.default_access_code +.. autofunction:: gnuradio.digital.packet_utils.dewhiten +.. autofunction:: gnuradio.digital.packet_utils.is_1_0_string +.. autofunction:: gnuradio.digital.packet_utils.make_header +.. autofunction:: gnuradio.digital.packet_utils.make_packet +.. data:: gnuradio.digital.packet_utils.preamble +.. autofunction:: gnuradio.digital.packet_utils.random_mask_tuple +.. autofunction:: gnuradio.digital.packet_utils.random_mask_vec8 +.. autofunction:: gnuradio.digital.packet_utils.string_to_hex_list +.. autofunction:: gnuradio.digital.packet_utils.unmake_packet +.. autofunction:: gnuradio.digital.packet_utils.whiten +.. autofunction:: gnuradio.digital.crc.check_crc32 +.. autofunction:: gnuradio.digital.crc.gen_and_append_crc32 diff --git a/docs/sphinx/source/digital/utilities.rst b/docs/sphinx/source/digital/utilities.rst new file mode 100644 index 0000000000..7a08725a58 --- /dev/null +++ b/docs/sphinx/source/digital/utilities.rst @@ -0,0 +1,12 @@ +gnuradio.digital: Modulation Utilities +====================================== + +.. autofunction:: gnuradio.digital.utils.gray_code.gray_code +.. data:: gnuradio.digital.utils.mod_codes.GRAY_CODE +.. data:: gnuradio.digital.utils.mod_codes.NO_CODE +.. autofunction:: gnuradio.digital.modulation_utils.add_type_1_constellation +.. autofunction:: gnuradio.digital.modulation_utils.add_type_1_demod +.. autofunction:: gnuradio.digital.modulation_utils.add_type_1_mod +.. data:: gnuradio.digital.modulation_utils.type_1_constellations +.. data:: gnuradio.digital.modulation_utils.type_1_demods +.. data:: gnuradio.digital.modulation_utils.type_1_mods diff --git a/docs/sphinx/source/eng_notation/index.rst b/docs/sphinx/source/eng_notation/index.rst new file mode 100644 index 0000000000..f457754ac2 --- /dev/null +++ b/docs/sphinx/source/eng_notation/index.rst @@ -0,0 +1,8 @@ +gnuradio.eng_notation +===================== + +.. automodule:: gnuradio.eng_notation + +.. autofunction:: gnuradio.eng_notation.num_to_str +.. autofunction:: gnuradio.eng_notation.str_to_num + diff --git a/docs/sphinx/source/eng_option/index.rst b/docs/sphinx/source/eng_option/index.rst new file mode 100644 index 0000000000..b9119ee698 --- /dev/null +++ b/docs/sphinx/source/eng_option/index.rst @@ -0,0 +1,6 @@ +gnuradio.eng_option +=================== + +.. automodule:: gnuradio.eng_option + +.. autoclass:: gnuradio.eng_option.eng_option diff --git a/docs/sphinx/source/fft.rst b/docs/sphinx/source/fft.rst new file mode 100644 index 0000000000..79a0a4ed2a --- /dev/null +++ b/docs/sphinx/source/fft.rst @@ -0,0 +1,8 @@ +gnuradio.fft +============ + +.. automodule:: gnuradio.fft + +.. autoblock:: gnuradio.fft.fft_vcc +.. autoblock:: gnuradio.fft.fft_vfc +.. autoblock:: gnuradio.fft.goertzel_fc diff --git a/docs/sphinx/source/gr/coding_blk.rst b/docs/sphinx/source/gr/coding_blk.rst new file mode 100644 index 0000000000..e50b990bcd --- /dev/null +++ b/docs/sphinx/source/gr/coding_blk.rst @@ -0,0 +1,11 @@ +gnuradio.gr: Information Coding and Decoding +============================================ + +.. autooldblock:: gnuradio.gr.additive_scrambler_bb +.. autooldblock:: gnuradio.gr.descrambler_bb +.. autooldblock:: gnuradio.gr.diff_decoder_bb +.. autooldblock:: gnuradio.gr.diff_encoder_bb +.. autooldblock:: gnuradio.gr.fake_channel_encoder_pp +.. autooldblock:: gnuradio.gr.fake_channel_decoder_pp +.. autooldblock:: gnuradio.gr.map_bb +.. autooldblock:: gnuradio.gr.scrambler_bb diff --git a/docs/sphinx/source/gr/converter_blk.rst b/docs/sphinx/source/gr/converter_blk.rst new file mode 100644 index 0000000000..790109a94f --- /dev/null +++ b/docs/sphinx/source/gr/converter_blk.rst @@ -0,0 +1,32 @@ +gnuradio.gr: Type Conversions +============================= + +.. autooldblock:: gnuradio.gr.bytes_to_syms +.. autooldblock:: gnuradio.gr.char_to_float +.. autooldblock:: gnuradio.gr.complex_to_interleaved_short +.. autooldblock:: gnuradio.gr.complex_to_float +.. autooldblock:: gnuradio.gr.complex_to_real +.. autooldblock:: gnuradio.gr.complex_to_imag +.. autooldblock:: gnuradio.gr.complex_to_mag +.. autooldblock:: gnuradio.gr.complex_to_mag_squared +.. autooldblock:: gnuradio.gr.complex_to_arg +.. autooldblock:: gnuradio.gr.float_to_char +.. autooldblock:: gnuradio.gr.float_to_complex +.. autooldblock:: gnuradio.gr.float_to_short +.. autooldblock:: gnuradio.gr.float_to_uchar +.. autooldblock:: gnuradio.gr.interleaved_short_to_complex +.. autooldblock:: gnuradio.gr.short_to_float +.. autooldblock:: gnuradio.gr.uchar_to_float +.. autooldblock:: gnuradio.gr.unpack_k_bits_bb +.. autooldblock:: gnuradio.gr.chunks_to_symbols_bc +.. autooldblock:: gnuradio.gr.chunks_to_symbols_bf +.. autooldblock:: gnuradio.gr.chunks_to_symbols_ic +.. autooldblock:: gnuradio.gr.chunks_to_symbols_if +.. autooldblock:: gnuradio.gr.chunks_to_symbols_sc +.. autooldblock:: gnuradio.gr.chunks_to_symbols_sf +.. autooldblock:: gnuradio.gr.packed_to_unpacked_bb +.. autooldblock:: gnuradio.gr.packed_to_unpacked_ii +.. autooldblock:: gnuradio.gr.packed_to_unpacked_ss +.. autooldblock:: gnuradio.gr.unpacked_to_packed_bb +.. autooldblock:: gnuradio.gr.unpacked_to_packed_ii +.. autooldblock:: gnuradio.gr.unpacked_to_packed_ss diff --git a/docs/sphinx/source/gr/demodulation_blk.rst b/docs/sphinx/source/gr/demodulation_blk.rst new file mode 100644 index 0000000000..4f800b642b --- /dev/null +++ b/docs/sphinx/source/gr/demodulation_blk.rst @@ -0,0 +1,4 @@ +gnuradio.gr: Demodulation +========================= + +.. autooldblock:: gnuradio.gr.quadrature_demod_cf diff --git a/docs/sphinx/source/gr/dft_blk.rst b/docs/sphinx/source/gr/dft_blk.rst new file mode 100644 index 0000000000..4ac1d2e621 --- /dev/null +++ b/docs/sphinx/source/gr/dft_blk.rst @@ -0,0 +1,6 @@ +gnuradio.gr: Fourier Transform +============================== + +.. autooldblock:: gnuradio.gr.goertzel_fc +.. autooldblock:: gnuradio.gr.fft_vcc +.. autooldblock:: gnuradio.gr.fft_vfc diff --git a/docs/sphinx/source/gr/filter_blk.rst b/docs/sphinx/source/gr/filter_blk.rst new file mode 100644 index 0000000000..a73ddda2a8 --- /dev/null +++ b/docs/sphinx/source/gr/filter_blk.rst @@ -0,0 +1,46 @@ +gnuradio.gr: Filters +==================== + +.. autooldblock:: gnuradio.gr.fft_filter_ccc +.. autooldblock:: gnuradio.gr.fft_filter_fff +.. autooldblock:: gnuradio.gr.filter_delay_fc +.. autooldblock:: gnuradio.gr.fir_filter_ccc +.. autooldblock:: gnuradio.gr.fir_filter_ccf +.. autooldblock:: gnuradio.gr.fir_filter_fcc +.. autooldblock:: gnuradio.gr.fir_filter_fff +.. autooldblock:: gnuradio.gr.fir_filter_fsf +.. autooldblock:: gnuradio.gr.fir_filter_scc +.. autooldblock:: gnuradio.gr.fractional_interpolator_cc +.. autooldblock:: gnuradio.gr.fractional_interpolator_ff +.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_ccc +.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_ccf +.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_fcc +.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_fcf +.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_scc +.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_scf +.. autooldblock:: gnuradio.gr.hilbert_fc +.. autooldblock:: gnuradio.gr.iir_filter_ffd +.. autooldblock:: gnuradio.gr.interp_fir_filter_ccc +.. autooldblock:: gnuradio.gr.interp_fir_filter_ccf +.. autooldblock:: gnuradio.gr.interp_fir_filter_fcc +.. autooldblock:: gnuradio.gr.interp_fir_filter_fff +.. autooldblock:: gnuradio.gr.interp_fir_filter_fsf +.. autooldblock:: gnuradio.gr.interp_fir_filter_scc +.. autooldblock:: gnuradio.gr.rational_resampler_base_ccc +.. autooldblock:: gnuradio.gr.rational_resampler_base_ccf +.. autooldblock:: gnuradio.gr.rational_resampler_base_fcc +.. autooldblock:: gnuradio.gr.rational_resampler_base_fff +.. autooldblock:: gnuradio.gr.rational_resampler_base_fsf +.. autooldblock:: gnuradio.gr.rational_resampler_base_scc +.. autooldblock:: gnuradio.gr.single_pole_iir_filter_cc +.. autooldblock:: gnuradio.gr.single_pole_iir_filter_ff +.. autooldblock:: gnuradio.gr.moving_average_cc +.. autooldblock:: gnuradio.gr.moving_average_ff +.. autooldblock:: gnuradio.gr.moving_average_ii +.. autooldblock:: gnuradio.gr.moving_average_ss +.. autooldblock:: gnuradio.gr.pfb_arb_resampler_ccf +.. autooldblock:: gnuradio.gr.pfb_channelizer_ccf +.. autooldblock:: gnuradio.gr.pfb_clock_sync_ccf +.. autooldblock:: gnuradio.gr.pfb_clock_sync_fff +.. autooldblock:: gnuradio.gr.pfb_decimator_ccf +.. autooldblock:: gnuradio.gr.pfb_interpolator_ccf diff --git a/docs/sphinx/source/gr/filter_design.rst b/docs/sphinx/source/gr/filter_design.rst new file mode 100644 index 0000000000..6ab23c50bf --- /dev/null +++ b/docs/sphinx/source/gr/filter_design.rst @@ -0,0 +1,7 @@ +gnuradio.gr: Digital Filter Design +================================== + +.. autoclass:: gnuradio.gr.firdes + :members: + +.. autofunction:: gnuradio.gr.remez diff --git a/docs/sphinx/source/gr/index.rst b/docs/sphinx/source/gr/index.rst new file mode 100644 index 0000000000..3d32599f1d --- /dev/null +++ b/docs/sphinx/source/gr/index.rst @@ -0,0 +1,380 @@ +gnuradio.gr +=========== + +.. automodule:: gnuradio.gr + +Signal Processing Blocks +------------------------ + +Top Block and Hierarchical Block Base Classes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.top_block + gnuradio.gr.hier_block2 + +Signal Sources +^^^^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.glfsr_source_b + gnuradio.gr.glfsr_source_f + gnuradio.gr.lfsr_32k_source_s + gnuradio.gr.null_source + gnuradio.gr.noise_source_c + gnuradio.gr.noise_source_f + gnuradio.gr.noise_source_i + gnuradio.gr.noise_source_s + gnuradio.gr.sig_source_c + gnuradio.gr.sig_source_f + gnuradio.gr.sig_source_i + gnuradio.gr.sig_source_s + gnuradio.gr.vector_source_b + gnuradio.gr.vector_source_c + gnuradio.gr.vector_source_f + gnuradio.gr.vector_source_i + gnuradio.gr.vector_source_s + gnuradio.gr.file_descriptor_source + gnuradio.gr.file_source + gnuradio.gr.message_source + gnuradio.gr.udp_source + gnuradio.gr.wavfile_source + +Signal Sinks +^^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.bin_statistics_f + gnuradio.gr.check_counting_s + gnuradio.gr.check_lfsr_32k_s + gnuradio.gr.framer_sink_1 + gnuradio.gr.null_sink + gnuradio.gr.packet_sink + gnuradio.gr.probe_avg_mag_sqrd_c + gnuradio.gr.probe_avg_mag_sqrd_cf + gnuradio.gr.probe_avg_mag_sqrd_f + gnuradio.gr.probe_signal_f + gnuradio.gr.vector_sink_b + gnuradio.gr.vector_sink_c + gnuradio.gr.vector_sink_f + gnuradio.gr.vector_sink_i + gnuradio.gr.vector_sink_s + gnuradio.gr.file_descriptor_sink + gnuradio.gr.file_sink + gnuradio.gr.histo_sink_f + gnuradio.gr.message_sink + gnuradio.gr.oscope_sink_f + gnuradio.gr.udp_sink + gnuradio.gr.wavfile_sink + +Filters +^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.fft_filter_ccc + gnuradio.gr.fft_filter_fff + gnuradio.gr.filter_delay_fc + gnuradio.gr.fir_filter_ccc + gnuradio.gr.fir_filter_ccf + gnuradio.gr.fir_filter_fcc + gnuradio.gr.fir_filter_fff + gnuradio.gr.fir_filter_fsf + gnuradio.gr.fir_filter_scc + gnuradio.gr.fractional_interpolator_cc + gnuradio.gr.fractional_interpolator_ff + gnuradio.gr.freq_xlating_fir_filter_ccc + gnuradio.gr.freq_xlating_fir_filter_ccf + gnuradio.gr.freq_xlating_fir_filter_fcc + gnuradio.gr.freq_xlating_fir_filter_fcf + gnuradio.gr.freq_xlating_fir_filter_scc + gnuradio.gr.freq_xlating_fir_filter_scf + gnuradio.gr.hilbert_fc + gnuradio.gr.iir_filter_ffd + gnuradio.gr.interp_fir_filter_ccc + gnuradio.gr.interp_fir_filter_ccf + gnuradio.gr.interp_fir_filter_fcc + gnuradio.gr.interp_fir_filter_fff + gnuradio.gr.interp_fir_filter_fsf + gnuradio.gr.interp_fir_filter_scc + gnuradio.gr.rational_resampler_base_ccc + gnuradio.gr.rational_resampler_base_ccf + gnuradio.gr.rational_resampler_base_fcc + gnuradio.gr.rational_resampler_base_fff + gnuradio.gr.rational_resampler_base_fsf + gnuradio.gr.rational_resampler_base_scc + gnuradio.gr.single_pole_iir_filter_cc + gnuradio.gr.single_pole_iir_filter_ff + gnuradio.gr.moving_average_cc + gnuradio.gr.moving_average_ff + gnuradio.gr.moving_average_ii + gnuradio.gr.moving_average_ss + gnuradio.gr.pfb_arb_resampler_ccf + gnuradio.gr.pfb_channelizer_ccf + gnuradio.gr.pfb_clock_sync_ccf + gnuradio.gr.pfb_clock_sync_fff + gnuradio.gr.pfb_decimator_ccf + gnuradio.gr.pfb_interpolator_ccf + +Mathematics +^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.conjugate_cc + gnuradio.gr.nlog10_ff + gnuradio.gr.rms_cf + gnuradio.gr.rms_ff + gnuradio.gr.add_cc + gnuradio.gr.add_const_cc + gnuradio.gr.add_const_ff + gnuradio.gr.add_const_ii + gnuradio.gr.add_const_sf + gnuradio.gr.add_const_ss + gnuradio.gr.add_const_vcc + gnuradio.gr.add_const_vff + gnuradio.gr.add_const_vii + gnuradio.gr.add_const_vss + gnuradio.gr.add_ff + gnuradio.gr.add_ii + gnuradio.gr.add_ss + gnuradio.gr.and_bb + gnuradio.gr.and_const_bb + gnuradio.gr.and_const_ii + gnuradio.gr.and_const_ss + gnuradio.gr.and_ii + gnuradio.gr.and_ss + gnuradio.gr.divide_cc + gnuradio.gr.divide_ff + gnuradio.gr.divide_ii + gnuradio.gr.divide_ss + gnuradio.gr.integrate_cc + gnuradio.gr.integrate_ff + gnuradio.gr.integrate_ii + gnuradio.gr.integrate_ss + gnuradio.gr.multiply_cc + gnuradio.gr.multiply_const_cc + gnuradio.gr.multiply_const_ff + gnuradio.gr.multiply_const_ii + gnuradio.gr.multiply_const_ss + gnuradio.gr.multiply_const_vcc + gnuradio.gr.multiply_const_vff + gnuradio.gr.multiply_const_vii + gnuradio.gr.multiply_const_vss + gnuradio.gr.multiply_ff + gnuradio.gr.multiply_ii + gnuradio.gr.multiply_ss + gnuradio.gr.not_bb + gnuradio.gr.not_ii + gnuradio.gr.not_ss + gnuradio.gr.or_bb + gnuradio.gr.or_ii + gnuradio.gr.or_ss + gnuradio.gr.sub_cc + gnuradio.gr.sub_ff + gnuradio.gr.sub_ii + gnuradio.gr.sub_ss + gnuradio.gr.xor_bb + gnuradio.gr.xor_ii + gnuradio.gr.xor_ss + +Modulation +^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.cpfsk_bc + gnuradio.gr.frequency_modulator_fc + gnuradio.gr.phase_modulator_fc + +Demodulation +^^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.quadrature_demod_cf + +Information Coding and Decoding +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.additive_scrambler_bb + gnuradio.gr.descrambler_bb + gnuradio.gr.diff_decoder_bb + gnuradio.gr.diff_encoder_bb + gnuradio.gr.fake_channel_encoder_pp + gnuradio.gr.fake_channel_decoder_pp + gnuradio.gr.map_bb + gnuradio.gr.scrambler_bb + +Synchronization +^^^^^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.pll_carriertracking_cc + gnuradio.gr.pll_freqdet_cf + gnuradio.gr.pll_refout_cc + gnuradio.gr.pn_correlator_cc + gnuradio.gr.simple_correlator + gnuradio.gr.simple_framer + +Type Conversions +^^^^^^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.bytes_to_syms + gnuradio.gr.char_to_float + gnuradio.gr.complex_to_interleaved_short + gnuradio.gr.complex_to_float + gnuradio.gr.complex_to_real + gnuradio.gr.complex_to_imag + gnuradio.gr.complex_to_mag + gnuradio.gr.complex_to_mag_squared + gnuradio.gr.complex_to_arg + gnuradio.gr.float_to_char + gnuradio.gr.float_to_complex + gnuradio.gr.float_to_short + gnuradio.gr.float_to_uchar + gnuradio.gr.interleaved_short_to_complex + gnuradio.gr.short_to_float + gnuradio.gr.uchar_to_float + gnuradio.gr.unpack_k_bits_bb + gnuradio.gr.chunks_to_symbols_bc + gnuradio.gr.chunks_to_symbols_bf + gnuradio.gr.chunks_to_symbols_ic + gnuradio.gr.chunks_to_symbols_if + gnuradio.gr.chunks_to_symbols_sc + gnuradio.gr.chunks_to_symbols_sf + gnuradio.gr.packed_to_unpacked_bb + gnuradio.gr.packed_to_unpacked_ii + gnuradio.gr.packed_to_unpacked_ss + gnuradio.gr.unpacked_to_packed_bb + gnuradio.gr.unpacked_to_packed_ii + gnuradio.gr.unpacked_to_packed_ss + +Signal Level Control (AGC) +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.agc2_cc + gnuradio.gr.agc2_ff + gnuradio.gr.agc_cc + gnuradio.gr.agc_ff + gnuradio.gr.ctcss_squelch_ff + gnuradio.gr.dpll_bb + gnuradio.gr.feedforward_agc_cc + gnuradio.gr.peak_detector2_fb + gnuradio.gr.pwr_squelch_cc + gnuradio.gr.pwr_squelch_ff + gnuradio.gr.regenerate_bb + gnuradio.gr.simple_squelch_cc + gnuradio.gr.mute_cc + gnuradio.gr.mute_ff + gnuradio.gr.mute_ii + gnuradio.gr.mute_ss + gnuradio.gr.peak_detector_fb + gnuradio.gr.peak_detector_ib + gnuradio.gr.peak_detector_sb + gnuradio.gr.sample_and_hold_bb + gnuradio.gr.sample_and_hold_ff + gnuradio.gr.sample_and_hold_ii + gnuradio.gr.sample_and_hold_ss + +Fourier Transform +^^^^^^^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.goertzel_fc + gnuradio.gr.fft_vcc + gnuradio.gr.fft_vfc + +Miscellaneous Blocks +^^^^^^^^^^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.copy + gnuradio.gr.delay + gnuradio.gr.kludge_copy + gnuradio.gr.nop + gnuradio.gr.pa_2x2_phase_combiner + gnuradio.gr.repeat + gnuradio.gr.threshold_ff + gnuradio.gr.throttle + gnuradio.gr.channel_model + +Slicing and Dicing Streams +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autosummary:: + :nosignatures: + + gnuradio.gr.deinterleave + gnuradio.gr.head + gnuradio.gr.interleave + gnuradio.gr.keep_one_in_n + gnuradio.gr.skiphead + gnuradio.gr.stream_to_streams + gnuradio.gr.stream_to_vector + gnuradio.gr.streams_to_stream + gnuradio.gr.streams_to_vector + gnuradio.gr.vector_to_stream + gnuradio.gr.vector_to_streams + +Digital Filter Design +--------------------- + +.. autosummary:: + :nosignatures: + + gnuradio.gr.firdes + gnuradio.gr.remez + +Miscellaneous +------------- + +.. autosummary:: + :nosignatures: + + gnuradio.gr.feval_dd + gnuradio.gr.feval_cc + gnuradio.gr.feval_ll + gnuradio.gr.feval + gnuradio.gr.prefs + gnuradio.gr.test + gnuradio.gr.message + gnuradio.gr.msg_queue + gnuradio.gr.enable_realtime_scheduling + +Implementation Details +---------------------- + +.. autosummary:: + :nosignatures: + + gnuradio.gr.block_detail + gnuradio.gr.buffer + gnuradio.gr.dispatcher + gnuradio.gr.single_threaded_scheduler + diff --git a/docs/sphinx/source/gr/internal.rst b/docs/sphinx/source/gr/internal.rst new file mode 100644 index 0000000000..4948b38d4d --- /dev/null +++ b/docs/sphinx/source/gr/internal.rst @@ -0,0 +1,7 @@ +gnuradio.gr: Implementation Details +=================================== + +.. autofunction:: gnuradio.gr.block_detail +.. autofunction:: gnuradio.gr.buffer +.. autofunction:: gnuradio.gr.dispatcher +.. autofunction:: gnuradio.gr.single_threaded_scheduler diff --git a/docs/sphinx/source/gr/level_blk.rst b/docs/sphinx/source/gr/level_blk.rst new file mode 100644 index 0000000000..d6c565c65d --- /dev/null +++ b/docs/sphinx/source/gr/level_blk.rst @@ -0,0 +1,26 @@ +gnuradio.gr: Signal Level Control (AGC) +======================================= + +.. autooldblock:: gnuradio.gr.agc2_cc +.. autooldblock:: gnuradio.gr.agc2_ff +.. autooldblock:: gnuradio.gr.agc_cc +.. autooldblock:: gnuradio.gr.agc_ff +.. autooldblock:: gnuradio.gr.ctcss_squelch_ff +.. autooldblock:: gnuradio.gr.dpll_bb +.. autooldblock:: gnuradio.gr.feedforward_agc_cc +.. autooldblock:: gnuradio.gr.peak_detector2_fb +.. autooldblock:: gnuradio.gr.pwr_squelch_cc +.. autooldblock:: gnuradio.gr.pwr_squelch_ff +.. autooldblock:: gnuradio.gr.regenerate_bb +.. autooldblock:: gnuradio.gr.simple_squelch_cc +.. autooldblock:: gnuradio.gr.mute_cc +.. autooldblock:: gnuradio.gr.mute_ff +.. autooldblock:: gnuradio.gr.mute_ii +.. autooldblock:: gnuradio.gr.mute_ss +.. autooldblock:: gnuradio.gr.peak_detector_fb +.. autooldblock:: gnuradio.gr.peak_detector_ib +.. autooldblock:: gnuradio.gr.peak_detector_sb +.. autooldblock:: gnuradio.gr.sample_and_hold_bb +.. autooldblock:: gnuradio.gr.sample_and_hold_ff +.. autooldblock:: gnuradio.gr.sample_and_hold_ii +.. autooldblock:: gnuradio.gr.sample_and_hold_ss diff --git a/docs/sphinx/source/gr/math_blk.rst b/docs/sphinx/source/gr/math_blk.rst new file mode 100644 index 0000000000..7b9437f995 --- /dev/null +++ b/docs/sphinx/source/gr/math_blk.rst @@ -0,0 +1,59 @@ +gnuradio.gr: Mathematics +======================== + +.. autooldblock:: gnuradio.gr.conjugate_cc +.. autooldblock:: gnuradio.gr.nlog10_ff +.. autooldblock:: gnuradio.gr.rms_cf +.. autooldblock:: gnuradio.gr.rms_ff +.. autooldblock:: gnuradio.gr.add_cc +.. autooldblock:: gnuradio.gr.add_const_cc +.. autooldblock:: gnuradio.gr.add_const_ff +.. autooldblock:: gnuradio.gr.add_const_ii +.. autooldblock:: gnuradio.gr.add_const_sf +.. autooldblock:: gnuradio.gr.add_const_ss +.. autooldblock:: gnuradio.gr.add_const_vcc +.. autooldblock:: gnuradio.gr.add_const_vff +.. autooldblock:: gnuradio.gr.add_const_vii +.. autooldblock:: gnuradio.gr.add_const_vss +.. autooldblock:: gnuradio.gr.add_ff +.. autooldblock:: gnuradio.gr.add_ii +.. autooldblock:: gnuradio.gr.add_ss +.. autooldblock:: gnuradio.gr.and_bb +.. autooldblock:: gnuradio.gr.and_const_bb +.. autooldblock:: gnuradio.gr.and_const_ii +.. autooldblock:: gnuradio.gr.and_const_ss +.. autooldblock:: gnuradio.gr.and_ii +.. autooldblock:: gnuradio.gr.and_ss +.. autooldblock:: gnuradio.gr.divide_cc +.. autooldblock:: gnuradio.gr.divide_ff +.. autooldblock:: gnuradio.gr.divide_ii +.. autooldblock:: gnuradio.gr.divide_ss +.. autooldblock:: gnuradio.gr.integrate_cc +.. autooldblock:: gnuradio.gr.integrate_ff +.. autooldblock:: gnuradio.gr.integrate_ii +.. autooldblock:: gnuradio.gr.integrate_ss +.. autooldblock:: gnuradio.gr.multiply_cc +.. autooldblock:: gnuradio.gr.multiply_const_cc +.. autooldblock:: gnuradio.gr.multiply_const_ff +.. autooldblock:: gnuradio.gr.multiply_const_ii +.. autooldblock:: gnuradio.gr.multiply_const_ss +.. autooldblock:: gnuradio.gr.multiply_const_vcc +.. autooldblock:: gnuradio.gr.multiply_const_vff +.. autooldblock:: gnuradio.gr.multiply_const_vii +.. autooldblock:: gnuradio.gr.multiply_const_vss +.. autooldblock:: gnuradio.gr.multiply_ff +.. autooldblock:: gnuradio.gr.multiply_ii +.. autooldblock:: gnuradio.gr.multiply_ss +.. autooldblock:: gnuradio.gr.not_bb +.. autooldblock:: gnuradio.gr.not_ii +.. autooldblock:: gnuradio.gr.not_ss +.. autooldblock:: gnuradio.gr.or_bb +.. autooldblock:: gnuradio.gr.or_ii +.. autooldblock:: gnuradio.gr.or_ss +.. autooldblock:: gnuradio.gr.sub_cc +.. autooldblock:: gnuradio.gr.sub_ff +.. autooldblock:: gnuradio.gr.sub_ii +.. autooldblock:: gnuradio.gr.sub_ss +.. autooldblock:: gnuradio.gr.xor_bb +.. autooldblock:: gnuradio.gr.xor_ii +.. autooldblock:: gnuradio.gr.xor_ss diff --git a/docs/sphinx/source/gr/misc.rst b/docs/sphinx/source/gr/misc.rst new file mode 100644 index 0000000000..b0a3f3ba10 --- /dev/null +++ b/docs/sphinx/source/gr/misc.rst @@ -0,0 +1,12 @@ +gnuradio.gr: Miscellaneous +========================== + +.. autofunction:: gnuradio.gr.feval_dd +.. autofunction:: gnuradio.gr.feval_cc +.. autofunction:: gnuradio.gr.feval_ll +.. autofunction:: gnuradio.gr.feval +.. autofunction:: gnuradio.gr.prefs +.. autofunction:: gnuradio.gr.test +.. autofunction:: gnuradio.gr.message +.. autofunction:: gnuradio.gr.msg_queue +.. autofunction:: gnuradio.gr.enable_realtime_scheduling diff --git a/docs/sphinx/source/gr/misc_blk.rst b/docs/sphinx/source/gr/misc_blk.rst new file mode 100644 index 0000000000..c69293056c --- /dev/null +++ b/docs/sphinx/source/gr/misc_blk.rst @@ -0,0 +1,12 @@ +gnuradio.gr: Miscellaneous Blocks +================================= + +.. autooldblock:: gnuradio.gr.copy +.. autooldblock:: gnuradio.gr.delay +.. autooldblock:: gnuradio.gr.kludge_copy +.. autooldblock:: gnuradio.gr.nop +.. autooldblock:: gnuradio.gr.pa_2x2_phase_combiner +.. autooldblock:: gnuradio.gr.repeat +.. autooldblock:: gnuradio.gr.threshold_ff +.. autooldblock:: gnuradio.gr.throttle +.. autooldblock:: gnuradio.gr.channel_model diff --git a/docs/sphinx/source/gr/modulation_blk.rst b/docs/sphinx/source/gr/modulation_blk.rst new file mode 100644 index 0000000000..1fff4614ca --- /dev/null +++ b/docs/sphinx/source/gr/modulation_blk.rst @@ -0,0 +1,6 @@ +gnuradio.gr: Modulation +======================= + +.. autooldblock:: gnuradio.gr.cpfsk_bc +.. autooldblock:: gnuradio.gr.frequency_modulator_fc +.. autooldblock:: gnuradio.gr.phase_modulator_fc diff --git a/docs/sphinx/source/gr/sink_blk.rst b/docs/sphinx/source/gr/sink_blk.rst new file mode 100644 index 0000000000..7608ff09b0 --- /dev/null +++ b/docs/sphinx/source/gr/sink_blk.rst @@ -0,0 +1,25 @@ +gnuradio.gr: Signal Sinks +========================= + +.. autooldblock:: gnuradio.gr.bin_statistics_f +.. autooldblock:: gnuradio.gr.check_counting_s +.. autooldblock:: gnuradio.gr.check_lfsr_32k_s +.. autooldblock:: gnuradio.gr.framer_sink_1 +.. autooldblock:: gnuradio.gr.null_sink +.. autooldblock:: gnuradio.gr.packet_sink +.. autooldblock:: gnuradio.gr.probe_avg_mag_sqrd_c +.. autooldblock:: gnuradio.gr.probe_avg_mag_sqrd_cf +.. autooldblock:: gnuradio.gr.probe_avg_mag_sqrd_f +.. autooldblock:: gnuradio.gr.probe_signal_f +.. autooldblock:: gnuradio.gr.vector_sink_b +.. autooldblock:: gnuradio.gr.vector_sink_c +.. autooldblock:: gnuradio.gr.vector_sink_f +.. autooldblock:: gnuradio.gr.vector_sink_i +.. autooldblock:: gnuradio.gr.vector_sink_s +.. autooldblock:: gnuradio.gr.file_descriptor_sink +.. autooldblock:: gnuradio.gr.file_sink +.. autooldblock:: gnuradio.gr.histo_sink_f +.. autooldblock:: gnuradio.gr.message_sink +.. autooldblock:: gnuradio.gr.oscope_sink_f +.. autooldblock:: gnuradio.gr.udp_sink +.. autooldblock:: gnuradio.gr.wavfile_sink diff --git a/docs/sphinx/source/gr/slicedice_blk.rst b/docs/sphinx/source/gr/slicedice_blk.rst new file mode 100644 index 0000000000..e845627aad --- /dev/null +++ b/docs/sphinx/source/gr/slicedice_blk.rst @@ -0,0 +1,14 @@ +gnuradio.gr: Slicing and Dicing Streams +======================================= + +.. autooldblock:: gnuradio.gr.deinterleave +.. autooldblock:: gnuradio.gr.head +.. autooldblock:: gnuradio.gr.interleave +.. autooldblock:: gnuradio.gr.keep_one_in_n +.. autooldblock:: gnuradio.gr.skiphead +.. autooldblock:: gnuradio.gr.stream_to_streams +.. autooldblock:: gnuradio.gr.stream_to_vector +.. autooldblock:: gnuradio.gr.streams_to_stream +.. autooldblock:: gnuradio.gr.streams_to_vector +.. autooldblock:: gnuradio.gr.vector_to_stream +.. autooldblock:: gnuradio.gr.vector_to_streams diff --git a/docs/sphinx/source/gr/source_blk.rst b/docs/sphinx/source/gr/source_blk.rst new file mode 100644 index 0000000000..df873bcf74 --- /dev/null +++ b/docs/sphinx/source/gr/source_blk.rst @@ -0,0 +1,26 @@ +gnuradio.gr: Signal Sources +=========================== + +.. autooldblock:: gnuradio.gr.glfsr_source_b +.. autooldblock:: gnuradio.gr.glfsr_source_f +.. autooldblock:: gnuradio.gr.lfsr_32k_source_s +.. autooldblock:: gnuradio.gr.null_source +.. autooldblock:: gnuradio.gr.noise_source_c +.. autooldblock:: gnuradio.gr.noise_source_f +.. autooldblock:: gnuradio.gr.noise_source_i +.. autooldblock:: gnuradio.gr.noise_source_s +.. autooldblock:: gnuradio.gr.sig_source_c +.. autooldblock:: gnuradio.gr.sig_source_f +.. autooldblock:: gnuradio.gr.sig_source_i +.. autooldblock:: gnuradio.gr.sig_source_s +.. autooldblock:: gnuradio.gr.vector_source_b +.. autooldblock:: gnuradio.gr.vector_source_c +.. autooldblock:: gnuradio.gr.vector_source_f +.. autooldblock:: gnuradio.gr.vector_source_i +.. autooldblock:: gnuradio.gr.vector_source_s +.. autooldblock:: gnuradio.gr.file_descriptor_source +.. autooldblock:: gnuradio.gr.file_source +.. autooldblock:: gnuradio.gr.message_source +.. autooldblock:: gnuradio.gr.udp_source +.. autooldblock:: gnuradio.gr.wavfile_source + diff --git a/docs/sphinx/source/gr/sync_blk.rst b/docs/sphinx/source/gr/sync_blk.rst new file mode 100644 index 0000000000..be9f908f73 --- /dev/null +++ b/docs/sphinx/source/gr/sync_blk.rst @@ -0,0 +1,9 @@ +gnuradio.gr: Synchronization +============================ + +.. autooldblock:: gnuradio.gr.pll_carriertracking_cc +.. autooldblock:: gnuradio.gr.pll_freqdet_cf +.. autooldblock:: gnuradio.gr.pll_refout_cc +.. autooldblock:: gnuradio.gr.pn_correlator_cc +.. autooldblock:: gnuradio.gr.simple_correlator +.. autooldblock:: gnuradio.gr.simple_framer diff --git a/docs/sphinx/source/gr/top_block.rst b/docs/sphinx/source/gr/top_block.rst new file mode 100644 index 0000000000..3d4e9ef3d6 --- /dev/null +++ b/docs/sphinx/source/gr/top_block.rst @@ -0,0 +1,7 @@ +gnuradio.gr: Top Block and Hierarchical Block Base Classes +========================================================== + +.. autoclass:: gnuradio.gr.top_block + +.. autoclass:: gnuradio.gr.hier_block2 + diff --git a/docs/sphinx/source/gr_unittest/index.rst b/docs/sphinx/source/gr_unittest/index.rst new file mode 100644 index 0000000000..2169a7da41 --- /dev/null +++ b/docs/sphinx/source/gr_unittest/index.rst @@ -0,0 +1,7 @@ +gnuradio.gr_unittest +==================== + +.. automodule:: gnuradio.gr_unittest + +.. autoclass:: gnuradio.gr_unittest.TestCase +.. autofunction:: gnuradio.gr_unittest.run diff --git a/docs/sphinx/source/index.rst b/docs/sphinx/source/index.rst new file mode 100644 index 0000000000..38d859aafd --- /dev/null +++ b/docs/sphinx/source/index.rst @@ -0,0 +1,120 @@ +gnuradio +======== + +.. automodule:: gnuradio + +Core Framework +-------------- + +.. autosummary:: + :nosignatures: + + gnuradio.gr + gnuradio.digital + gnuradio.blks2 + gnuradio.audio + gnuradio.trellis + gnuradio.wavelet + gnuradio.fft + gnuradio.window + gnuradio.optfir + gnuradio.gr_unittest + gnuradio.qtgui + gnuradio.wxgui + +.. toctree:: + :hidden: + + gnuradio.gr <gr/index> + gnuradio.digital <digital/index> + gnuradio.blks2 <blks2/index> + gnuradio.audio <audio/index> + gnuradio.gr_unittest <gr_unittest/index> + gnuradio.optfir <optfir/index> + gnuradio.trellis <trellis/index> + gnuradio.wavelet <wavelet> + gnuradio.fft <fft> + gnuradio.window <window/index> + gnuradio.qtgui <qtgui/index> + gnuradio.wxgui <wxgui/index> + +Utilities +--------- + +.. autosummary:: + :nosignatures: + + gnuradio.plot_data + gnuradio.eng_notation + gnuradio.eng_option + +.. toctree:: + :hidden: + + gnuradio.plot_data <plot_data> + gnuradio.eng_notation <eng_notation/index> + gnuradio.eng_option <eng_option/index> + +Framework Extensions +-------------------- + +.. autosummary:: + :nosignatures: + + gnuradio.atsc + gnuradio.noaa + gnuradio.pager + gnuradio.video_sdl + gnuradio.vocoder + +.. toctree:: + :hidden: + + gnuradio.atsc <atsc/index> + gnuradio.noaa <noaa> + gnuradio.pager <pager/index> + gnuradio.video_sdl <video_sdl> + gnuradio.vocoder <vocoder/index> + + +.. Use this to add to the toctree but not displayed +.. It's mostly to get rid of warnings + +.. toctree:: + :hidden: + + coding <gr/coding_blk> + converter <gr/converter_blk> + demodulation <gr/demodulation_blk> + dft <gr/dft_blk> + filter <gr/filter_blk> + filter_design <gr/filter_design> + internal <gr/internal> + level <gr/level_blk> + math <gr/math_blk> + misc <gr/misc> + misc <gr/misc_blk> + modulation <gr/modulation_blk> + sink <gr/sink_blk> + slicedice <gr/slicedice_blk> + source <gr/source_blk> + sync <gr/sync_blk> + top_block <gr/top_block> + + atsc_blks <atsc/blks> + blks <blks2/blks> + blks2_utilities <blks2/utilities> + digital_blocks <digital/blocks> + constellations <digital/constellations> + ofdm <digital/ofdm> + pkt_utils <digital/pkt_utils> + digital_utilities <digital/utilities> + optfir <optfir/detail> + pager_blks <pager/blks> + pyqt_filter <pyqt_filter> + pyqt_plot <pyqt_plot> + trellis_blks <trellis/blks> + trellis_objs <trellis/objs> + vocoder_blks <vocoder/blks> + window_detail <window/detail> + wxgui_blks <wxgui/blks> diff --git a/docs/sphinx/source/noaa.rst b/docs/sphinx/source/noaa.rst new file mode 100644 index 0000000000..65461f99b8 --- /dev/null +++ b/docs/sphinx/source/noaa.rst @@ -0,0 +1,8 @@ +gnuradio.noaa +============== + +.. automodule:: gnuradio.noaa + +.. autooldblock:: gnuradio.noaa.hrpt_decoder +.. autooldblock:: gnuradio.noaa.hrpt_deframer +.. autooldblock:: gnuradio.noaa.hrpt_pll_cf diff --git a/docs/sphinx/source/optfir/detail.rst b/docs/sphinx/source/optfir/detail.rst new file mode 100644 index 0000000000..78807bee02 --- /dev/null +++ b/docs/sphinx/source/optfir/detail.rst @@ -0,0 +1,14 @@ +gnuradio.optfir +=============== + +.. autofunction:: gnuradio.optfir.band_pass +.. autofunction:: gnuradio.optfir.band_reject +.. autofunction:: gnuradio.optfir.bporder +.. autofunction:: gnuradio.optfir.complex_band_pass +.. autofunction:: gnuradio.optfir.high_pass +.. autofunction:: gnuradio.optfir.low_pass +.. autofunction:: gnuradio.optfir.lporder +.. autofunction:: gnuradio.optfir.passband_ripple_to_dev +.. autofunction:: gnuradio.optfir.remez +.. autofunction:: gnuradio.optfir.remezord +.. autofunction:: gnuradio.optfir.stopband_atten_to_dev diff --git a/docs/sphinx/source/optfir/index.rst b/docs/sphinx/source/optfir/index.rst new file mode 100644 index 0000000000..f49b01a1f8 --- /dev/null +++ b/docs/sphinx/source/optfir/index.rst @@ -0,0 +1,19 @@ +gnuradio.optfir +=============== + +.. automodule:: gnuradio.optfir + +.. autosummary:: + :nosignatures: + + gnuradio.optfir.band_pass + gnuradio.optfir.band_reject + gnuradio.optfir.bporder + gnuradio.optfir.complex_band_pass + gnuradio.optfir.high_pass + gnuradio.optfir.low_pass + gnuradio.optfir.lporder + gnuradio.optfir.passband_ripple_to_dev + gnuradio.optfir.remez + gnuradio.optfir.remezord + gnuradio.optfir.stopband_atten_to_dev diff --git a/docs/sphinx/source/pager/blks.rst b/docs/sphinx/source/pager/blks.rst new file mode 100644 index 0000000000..a36103d1fa --- /dev/null +++ b/docs/sphinx/source/pager/blks.rst @@ -0,0 +1,9 @@ +gnuradio.pager: Signal Processing Blocks +======================================== + +.. autooldblock:: gnuradio.pager.flex_deinterleave +.. autopyblock:: gnuradio.pager.flex_demod +.. autooldblock:: gnuradio.pager.flex_frame +.. autooldblock:: gnuradio.pager.flex_parse +.. autooldblock:: gnuradio.pager.flex_sync +.. autooldblock:: gnuradio.pager.slicer_fb diff --git a/docs/sphinx/source/pager/index.rst b/docs/sphinx/source/pager/index.rst new file mode 100644 index 0000000000..36df48451d --- /dev/null +++ b/docs/sphinx/source/pager/index.rst @@ -0,0 +1,23 @@ +gnuradio.pager +============== + +.. automodule:: gnuradio.pager + +Signal Processing Blocks +------------------------ + +.. autosummary:: + :nosignatures: + + gnuradio.pager.flex_deinterleave + gnuradio.pager.flex_demod + gnuradio.pager.flex_frame + gnuradio.pager.flex_parse + gnuradio.pager.flex_sync + gnuradio.pager.pager_flex_frame + gnuradio.pager.slicer_fb + +Utility Functions +----------------- + +.. autofunction:: gnuradio.pager.queue_runner diff --git a/docs/sphinx/source/plot_data.rst b/docs/sphinx/source/plot_data.rst new file mode 100644 index 0000000000..1b52a083c0 --- /dev/null +++ b/docs/sphinx/source/plot_data.rst @@ -0,0 +1,6 @@ +gnuradio.plot_data +================== + +.. automodule:: gnuradio.plot_data + +.. autoclass:: gnuradio.plot_data.plot_data diff --git a/docs/sphinx/source/pyqt_filter.rst b/docs/sphinx/source/pyqt_filter.rst new file mode 100644 index 0000000000..cc52abfa79 --- /dev/null +++ b/docs/sphinx/source/pyqt_filter.rst @@ -0,0 +1,6 @@ +gnuradio.pyqt_filter +==================== + +.. automodule:: gnuradio.pyqt_filter + +.. autoclass:: gnuradio.pyqt_filter.Ui_MainWindow diff --git a/docs/sphinx/source/pyqt_plot.rst b/docs/sphinx/source/pyqt_plot.rst new file mode 100644 index 0000000000..3537a080bc --- /dev/null +++ b/docs/sphinx/source/pyqt_plot.rst @@ -0,0 +1,6 @@ +gnuradio.pyqt_plot +================== + +.. automodule:: gnuradio.pyqt_plot + +.. autoclass:: gnuradio.pyqt_plot.Ui_MainWindow diff --git a/docs/sphinx/source/qtgui/index.rst b/docs/sphinx/source/qtgui/index.rst new file mode 100644 index 0000000000..83bdedca89 --- /dev/null +++ b/docs/sphinx/source/qtgui/index.rst @@ -0,0 +1,9 @@ +gnuradio.qtgui +============== + +.. automodule:: gnuradio.qtgui + +.. autooldblock:: gnuradio.qtgui.sink_c +.. autooldblock:: gnuradio.qtgui.sink_f +.. autooldblock:: gnuradio.qtgui.time_sink_c +.. autooldblock:: gnuradio.qtgui.time_sink_f diff --git a/docs/sphinx/source/trellis/blks.rst b/docs/sphinx/source/trellis/blks.rst new file mode 100644 index 0000000000..d82319bad6 --- /dev/null +++ b/docs/sphinx/source/trellis/blks.rst @@ -0,0 +1,62 @@ +gnuradio.trellis: Signal Processing Blocks +========================================== + +.. autooldblock:: gnuradio.trellis.constellation_metrics_cf +.. autooldblock:: gnuradio.trellis.encoder_bb +.. autooldblock:: gnuradio.trellis.encoder_bi +.. autooldblock:: gnuradio.trellis.encoder_bs +.. autooldblock:: gnuradio.trellis.encoder_ii +.. autooldblock:: gnuradio.trellis.encoder_si +.. autooldblock:: gnuradio.trellis.encoder_ss +.. autooldblock:: gnuradio.trellis.metrics_c +.. autooldblock:: gnuradio.trellis.metrics_f +.. autooldblock:: gnuradio.trellis.metrics_i +.. autooldblock:: gnuradio.trellis.metrics_s +.. autooldblock:: gnuradio.trellis.pccc_decoder_b +.. autooldblock:: gnuradio.trellis.pccc_decoder_combined_cb +.. autooldblock:: gnuradio.trellis.pccc_decoder_combined_ci +.. autooldblock:: gnuradio.trellis.pccc_decoder_combined_cs +.. autooldblock:: gnuradio.trellis.pccc_decoder_combined_fb +.. autooldblock:: gnuradio.trellis.pccc_decoder_combined_fi +.. autooldblock:: gnuradio.trellis.pccc_decoder_combined_fs +.. autooldblock:: gnuradio.trellis.pccc_decoder_i +.. autooldblock:: gnuradio.trellis.pccc_decoder_s +.. autooldblock:: gnuradio.trellis.pccc_encoder_bb +.. autooldblock:: gnuradio.trellis.pccc_encoder_bi +.. autooldblock:: gnuradio.trellis.pccc_encoder_bs +.. autooldblock:: gnuradio.trellis.pccc_encoder_ii +.. autooldblock:: gnuradio.trellis.pccc_encoder_si +.. autooldblock:: gnuradio.trellis.pccc_encoder_ss +.. autooldblock:: gnuradio.trellis.permutation +.. autooldblock:: gnuradio.trellis.sccc_decoder_b +.. autooldblock:: gnuradio.trellis.sccc_decoder_combined_cb +.. autooldblock:: gnuradio.trellis.sccc_decoder_combined_ci +.. autooldblock:: gnuradio.trellis.sccc_decoder_combined_cs +.. autooldblock:: gnuradio.trellis.sccc_decoder_combined_fb +.. autooldblock:: gnuradio.trellis.sccc_decoder_combined_fi +.. autooldblock:: gnuradio.trellis.sccc_decoder_combined_fs +.. autooldblock:: gnuradio.trellis.sccc_decoder_i +.. autooldblock:: gnuradio.trellis.sccc_decoder_s +.. autooldblock:: gnuradio.trellis.sccc_encoder_bb +.. autooldblock:: gnuradio.trellis.sccc_encoder_bi +.. autooldblock:: gnuradio.trellis.sccc_encoder_bs +.. autooldblock:: gnuradio.trellis.sccc_encoder_ii +.. autooldblock:: gnuradio.trellis.sccc_encoder_si +.. autooldblock:: gnuradio.trellis.sccc_encoder_ss +.. autooldblock:: gnuradio.trellis.siso_combined_f +.. autooldblock:: gnuradio.trellis.siso_f +.. autooldblock:: gnuradio.trellis.viterbi_b +.. autooldblock:: gnuradio.trellis.viterbi_combined_cb +.. autooldblock:: gnuradio.trellis.viterbi_combined_ci +.. autooldblock:: gnuradio.trellis.viterbi_combined_cs +.. autooldblock:: gnuradio.trellis.viterbi_combined_fb +.. autooldblock:: gnuradio.trellis.viterbi_combined_fi +.. autooldblock:: gnuradio.trellis.viterbi_combined_fs +.. autooldblock:: gnuradio.trellis.viterbi_combined_ib +.. autooldblock:: gnuradio.trellis.viterbi_combined_ii +.. autooldblock:: gnuradio.trellis.viterbi_combined_is +.. autooldblock:: gnuradio.trellis.viterbi_combined_sb +.. autooldblock:: gnuradio.trellis.viterbi_combined_si +.. autooldblock:: gnuradio.trellis.viterbi_combined_ss +.. autooldblock:: gnuradio.trellis.viterbi_i +.. autooldblock:: gnuradio.trellis.viterbi_s diff --git a/docs/sphinx/source/trellis/index.rst b/docs/sphinx/source/trellis/index.rst new file mode 100644 index 0000000000..8a451a9130 --- /dev/null +++ b/docs/sphinx/source/trellis/index.rst @@ -0,0 +1,90 @@ +gnuradio.trellis +================ + +.. automodule:: gnuradio.trellis + +Object Classes +-------------- + +.. autosummary:: + :nosignatures: + + gnuradio.trellis.fsm + gnuradio.trellis.interleaver + +Signal Processing Blocks +------------------------ + +.. autosummary:: + :nosignatures: + + gnuradio.trellis.constellation_metrics_cf + gnuradio.trellis.encoder_bb + gnuradio.trellis.encoder_bi + gnuradio.trellis.encoder_bs + gnuradio.trellis.encoder_ii + gnuradio.trellis.encoder_si + gnuradio.trellis.encoder_ss + gnuradio.trellis.metrics_c + gnuradio.trellis.metrics_f + gnuradio.trellis.metrics_i + gnuradio.trellis.metrics_s + gnuradio.trellis.pccc_decoder_b + gnuradio.trellis.pccc_decoder_combined_cb + gnuradio.trellis.pccc_decoder_combined_ci + gnuradio.trellis.pccc_decoder_combined_cs + gnuradio.trellis.pccc_decoder_combined_fb + gnuradio.trellis.pccc_decoder_combined_fi + gnuradio.trellis.pccc_decoder_combined_fs + gnuradio.trellis.pccc_decoder_i + gnuradio.trellis.pccc_decoder_s + gnuradio.trellis.pccc_encoder_bb + gnuradio.trellis.pccc_encoder_bi + gnuradio.trellis.pccc_encoder_bs + gnuradio.trellis.pccc_encoder_ii + gnuradio.trellis.pccc_encoder_si + gnuradio.trellis.pccc_encoder_ss + gnuradio.trellis.permutation + gnuradio.trellis.sccc_decoder_b + gnuradio.trellis.sccc_decoder_combined_cb + gnuradio.trellis.sccc_decoder_combined_ci + gnuradio.trellis.sccc_decoder_combined_cs + gnuradio.trellis.sccc_decoder_combined_fb + gnuradio.trellis.sccc_decoder_combined_fi + gnuradio.trellis.sccc_decoder_combined_fs + gnuradio.trellis.sccc_decoder_i + gnuradio.trellis.sccc_decoder_s + gnuradio.trellis.sccc_encoder_bb + gnuradio.trellis.sccc_encoder_bi + gnuradio.trellis.sccc_encoder_bs + gnuradio.trellis.sccc_encoder_ii + gnuradio.trellis.sccc_encoder_si + gnuradio.trellis.sccc_encoder_ss + gnuradio.trellis.siso_combined_f + gnuradio.trellis.siso_f + gnuradio.trellis.viterbi_b + gnuradio.trellis.viterbi_combined_cb + gnuradio.trellis.viterbi_combined_ci + gnuradio.trellis.viterbi_combined_cs + gnuradio.trellis.viterbi_combined_fb + gnuradio.trellis.viterbi_combined_fi + gnuradio.trellis.viterbi_combined_fs + gnuradio.trellis.viterbi_combined_ib + gnuradio.trellis.viterbi_combined_ii + gnuradio.trellis.viterbi_combined_is + gnuradio.trellis.viterbi_combined_sb + gnuradio.trellis.viterbi_combined_si + gnuradio.trellis.viterbi_combined_ss + gnuradio.trellis.viterbi_i + gnuradio.trellis.viterbi_s + +Constants +--------- + +.. autosummary:: + :nosignatures: + + gnuradio.trellis.TRELLIS_MIN_SUM + gnuradio.trellis.TRELLIS_SUM_PRODUCT + + diff --git a/docs/sphinx/source/trellis/objs.rst b/docs/sphinx/source/trellis/objs.rst new file mode 100644 index 0000000000..b3a4b7a4ae --- /dev/null +++ b/docs/sphinx/source/trellis/objs.rst @@ -0,0 +1,5 @@ +gnuradio.trellis: Object Classes +-------------------------------- + +.. autoclass:: gnuradio.trellis.fsm +.. autoclass:: gnuradio.trellis.interleaver diff --git a/docs/sphinx/source/video_sdl.rst b/docs/sphinx/source/video_sdl.rst new file mode 100644 index 0000000000..6be88d788c --- /dev/null +++ b/docs/sphinx/source/video_sdl.rst @@ -0,0 +1,7 @@ +gnuradio.video_sdl +================== + +.. automodule:: gnuradio.video_sdl + +.. autooldblock:: gnuradio.video_sdl.sink_s +.. autooldblock:: gnuradio.video_sdl.sink_uc diff --git a/docs/sphinx/source/vocoder/blks.rst b/docs/sphinx/source/vocoder/blks.rst new file mode 100644 index 0000000000..34eda9d250 --- /dev/null +++ b/docs/sphinx/source/vocoder/blks.rst @@ -0,0 +1,19 @@ +gnuradio.vocoder +================ + +.. autooldblock:: gnuradio.vocoder.alaw_decode_bs +.. autooldblock:: gnuradio.vocoder.alaw_encode_sb +.. autooldblock:: gnuradio.vocoder.codec2_decode_ps +.. autooldblock:: gnuradio.vocoder.codec2_encode_sp +.. autooldblock:: gnuradio.vocoder.cvsd_decode_bs +.. autooldblock:: gnuradio.vocoder.cvsd_encode_sb +.. autooldblock:: gnuradio.vocoder.g721_decode_bs +.. autooldblock:: gnuradio.vocoder.g721_encode_sb +.. autooldblock:: gnuradio.vocoder.g723_24_decode_bs +.. autooldblock:: gnuradio.vocoder.g723_24_encode_sb +.. autooldblock:: gnuradio.vocoder.g723_40_decode_bs +.. autooldblock:: gnuradio.vocoder.g723_40_encode_sb +.. autooldblock:: gnuradio.vocoder.gsm_fr_decode_ps +.. autooldblock:: gnuradio.vocoder.gsm_fr_encode_sp +.. autooldblock:: gnuradio.vocoder.ulaw_decode_bs +.. autooldblock:: gnuradio.vocoder.ulaw_encode_sb diff --git a/docs/sphinx/source/vocoder/index.rst b/docs/sphinx/source/vocoder/index.rst new file mode 100644 index 0000000000..2e31809958 --- /dev/null +++ b/docs/sphinx/source/vocoder/index.rst @@ -0,0 +1,26 @@ +gnuradio.vocoder +================ + +.. automodule:: gnuradio.vocoder + +.. autosummary:: + :nosignatures: + + gnuradio.vocoder.alaw_decode_bs + gnuradio.vocoder.alaw_encode_sb + gnuradio.vocoder.codec2_decode_ps + gnuradio.vocoder.codec2_encode_sp + gnuradio.vocoder.cvsd_decode_bf + gnuradio.vocoder.cvsd_decode_bs + gnuradio.vocoder.cvsd_encode_fb + gnuradio.vocoder.cvsd_encode_sb + gnuradio.vocoder.g721_decode_bs + gnuradio.vocoder.g721_encode_sb + gnuradio.vocoder.g723_24_decode_bs + gnuradio.vocoder.g723_24_encode_sb + gnuradio.vocoder.g723_40_decode_bs + gnuradio.vocoder.g723_40_encode_sb + gnuradio.vocoder.gsm_fr_decode_ps + gnuradio.vocoder.gsm_fr_encode_sp + gnuradio.vocoder.ulaw_decode_bs + gnuradio.vocoder.ulaw_encode_sb diff --git a/docs/sphinx/source/wavelet.rst b/docs/sphinx/source/wavelet.rst new file mode 100644 index 0000000000..5236c4dbb2 --- /dev/null +++ b/docs/sphinx/source/wavelet.rst @@ -0,0 +1,8 @@ +gnuradio.wavelet +================ + +.. automodule:: gnuradio.wavelet + +.. autooldblock:: gnuradio.wavelet.squash_ff +.. autooldblock:: gnuradio.wavelet.wavelet_ff +.. autooldblock:: gnuradio.wavelet.wvps_ff diff --git a/docs/sphinx/source/window/detail.rst b/docs/sphinx/source/window/detail.rst new file mode 100644 index 0000000000..7222a0cb47 --- /dev/null +++ b/docs/sphinx/source/window/detail.rst @@ -0,0 +1,20 @@ +gnuradio.window +=============== + +.. autofunction:: gnuradio.window.bartlett +.. autofunction:: gnuradio.window.blackman2 +.. autofunction:: gnuradio.window.blackman3 +.. autofunction:: gnuradio.window.blackman4 +.. autofunction:: gnuradio.window.blackmanharris +.. autofunction:: gnuradio.window.coswindow +.. autofunction:: gnuradio.window.exponential +.. autofunction:: gnuradio.window.flattop +.. autofunction:: gnuradio.window.hamming +.. autofunction:: gnuradio.window.hanning +.. autofunction:: gnuradio.window.kaiser +.. autofunction:: gnuradio.window.nuttall +.. autofunction:: gnuradio.window.nuttall_cfd +.. autofunction:: gnuradio.window.parzen +.. autofunction:: gnuradio.window.rectangular +.. autofunction:: gnuradio.window.riemann +.. autofunction:: gnuradio.window.welch diff --git a/docs/sphinx/source/window/index.rst b/docs/sphinx/source/window/index.rst new file mode 100644 index 0000000000..6ecfea0e9f --- /dev/null +++ b/docs/sphinx/source/window/index.rst @@ -0,0 +1,25 @@ +gnuradio.window +=============== + +.. automodule:: gnuradio.window + +.. autosummary:: + :nosignatures: + + gnuradio.window.bartlett + gnuradio.window.blackman2 + gnuradio.window.blackman3 + gnuradio.window.blackman4 + gnuradio.window.blackmanharris + gnuradio.window.coswindow + gnuradio.window.exponential + gnuradio.window.flattop + gnuradio.window.hamming + gnuradio.window.hanning + gnuradio.window.kaiser + gnuradio.window.nuttall + gnuradio.window.nuttall_cfd + gnuradio.window.parzen + gnuradio.window.rectangular + gnuradio.window.riemann + gnuradio.window.welch diff --git a/docs/sphinx/source/wxgui/blks.rst b/docs/sphinx/source/wxgui/blks.rst new file mode 100644 index 0000000000..c304ea0a83 --- /dev/null +++ b/docs/sphinx/source/wxgui/blks.rst @@ -0,0 +1,13 @@ +gnuradio.wxgui +===================== + +.. autopyblock:: gnuradio.wxgui.constsink_gl.const_sink_c +.. autopyblock:: gnuradio.wxgui.fftsink2.fft_sink_c +.. autopyblock:: gnuradio.wxgui.fftsink2.fft_sink_f +.. autopyblock:: gnuradio.wxgui.histosink_gl.histo_sink_f +.. autopyblock:: gnuradio.wxgui.numbersink2.number_sink_c +.. autopyblock:: gnuradio.wxgui.numbersink2.number_sink_f +.. autopyblock:: gnuradio.wxgui.scopesink2.scope_sink_c +.. autopyblock:: gnuradio.wxgui.scopesink2.scope_sink_f +.. autopyblock:: gnuradio.wxgui.waterfallsink2.waterfall_sink_c +.. autopyblock:: gnuradio.wxgui.waterfallsink2.waterfall_sink_f diff --git a/docs/sphinx/source/wxgui/index.rst b/docs/sphinx/source/wxgui/index.rst new file mode 100644 index 0000000000..f3fa4f3370 --- /dev/null +++ b/docs/sphinx/source/wxgui/index.rst @@ -0,0 +1,18 @@ +gnuradio.wxgui +============== + +.. automodule:: gnuradio.wxgui + +.. autosummary:: + :nosignatures: + + gnuradio.wxgui.common.const_sink_c + gnuradio.wxgui.fftsink2.fft_sink_c + gnuradio.wxgui.fftsink2.fft_sink_f + gnuradio.wxgui.histosink_gl.histosink_f + gnuradio.wxgui.numbersink2.number_sink_c + gnuradio.wxgui.numbersink2.number_sink_f + gnuradio.wxgui.scopesink2.scope_sink_c + gnuradio.wxgui.scopesink2.scope_sink_f + gnuradio.wxgui.waterfallsink2.waterfall_sink_c + gnuradio.wxgui.waterfallsink2.waterfall_sink_f diff --git a/gnuradio-core/CMakeLists.txt b/gnuradio-core/CMakeLists.txt index 0227108446..4e76b3c5a6 100644 --- a/gnuradio-core/CMakeLists.txt +++ b/gnuradio-core/CMakeLists.txt @@ -64,6 +64,7 @@ GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS GR_SET_GLOBAL(GNURADIO_CORE_SWIG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/gruel/src/swig + ${CMAKE_BINARY_DIR}/gruel/src/swig/ ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/swig ${GNURADIO_CORE_INCLUDE_DIRS} ) @@ -109,7 +110,7 @@ CPACK_COMPONENT("core_swig" install( FILES gnuradio-core.conf - DESTINATION ${GR_PKG_CONF_DIR} + DESTINATION ${GR_PREFSDIR} COMPONENT "core_runtime" ) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index cb7c939626..a8cb849e27 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -96,6 +96,7 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, gr_pfb_channelizer_ccf::~gr_pfb_channelizer_ccf () { + delete d_fft; delete [] d_idxlut; for(unsigned int i = 0; i < d_numchans; i++) { diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc index c973daf829..e563daa513 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc @@ -69,6 +69,7 @@ gr_pfb_decimator_ccf::gr_pfb_decimator_ccf (unsigned int decim, gr_pfb_decimator_ccf::~gr_pfb_decimator_ccf () { + delete d_fft; for(unsigned int i = 0; i < d_rate; i++) { delete d_filters[i]; } diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc index 9910a18510..cd01aaff5c 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc @@ -74,6 +74,7 @@ gr_pfb_synthesizer_ccf::gr_pfb_synthesizer_ccf gr_pfb_synthesizer_ccf::~gr_pfb_synthesizer_ccf () { + delete d_fft; for(unsigned int i = 0; i < d_twox*d_numchans; i++) { delete d_filters[i]; } diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 207d85c4c4..399e075996 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -48,9 +48,6 @@ message(STATUS "Loading build date ${BUILD_DATE} into gr_constants...") message(STATUS "Loading version ${VERSION} into gr_constants...") -file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${GR_CONF_DIR}" SYSCONFDIR) -file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${GR_PKG_CONF_DIR}" GR_PREFSDIR) - #double escape for windows backslash path separators string(REPLACE "\\" "\\\\" prefix ${prefix}) string(REPLACE "\\" "\\\\" SYSCONFDIR ${SYSCONFDIR}) @@ -228,6 +225,7 @@ set(gr_core_general_triple_threats gr_interleaved_short_to_complex gr_iqcomp_cc gr_keep_one_in_n + gr_keep_m_in_n gr_kludge_copy gr_lfsr_32k_source_s gr_map_bb @@ -281,14 +279,17 @@ set(gr_core_general_triple_threats gr_transcendental gr_uchar_to_float gr_vco_f + gr_vector_map gr_vector_to_stream gr_vector_to_streams gr_unpack_k_bits_bb + gr_pack_k_bits_bb gr_descrambler_bb gr_scrambler_bb gr_probe_density_b gr_annotator_alltoall gr_annotator_1to1 + gr_annotator_raw gr_burst_tagger gr_correlate_access_code_tag_bb ) diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index cd8c279c92..fe2cbdb822 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -37,6 +37,7 @@ #include <gr_stream_to_vector.h> #include <gr_vector_to_stream.h> #include <gr_keep_one_in_n.h> +#include <gr_keep_m_in_n.h> #include <gr_fft_vcc.h> #include <gr_fft_vfc.h> #include <gr_float_to_int.h> @@ -100,6 +101,7 @@ #include <gr_test_types.h> #include <gr_test.h> #include <gr_unpack_k_bits_bb.h> +#include <gr_pack_k_bits_bb.h> #include <gr_diff_phasor_cc.h> #include <gr_diff_encoder_bb.h> #include <gr_diff_decoder_bb.h> @@ -133,10 +135,12 @@ #include <complex_vec_test.h> #include <gr_annotator_alltoall.h> #include <gr_annotator_1to1.h> +#include <gr_annotator_raw.h> #include <gr_burst_tagger.h> #include <gr_cpm.h> #include <gr_correlate_access_code_tag_bb.h> #include <gr_add_ff.h> +#include <gr_vector_map.h> %} %include "gri_control_loop.i" @@ -154,6 +158,7 @@ %include "gr_stream_to_vector.i" %include "gr_vector_to_stream.i" %include "gr_keep_one_in_n.i" +%include "gr_keep_m_in_n.i" %include "gr_fft_vcc.i" %include "gr_fft_vfc.i" %include "gr_float_to_int.i" @@ -217,6 +222,7 @@ %include "gr_test_types.h" %include "gr_test.i" %include "gr_unpack_k_bits_bb.i" +%include "gr_pack_k_bits_bb.i" %include "gr_diff_phasor_cc.i" %include "gr_diff_encoder_bb.i" %include "gr_diff_decoder_bb.i" @@ -250,7 +256,9 @@ %include "complex_vec_test.i" %include "gr_annotator_alltoall.i" %include "gr_annotator_1to1.i" +%include "gr_annotator_raw.i" %include "gr_burst_tagger.i" %include "gr_cpm.i" %include "gr_correlate_access_code_tag_bb.i" %include "gr_add_ff.i" +%include "gr_vector_map.i" diff --git a/gnuradio-core/src/lib/general/gr_add_ff.cc b/gnuradio-core/src/lib/general/gr_add_ff.cc index 2e45673d3b..5f6676bb7b 100644 --- a/gnuradio-core/src/lib/general/gr_add_ff.cc +++ b/gnuradio-core/src/lib/general/gr_add_ff.cc @@ -42,7 +42,7 @@ gr_add_ff::gr_add_ff (size_t vlen) { const int alignment_multiple = volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.cc b/gnuradio-core/src/lib/general/gr_annotator_raw.cc new file mode 100644 index 0000000000..e1ae73efb6 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_annotator_raw.cc @@ -0,0 +1,106 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_annotator_raw.h> +#include <gr_io_signature.h> +#include <string.h> +#include <iostream> +#include <iomanip> +#include <stdexcept> + +using namespace pmt; + +gr_annotator_raw_sptr +gr_make_annotator_raw(size_t sizeof_stream_item) +{ + return gnuradio::get_initial_sptr(new gr_annotator_raw + (sizeof_stream_item)); +} + +gr_annotator_raw::gr_annotator_raw(size_t sizeof_stream_item) + : gr_sync_block("annotator_raw", + gr_make_io_signature(1, 1, sizeof_stream_item), + gr_make_io_signature(1, 1, sizeof_stream_item)), + d_itemsize(sizeof_stream_item) +{ + set_tag_propagation_policy(TPP_ONE_TO_ONE); + set_relative_rate(1.0); +} + +void gr_annotator_raw::add_tag(uint64_t offset, pmt_t key, pmt_t val) +{ + gruel::scoped_lock l(d_mutex); + + gr_tag_t tag; + tag.srcid = pmt::pmt_intern(d_name); + tag.key = key; + tag.value = val; + tag.offset = offset; + + // add our new tag + d_queued_tags.push_back(tag); + // make sure our tags are in offset order + std::sort(d_queued_tags.begin(), d_queued_tags.end(), + gr_tag_t::offset_compare); + // make sure we are not adding an item in the past! + if(tag.offset > nitems_read(0)) { + throw std::runtime_error("gr_annotator_raw::add_tag: item added too far in the past\n."); + } +} + +gr_annotator_raw::~gr_annotator_raw() +{ +} + +int +gr_annotator_raw::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + gruel::scoped_lock l(d_mutex); + + const char *in = (const char*)input_items[0]; + char *out = (char*)output_items[0]; + + uint64_t start_N = nitems_read(0); + uint64_t end_N = start_N + (uint64_t)(noutput_items); + + // locate queued tags that fall in this range and insert them when appropriate + std::vector<gr_tag_t>::iterator i = d_queued_tags.begin(); + while( i != d_queued_tags.end() ) { + if( (*i).offset >= start_N && (*i).offset < end_N) { + add_item_tag(0, (*i).offset,(*i).key, (*i).value, (*i).srcid); + i = d_queued_tags.erase(i); + } + else { + break; + } + } + + // copy data across + memcpy(out, in, noutput_items*d_itemsize); + return noutput_items; +} diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.h b/gnuradio-core/src/lib/general/gr_annotator_raw.h new file mode 100644 index 0000000000..8a6c3f6c02 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_annotator_raw.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_ANNOTATOR_RAW_H +#define INCLUDED_GR_ANNOTATOR_RAW_H + +#include <gr_core_api.h> +#include <gr_sync_block.h> +#include <gruel/pmt.h> +#include <gruel/thread.h> + +class gr_annotator_raw; +typedef boost::shared_ptr<gr_annotator_raw> gr_annotator_raw_sptr; + +// public constructor +GR_CORE_API gr_annotator_raw_sptr +gr_make_annotator_raw(size_t sizeof_stream_item); + +/*! + * \brief raw stream annotator testing block. + * + * This block creates arbitrary tags to be sent downstream + * blocks to be sent are set manually via accessor methods and are sent only once. + * + * This block is intended for testing of tag related blocks + */ +class GR_CORE_API gr_annotator_raw : public gr_sync_block +{ + public: + ~gr_annotator_raw(); + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + // insert a tag to be added + void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val); + +protected: + gr_annotator_raw(size_t sizeof_stream_item); + + private: + size_t d_itemsize; + std::vector<gr_tag_t> d_queued_tags; + gruel::mutex d_mutex; + + friend GR_CORE_API gr_annotator_raw_sptr + gr_make_annotator_raw(size_t sizeof_stream_item); +}; + +#endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.i b/gnuradio-core/src/lib/general/gr_annotator_raw.i new file mode 100644 index 0000000000..85777ef5d4 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_annotator_raw.i @@ -0,0 +1,26 @@ +/* -*- c++ -*- */ +/* + * Copyright 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. + */ + +GR_SWIG_BLOCK_MAGIC(gr,annotator_raw); + +%include <pmt_swig.i> +%include <gr_annotator_raw.h> diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.cc b/gnuradio-core/src/lib/general/gr_char_to_float.cc index aec7ad8522..f63aa5b169 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_float.cc +++ b/gnuradio-core/src/lib/general/gr_char_to_float.cc @@ -42,7 +42,7 @@ gr_char_to_float::gr_char_to_float (size_t vlen, float scale) { const int alignment_multiple = volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } float diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.cc b/gnuradio-core/src/lib/general/gr_char_to_short.cc index c20d6cd888..bb9bd8909e 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_short.cc +++ b/gnuradio-core/src/lib/general/gr_char_to_short.cc @@ -42,7 +42,7 @@ gr_char_to_short::gr_char_to_short (size_t vlen) { const int alignment_multiple = volk_get_alignment() / sizeof(char); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc index 3b1fbf9acd..cdf6d7f3a6 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc +++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc @@ -45,7 +45,7 @@ gr_complex_to_float::gr_complex_to_float (unsigned int vlen) { const int alignment_multiple = volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int @@ -106,7 +106,7 @@ gr_complex_to_real::gr_complex_to_real (unsigned int vlen) { const int alignment_multiple = volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int @@ -146,7 +146,7 @@ gr_complex_to_imag::gr_complex_to_imag (unsigned int vlen) { const int alignment_multiple = volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int @@ -186,7 +186,7 @@ gr_complex_to_mag::gr_complex_to_mag (unsigned int vlen) { const int alignment_multiple = volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int @@ -220,7 +220,7 @@ gr_complex_to_mag_squared::gr_complex_to_mag_squared (unsigned int vlen) { const int alignment_multiple = volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int @@ -258,7 +258,7 @@ gr_complex_to_arg::gr_complex_to_arg (unsigned int vlen) { const int alignment_multiple = volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc index aaa7f490c7..94ac3e162b 100644 --- a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc +++ b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc @@ -43,7 +43,7 @@ gr_conjugate_cc::gr_conjugate_cc () { const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.cc b/gnuradio-core/src/lib/general/gr_float_to_char.cc index 3602ad7453..d67ded3ea6 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_char.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_char.cc @@ -42,7 +42,7 @@ gr_float_to_char::gr_float_to_char (size_t vlen, float scale) { const int alignment_multiple = volk_get_alignment() / sizeof(char); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } float diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.cc b/gnuradio-core/src/lib/general/gr_float_to_int.cc index bd3cd6a3b3..43b8518956 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_int.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_int.cc @@ -43,7 +43,7 @@ gr_float_to_int::gr_float_to_int (size_t vlen, float scale) { const int alignment_multiple = volk_get_alignment() / sizeof(int); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } float diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.cc b/gnuradio-core/src/lib/general/gr_float_to_short.cc index 07995c99aa..ab720168bf 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_short.cc @@ -42,7 +42,7 @@ gr_float_to_short::gr_float_to_short (size_t vlen, float scale) { const int alignment_multiple = volk_get_alignment() / sizeof(short); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } float diff --git a/gnuradio-core/src/lib/general/gr_head.h b/gnuradio-core/src/lib/general/gr_head.h index 17dd737f0b..48415892dd 100644 --- a/gnuradio-core/src/lib/general/gr_head.h +++ b/gnuradio-core/src/lib/general/gr_head.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2009 Free Software Foundation, Inc. + * Copyright 2004,2009,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -51,6 +51,7 @@ class GR_CORE_API gr_head : public gr_sync_block gr_vector_void_star &output_items); void reset() { d_ncopied_items = 0; } + void set_length(int nitems) { d_nitems = nitems; } }; GR_CORE_API gr_head_sptr diff --git a/gnuradio-core/src/lib/general/gr_head.i b/gnuradio-core/src/lib/general/gr_head.i index 73feaf181c..11f3331d47 100644 --- a/gnuradio-core/src/lib/general/gr_head.i +++ b/gnuradio-core/src/lib/general/gr_head.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2009 Free Software Foundation, Inc. + * Copyright 2004,2009,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -28,5 +28,6 @@ class gr_head : public gr_block { gr_head(); public: void reset(); + void set_length(int nitems); }; diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.cc b/gnuradio-core/src/lib/general/gr_int_to_float.cc index a284853055..a7fb24dc69 100644 --- a/gnuradio-core/src/lib/general/gr_int_to_float.cc +++ b/gnuradio-core/src/lib/general/gr_int_to_float.cc @@ -42,7 +42,7 @@ gr_int_to_float::gr_int_to_float (size_t vlen, float scale) { const int alignment_multiple = volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc new file mode 100644 index 0000000000..1becbfa116 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc @@ -0,0 +1,98 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_keep_m_in_n.h> +#include <gr_io_signature.h> +#include <string.h> +#include <stdio.h> + +gr_keep_m_in_n_sptr +gr_make_keep_m_in_n(size_t item_size, int m, int n, int offset) +{ + return gnuradio::get_initial_sptr(new gr_keep_m_in_n(item_size, m, n, offset)); +} + + +/* +* +* offset = 0, starts with 0th item +* offset = 1, starts with 1st item, etc... +* +* we take m items out of each n +*/ +gr_keep_m_in_n::gr_keep_m_in_n(size_t item_size, int m, int n, int offset) + : gr_block("keep_m_in_n", + gr_make_io_signature(1, 1, item_size), + gr_make_io_signature(1, 1, item_size)), + d_n(n), + d_m(m), + d_offset(offset), + d_itemsize(item_size) +{ + // sanity checking + assert(d_m > 0); + assert(d_n > 0); + assert(d_m <= d_n); + assert(d_offset <= (d_n-d_m)); + + set_output_multiple(m); +} + + +void +gr_keep_m_in_n::forecast(int noutput_items, gr_vector_int &ninput_items_required) +{ + ninput_items_required[0] = d_n*(noutput_items/d_m); +} + +void +gr_keep_m_in_n::set_offset(int offset) +{ + d_offset = offset; +} + +int +gr_keep_m_in_n::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + uint8_t* out = (uint8_t*)output_items[0]; + const uint8_t* in = (const uint8_t*)input_items[0]; + + // iterate over data blocks of size {n, input : m, output} + int blks = std::min(noutput_items/d_m, ninput_items[0]/d_n); + for(int i=0; i<blks; i++) { + // set up copy pointers + const uint8_t* iptr = &in[(i*d_n + d_offset)*d_itemsize]; + uint8_t* optr = &out[i*d_m*d_itemsize]; + // perform copy + memcpy( optr, iptr, d_m*d_itemsize ); + } + + consume_each(d_n); + return d_m; +} diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.h b/gnuradio-core/src/lib/general/gr_keep_m_in_n.h new file mode 100644 index 0000000000..c6bf40ecf2 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.h @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_KEEP_M_IN_N_H +#define INCLUDED_GR_KEEP_M_IN_N_H + +#include <gr_core_api.h> +#include <gr_block.h> + +class gr_keep_m_in_n; +typedef boost::shared_ptr<gr_keep_m_in_n> gr_keep_m_in_n_sptr; + +GR_CORE_API gr_keep_m_in_n_sptr +gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset); + + +/*! + * \brief decimate a stream, keeping one item out of every n. + * \ingroup slicedice_blk + */ +class GR_CORE_API gr_keep_m_in_n : public gr_block +{ + friend GR_CORE_API gr_keep_m_in_n_sptr + gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset); + + int d_n; + int d_m; + int d_count; + int d_offset; + int d_itemsize; + + protected: + gr_keep_m_in_n (size_t item_size, int m, int n, int offset); + void forecast (int noutput_items, gr_vector_int &ninput_items_required); + + public: + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + void set_offset(int offset); + void set_n(int n){ d_n = n; } + void set_m(int m){ d_m = m; } + +}; + +#endif /* INCLUDED_GR_KEEP_M_IN_N_H */ diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.i b/gnuradio-core/src/lib/general/gr_keep_m_in_n.i new file mode 100644 index 0000000000..f280c0248a --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.i @@ -0,0 +1,35 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(gr,keep_m_in_n) + +gr_keep_m_in_n_sptr +gr_make_keep_m_in_n (size_t itemsize, int m, int n, int offset); + +class gr_keep_m_in_n : public gr_sync_block +{ + protected: + gr_keep_m_in_n (size_t itemsize, int m, int n, int offset); + public: + void set_offset(int offset); + +}; diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_cc.cc index 32c44a19e4..4a3751419f 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_cc.cc +++ b/gnuradio-core/src/lib/general/gr_multiply_cc.cc @@ -40,9 +40,9 @@ gr_multiply_cc::gr_multiply_cc (size_t vlen) gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)), d_vlen(vlen) { - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(alignment_multiple); + const int alignment_multiple = + volk_get_alignment() / sizeof(gr_complex); + set_alignment(std::max(1,alignment_multiple)); } int diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc index 53ede2eeda..0c5fb4a926 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc +++ b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc @@ -40,9 +40,9 @@ gr_multiply_conjugate_cc::gr_multiply_conjugate_cc (size_t vlen) gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)), d_vlen(vlen) { - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(alignment_multiple); + const int alignment_multiple = + volk_get_alignment() / sizeof(gr_complex); + set_alignment(std::max(1,alignment_multiple)); } int diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc index 359ab6ba05..bd4511937f 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc +++ b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc @@ -40,9 +40,9 @@ gr_multiply_const_cc::gr_multiply_const_cc (gr_complex k, size_t vlen) gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)), d_k(k), d_vlen(vlen) { - const int alignment_multiple = - volk_get_alignment() / sizeof(gr_complex); - set_alignment(alignment_multiple); + const int alignment_multiple = + volk_get_alignment() / sizeof(gr_complex); + set_alignment(std::max(1,alignment_multiple)); } gr_complex diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc index 263f066106..16ba39df93 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc +++ b/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc @@ -40,9 +40,9 @@ gr_multiply_const_ff::gr_multiply_const_ff (float k, size_t vlen) gr_make_io_signature (1, 1, sizeof (float)*vlen)), d_k(k), d_vlen(vlen) { - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + const int alignment_multiple = + volk_get_alignment() / sizeof(float); + set_alignment(std::max(1,alignment_multiple)); } float diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_ff.cc index f764a71e8f..bb7bd07550 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_ff.cc +++ b/gnuradio-core/src/lib/general/gr_multiply_ff.cc @@ -42,7 +42,7 @@ gr_multiply_ff::gr_multiply_ff (size_t vlen) { const int alignment_multiple = volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc new file mode 100644 index 0000000000..0ea0c9e388 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_pack_k_bits_bb.h> +#include <gr_io_signature.h> +#include <stdexcept> +#include <iostream> + +gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb(unsigned k) +{ + return gnuradio::get_initial_sptr(new gr_pack_k_bits_bb(k)); +} + + +gr_pack_k_bits_bb::gr_pack_k_bits_bb (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"); +} + +gr_pack_k_bits_bb::~gr_pack_k_bits_bb() +{ +} + +int +gr_pack_k_bits_bb::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; +} diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h new file mode 100644 index 0000000000..8e1508c78b --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_PACK_K_BITS_BB_H +#define INCLUDED_GR_PACK_K_BITS_BB_H + +#include <gr_core_api.h> +#include <gr_sync_decimator.h> + +class gr_pack_k_bits_bb; +typedef boost::shared_ptr<gr_pack_k_bits_bb> gr_pack_k_bits_bb_sptr; +GR_CORE_API gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k); + +class gr_pack_k_bits_bb; + +/*! + * \brief Converts a stream of bytes with 1 bit in the LSB to a byte with k relevent bits. + * \ingroup converter_blk + */ +class GR_CORE_API gr_pack_k_bits_bb : public gr_sync_decimator +{ + private: + friend GR_CORE_API gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k); + + gr_pack_k_bits_bb (unsigned k); + + unsigned d_k; // number of relevent bits to pack from k input bytes + + public: + ~gr_pack_k_bits_bb (); + + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i new file mode 100644 index 0000000000..6ae2095ec7 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i @@ -0,0 +1,34 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(gr,pack_k_bits_bb) + +gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (int k) throw(std::exception); + +class gr_pack_k_bits_bb : public gr_sync_decimator +{ + private: + gr_pack_k_bits_bb (int k); + + public: + ~gr_pack_k_bits_bb (); +}; diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.cc b/gnuradio-core/src/lib/general/gr_short_to_char.cc index 9d6c41406e..8c146a351d 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_char.cc +++ b/gnuradio-core/src/lib/general/gr_short_to_char.cc @@ -42,7 +42,7 @@ gr_short_to_char::gr_short_to_char (size_t vlen) { const int alignment_multiple = volk_get_alignment() / sizeof(char); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } int diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.cc b/gnuradio-core/src/lib/general/gr_short_to_float.cc index 960cf644d1..093d6024fa 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_float.cc +++ b/gnuradio-core/src/lib/general/gr_short_to_float.cc @@ -42,7 +42,7 @@ gr_short_to_float::gr_short_to_float (size_t vlen, float scale) { const int alignment_multiple = volk_get_alignment() / sizeof(float); - set_alignment(alignment_multiple); + set_alignment(std::max(1,alignment_multiple)); } float diff --git a/gnuradio-core/src/lib/general/gr_vector_map.cc b/gnuradio-core/src/lib/general/gr_vector_map.cc new file mode 100644 index 0000000000..2a13efb06d --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_vector_map.cc @@ -0,0 +1,117 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_vector_map.h> +#include <gr_io_signature.h> +#include <string.h> + +std::vector<int> +get_in_sizeofs(size_t item_size, std::vector<size_t> in_vlens) +{ + std::vector<int> in_sizeofs; + for(unsigned int i = 0; i < in_vlens.size(); i++) { + in_sizeofs.push_back(in_vlens[i]*item_size); + } + return in_sizeofs; +} + +std::vector<int> +get_out_sizeofs(size_t item_size, + std::vector< std::vector< std::vector<size_t> > > mapping) +{ + std::vector<int> out_sizeofs; + for(unsigned int i = 0; i < mapping.size(); i++) { + out_sizeofs.push_back(mapping[i].size()*item_size); + } + return out_sizeofs; +} + +gr_vector_map_sptr +gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping) +{ + return gnuradio::get_initial_sptr(new gr_vector_map(item_size, + in_vlens, + mapping)); +} + +gr_vector_map::gr_vector_map(size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping) + : gr_sync_block("vector_map", + gr_make_io_signaturev(in_vlens.size(), in_vlens.size(), + get_in_sizeofs(item_size, in_vlens)), + gr_make_io_signaturev(mapping.size(), mapping.size(), + get_out_sizeofs(item_size, mapping))), + d_item_size(item_size), d_in_vlens(in_vlens) +{ + set_mapping(mapping); +} + +void +gr_vector_map::set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping) { + // Make sure the contents of the mapping vectors are possible. + for(unsigned int i=0; i<mapping.size(); i++) { + for(unsigned int j=0; j<mapping[i].size(); j++) { + if(mapping[i][j].size() != 2) { + throw std::runtime_error("Mapping must be of the form (out_mapping_stream1, out_mapping_stream2, ...), where out_mapping_stream1 is of the form (mapping_element1, mapping_element2, ...), where mapping_element1 is of the form (input_stream, input_element). This error is raised because a mapping_element vector does not contain exactly 2 items."); + } + unsigned int s = mapping[i][j][0]; + unsigned int index = mapping[i][j][1]; + if(s >= d_in_vlens.size()) { + throw std::runtime_error("Stream numbers in mapping must be less than the number of input streams."); + } + if((index < 0) || (index >= d_in_vlens[s])) { + throw std::runtime_error ("Indices in mapping must be greater than 0 and less than the input vector lengths."); + } + } + } + gruel::scoped_lock guard(d_mutex); + d_mapping = mapping; +} + +int +gr_vector_map::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const char **inv = (const char **) &input_items[0]; + char **outv = (char **) &output_items[0]; + + for(unsigned int n = 0; n < (unsigned int)(noutput_items); n++) { + for(unsigned int i = 0; i < d_mapping.size(); i++) { + unsigned int out_vlen = d_mapping[i].size(); + for(unsigned int j = 0; j < out_vlen; j++) { + unsigned int s = d_mapping[i][j][0]; + unsigned int k = d_mapping[i][j][1]; + memcpy(outv[i] + out_vlen*d_item_size*n + + d_item_size*j, inv[s] + d_in_vlens[s]*d_item_size*n + + k*d_item_size, d_item_size); + } + } + } + + return noutput_items; +} diff --git a/gnuradio-core/src/lib/general/gr_vector_map.h b/gnuradio-core/src/lib/general/gr_vector_map.h new file mode 100644 index 0000000000..f5492b1e3a --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_vector_map.h @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_VECTOR_MAP_H +#define INCLUDED_GR_VECTOR_MAP_H + +#include <vector> +#include <gr_core_api.h> +#include <gr_sync_interpolator.h> +#include <gruel/thread.h> + +class gr_vector_map; +typedef boost::shared_ptr<gr_vector_map> gr_vector_map_sptr; + +GR_CORE_API gr_vector_map_sptr +gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping); + +/*! + * \brief Maps elements from a set of input vectors to a set of output vectors. + * + * If in[i] is the input vector in the i'th stream then the output + * vector in the j'th stream is: + * + * out[j][k] = in[mapping[j][k][0]][mapping[j][k][1]] + * + * That is mapping is of the form (out_stream1_mapping, + * out_stream2_mapping, ...) and out_stream1_mapping is of the form + * (element1_mapping, element2_mapping, ...) and element1_mapping is + * of the form (in_stream, in_element). + * + * \param item_size (integer) size of vector elements + * + * \param in_vlens (vector of integers) number of elements in each + * input vector + * + * \param mapping (vector of vectors of vectors of integers) how to + * map elements from input to output vectors + * + * \ingroup slicedice_blk + */ +class GR_CORE_API gr_vector_map : public gr_sync_block +{ + friend GR_CORE_API gr_vector_map_sptr + gr_make_vector_map(size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping); + size_t d_item_size; + std::vector<size_t> d_in_vlens; + std::vector< std::vector< std::vector<size_t> > > d_mapping; + gruel::mutex d_mutex; // mutex to protect set/work access + + protected: + gr_vector_map(size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping); + + public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping); +}; + +#endif /* INCLUDED_GR_VECTOR_MAP_H */ diff --git a/gnuradio-core/src/lib/general/gr_vector_map.i b/gnuradio-core/src/lib/general/gr_vector_map.i new file mode 100644 index 0000000000..e9fa3f27e5 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_vector_map.i @@ -0,0 +1,28 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(gr, vector_map); + +%template() std::vector<size_t>; +%template() std::vector< std::vector< std::vector<size_t> > >; + +%include "gr_vector_map.h" diff --git a/gnuradio-core/src/lib/gengen/CMakeLists.txt b/gnuradio-core/src/lib/gengen/CMakeLists.txt index d137769907..b44a470750 100644 --- a/gnuradio-core/src/lib/gengen/CMakeLists.txt +++ b/gnuradio-core/src/lib/gengen/CMakeLists.txt @@ -82,13 +82,14 @@ endmacro(expand_h_cc_i) # Invoke macro to generate various sources ######################################################################## expand_h_cc_i(gr_vector_source_X b s i f c) +expand_h_cc_i(gr_vector_insert_X b) expand_h_cc_i(gr_vector_sink_X b s i f c) expand_h_cc_i(gr_noise_source_X s i f c) expand_h_cc_i(gr_sig_source_X s i f c) expand_h_cc_i(gr_probe_signal_X b s i f c) expand_h_cc_i(gr_probe_signal_vX b s i f c) -expand_h_cc_i(gr_add_const_XX ss ii ff cc sf) +expand_h_cc_i(gr_add_const_XX bb ss ii ff cc sf) expand_h_cc_i(gr_multiply_const_XX ss ii) expand_h_cc_i(gr_add_XX ss ii cc) expand_h_cc_i(gr_sub_XX ss ii ff cc) diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t new file mode 100644 index 0000000000..37963cdfee --- /dev/null +++ b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t @@ -0,0 +1,100 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <@NAME@.h> +#include <algorithm> +#include <gr_io_signature.h> +#include <stdexcept> + +#include <stdio.h> + +@NAME@::@NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset) + : gr_block("@BASE_NAME@", + gr_make_io_signature (1, 1, sizeof(@TYPE@)), + gr_make_io_signature (1, 1, sizeof(@TYPE@))), + d_data(data), + d_offset(offset), + d_periodicity(periodicity) +{ + //printf("INITIAL: periodicity = %d, offset = %d\n", periodicity, offset); + // some sanity checks + assert(offset < periodicity); + assert(offset >= 0); + assert(periodicity > data.size()); +} + +int +@NAME@::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + @TYPE@ *out = (@TYPE@ *)output_items[0]; + const @TYPE@ *in = (const @TYPE@ *)input_items[0]; + + int ii(0), oo(0); + + while((oo < noutput_items) && (ii < ninput_items[0])) { + + //printf("oo = %d, ii = %d, d_offset = %d, noutput_items = %d, ninput_items[0] = %d", oo, ii, d_offset, noutput_items, ninput_items[0]); + //printf(", d_periodicity = %d\n", d_periodicity); + + if(d_offset >= ((int)d_data.size())) { // if we are in the copy region + int max_copy = std::min( std::min( noutput_items - oo, ninput_items[0] - ii ), d_periodicity - d_offset ); + //printf("copy %d from input\n", max_copy); + memcpy( &out[oo], &in[ii], sizeof(@TYPE@)*max_copy ); + //printf(" * memcpy returned.\n"); + ii += max_copy; + oo += max_copy; + d_offset = (d_offset + max_copy)%d_periodicity; + + } + else { // if we are in the insertion region + int max_copy = std::min( noutput_items - oo, ((int)d_data.size()) - d_offset ); + //printf("copy %d from d_data[%d] to out[%d]\n", max_copy, d_offset, oo); + memcpy( &out[oo], &d_data[d_offset], sizeof(@TYPE@)*max_copy ); + //printf(" * memcpy returned.\n"); + oo += max_copy; + d_offset = (d_offset + max_copy)%d_periodicity; + //printf(" ## (inelse) oo = %d, d_offset = %d\n", oo, d_offset); + } + + //printf(" # exit else, on to next loop.\n"); + } + //printf(" # got out of loop\n"); + + //printf("consume = %d, produce = %d\n", ii, oo); + consume_each(ii); + return oo; +} + +@NAME@_sptr +gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset) +{ + return gnuradio::get_initial_sptr(new @NAME@ (data, periodicity, offset)); +} + diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t new file mode 100644 index 0000000000..26f851700d --- /dev/null +++ b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <gr_core_api.h> +#include <gr_block.h> + +class GR_CORE_API @NAME@; +typedef boost::shared_ptr<@NAME@> @NAME@_sptr; + +/*! + * \brief source of @TYPE@'s that gets its data from a vector + * \ingroup source_blk + */ + +class @NAME@ : public gr_block { + friend GR_CORE_API @NAME@_sptr + gr_make_@BASE_NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset); + + std::vector<@TYPE@> d_data; + int d_offset; + int d_periodicity; + + @NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset); + + public: + void rewind() {d_offset=0;} + virtual int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + void set_data(const std::vector<@TYPE@> &data){ d_data = data; rewind(); } +}; + +GR_CORE_API @NAME@_sptr +gr_make_@BASE_NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset=0); + +#endif diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t new file mode 100644 index 0000000000..f3341eec4f --- /dev/null +++ b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t @@ -0,0 +1,37 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); + +@NAME@_sptr +gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset = 0) + throw(std::invalid_argument); + +class @NAME@ : public gr_block { + public: + void rewind(); + void set_data(const std::vector<@TYPE@> &data); + private: + @NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset = 0); +}; diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t index fe0a77f818..fe02c1346f 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2008,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -52,6 +52,7 @@ class @NAME@ : public gr_sync_block { virtual int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); + void set_data(const std::vector<@TYPE@> &data){ d_data = data; rewind(); } }; GR_CORE_API @NAME@_sptr diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t index 6c20539ac8..4986c68a35 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2008,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,8 @@ gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int v class @NAME@ : public gr_sync_block { public: - void rewind() {d_offset=0;} + void rewind(); + void set_data(const std::vector<@TYPE@> &data); private: @NAME@ (const std::vector<@TYPE@> &data, int vlen); }; diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.i b/gnuradio-core/src/lib/runtime/gr_top_block.i index 80a1b82aea..6ae4c65a99 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.i +++ b/gnuradio-core/src/lib/runtime/gr_top_block.i @@ -20,8 +20,6 @@ * Boston, MA 02110-1301, USA. */ -%include <gr_top_block.i> - class gr_top_block; typedef boost::shared_ptr<gr_top_block> gr_top_block_sptr; %template(gr_top_block_sptr) boost::shared_ptr<gr_top_block>; diff --git a/gnuradio-core/src/python/build_utils.py b/gnuradio-core/src/python/build_utils.py index e468b9bd1c..77bf0607a3 100644 --- a/gnuradio-core/src/python/build_utils.py +++ b/gnuradio-core/src/python/build_utils.py @@ -176,11 +176,11 @@ def is_complex (code3): return '0' -def standard_dict (name, code3): +def standard_dict (name, code3, package='gr'): d = {} d['NAME'] = name d['GUARD_NAME'] = 'INCLUDED_%s_H' % name.upper () - d['BASE_NAME'] = re.sub ('^gr_', '', name) + d['BASE_NAME'] = re.sub ('^' + package + '_', '', name) d['SPTR_NAME'] = '%s_sptr' % name d['WARNING'] = 'WARNING: this file is machine generated. Edits will be overwritten' d['COPYRIGHT'] = copyright diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_keep_m_in_n.py b/gnuradio-core/src/python/gnuradio/gr/qa_keep_m_in_n.py new file mode 100755 index 0000000000..922671d024 --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr/qa_keep_m_in_n.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# +# Copyright 2008,2010 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +from gnuradio import gr, gr_unittest +import sys +import random + +class test_keep_m_in_n(gr_unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_001(self): + self.maxDiff = None; + tb = gr.top_block() + src = gr.vector_source_b( range(0,100) ) + + # itemsize, M, N, offset + km2 = gr.keep_m_in_n( 1, 1, 2, 0 ); + km3 = gr.keep_m_in_n( 1, 1, 3, 1 ); + km7 = gr.keep_m_in_n( 1, 1, 7, 2 ); + snk2 = gr.vector_sink_b(); + snk3 = gr.vector_sink_b(); + snk7 = gr.vector_sink_b(); + tb.connect(src,km2,snk2); + tb.connect(src,km3,snk3); + tb.connect(src,km7,snk7); + tb.run(); + + self.assertEqual(range(0,100,2), list(snk2.data())); + self.assertEqual(range(1,100,3), list(snk3.data())); + self.assertEqual(range(2,100,7), list(snk7.data())); + + +if __name__ == '__main__': + gr_unittest.run(test_keep_m_in_n, "test_keep_m_in_n.xml") + diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pack_k_bits.py b/gnuradio-core/src/python/gnuradio/gr/qa_pack_k_bits.py new file mode 100755 index 0000000000..25fc5e9fcc --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr/qa_pack_k_bits.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# +# Copyright 2006,2010 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +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 = gr.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 = gr.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 = gr.pack_k_bits_bb(2); + unpack = gr.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/gnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py b/gnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py new file mode 100755 index 0000000000..acc06dfded --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import math + +class test_vector_insert(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001(self): + src_data = [float(x) for x in range(16)] + expected_result = tuple(src_data) + + period = 9177; + offset = 0; + + src = gr.null_source(1) + head = gr.head(1, 10000000); + ins = gr.vector_insert_b([1], period, offset); + dst = gr.vector_sink_b() + + self.tb.connect(src, head, ins, dst) + self.tb.run() + result_data = dst.data() + + for i in range(10000): + if(i%period == offset): + self.assertEqual(1, result_data[i]) + else: + self.assertEqual(0, result_data[i]) + +if __name__ == '__main__': + gr_unittest.run(test_vector_insert, "test_vector_insert.xml") + diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_vector_map.py b/gnuradio-core/src/python/gnuradio/gr/qa_vector_map.py new file mode 100644 index 0000000000..12f4be5898 --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr/qa_vector_map.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import math + +class test_vector_map(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block() + + def tearDown (self): + self.tb = None + + def test_reversing(self): + # Chunk data in blocks of N and reverse the block contents. + N = 5 + src_data = range(0, 20) + expected_result = [] + for i in range(N-1, len(src_data), N): + for j in range(0, N): + expected_result.append(1.0*(i-j)) + mapping = [list(reversed([(0, i) for i in range(0, N)]))] + src = gr.vector_source_f(src_data, False, N) + vmap = gr.vector_map(gr.sizeof_float, (N, ), mapping) + dst = gr.vector_sink_f(N) + self.tb.connect(src, vmap, dst) + self.tb.run() + result_data = list(dst.data()) + self.assertEqual(expected_result, result_data) + + def test_vector_to_streams(self): + # Split an input vector into N streams. + N = 5 + M = 20 + src_data = range(0, M) + expected_results = [] + for n in range(0, N): + expected_results.append(range(n, M, N)) + mapping = [[(0, n)] for n in range(0, N)] + src = gr.vector_source_f(src_data, False, N) + vmap = gr.vector_map(gr.sizeof_float, (N, ), mapping) + dsts = [gr.vector_sink_f(1) for n in range(0, N)] + self.tb.connect(src, vmap) + for n in range(0, N): + self.tb.connect((vmap, n), dsts[n]) + self.tb.run() + for n in range(0, N): + result_data = list(dsts[n].data()) + self.assertEqual(expected_results[n], result_data) + + def test_interleaving(self): + # Takes 3 streams (a, b and c) + # Outputs 2 streams. + # First (d) is interleaving of a and b. + # Second (e) is interleaving of a and b and c. c is taken in + # chunks of 2 which are reversed. + A = (1, 2, 3, 4, 5) + B = (11, 12, 13, 14, 15) + C = (99, 98, 97, 96, 95, 94, 93, 92, 91, 90) + expected_D = (1, 11, 2, 12, 3, 13, 4, 14, 5, 15) + expected_E = (1, 11, 98, 99, 2, 12, 96, 97, 3, 13, 94, 95, + 4, 14, 92, 93, 5, 15, 90, 91) + mapping = [[(0, 0), (1, 0)], # mapping to produce D + [(0, 0), (1, 0), (2, 1), (2, 0)], # mapping to produce E + ] + srcA = gr.vector_source_f(A, False, 1) + srcB = gr.vector_source_f(B, False, 1) + srcC = gr.vector_source_f(C, False, 2) + vmap = gr.vector_map(gr.sizeof_int, (1, 1, 2), mapping) + dstD = gr.vector_sink_f(2) + dstE = gr.vector_sink_f(4) + self.tb.connect(srcA, (vmap, 0)) + self.tb.connect(srcB, (vmap, 1)) + self.tb.connect(srcC, (vmap, 2)) + self.tb.connect((vmap, 0), dstD) + self.tb.connect((vmap, 1), dstE) + self.tb.run() + self.assertEqual(expected_D, dstD.data()) + self.assertEqual(expected_E, dstE.data()) + + + +if __name__ == '__main__': + gr_unittest.run(test_vector_map, "test_vector_map.xml") + diff --git a/gr-audio/lib/CMakeLists.txt b/gr-audio/lib/CMakeLists.txt index 7e0252a8b1..c1781af79e 100644 --- a/gr-audio/lib/CMakeLists.txt +++ b/gr-audio/lib/CMakeLists.txt @@ -150,4 +150,4 @@ add_library(gnuradio-audio SHARED ${gr_audio_sources}) target_link_libraries(gnuradio-audio ${gr_audio_libs}) GR_LIBRARY_FOO(gnuradio-audio RUNTIME_COMPONENT "audio_runtime" DEVEL_COMPONENT "audio_devel") -install(FILES ${gr_audio_confs} DESTINATION ${GR_PKG_CONF_DIR} COMPONENT "audio_runtime") +install(FILES ${gr_audio_confs} DESTINATION ${GR_PREFSDIR} COMPONENT "audio_runtime") diff --git a/gr-digital/grc/digital_additive_scrambler_bb.xml b/gr-digital/grc/digital_additive_scrambler_bb.xml new file mode 100644 index 0000000000..5ae5ba06f0 --- /dev/null +++ b/gr-digital/grc/digital_additive_scrambler_bb.xml @@ -0,0 +1,44 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Additive Scrambler +################################################### + --> +<block> + <name>Additive Scrambler</name> + <key>digital_additive_scrambler_bb</key> + <import>from gnuradio import digital</import> + <make>digital.additive_scrambler_bb($mask, $seed, $len, $count)</make> + <param> + <name>Mask</name> + <key>mask</key> + <value>0x8A</value> + <type>hex</type> + </param> + <param> + <name>Seed</name> + <key>seed</key> + <value>0x7F</value> + <type>hex</type> + </param> + <param> + <name>Length</name> + <key>len</key> + <value>7</value> + <type>int</type> + </param> + <param> + <name>Count</name> + <key>count</key> + <value>0</value> + <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-digital/grc/digital_block_tree.xml b/gr-digital/grc/digital_block_tree.xml index 3ef4d0b1d0..9efa0d3fb5 100644 --- a/gr-digital/grc/digital_block_tree.xml +++ b/gr-digital/grc/digital_block_tree.xml @@ -30,19 +30,35 @@ <name></name> <!-- Blank for Root Name --> <cat> <name>Digital</name> + <block>digital_additive_scrambler_bb</block> <block>digital_binary_slicer_fb</block> + <block>digital_bytes_to_syms</block> + <block>digital_chunks_to_symbols_xx</block> <block>digital_clock_recovery_mm_xx</block> <block>digital_cma_equalizer_cc</block> <block>digital_constellation_decoder_cb</block> <block>digital_constellation_receiver_cb</block> <block>digital_correlate_access_code_bb</block> <block>digital_costas_loop_cc</block> + <block>digital_descrambler_bb</block> <block>digital_fll_band_edge_cc</block> + <block>digital_glfsr_source_x</block> <block>digital_kurtotic_equalizer_cc</block> <block>digital_lms_dd_equalizer_cc</block> + <block>digital_map_bb</block> <block>digital_mpsk_receiver_cc</block> <block>digital_mpsk_snr_est_cc</block> + <block>digital_pfb_clock_sync_xxx</block> + <block>digital_pn_correlator_cc</block> + <block>digital_probe_density_b</block> <block>digital_probe_mpsk_snr_est_c</block> + <block>digital_scrambler_bb</block> + <block>digital_diff_decoder_bb</block> + <block>digital_diff_encoder_bb</block> + <block>digital_diff_phasor_cc</block> + <block>digital_framer_sink_1</block> + <block>digital_packet_sink</block> + <block>digital_simple_framer</block> </cat> <cat> <name>Digital Modulators</name> diff --git a/gr-digital/grc/digital_bytes_to_syms.xml b/gr-digital/grc/digital_bytes_to_syms.xml new file mode 100644 index 0000000000..fb17bb6def --- /dev/null +++ b/gr-digital/grc/digital_bytes_to_syms.xml @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Bytes to Syms +################################################### + --> +<block> + <name>Bytes to Symbols</name> + <key>digital_bytes_to_syms</key> + <import>from gnuradio import digital</import> + <make>digital.bytes_to_syms()</make> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>float</type> + </source> +</block> diff --git a/gr-digital/grc/digital_chunks_to_symbols.xml b/gr-digital/grc/digital_chunks_to_symbols.xml new file mode 100644 index 0000000000..494be274df --- /dev/null +++ b/gr-digital/grc/digital_chunks_to_symbols.xml @@ -0,0 +1,77 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Chunks to Symbols +################################################### + --> +<block> + <name>Chunks to Symbols</name> + <key>digital_chunks_to_symbols_xx</key> + <import>from gnuradio import digital</import> + <make>digital.chunks_to_symbols_$(in_type.fcn)$(out_type.fcn)($symbol_table, $dimension)</make> + <param> + <name>Input Type</name> + <key>in_type</key> + <type>enum</type> + <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>Output Type</name> + <key>out_type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:c</opt> + <opt>table:complex_vector</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + <opt>table:real_vector</opt> + </option> + </param> + <param> + <name>Symbol Table</name> + <key>symbol_table</key> + <type>$out_type.table</type> + </param> + <param> + <name>Dimension</name> + <key>dimension</key> + <value>2</value> + <type>int</type> + </param> + <param> + <name>Num Ports</name> + <key>num_ports</key> + <value>1</value> + <type>int</type> + </param> + <check>$num_ports > 0</check> + <sink> + <name>in</name> + <type>$in_type</type> + <nports>$num_ports</nports> + </sink> + <source> + <name>out</name> + <type>$out_type</type> + <nports>$num_ports</nports> + </source> +</block> diff --git a/gr-digital/grc/digital_descrambler_bb.xml b/gr-digital/grc/digital_descrambler_bb.xml new file mode 100644 index 0000000000..4f52c79645 --- /dev/null +++ b/gr-digital/grc/digital_descrambler_bb.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Descrambler +################################################### + --> +<block> + <name>Descrambler</name> + <key>digital_descrambler_bb</key> + <import>from gnuradio import digital</import> + <make>digital.descrambler_bb($mask, $seed, $len)</make> + <param> + <name>Mask</name> + <key>mask</key> + <value>0x8A</value> + <type>hex</type> + </param> + <param> + <name>Seed</name> + <key>seed</key> + <value>0x7F</value> + <type>hex</type> + </param> + <param> + <name>Length</name> + <key>len</key> + <value>7</value> + <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-digital/grc/digital_diff_decoder_bb.xml b/gr-digital/grc/digital_diff_decoder_bb.xml new file mode 100644 index 0000000000..a7c94b834c --- /dev/null +++ b/gr-digital/grc/digital_diff_decoder_bb.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Differential Decoder +################################################### + --> +<block> + <name>Differential Decoder</name> + <key>digital_diff_decoder_bb</key> + <import>from gnuradio import digital</import> + <make>digital.diff_decoder_bb($modulus)</make> + <param> + <name>Modulus</name> + <key>modulus</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-digital/grc/digital_diff_encoder_bb.xml b/gr-digital/grc/digital_diff_encoder_bb.xml new file mode 100644 index 0000000000..3885bed9aa --- /dev/null +++ b/gr-digital/grc/digital_diff_encoder_bb.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Differential Encoder +################################################### + --> +<block> + <name>Differential Encoder</name> + <key>digital_diff_encoder_bb</key> + <import>from gnuradio import digital</import> + <make>digital.diff_encoder_bb($modulus)</make> + <param> + <name>Modulus</name> + <key>modulus</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-digital/grc/digital_diff_phasor_cc.xml b/gr-digital/grc/digital_diff_phasor_cc.xml new file mode 100644 index 0000000000..506bf400ba --- /dev/null +++ b/gr-digital/grc/digital_diff_phasor_cc.xml @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Differential Phasor +################################################### + --> +<block> + <name>Differential Phasor</name> + <key>digital_diff_phasor_cc</key> + <import>from gnuradio import digital</import> + <make>digital.diff_phasor_cc()</make> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> +</block> diff --git a/gr-digital/grc/digital_dxpsk_demod.xml b/gr-digital/grc/digital_dxpsk_demod.xml index cfd474f68f..6366596d91 100644 --- a/gr-digital/grc/digital_dxpsk_demod.xml +++ b/gr-digital/grc/digital_dxpsk_demod.xml @@ -36,7 +36,7 @@ freq_bw=$freq_bw, phase_bw=$phase_bw, timing_bw=$timing_bw, - gray_coded=$gray_coded, + mod_code=$mod_code, verbose=$verbose, log=$log )</make> @@ -93,16 +93,16 @@ </param> <param> <name>Gray Code</name> - <key>gray_coded</key> + <key>mod_code</key> <value>True</value> - <type>bool</type> + <type>enum</type> <option> <name>Yes</name> - <key>True</key> + <key>"gray"</key> </option> <option> <name>No</name> - <key>False</key> + <key>"none"</key> </option> </param> <param> diff --git a/gr-digital/grc/digital_dxpsk_mod.xml b/gr-digital/grc/digital_dxpsk_mod.xml index fbda9fb1f9..58e30436df 100644 --- a/gr-digital/grc/digital_dxpsk_mod.xml +++ b/gr-digital/grc/digital_dxpsk_mod.xml @@ -33,7 +33,7 @@ <make>digital.$(type)_mod( samples_per_symbol=$samples_per_symbol, excess_bw=$excess_bw, - gray_coded=$gray_coded, + mod_code=$mod_code, verbose=$verbose, log=$log) </make> @@ -68,16 +68,16 @@ </param> <param> <name>Gray Code</name> - <key>gray_coded</key> - <value>True</value> - <type>bool</type> + <key>mod_code</key> + <value>"gray"</value> + <type>enum</type> <option> <name>Yes</name> - <key>True</key> + <key>"gray"</key> </option> <option> <name>No</name> - <key>False</key> + <key>"none"</key> </option> </param> <param> diff --git a/gr-digital/grc/digital_framer_sink_1.xml b/gr-digital/grc/digital_framer_sink_1.xml new file mode 100644 index 0000000000..9124e6d0dc --- /dev/null +++ b/gr-digital/grc/digital_framer_sink_1.xml @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Framer Sink 1 +################################################### + --> +<block> + <name>Framer Sink 1</name> + <key>digital_framer_sink_1</key> + <import>from gnuradio import digital</import> + <make>digital.framer_sink_1($target_queue)</make> + <param> + <name>Target Message Queue</name> + <key>target_queue</key> + <type>raw</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> +</block> diff --git a/gr-digital/grc/digital_glfsr_source_x.xml b/gr-digital/grc/digital_glfsr_source_x.xml new file mode 100644 index 0000000000..654dfa71c0 --- /dev/null +++ b/gr-digital/grc/digital_glfsr_source_x.xml @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<!-- +################################################### +##GLFSR Source +################################################### + --> +<block> + <name>GLFSR Source</name> + <key>digital_glfsr_source_x</key> + <import>from gnuradio import digital</import> + <make>digital.glfsr_source_$(type.fcn)($degree, $repeat, $mask, $seed)</make> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:b</opt> + </option> + </param> + <param> + <name>Degree</name> + <key>degree</key> + <type>int</type> + </param> + <param> + <name>Repeat</name> + <key>repeat</key> + <type>enum</type> + <option> + <name>Yes</name> + <key>True</key> + </option> + <option> + <name>No</name> + <key>False</key> + </option> + </param> + <param> + <name>Mask</name> + <key>mask</key> + <value>0</value> + <type>int</type> + </param> + <param> + <name>Seed</name> + <key>seed</key> + <value>1</value> + <type>int</type> + </param> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/gr-digital/grc/digital_map_bb.xml b/gr-digital/grc/digital_map_bb.xml new file mode 100644 index 0000000000..1435c5ac78 --- /dev/null +++ b/gr-digital/grc/digital_map_bb.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Map +################################################### + --> +<block> + <name>Map</name> + <key>digital_map_bb</key> + <import>from gnuradio import digital</import> + <make>digital.map_bb($map)</make> + <param> + <name>Map</name> + <key>map</key> + <type>int_vector</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-digital/grc/digital_mpsk_receiver_cc.xml b/gr-digital/grc/digital_mpsk_receiver_cc.xml index ab7e5c2091..bd738fccc3 100644 --- a/gr-digital/grc/digital_mpsk_receiver_cc.xml +++ b/gr-digital/grc/digital_mpsk_receiver_cc.xml @@ -7,7 +7,7 @@ <block> <name>MPSK Receiver</name> <key>digital_mpsk_receiver_cc</key> - <import>from gnuradio import digital</import> + <import>from gnuradio import digital;import cmath</import> <make>digital.mpsk_receiver_cc($M, $theta, $w, $fmin, $fmax, $mu, $gain_mu, $omega, $gain_omega, $omega_relative_limit)</make> <callback>set_loop_bandwidth($w)</callback> <callback>set_mu($mu)</callback> @@ -17,51 +17,61 @@ <param> <name>M</name> <key>M</key> + <value>4</value> <type>int</type> </param> <param> <name>Theta</name> <key>theta</key> + <value>0</value> <type>real</type> </param> <param> <name>Loop Bandwidth</name> <key>w</key> + <value>cmath.pi/100.0</value> <type>real</type> </param> <param> <name>Min Freq</name> <key>fmin</key> + <value>-0.5</value> <type>real</type> </param> <param> <name>Max Freq</name> <key>fmax</key> + <value>0.5</value> <type>real</type> </param> <param> <name>Mu</name> <key>mu</key> + <value>0.25</value> <type>real</type> </param> <param> <name>Gain Mu</name> <key>gain_mu</key> + <value>0.01</value> <type>real</type> </param> <param> <name>Omega</name> <key>omega</key> + <value>2</value> <type>real</type> </param> <param> <name>Gain Omega</name> <key>gain_omega</key> + <value>0.001</value> <type>real</type> </param> <param> <name>Omega Relative Limit</name> <key>omega_relative_limit</key> + <value>0.001</value> <type>real</type> </param> <sink> @@ -72,4 +82,5 @@ <name>out</name> <type>complex</type> </source> + </block> diff --git a/gr-digital/grc/digital_ofdm_insert_preamble.xml b/gr-digital/grc/digital_ofdm_insert_preamble.xml index 33a93058f9..9ad8fa793b 100644 --- a/gr-digital/grc/digital_ofdm_insert_preamble.xml +++ b/gr-digital/grc/digital_ofdm_insert_preamble.xml @@ -48,10 +48,16 @@ <sink> <name>flag</name> <type>byte</type> + <optional>1</optional> </sink> <source> <name>out</name> <type>complex</type> <vlen>$fft_length</vlen> </source> + <source> + <name>flag</name> + <type>byte</type> + <optional>1</optional> + </source> </block> diff --git a/gr-digital/grc/digital_packet_sink.xml b/gr-digital/grc/digital_packet_sink.xml new file mode 100644 index 0000000000..e9231bd059 --- /dev/null +++ b/gr-digital/grc/digital_packet_sink.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Packet Sink +################################################### + --> +<block> + <name>Packet Sink</name> + <key>digital_packet_sink</key> + <import>from gnuradio import digital</import> + <make>digital.packet_sink($sync_vector, $target_queue, $threshold)</make> + <param> + <name>Sync Vector</name> + <key>sync_vector</key> + <type>int_vector</type> + </param> + <param> + <name>Target Message Queue</name> + <key>target_queue</key> + <type>raw</type> + </param> + <param> + <name>Threshold</name> + <key>threshold</key> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>float</type> + </sink> +</block> diff --git a/gr-digital/grc/digital_pfb_clock_sync.xml b/gr-digital/grc/digital_pfb_clock_sync.xml new file mode 100644 index 0000000000..9e2a4cd5ef --- /dev/null +++ b/gr-digital/grc/digital_pfb_clock_sync.xml @@ -0,0 +1,104 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Polyphase Filter based Clock Sync +################################################### + --> +<block> + <name>Polyphase Clock Sync</name> + <key>digital_pfb_clock_sync_xxx</key> + <import>from gnuradio import digital</import> + <make>digital.pfb_clock_sync_$(type)($sps, $alpha, $taps, $filter_size, $init_phase, $max_dev, $osps) +self.$(id).set_beta($beta)</make> + <callback>set_taps($taps)</callback> + <callback>set_alpha($alpha)</callback> + <callback>set_beta($beta)</callback> + + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex->Complex (Real Taps)</name> + <key>ccf</key> + <opt>input:complex</opt> + <opt>output:complex</opt> + <opt>taps:real_vector</opt> + </option> + <option> + <name>Float->Float (Real Taps)</name> + <key>fff</key> + <opt>input:float</opt> + <opt>output:float</opt> + <opt>taps:real_vector</opt> + </option> + </param> + + <param> + <name>Samples/Symbol</name> + <key>sps</key> + <type>real</type> + </param> + <param> + <name>Alpha</name> + <key>alpha</key> + <type>real</type> + </param> + <param> + <name>Beta</name> + <key>beta</key> + <type>real</type> + </param> + <param> + <name>Taps</name> + <key>taps</key> + <type>real_vector</type> + </param> + <param> + <name>Filter Size</name> + <key>filter_size</key> + <value>32</value> + <type>int</type> + </param> + <param> + <name>Initial Phase</name> + <key>init_phase</key> + <value>16</value> + <type>real</type> + </param> + <param> + <name>Maximum Rate Deviation</name> + <key>max_dev</key> + <value>1.5</value> + <type>real</type> + </param> + <param> + <name>Output SPS</name> + <key>osps</key> + <value>1</value> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>$type.input</type> + </sink> + <source> + <name>out</name> + <type>$type.output</type> + </source> + <source> + <name>err</name> + <type>float</type> + <optional>1</optional> + </source> + <source> + <name>rate</name> + <type>float</type> + <optional>1</optional> + </source> + <source> + <name>phase</name> + <type>float</type> + <optional>1</optional> + </source> +</block> diff --git a/gr-digital/grc/digital_pn_correlator_cc.xml b/gr-digital/grc/digital_pn_correlator_cc.xml new file mode 100644 index 0000000000..999cea15d9 --- /dev/null +++ b/gr-digital/grc/digital_pn_correlator_cc.xml @@ -0,0 +1,37 @@ +<?xml version="1.0"?> +<!-- +################################################### +##PN Correlator +################################################### + --> +<block> + <name>PN Correlator</name> + <key>digital_pn_correlator_cc</key> + <import>from gnuradio import digital</import> + <make>digital.pn_correlator_cc($degree, $mask, $seed)</make> + <param> + <name>Degree</name> + <key>degree</key> + <type>int</type> + </param> + <param> + <name>Mask</name> + <key>mask</key> + <value>0</value> + <type>int</type> + </param> + <param> + <name>Seed</name> + <key>seed</key> + <value>1</value> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> +</block> diff --git a/gr-digital/grc/digital_probe_density_b.xml b/gr-digital/grc/digital_probe_density_b.xml new file mode 100644 index 0000000000..8cf5dd8943 --- /dev/null +++ b/gr-digital/grc/digital_probe_density_b.xml @@ -0,0 +1,29 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Probe Density +################################################### + --> +<block> + <name>Probe Density</name> + <key>digital_probe_density_b</key> + <import>from gnuradio import digital</import> + <make>digital.probe_density_b($alpha)</make> + <callback>set_alpha($alpha)</callback> + <param> + <name>Alpha</name> + <key>alpha</key> + <value>1</value> + <type>real</type> + </param> + <param> + <name>Probe Rate</name> + <key>probe_rate</key> + <value>10</value> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> +</block> diff --git a/gr-digital/grc/digital_psk_demod.xml b/gr-digital/grc/digital_psk_demod.xml index 7e0773a986..2e0e86ebc6 100644 --- a/gr-digital/grc/digital_psk_demod.xml +++ b/gr-digital/grc/digital_psk_demod.xml @@ -37,7 +37,7 @@ excess_bw=$excess_bw, phase_bw=$phase_bw, timing_bw=$timing_bw, - gray_coded=$gray_coded, + mod_code=$mod_code, verbose=$verbose, log=$log, )</make> @@ -93,7 +93,7 @@ </param> <param> <name>Gray Code</name> - <key>gray_coded</key> + <key>mod_code</key> <type>enum</type> <option> <name>Yes</name> diff --git a/gr-digital/grc/digital_qam_demod.xml b/gr-digital/grc/digital_qam_demod.xml index 86080fff79..5aaec1bd0a 100644 --- a/gr-digital/grc/digital_qam_demod.xml +++ b/gr-digital/grc/digital_qam_demod.xml @@ -38,7 +38,7 @@ freq_bw=$freq_bw, timing_bw=$timing_bw, phase_bw=$phase_bw, - gray_coded=$gray_coded, + mod_code=$mod_code, verbose=$verbose, log=$log, )</make> diff --git a/gr-digital/grc/digital_scrambler_bb.xml b/gr-digital/grc/digital_scrambler_bb.xml new file mode 100644 index 0000000000..9c40b49f64 --- /dev/null +++ b/gr-digital/grc/digital_scrambler_bb.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Descrambler +################################################### + --> +<block> + <name>Scrambler</name> + <key>digital_scrambler_bb</key> + <import>from gnuradio import digital</import> + <make>digital.scrambler_bb($mask, $seed, $len)</make> + <param> + <name>Mask</name> + <key>mask</key> + <value>0x8A</value> + <type>hex</type> + </param> + <param> + <name>Seed</name> + <key>seed</key> + <value>0x7F</value> + <type>hex</type> + </param> + <param> + <name>Length</name> + <key>len</key> + <value>7</value> + <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-digital/grc/digital_simple_framer.xml b/gr-digital/grc/digital_simple_framer.xml new file mode 100644 index 0000000000..bbeed32d3e --- /dev/null +++ b/gr-digital/grc/digital_simple_framer.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Simple Framer +################################################### + --> +<block> + <name>Simple Framer</name> + <key>digital_simple_framer</key> + <import>from gnuradio import gr</import> + <make>gr.simple_framer($payload_bytesize)</make> + <param> + <name>Payload Byte Size</name> + <key>payload_bytesize</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-digital/include/CMakeLists.txt b/gr-digital/include/CMakeLists.txt index 81ed8d368e..f863b28757 100644 --- a/gr-digital/include/CMakeLists.txt +++ b/gr-digital/include/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -17,25 +17,94 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. + +######################################################################## +# generate helper scripts to expand templated files +######################################################################## +include(GrPython) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " +#!${PYTHON_EXECUTABLE} + +import sys, os, re +sys.path.append('${GR_CORE_PYTHONPATH}') +os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' +os.chdir('${CMAKE_CURRENT_BINARY_DIR}') + +if __name__ == '__main__': + import build_utils + root, inp = sys.argv[1:3] + for sig in sys.argv[3:]: + name = re.sub ('X+', sig, root) + d = build_utils.standard_dict(name, sig, 'digital') + build_utils.expand_template(d, inp) + +") + +macro(expand_h root) + #make a list of all the generated files + unset(expanded_files_h) + foreach(sig ${ARGN}) + string(REGEX REPLACE "X+" ${sig} name ${root}) + list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/${name}.h) + endforeach(sig) + + #create a command to generate the files + add_custom_command( + OUTPUT ${expanded_files_h} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py + ${root} ${root}.h.t ${ARGN} + ) + + #install rules for the generated h files + list(APPEND generated_includes ${expanded_files_h}) +endmacro(expand_h) + +######################################################################## +# Invoke macro to generate various sources +######################################################################## +expand_h(digital_chunks_to_symbols_XX bf bc sf sc if ic) + +add_custom_target(digital_generated_includes DEPENDS + ${generated_includes} +) + ######################################################################## # Install header files ######################################################################## install(FILES + ${generated_includes} digital_api.h + digital_impl_glfsr.h digital_impl_mpsk_snr_est.h + digital_additive_scrambler_bb.h digital_binary_slicer_fb.h + digital_bytes_to_syms.h digital_clock_recovery_mm_cc.h digital_clock_recovery_mm_ff.h + digital_cma_equalizer_cc.h + digital_cpmmod_bc.h digital_constellation.h digital_constellation_receiver_cb.h digital_constellation_decoder_cb.h digital_correlate_access_code_bb.h + digital_correlate_access_code_tag_bb.h digital_costas_loop_cc.h - digital_cma_equalizer_cc.h digital_crc32.h + digital_descrambler_bb.h + digital_diff_decoder_bb.h + digital_diff_encoder_bb.h + digital_diff_phasor_cc.h + digital_framer_sink_1.h digital_fll_band_edge_cc.h + digital_glfsr_source_b.h + digital_glfsr_source_f.h + digital_gmskmod_bc.h digital_lms_dd_equalizer_cc.h digital_kurtotic_equalizer_cc.h + digital_map_bb.h digital_metric_type.h digital_mpsk_receiver_cc.h digital_mpsk_snr_est_cc.h @@ -45,9 +114,16 @@ install(FILES digital_ofdm_insert_preamble.h digital_ofdm_mapper_bcv.h digital_ofdm_sampler.h + digital_packet_sink.h + digital_pfb_clock_sync_ccf.h + digital_pfb_clock_sync_fff.h + digital_pn_correlator_cc.h + digital_probe_density_b.h digital_probe_mpsk_snr_est_c.h - digital_gmskmod_bc.h - digital_cpmmod_bc.h + digital_scrambler_bb.h + digital_simple_framer.h + digital_simple_framer_sync.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "digital_devel" ) + diff --git a/gr-digital/include/digital_additive_scrambler_bb.h b/gr-digital/include/digital_additive_scrambler_bb.h new file mode 100644 index 0000000000..d4bd7d4ae8 --- /dev/null +++ b/gr-digital/include/digital_additive_scrambler_bb.h @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H +#define INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H + +#include <digital_api.h> +#include <gr_sync_block.h> +#include <gri_lfsr.h> + +class digital_additive_scrambler_bb; +typedef boost::shared_ptr<digital_additive_scrambler_bb> digital_additive_scrambler_bb_sptr; + +DIGITAL_API digital_additive_scrambler_bb_sptr +digital_make_additive_scrambler_bb(int mask, int seed, + int len, int count=0); + +/*! + * Scramble an input stream using an LFSR. This block works on the LSB only + * of the input data stream, i.e., on an "unpacked binary" stream, and + * produces the same format on its output. + * + * \param mask Polynomial mask for LFSR + * \param seed Initial shift register contents + * \param len Shift register length + * \param count Number of bits after which shift register is reset, 0=never + * + * The scrambler works by XORing the incoming bit stream by the output of + * the LFSR. Optionally, after 'count' bits have been processed, the shift + * register is reset to the seed value. This allows processing fixed length + * vectors of samples. + * + * \ingroup coding_blk + */ + +class DIGITAL_API digital_additive_scrambler_bb : public gr_sync_block +{ + friend DIGITAL_API digital_additive_scrambler_bb_sptr + digital_make_additive_scrambler_bb(int mask, int seed, + int len, int count); + + gri_lfsr d_lfsr; + int d_count; + int d_bits; + + digital_additive_scrambler_bb(int mask, int seed, + int len, int count); + +public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H */ diff --git a/gr-digital/include/digital_bytes_to_syms.h b/gr-digital/include/digital_bytes_to_syms.h new file mode 100644 index 0000000000..3062366b95 --- /dev/null +++ b/gr-digital/include/digital_bytes_to_syms.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDED_GR_BYTES_TO_SYMS_H +#define INCLUDED_GR_BYTES_TO_SYMS_H + +#include <digital_api.h> +#include <gr_sync_interpolator.h> + +class digital_bytes_to_syms; +typedef boost::shared_ptr<digital_bytes_to_syms> digital_bytes_to_syms_sptr; + +DIGITAL_API digital_bytes_to_syms_sptr digital_make_bytes_to_syms(); + +/*! + * \brief Convert stream of bytes to stream of +/- 1 symbols + * \ingroup converter_blk + * + * input: stream of bytes; output: stream of float + * + * This block is deprecated. + * + * The combination of gr_packed_to_unpacked_bb followed by + * gr_chunks_to_symbols_bf or gr_chunks_to_symbols_bc handles the + * general case of mapping from a stream of bytes into arbitrary float + * or complex symbols. + * + * \sa gr_packed_to_unpacked_bb, gr_unpacked_to_packed_bb, + * \sa gr_chunks_to_symbols_bf, gr_chunks_to_symbols_bc. + */ +class DIGITAL_API digital_bytes_to_syms : public gr_sync_interpolator +{ + friend DIGITAL_API digital_bytes_to_syms_sptr + digital_make_bytes_to_syms(); + + digital_bytes_to_syms(); + + public: + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_GR_BYTES_TO_SYMS_H */ diff --git a/gr-digital/include/digital_chunks_to_symbols_XX.h.t b/gr-digital/include/digital_chunks_to_symbols_XX.h.t new file mode 100644 index 0000000000..92b7c94d58 --- /dev/null +++ b/gr-digital/include/digital_chunks_to_symbols_XX.h.t @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <digital_api.h> +#include <gr_sync_interpolator.h> + +class @NAME@; +typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; + +DIGITAL_API @SPTR_NAME@ +digital_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); + +/*! + * \brief Map a stream of symbol indexes (unpacked bytes or shorts) to stream of float or complex constellation points in D dimensions (D = 1 by default) + * \ingroup converter_blk + * + * input: stream of @I_TYPE@; output: stream of @O_TYPE@ + * + * out[n D + k] = symbol_table[in[n] D + k], k=0,1,...,D-1 + * + * The combination of gr_packed_to_unpacked_XX followed by + * gr_chunks_to_symbols_XY handles the general case of mapping + * from a stream of bytes or shorts into arbitrary float + * or complex symbols. + * + * \sa gr_packed_to_unpacked_bb, gr_unpacked_to_packed_bb, + * \sa gr_packed_to_unpacked_ss, gr_unpacked_to_packed_ss, + * \sa digital_chunks_to_symbols_bf, digital_chunks_to_symbols_bc. + * \sa digital_chunks_to_symbols_sf, digital_chunks_to_symbols_sc. + */ + +class DIGITAL_API @NAME@ : public gr_sync_interpolator +{ + friend DIGITAL_API @SPTR_NAME@ digital_make_@BASE_NAME@ + (const std::vector<@O_TYPE@> &symbol_table, const int D); + + int d_D; + std::vector<@O_TYPE@> d_symbol_table; + @NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); + + public: + int D () const { return d_D; } + std::vector<@O_TYPE@> symbol_table () const { return d_symbol_table; } + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + bool check_topology(int ninputs, int noutputs) { return ninputs == noutputs; } +}; + +#endif diff --git a/gr-digital/include/digital_cma_equalizer_cc.h b/gr-digital/include/digital_cma_equalizer_cc.h index 0d703789a9..79e84ca4b3 100644 --- a/gr-digital/include/digital_cma_equalizer_cc.h +++ b/gr-digital/include/digital_cma_equalizer_cc.h @@ -41,9 +41,9 @@ digital_make_cma_equalizer_cc(int num_taps, float modulus, float mu, int sps); * * The error value and tap update equations (for p=2) can be found in: * - * D. Godard, "Self-Recovering Equalization and Carrier Tracking in + * "D. Godard, "Self-Recovering Equalization and Carrier Tracking in * Two-Dimensional Data Communication Systems," IEEE Transactions on - * Communications, Vol. 28, No. 11, pp. 1867 - 1875, 1980, + * Communications, Vol. 28, No. 11, pp. 1867 - 1875, 1980." */ class DIGITAL_API digital_cma_equalizer_cc : public gr_adaptive_fir_ccc { diff --git a/gr-digital/include/digital_constellation_receiver_cb.h b/gr-digital/include/digital_constellation_receiver_cb.h index 8547bdd68e..3a14bb5dee 100644 --- a/gr-digital/include/digital_constellation_receiver_cb.h +++ b/gr-digital/include/digital_constellation_receiver_cb.h @@ -60,9 +60,9 @@ digital_make_constellation_receiver_cb (digital_constellation_sptr constellation * The symbol synchronization is done using a modified Mueller and * Muller circuit from the paper: * - * G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller - * and Muller algorithm," Electronics Letters, Vol. 31, no. 13, 22 - * June 1995, pp. 1032 - 1033. + * "G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller + * and Muller algorithm," Electronics Letters, Vol. 31, no. 13, 22 + * June 1995, pp. 1032 - 1033." * * This circuit interpolates the downconverted sample (using the NCO * developed by the Costas loop) every mu samples, then it finds the diff --git a/gr-digital/include/digital_correlate_access_code_tag_bb.h b/gr-digital/include/digital_correlate_access_code_tag_bb.h new file mode 100644 index 0000000000..b4a12108f4 --- /dev/null +++ b/gr-digital/include/digital_correlate_access_code_tag_bb.h @@ -0,0 +1,89 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2011,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_digital_correlate_access_code_tag_bb_H +#define INCLUDED_digital_correlate_access_code_tag_bb_H + +#include <digital_api.h> +#include <gr_sync_block.h> +#include <string> + +class digital_correlate_access_code_tag_bb; +typedef boost::shared_ptr<digital_correlate_access_code_tag_bb> digital_correlate_access_code_tag_bb_sptr; + +/*! + * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" + * \param threshold maximum number of bits that may be wrong + * \param tag_name key of the tag inserted into the tag stream + */ +DIGITAL_API digital_correlate_access_code_tag_bb_sptr +digital_make_correlate_access_code_tag_bb(const std::string &access_code, + int threshold, + const std::string &tag_name); + +/*! + * \brief Examine input for specified access code, one bit at a time. + * \ingroup sync_blk + * + * input: stream of bits, 1 bit per input byte (data in LSB) + * output: unaltered stream of bits (plus tags) + * + * This block annotates the input stream with tags. The tags have key + * name [tag_name], specified in the constructor. Used for searching + * an input data stream for preambles, etc. + */ +class DIGITAL_API digital_correlate_access_code_tag_bb : public gr_sync_block +{ + friend DIGITAL_API digital_correlate_access_code_tag_bb_sptr + digital_make_correlate_access_code_tag_bb(const std::string &access_code, + int threshold, + const std::string &tag_name); + private: + unsigned long long d_access_code; // access code to locate start of packet + // access code is left justified in the word + unsigned long long d_data_reg; // used to look for access_code + unsigned long long d_mask; // masks access_code bits (top N bits are set where + // N is the number of bits in the access code) + unsigned int d_threshold; // how many bits may be wrong in sync vector + unsigned int d_len; // the length of the access code + + pmt::pmt_t d_key, d_me; //d_key is the tag name, d_me is the block name + unique ID + + protected: + digital_correlate_access_code_tag_bb(const std::string &access_code, + int threshold, + const std::string &tag_name); + + public: + ~digital_correlate_access_code_tag_bb(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + /*! + * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" + */ + bool set_access_code(const std::string &access_code); +}; + +#endif /* INCLUDED_digital_correlate_access_code_tag_bb_H */ diff --git a/gr-digital/include/digital_cpmmod_bc.h b/gr-digital/include/digital_cpmmod_bc.h index 332856afce..f0f11ee30e 100644 --- a/gr-digital/include/digital_cpmmod_bc.h +++ b/gr-digital/include/digital_cpmmod_bc.h @@ -74,9 +74,10 @@ digital_make_cpmmod_bc(int type, float h, */ class DIGITAL_API digital_cpmmod_bc : public gr_hier_block2 { - friend DIGITAL_API digital_cpmmod_bc_sptr digital_make_cpmmod_bc(int type, float h, - unsigned samples_per_sym, - unsigned L, double beta); + friend DIGITAL_API digital_cpmmod_bc_sptr + digital_make_cpmmod_bc(int type, float h, + unsigned samples_per_sym, + unsigned L, double beta); std::vector<float> d_taps; gr_char_to_float_sptr d_char_to_float; diff --git a/gr-digital/include/digital_descrambler_bb.h b/gr-digital/include/digital_descrambler_bb.h new file mode 100644 index 0000000000..b719803f33 --- /dev/null +++ b/gr-digital/include/digital_descrambler_bb.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDED_GR_DESCRAMBLER_BB_H +#define INCLUDED_GR_DESCRAMBLER_BB_H + +#include <digital_api.h> +#include <gr_sync_block.h> +#include "gri_lfsr.h" + +class digital_descrambler_bb; +typedef boost::shared_ptr<digital_descrambler_bb> digital_descrambler_bb_sptr; + +DIGITAL_API digital_descrambler_bb_sptr +digital_make_descrambler_bb(int mask, int seed, int len); + +/*! + * Descramble an input stream using an LFSR. This block works on the LSB only + * of the input data stream, i.e., on an "unpacked binary" stream, and + * produces the same format on its output. + * + * \param mask Polynomial mask for LFSR + * \param seed Initial shift register contents + * \param len Shift register length + * + * \ingroup coding_blk + */ + +class DIGITAL_API digital_descrambler_bb : public gr_sync_block +{ + friend DIGITAL_API digital_descrambler_bb_sptr + digital_make_descrambler_bb(int mask, int seed, int len); + + gri_lfsr d_lfsr; + + digital_descrambler_bb(int mask, int seed, int len); + +public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_GR_DESCRAMBLER_BB_H */ diff --git a/gr-digital/include/digital_diff_decoder_bb.h b/gr-digital/include/digital_diff_decoder_bb.h new file mode 100644 index 0000000000..928035d0e7 --- /dev/null +++ b/gr-digital/include/digital_diff_decoder_bb.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_DIFF_DECODER_BB_H +#define INCLUDED_GR_DIFF_DECODER_BB_H + +#include <digital_api.h> +#include <gr_sync_block.h> + +class digital_diff_decoder_bb; +typedef boost::shared_ptr<digital_diff_decoder_bb> digital_diff_decoder_bb_sptr; + +DIGITAL_API digital_diff_decoder_bb_sptr +digital_make_diff_decoder_bb(unsigned int modulus); + +/*! + * \brief y[0] = (x[0] - x[-1]) % M + * \ingroup coding_blk + * + * Uses current and previous symbols and the alphabet modulus to + * perform differential decoding. + */ +class DIGITAL_API digital_diff_decoder_bb : public gr_sync_block +{ + friend DIGITAL_API digital_diff_decoder_bb_sptr + digital_make_diff_decoder_bb(unsigned int modulus); + digital_diff_decoder_bb(unsigned int modulus); + + unsigned int d_modulus; + + public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/gr-digital/include/digital_diff_encoder_bb.h b/gr-digital/include/digital_diff_encoder_bb.h new file mode 100644 index 0000000000..d4be69cadd --- /dev/null +++ b/gr-digital/include/digital_diff_encoder_bb.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_DIFF_ENCODER_BB_H +#define INCLUDED_GR_DIFF_ENCODER_BB_H + +#include <digital_api.h> +#include <gr_sync_block.h> + +class digital_diff_encoder_bb; +typedef boost::shared_ptr<digital_diff_encoder_bb> digital_diff_encoder_bb_sptr; + +DIGITAL_API digital_diff_encoder_bb_sptr +digital_make_diff_encoder_bb(unsigned int modulus); + +/*! + * \brief y[0] = (x[0] + y[-1]) % M + * \ingroup coding_blk + * + * Uses current and previous symbols and the alphabet modulus to + * perform differential encoding. + */ +class DIGITAL_API digital_diff_encoder_bb : public gr_sync_block +{ + friend DIGITAL_API digital_diff_encoder_bb_sptr + digital_make_diff_encoder_bb(unsigned int modulus); + digital_diff_encoder_bb(unsigned int modulus); + + unsigned int d_last_out; + unsigned int d_modulus; + + public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/gr-digital/include/digital_diff_phasor_cc.h b/gr-digital/include/digital_diff_phasor_cc.h new file mode 100644 index 0000000000..32a2464b28 --- /dev/null +++ b/gr-digital/include/digital_diff_phasor_cc.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_DIFF_PHASOR_CC_H +#define INCLUDED_GR_DIFF_PHASOR_CC_H + +#include <digital_api.h> +#include <gr_sync_block.h> + +/*! + * \brief Differential decoding based on phase change. + * \ingroup coding_blk + * + * Uses the phase difference between two symbols to determine the + * output symbol: + * + * out[i] = in[i] * conj(in[i-1]); + */ +class digital_diff_phasor_cc; +typedef boost::shared_ptr<digital_diff_phasor_cc> digital_diff_phasor_cc_sptr; + +DIGITAL_API digital_diff_phasor_cc_sptr digital_make_diff_phasor_cc(); + + +class DIGITAL_API digital_diff_phasor_cc : public gr_sync_block +{ + friend DIGITAL_API digital_diff_phasor_cc_sptr + digital_make_diff_phasor_cc(); + + digital_diff_phasor_cc(); //constructor + + public: + ~digital_diff_phasor_cc(); //destructor + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/gr-digital/include/digital_fll_band_edge_cc.h b/gr-digital/include/digital_fll_band_edge_cc.h index f07d7ba42b..c70bfc86d4 100644 --- a/gr-digital/include/digital_fll_band_edge_cc.h +++ b/gr-digital/include/digital_fll_band_edge_cc.h @@ -65,8 +65,8 @@ DIGITAL_API digital_fll_band_edge_cc_sptr digital_make_fll_band_edge_cc (float s * abs(x_l(t))^2 - abs(x_u(t))^2 = norm(x_l(t)) - norm(x_u(t)). * * In theory, the band-edge filter is the derivative of the matched - * filter in frequency, (H_be(f) = \\frac{H(f)}{df}. In practice, this - * comes down to a quarter sine wave at the point of the matched + * filter in frequency, (H_be(f) = frac{H(f)}{df}). In practice, + * this comes down to a quarter sine wave at the point of the matched * filter's rolloff (if it's a raised-cosine, the derivative of a * cosine is a sine). Extend this sine by another quarter wave to * make a half wave around the band-edges is equivalent in time to the diff --git a/gr-digital/include/digital_framer_sink_1.h b/gr-digital/include/digital_framer_sink_1.h new file mode 100644 index 0000000000..bb82bf5a73 --- /dev/null +++ b/gr-digital/include/digital_framer_sink_1.h @@ -0,0 +1,107 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_FRAMER_SINK_1_H +#define INCLUDED_GR_FRAMER_SINK_1_H + +#include <digital_api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +class digital_framer_sink_1; +typedef boost::shared_ptr<digital_framer_sink_1> digital_framer_sink_1_sptr; + +DIGITAL_API digital_framer_sink_1_sptr +digital_make_framer_sink_1(gr_msg_queue_sptr target_queue); + +/*! + * \brief Given a stream of bits and access_code flags, assemble packets. + * \ingroup sink_blk + * + * input: stream of bytes from gr_correlate_access_code_bb + * output: none. Pushes assembled packet into target queue + * + * The framer expects a fixed length header of 2 16-bit shorts + * containing the payload length, followed by the payload. If the + * 2 16-bit shorts are not identical, this packet is ignored. Better + * algs are welcome. + * + * The input data consists of bytes that have two bits used. + * Bit 0, the LSB, contains the data bit. + * Bit 1 if set, indicates that the corresponding bit is the + * the first bit of the packet. That is, this bit is the first + * one after the access code. + */ +class DIGITAL_API digital_framer_sink_1 : public gr_sync_block +{ + friend DIGITAL_API digital_framer_sink_1_sptr + digital_make_framer_sink_1(gr_msg_queue_sptr target_queue); + + private: + enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; + + static const int MAX_PKT_LEN = 4096; + static const int HEADERBITLEN = 32; + + gr_msg_queue_sptr d_target_queue; // where to send the packet when received + state_t d_state; + unsigned int d_header; // header bits + int d_headerbitlen_cnt; // how many so far + + unsigned char d_packet[MAX_PKT_LEN]; // assembled payload + unsigned char d_packet_byte; // byte being assembled + int d_packet_byte_index; // which bit of d_packet_byte we're working on + int d_packetlen; // length of packet + int d_packet_whitener_offset; // offset into whitener string to use + int d_packetlen_cnt; // how many so far + + protected: + digital_framer_sink_1(gr_msg_queue_sptr target_queue); + + void enter_search(); + void enter_have_sync(); + void enter_have_header(int payload_len, int whitener_offset); + + bool header_ok() + { + // confirm that two copies of header info are identical + return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; + } + + void header_payload(int *len, int *offset) + { + // header consists of two 16-bit shorts in network byte order + // payload length is lower 12 bits + // whitener offset is upper 4 bits + *len = (d_header >> 16) & 0x0fff; + *offset = (d_header >> 28) & 0x000f; + } + + public: + ~digital_framer_sink_1(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_GR_FRAMER_SINK_1_H */ diff --git a/gr-digital/include/digital_glfsr_source_b.h b/gr-digital/include/digital_glfsr_source_b.h new file mode 100644 index 0000000000..92e5e81f5c --- /dev/null +++ b/gr-digital/include/digital_glfsr_source_b.h @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_GLFSR_SOURCE_B_H +#define INCLUDED_GR_GLFSR_SOURCE_B_H + +#include <digital_api.h> +#include <gr_sync_block.h> + +class gri_glfsr; + +class digital_glfsr_source_b; +typedef boost::shared_ptr<digital_glfsr_source_b> digital_glfsr_source_b_sptr; + +DIGITAL_API digital_glfsr_source_b_sptr +digital_make_glfsr_source_b(int degree, bool repeat=true, + int mask=0, int seed=1); + +/*! + * \brief Galois LFSR pseudo-random source + * \ingroup source_blk + * + * \param degree Degree of shift register must be in [1, 32]. If mask + * is 0, the degree determines a default mask (see + * digital_impl_glfsr.cc for the mapping). + * \param repeat Set to repeat sequence. + * \param mask Allows a user-defined bit mask for indexes of the shift + * register to feed back. + * \param seed Initial setting for values in shift register. + */ +class DIGITAL_API digital_glfsr_source_b : public gr_sync_block +{ + private: + friend DIGITAL_API digital_glfsr_source_b_sptr + digital_make_glfsr_source_b(int degree, bool repeat, + int mask, int seed); + + gri_glfsr *d_glfsr; + + bool d_repeat; + unsigned int d_index; + unsigned int d_length; + + digital_glfsr_source_b(int degree, bool repeat, + int mask, int seed); + + public: + + ~digital_glfsr_source_b(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + unsigned int period() const { return d_length; } + int mask() const; +}; + +#endif /* INCLUDED_GR_GLFSR_SOURCE_B_H */ diff --git a/gr-digital/include/digital_glfsr_source_f.h b/gr-digital/include/digital_glfsr_source_f.h new file mode 100644 index 0000000000..77d7b0f741 --- /dev/null +++ b/gr-digital/include/digital_glfsr_source_f.h @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_GLFSR_SOURCE_F_H +#define INCLUDED_GR_GLFSR_SOURCE_F_H + +#include <digital_api.h> +#include <gr_sync_block.h> + +class gri_glfsr; + +class digital_glfsr_source_f; +typedef boost::shared_ptr<digital_glfsr_source_f> digital_glfsr_source_f_sptr; + +DIGITAL_API digital_glfsr_source_f_sptr +digital_make_glfsr_source_f(int degree, bool repeat=true, + int mask=0, int seed=1); + +/*! + * \brief Galois LFSR pseudo-random source generating float outputs -1.0 - 1.0. + * \ingroup source_blk + * + * \param degree Degree of shift register must be in [1, 32]. If mask + * is 0, the degree determines a default mask (see + * digital_impl_glfsr.cc for the mapping). + * \param repeat Set to repeat sequence. + * \param mask Allows a user-defined bit mask for indexes of the shift + * register to feed back. + * \param seed Initial setting for values in shift register. + */ +class DIGITAL_API digital_glfsr_source_f : public gr_sync_block +{ + private: + friend DIGITAL_API digital_glfsr_source_f_sptr + digital_make_glfsr_source_f(int degree, bool repeat, + int mask, int seed); + + gri_glfsr *d_glfsr; + + bool d_repeat; + unsigned int d_index; + unsigned int d_length; + + digital_glfsr_source_f(int degree, bool repeat, + int mask, int seed); + + public: + + ~digital_glfsr_source_f(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + unsigned int period() const { return d_length; } + int mask() const; +}; + +#endif /* INCLUDED_GR_GLFSR_SOURCE_F_H */ diff --git a/gr-digital/include/digital_impl_glfsr.h b/gr-digital/include/digital_impl_glfsr.h new file mode 100644 index 0000000000..3aadf7cf2f --- /dev/null +++ b/gr-digital/include/digital_impl_glfsr.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_DIGITAL_IMPL_GLFSR_H +#define INCLUDED_DIGITAL_IMPL_GLFSR_H + +#include <digital_api.h> + +/*! + * \brief Galois Linear Feedback Shift Register using specified polynomial mask + * \ingroup misc + * + * Generates a maximal length pseudo-random sequence of length 2^degree-1 + */ + +class DIGITAL_API digital_impl_glfsr +{ + private: + int d_shift_register; + int d_mask; + + public: + + digital_impl_glfsr(int mask, int seed) { d_shift_register = seed; d_mask = mask; } + static int glfsr_mask(int degree); + + unsigned char next_bit() { + unsigned char bit = d_shift_register & 1; + d_shift_register >>= 1; + if (bit) + d_shift_register ^= d_mask; + return bit; + } + + int mask() const { return d_mask; } +}; + +#endif /* INCLUDED_DIGITAL_IMPL_GLFSR_H */ diff --git a/gr-digital/include/digital_kurtotic_equalizer_cc.h b/gr-digital/include/digital_kurtotic_equalizer_cc.h index 3ac8712d5e..fed88c3741 100644 --- a/gr-digital/include/digital_kurtotic_equalizer_cc.h +++ b/gr-digital/include/digital_kurtotic_equalizer_cc.h @@ -39,9 +39,9 @@ digital_make_kurtotic_equalizer_cc(int num_taps, float mu); * \ingroup eq_blk * \ingroup digital * - * Y. Guo, J. Zhao, Y. Sun, "Sign kurtosis maximization based blind + * "Y. Guo, J. Zhao, Y. Sun, "Sign kurtosis maximization based blind * equalization algorithm," IEEE Conf. on Control, Automation, - * Robotics and Vision, Vol. 3, Dec. 2004, pp. 2052 - 2057. + * Robotics and Vision, Vol. 3, Dec. 2004, pp. 2052 - 2057." */ class DIGITAL_API digital_kurtotic_equalizer_cc : public gr_adaptive_fir_ccc { diff --git a/gr-digital/include/digital_map_bb.h b/gr-digital/include/digital_map_bb.h new file mode 100644 index 0000000000..4aca66fbe1 --- /dev/null +++ b/gr-digital/include/digital_map_bb.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDED_GR_MAP_BB_H +#define INCLUDED_GR_MAP_BB_H + +#include <digital_api.h> +#include <gr_sync_block.h> + +class digital_map_bb; +typedef boost::shared_ptr<digital_map_bb> digital_map_bb_sptr; + +DIGITAL_API digital_map_bb_sptr +digital_make_map_bb(const std::vector<int> &map); + +/*! + * \brief output[i] = map[input[i]] + * \ingroup coding_blk + * + * This block maps an incoming signal to the value in the map. + * The block expects that the incoming signal has a maximum + * value of len(map)-1. + * + * -> output[i] = map[input[i]] + * + * \param map a vector of integers. + */ + +class DIGITAL_API digital_map_bb : public gr_sync_block +{ + friend DIGITAL_API digital_map_bb_sptr + digital_make_map_bb(const std::vector<int> &map); + + unsigned char d_map[0x100]; + + digital_map_bb(const std::vector<int> &map); + +public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_GR_MAP_BB_H */ diff --git a/gr-digital/include/digital_mpsk_receiver_cc.h b/gr-digital/include/digital_mpsk_receiver_cc.h index 02cea8d25b..1f11a26b64 100644 --- a/gr-digital/include/digital_mpsk_receiver_cc.h +++ b/gr-digital/include/digital_mpsk_receiver_cc.h @@ -65,10 +65,10 @@ digital_make_mpsk_receiver_cc (unsigned int M, float theta, * * The symbol synchronization is done using a modified Mueller and * Muller circuit from the paper: - * - * G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller - * and Muller algorithm," Electronics Letters, Vol. 31, no. 13, 22 - * June 1995, pp. 1032 - 1033. + * + * "G. R. Danesfahani, T. G. Jeans, "Optimisation of modified Mueller + * and Muller algorithm," Electronics Letters, Vol. 31, no. 13, 22 + * June 1995, pp. 1032 - 1033." * * This circuit interpolates the downconverted sample (using the NCO * developed by the Costas loop) every mu samples, then it finds the diff --git a/gr-digital/include/digital_ofdm_insert_preamble.h b/gr-digital/include/digital_ofdm_insert_preamble.h index 6f9dae5d6b..fa44558add 100644 --- a/gr-digital/include/digital_ofdm_insert_preamble.h +++ b/gr-digital/include/digital_ofdm_insert_preamble.h @@ -88,18 +88,20 @@ private: int d_pending_flag; void enter_idle(); - void enter_preamble(); void enter_first_payload(); void enter_payload(); public: ~digital_ofdm_insert_preamble(); + void enter_preamble(); int general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); + void forecast (int noutput_items, gr_vector_int &ninput_items_required); + }; #endif /* INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_H */ diff --git a/gr-digital/include/digital_packet_sink.h b/gr-digital/include/digital_packet_sink.h new file mode 100644 index 0000000000..7ab41c0ef7 --- /dev/null +++ b/gr-digital/include/digital_packet_sink.h @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_PACKET_SINK_H +#define INCLUDED_GR_PACKET_SINK_H + +#include <digital_api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +class digital_packet_sink; +typedef boost::shared_ptr<digital_packet_sink> digital_packet_sink_sptr; + +DIGITAL_API digital_packet_sink_sptr +digital_make_packet_sink(const std::vector<unsigned char>& sync_vector, + gr_msg_queue_sptr target_queue, + int threshold = -1); // -1 -> use default + +/*! + * \brief process received bits looking for packet sync, header, and process bits into packet + * \ingroup sink_blk + * + * input: stream of symbols to be sliced. + * + * output: none. Pushes assembled packet into target queue + * + * The packet sink takes in a stream of binary symbols that are sliced + * around 0. The bits are then checked for the \p sync_vector to + * determine find and decode the packet. It then expects a fixed + * length header of 2 16-bit shorts containing the payload length, + * followed by the payload. If the 2 16-bit shorts are not identical, + * this packet is ignored. Better algs are welcome. + * + * This block is not very useful anymore as it only works with 2-level + * modulations such as BPSK or GMSK. The block can generally be + * replaced with a correlate access code and frame sink blocks. + * + * \param sync_vector The synchronization vector as a vector of 1's and 0's. + * \param target_queue The message queue that packets are sent to. + * \param threshold Number of bits that can be incorrect in the \p sync_vector. + */ +class DIGITAL_API digital_packet_sink : public gr_sync_block +{ + friend DIGITAL_API digital_packet_sink_sptr + digital_make_packet_sink(const std::vector<unsigned char>& sync_vector, + gr_msg_queue_sptr target_queue, + int threshold); + + private: + enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; + + static const int MAX_PKT_LEN = 4096; + static const int HEADERBITLEN = 32; + + gr_msg_queue_sptr d_target_queue; // where to send the packet when received + unsigned long long d_sync_vector; // access code to locate start of packet + unsigned int d_threshold; // how many bits may be wrong in sync vector + + state_t d_state; + + unsigned long long d_shift_reg; // used to look for sync_vector + + unsigned int d_header; // header bits + int d_headerbitlen_cnt; // how many so far + + unsigned char d_packet[MAX_PKT_LEN]; // assembled payload + unsigned char d_packet_byte; // byte being assembled + int d_packet_byte_index; // which bit of d_packet_byte we're working on + int d_packetlen; // length of packet + int d_packetlen_cnt; // how many so far + + protected: + digital_packet_sink(const std::vector<unsigned char>& sync_vector, + gr_msg_queue_sptr target_queue, + int threshold); + + void enter_search(); + void enter_have_sync(); + void enter_have_header(int payload_len); + + int slice(float x) { return x > 0 ? 1 : 0; } + + bool header_ok() + { + // confirm that two copies of header info are identical + return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; + } + + int header_payload_len() + { + // header consists of two 16-bit shorts in network byte order + int t = (d_header >> 16) & 0xffff; + return t; + } + + public: + ~digital_packet_sink(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + + //! return true if we detect carrier + bool carrier_sensed() const + { + return d_state != STATE_SYNC_SEARCH; + } + +}; + +#endif /* INCLUDED_GR_PACKET_SINK_H */ diff --git a/gr-digital/include/digital_pfb_clock_sync_ccf.h b/gr-digital/include/digital_pfb_clock_sync_ccf.h new file mode 100644 index 0000000000..1b403ab253 --- /dev/null +++ b/gr-digital/include/digital_pfb_clock_sync_ccf.h @@ -0,0 +1,376 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + + +#ifndef INCLUDED_DIGITAL_PFB_CLOCK_SYNC_CCF_H +#define INCLUDED_DIGITAL_PFB_CLOCK_SYNC_CCF_H + +#include <digital_api.h> +#include <gr_block.h> + +class digital_pfb_clock_sync_ccf; +typedef boost::shared_ptr<digital_pfb_clock_sync_ccf> digital_pfb_clock_sync_ccf_sptr; +DIGITAL_API digital_pfb_clock_sync_ccf_sptr +digital_make_pfb_clock_sync_ccf(double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size=32, + float init_phase=0, + float max_rate_deviation=1.5, + int osps=1); + +class gr_fir_ccf; + +/*! + * \class digital_pfb_clock_sync_ccf + * + * \brief Timing synchronizer using polyphase filterbanks + * + * \ingroup filter_blk + * \ingroup pfb_blk + * + * This block performs timing synchronization for PAM signals by + * minimizing the derivative of the filtered signal, which in turn + * maximizes the SNR and minimizes ISI. + * + * This approach works by setting up two filterbanks; one filterbank + * contains the signal's pulse shaping matched filter (such as a root + * raised cosine filter), where each branch of the filterbank contains + * a different phase of the filter. The second filterbank contains + * the derivatives of the filters in the first filterbank. Thinking of + * this in the time domain, the first filterbank contains filters that + * have a sinc shape to them. We want to align the output signal to be + * sampled at exactly the peak of the sinc shape. The derivative of + * the sinc contains a zero at the maximum point of the sinc (sinc(0) + * = 1, sinc(0)' = 0). Furthermore, the region around the zero point + * is relatively linear. We make use of this fact to generate the + * error signal. + * + * If the signal out of the derivative filters is d_i[n] for the ith + * filter, and the output of the matched filter is x_i[n], we + * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + + * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error in + * the real and imaginary parts. There are two reasons we multiply by + * the signal itself. First, if the symbol could be positive or + * negative going, but we want the error term to always tell us to go + * in the same direction depending on which side of the zero point we + * are on. The sign of x_i[n] adjusts the error term to do + * this. Second, the magnitude of x_i[n] scales the error term + * depending on the symbol's amplitude, so larger signals give us a + * stronger error term because we have more confidence in that + * symbol's value. Using the magnitude of x_i[n] instead of just the + * sign is especially good for signals with low SNR. + * + * The error signal, e[n], gives us a value proportional to how far + * away from the zero point we are in the derivative signal. We want + * to drive this value to zero, so we set up a second order loop. We + * have two variables for this loop; d_k is the filter number in the + * filterbank we are on and d_rate is the rate which we travel through + * the filters in the steady state. That is, due to the natural clock + * differences between the transmitter and receiver, d_rate represents + * that difference and would traverse the filter phase paths to keep + * the receiver locked. Thinking of this as a second-order PLL, the + * d_rate is the frequency and d_k is the phase. So we update d_rate + * and d_k using the standard loop equations based on two error + * signals, d_alpha and d_beta. We have these two values set based on + * each other for a critically damped system, so in the block + * constructor, we just ask for "gain," which is d_alpha while d_beta + * is equal to (gain^2)/4. + * + * The block's parameters are: + * + * \li \p sps: The clock sync block needs to know the number of samples per + * symbol, because it defaults to return a single point representing + * the symbol. The sps can be any positive real number and does not + * need to be an integer. + * + * \li \p loop_bw: The loop bandwidth is used to set the gain of the + * inner control loop (see: + * http://gnuradio.squarespace.com/blog/2011/8/13/control-loop-gain-values.html). + * This should be set small (a value of around 2pi/100 is suggested in + * that blog post as the step size for the number of radians around + * the unit circle to move relative to the error). + * + * \li \p taps: One of the most important parameters for this block is + * the taps of the filter. One of the benefits of this algorithm is + * that you can put the matched filter in here as the taps, so you get + * both the matched filter and sample timing correction in one go. So + * create your normal matched filter. For a typical digital + * modulation, this is a root raised cosine filter. The number of taps + * of this filter is based on how long you expect the channel to be; + * that is, how many symbols do you want to combine to get the current + * symbols energy back (there's probably a better way of stating + * that). It's usually 5 to 10 or so. That gives you your filter, but + * now we need to think about it as a filter with different phase + * profiles in each filter. So take this number of taps and multiply + * it by the number of filters. This is the number you would use to + * create your prototype filter. When you use this in the PFB + * filerbank, it segments these taps into the filterbanks in such a + * way that each bank now represents the filter at different phases, + * equally spaced at 2pi/N, where N is the number of filters. + * + * \li \p filter_size (default=32): The number of filters can also be + * set and defaults to 32. With 32 filters, you get a good enough + * resolution in the phase to produce very small, almost unnoticeable, + * ISI. Going to 64 filters can reduce this more, but after that + * there is very little gained for the extra complexity. + * + * \li \p init_phase (default=0): The initial phase is another + * settable parameter and refers to the filter path the algorithm + * initially looks at (i.e., d_k starts at init_phase). This value + * defaults to zero, but it might be useful to start at a different + * phase offset, such as the mid-point of the filters. + * + * \li \p max_rate_deviation (default=1.5): The next parameter is the + * max_rate_devitation, which defaults to 1.5. This is how far we + * allow d_rate to swing, positive or negative, from 0. Constraining + * the rate can help keep the algorithm from walking too far away to + * lock during times when there is no signal. + * + * \li \p osps (default=1): The osps is the number of output samples per symbol. By default, + * the algorithm produces 1 sample per symbol, sampled at the exact + * sample value. This osps value was added to better work with + * equalizers, which do a better job of modeling the channel if they + * have 2 samps/sym. + */ + +class DIGITAL_API digital_pfb_clock_sync_ccf : public gr_block +{ + private: + /*! + * Build the polyphase filterbank timing synchronizer. + * \param sps (double) The number of samples per symbol in the incoming signal + * \param loop_bw (float) The bandwidth of the control loop; set's alpha and beta. + * \param taps (vector<int>) The filter taps. + * \param filter_size (uint) The number of filters in the filterbank (default = 32). + * \param init_phase (float) The initial phase to look at, or which filter to start + * with (default = 0). + * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). + * \param osps (int) The number of output samples per symbol (default=1). + * + */ + friend DIGITAL_API digital_pfb_clock_sync_ccf_sptr + digital_make_pfb_clock_sync_ccf(double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps); + + bool d_updated; + double d_sps; + double d_sample_num; + float d_loop_bw; + float d_damping; + float d_alpha; + float d_beta; + + int d_nfilters; + int d_taps_per_filter; + std::vector<gr_fir_ccf*> d_filters; + std::vector<gr_fir_ccf*> d_diff_filters; + std::vector< std::vector<float> > d_taps; + std::vector< std::vector<float> > d_dtaps; + + float d_k; + float d_rate; + float d_rate_i; + float d_rate_f; + float d_max_dev; + int d_filtnum; + int d_osps; + float d_error; + int d_out_idx; + + /*! + * Build the polyphase filterbank timing synchronizer. + */ + digital_pfb_clock_sync_ccf(double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps); + + void create_diff_taps(const std::vector<float> &newtaps, + std::vector<float> &difftaps); + +public: + ~digital_pfb_clock_sync_ccf(); + + /*! \brief update the system gains from omega and eta + * + * This function updates the system gains based on the loop + * bandwidth and damping factor of the system. + * These two factors can be set separately through their own + * set functions. + */ + void update_gains(); + + /*! + * Resets the filterbank's filter taps with the new prototype filter + */ + void set_taps(const std::vector<float> &taps, + std::vector< std::vector<float> > &ourtaps, + std::vector<gr_fir_ccf*> &ourfilter); + + /*! + * Returns all of the taps of the matched filter + */ + std::vector< std::vector<float> > get_taps(); + + /*! + * Returns all of the taps of the derivative filter + */ + std::vector< std::vector<float> > get_diff_taps(); + + /*! + * Returns the taps of the matched filter for a particular channel + */ + std::vector<float> get_channel_taps(int channel); + + /*! + * Returns the taps in the derivative filter for a particular channel + */ + std::vector<float> get_diff_channel_taps(int channel); + + /*! + * Return the taps as a formatted string for printing + */ + std::string get_taps_as_string(); + + /*! + * Return the derivative filter taps as a formatted string for printing + */ + std::string get_diff_taps_as_string(); + + + /******************************************************************* + SET FUNCTIONS + *******************************************************************/ + + + /*! + * \brief Set the loop bandwidth + * + * Set the loop filter's bandwidth to \p bw. This should be between + * 2*pi/200 and 2*pi/100 (in rads/samp). It must also be a positive + * number. + * + * When a new damping factor is set, the gains, alpha and beta, of the loop + * are recalculated by a call to update_gains(). + * + * \param bw (float) new bandwidth + * + */ + void set_loop_bandwidth(float bw); + + /*! + * \brief Set the loop damping factor + * + * Set the loop filter's damping factor to \p df. The damping factor + * should be sqrt(2)/2.0 for critically damped systems. + * Set it to anything else only if you know what you are doing. It must + * be a number between 0 and 1. + * + * When a new damping factor is set, the gains, alpha and beta, of the loop + * are recalculated by a call to update_gains(). + * + * \param df (float) new damping factor + * + */ + void set_damping_factor(float df); + + /*! + * \brief Set the loop gain alpha + * + * Set's the loop filter's alpha gain parameter. + * + * This value should really only be set by adjusting the loop bandwidth + * and damping factor. + * + * \param alpha (float) new alpha gain + * + */ + void set_alpha(float alpha); + + /*! + * \brief Set the loop gain beta + * + * Set's the loop filter's beta gain parameter. + * + * This value should really only be set by adjusting the loop bandwidth + * and damping factor. + * + * \param beta (float) new beta gain + * + */ + void set_beta(float beta); + + /*! + * Set the maximum deviation from 0 d_rate can have + */ + void set_max_rate_deviation(float m) + { + d_max_dev = m; + } + + /******************************************************************* + GET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Returns the loop bandwidth + */ + float get_loop_bandwidth() const; + + /*! + * \brief Returns the loop damping factor + */ + float get_damping_factor() const; + + /*! + * \brief Returns the loop gain alpha + */ + float get_alpha() const; + + /*! + * \brief Returns the loop gain beta + */ + float get_beta() const; + + /*! + * \brief Returns the current clock rate + */ + float get_clock_rate() const; + + /******************************************************************* + *******************************************************************/ + + bool check_topology(int ninputs, int noutputs); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/gr-digital/include/digital_pfb_clock_sync_fff.h b/gr-digital/include/digital_pfb_clock_sync_fff.h new file mode 100644 index 0000000000..c7e8babd69 --- /dev/null +++ b/gr-digital/include/digital_pfb_clock_sync_fff.h @@ -0,0 +1,376 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + + +#ifndef INCLUDED_DIGITAL_PFB_CLOCK_SYNC_FFF_H +#define INCLUDED_DIGITAL_PFB_CLOCK_SYNC_FFF_H + +#include <digital_api.h> +#include <gr_block.h> + +class digital_pfb_clock_sync_fff; +typedef boost::shared_ptr<digital_pfb_clock_sync_fff> digital_pfb_clock_sync_fff_sptr; +DIGITAL_API digital_pfb_clock_sync_fff_sptr +digital_make_pfb_clock_sync_fff(double sps, float gain, + const std::vector<float> &taps, + unsigned int filter_size=32, + float init_phase=0, + float max_rate_deviation=1.5, + int osps=1); + +class gr_fir_fff; + +/*! + * \class digital_pfb_clock_sync_fff + * + * \brief Timing synchronizer using polyphase filterbanks + * + * \ingroup filter_blk + * \ingroup pfb_blk + * + * This block performs timing synchronization for PAM signals by + * minimizing the derivative of the filtered signal, which in turn + * maximizes the SNR and minimizes ISI. + * + * This approach works by setting up two filterbanks; one filterbank + * contains the signal's pulse shaping matched filter (such as a root + * raised cosine filter), where each branch of the filterbank contains + * a different phase of the filter. The second filterbank contains + * the derivatives of the filters in the first filterbank. Thinking of + * this in the time domain, the first filterbank contains filters that + * have a sinc shape to them. We want to align the output signal to be + * sampled at exactly the peak of the sinc shape. The derivative of + * the sinc contains a zero at the maximum point of the sinc (sinc(0) + * = 1, sinc(0)' = 0). Furthermore, the region around the zero point + * is relatively linear. We make use of this fact to generate the + * error signal. + * + * If the signal out of the derivative filters is d_i[n] for the ith + * filter, and the output of the matched filter is x_i[n], we + * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + + * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error in + * the real and imaginary parts. There are two reasons we multiply by + * the signal itself. First, if the symbol could be positive or + * negative going, but we want the error term to always tell us to go + * in the same direction depending on which side of the zero point we + * are on. The sign of x_i[n] adjusts the error term to do + * this. Second, the magnitude of x_i[n] scales the error term + * depending on the symbol's amplitude, so larger signals give us a + * stronger error term because we have more confidence in that + * symbol's value. Using the magnitude of x_i[n] instead of just the + * sign is especially good for signals with low SNR. + * + * The error signal, e[n], gives us a value proportional to how far + * away from the zero point we are in the derivative signal. We want + * to drive this value to zero, so we set up a second order loop. We + * have two variables for this loop; d_k is the filter number in the + * filterbank we are on and d_rate is the rate which we travel through + * the filters in the steady state. That is, due to the natural clock + * differences between the transmitter and receiver, d_rate represents + * that difference and would traverse the filter phase paths to keep + * the receiver locked. Thinking of this as a second-order PLL, the + * d_rate is the frequency and d_k is the phase. So we update d_rate + * and d_k using the standard loop equations based on two error + * signals, d_alpha and d_beta. We have these two values set based on + * each other for a critically damped system, so in the block + * constructor, we just ask for "gain," which is d_alpha while d_beta + * is equal to (gain^2)/4. + * + * The block's parameters are: + * + * \li \p sps: The clock sync block needs to know the number of samples per + * symbol, because it defaults to return a single point representing + * the symbol. The sps can be any positive real number and does not + * need to be an integer. + * + * \li \p loop_bw: The loop bandwidth is used to set the gain of the + * inner control loop (see: + * http://gnuradio.squarespace.com/blog/2011/8/13/control-loop-gain-values.html). + * This should be set small (a value of around 2pi/100 is suggested in + * that blog post as the step size for the number of radians around + * the unit circle to move relative to the error). + * + * \li \p taps: One of the most important parameters for this block is + * the taps of the filter. One of the benefits of this algorithm is + * that you can put the matched filter in here as the taps, so you get + * both the matched filter and sample timing correction in one go. So + * create your normal matched filter. For a typical digital + * modulation, this is a root raised cosine filter. The number of taps + * of this filter is based on how long you expect the channel to be; + * that is, how many symbols do you want to combine to get the current + * symbols energy back (there's probably a better way of stating + * that). It's usually 5 to 10 or so. That gives you your filter, but + * now we need to think about it as a filter with different phase + * profiles in each filter. So take this number of taps and multiply + * it by the number of filters. This is the number you would use to + * create your prototype filter. When you use this in the PFB + * filerbank, it segments these taps into the filterbanks in such a + * way that each bank now represents the filter at different phases, + * equally spaced at 2pi/N, where N is the number of filters. + * + * \li \p filter_size (default=32): The number of filters can also be + * set and defaults to 32. With 32 filters, you get a good enough + * resolution in the phase to produce very small, almost unnoticeable, + * ISI. Going to 64 filters can reduce this more, but after that + * there is very little gained for the extra complexity. + * + * \li \p init_phase (default=0): The initial phase is another + * settable parameter and refers to the filter path the algorithm + * initially looks at (i.e., d_k starts at init_phase). This value + * defaults to zero, but it might be useful to start at a different + * phase offset, such as the mid-point of the filters. + * + * \li \p max_rate_deviation (default=1.5): The next parameter is the + * max_rate_devitation, which defaults to 1.5. This is how far we + * allow d_rate to swing, positive or negative, from 0. Constraining + * the rate can help keep the algorithm from walking too far away to + * lock during times when there is no signal. + * + * \li \p osps (default=1): The osps is the number of output samples + * per symbol. By default, the algorithm produces 1 sample per symbol, + * sampled at the exact sample value. This osps value was added to + * better work with equalizers, which do a better job of modeling the + * channel if they have 2 samps/sym. + */ + +class DIGITAL_API digital_pfb_clock_sync_fff : public gr_block +{ + private: + /*! + * Build the polyphase filterbank timing synchronizer. + * \param sps (double) The number of samples per second in the incoming signal + * \param gain (float) The alpha gain of the control loop; beta = (gain^2)/4 by default. + * \param taps (vector<int>) The filter taps. + * \param filter_size (uint) The number of filters in the filterbank (default = 32). + * \param init_phase (float) The initial phase to look at, or which filter to start + * with (default = 0). + * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). + * \param osps (int) The number of output samples per symbol (default=1). + * + */ + friend DIGITAL_API digital_pfb_clock_sync_fff_sptr + digital_make_pfb_clock_sync_fff(double sps, float gain, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps); + + bool d_updated; + double d_sps; + double d_sample_num; + float d_loop_bw; + float d_damping; + float d_alpha; + float d_beta; + + int d_nfilters; + int d_taps_per_filter; + std::vector<gr_fir_fff*> d_filters; + std::vector<gr_fir_fff*> d_diff_filters; + std::vector< std::vector<float> > d_taps; + std::vector< std::vector<float> > d_dtaps; + + float d_k; + float d_rate; + float d_rate_i; + float d_rate_f; + float d_max_dev; + int d_filtnum; + int d_osps; + float d_error; + int d_out_idx; + + /*! + * Build the polyphase filterbank timing synchronizer. + */ + digital_pfb_clock_sync_fff(double sps, float gain, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps); + + void create_diff_taps(const std::vector<float> &newtaps, + std::vector<float> &difftaps); + +public: + ~digital_pfb_clock_sync_fff (); + + /*! \brief update the system gains from omega and eta + * + * This function updates the system gains based on the loop + * bandwidth and damping factor of the system. + * These two factors can be set separately through their own + * set functions. + */ + void update_gains(); + + /*! + * Resets the filterbank's filter taps with the new prototype filter + */ + void set_taps(const std::vector<float> &taps, + std::vector< std::vector<float> > &ourtaps, + std::vector<gr_fir_fff*> &ourfilter); + + /*! + * Returns all of the taps of the matched filter + */ + std::vector< std::vector<float> > get_taps(); + + /*! + * Returns all of the taps of the derivative filter + */ + std::vector< std::vector<float> > get_diff_taps(); + + /*! + * Returns the taps of the matched filter for a particular channel + */ + std::vector<float> get_channel_taps(int channel); + + /*! + * Returns the taps in the derivative filter for a particular channel + */ + std::vector<float> get_diff_channel_taps(int channel); + + /*! + * Return the taps as a formatted string for printing + */ + std::string get_taps_as_string(); + + /*! + * Return the derivative filter taps as a formatted string for printing + */ + std::string get_diff_taps_as_string(); + + + /******************************************************************* + SET FUNCTIONS + *******************************************************************/ + + + /*! + * \brief Set the loop bandwidth + * + * Set the loop filter's bandwidth to \p bw. This should be between + * 2*pi/200 and 2*pi/100 (in rads/samp). It must also be a positive + * number. + * + * When a new damping factor is set, the gains, alpha and beta, of the loop + * are recalculated by a call to update_gains(). + * + * \param bw (float) new bandwidth + * + */ + void set_loop_bandwidth(float bw); + + /*! + * \brief Set the loop damping factor + * + * Set the loop filter's damping factor to \p df. The damping factor + * should be sqrt(2)/2.0 for critically damped systems. + * Set it to anything else only if you know what you are doing. It must + * be a number between 0 and 1. + * + * When a new damping factor is set, the gains, alpha and beta, of the loop + * are recalculated by a call to update_gains(). + * + * \param df (float) new damping factor + * + */ + void set_damping_factor(float df); + + /*! + * \brief Set the loop gain alpha + * + * Set's the loop filter's alpha gain parameter. + * + * This value should really only be set by adjusting the loop bandwidth + * and damping factor. + * + * \param alpha (float) new alpha gain + * + */ + void set_alpha(float alpha); + + /*! + * \brief Set the loop gain beta + * + * Set's the loop filter's beta gain parameter. + * + * This value should really only be set by adjusting the loop bandwidth + * and damping factor. + * + * \param beta (float) new beta gain + * + */ + void set_beta(float beta); + + /*! + * Set the maximum deviation from 0 d_rate can have + */ + void set_max_rate_deviation(float m) + { + d_max_dev = m; + } + + /******************************************************************* + GET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Returns the loop bandwidth + */ + float get_loop_bandwidth() const; + + /*! + * \brief Returns the loop damping factor + */ + float get_damping_factor() const; + + /*! + * \brief Returns the loop gain alpha + */ + float get_alpha() const; + + /*! + * \brief Returns the loop gain beta + */ + float get_beta() const; + + /*! + * \brief Returns the current clock rate + */ + float get_clock_rate() const; + + /******************************************************************* + *******************************************************************/ + + bool check_topology(int ninputs, int noutputs); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/gr-digital/include/digital_pn_correlator_cc.h b/gr-digital/include/digital_pn_correlator_cc.h new file mode 100644 index 0000000000..87cc2ff93c --- /dev/null +++ b/gr-digital/include/digital_pn_correlator_cc.h @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_PN_CORRELATOR_CC_H +#define INCLUDED_GR_PN_CORRELATOR_CC_H + +#include <digital_api.h> +#include <gr_sync_decimator.h> +#include <gri_glfsr.h> + +class digital_pn_correlator_cc; +typedef boost::shared_ptr<digital_pn_correlator_cc> digital_pn_correlator_cc_sptr; + +DIGITAL_API digital_pn_correlator_cc_sptr +digital_make_pn_correlator_cc(int degree, int mask=0, int seed=1); +/*! + * \brief PN code sequential search correlator + * + * \ingroup sync_blk + * + * Receives complex baseband signal, outputs complex correlation + * against reference PN code, one sample per PN code period. The PN + * sequence is generated using a GLFSR. + * + * \param degree Degree of shift register must be in [1, 32]. If mask + * is 0, the degree determines a default mask (see + * digital_impl_glfsr.cc for the mapping). + * \param repeat Set to repeat sequence. + * \param mask Allows a user-defined bit mask for indexes of the shift + * register to feed back. + * \param seed Initial setting for values in shift register. + */ +class DIGITAL_API digital_pn_correlator_cc : public gr_sync_decimator +{ + friend DIGITAL_API digital_pn_correlator_cc_sptr + digital_make_pn_correlator_cc(int degree, int mask, int seed); + + int d_len; + float d_pn; + gri_glfsr *d_reference; + + protected: + digital_pn_correlator_cc(int degree, int mask, int seed); + + public: + virtual int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + ~digital_pn_correlator_cc(); +}; + +#endif /* INCLUDED_GR_PN_CORRELATOR_CC_H */ diff --git a/gr-digital/include/digital_probe_density_b.h b/gr-digital/include/digital_probe_density_b.h new file mode 100644 index 0000000000..271ad2a072 --- /dev/null +++ b/gr-digital/include/digital_probe_density_b.h @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 Free Software Foundation, Inc. + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDED_GR_PROBE_DENSITY_B_H +#define INCLUDED_GR_PROBE_DENSITY_B_H + +#include <digital_api.h> +#include <gr_sync_block.h> + +class digital_probe_density_b; + +typedef boost::shared_ptr<digital_probe_density_b> digital_probe_density_b_sptr; + +DIGITAL_API digital_probe_density_b_sptr +digital_make_probe_density_b(double alpha); + +/*! + * This block maintains a running average of the input stream and + * makes it available as an accessor function. The input stream + * is type unsigned char. + * + * If you send this block a stream of unpacked bytes, it will tell + * you what the bit density is. + * + * \param alpha Average filter constant + * + */ + +class DIGITAL_API digital_probe_density_b : public gr_sync_block +{ +private: + friend DIGITAL_API digital_probe_density_b_sptr + digital_make_probe_density_b(double alpha); + + double d_alpha; + double d_beta; + double d_density; + + digital_probe_density_b(double alpha); + +public: + ~digital_probe_density_b(); + + /*! + * \brief Returns the current density value + */ + double density() const { return d_density; } + + /*! + * \brief Set the average filter constant + */ + void set_alpha(double alpha); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_GR_PROBE_DENSITY_B_H */ diff --git a/gr-digital/include/digital_scrambler_bb.h b/gr-digital/include/digital_scrambler_bb.h new file mode 100644 index 0000000000..d6f08dcc83 --- /dev/null +++ b/gr-digital/include/digital_scrambler_bb.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDED_GR_SCRAMBLER_BB_H +#define INCLUDED_GR_SCRAMBLER_BB_H + +#include <digital_api.h> +#include <gr_sync_block.h> +#include "gri_lfsr.h" + +class digital_scrambler_bb; +typedef boost::shared_ptr<digital_scrambler_bb> digital_scrambler_bb_sptr; + +DIGITAL_API digital_scrambler_bb_sptr +digital_make_scrambler_bb(int mask, int seed, int len); + +/*! + * Scramble an input stream using an LFSR. This block works on the LSB only + * of the input data stream, i.e., on an "unpacked binary" stream, and + * produces the same format on its output. + * + * \param mask Polynomial mask for LFSR + * \param seed Initial shift register contents + * \param len Shift register length + * + * \ingroup coding_blk + */ + +class DIGITAL_API digital_scrambler_bb : public gr_sync_block +{ + friend DIGITAL_API digital_scrambler_bb_sptr + digital_make_scrambler_bb(int mask, int seed, int len); + + gri_lfsr d_lfsr; + + digital_scrambler_bb(int mask, int seed, int len); + +public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_GR_SCRAMBLER_BB_H */ diff --git a/gr-digital/include/digital_simple_framer.h b/gr-digital/include/digital_simple_framer.h new file mode 100644 index 0000000000..b622ae5dd4 --- /dev/null +++ b/gr-digital/include/digital_simple_framer.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_SIMPLE_FRAMER_H +#define INCLUDED_GR_SIMPLE_FRAMER_H + +#include <digital_api.h> +#include <gr_block.h> + +class digital_simple_framer; +typedef boost::shared_ptr<digital_simple_framer> digital_simple_framer_sptr; + +DIGITAL_API digital_simple_framer_sptr digital_make_simple_framer(int payload_bytesize); + +/*! + * \brief add sync field, seq number and command field to payload + * \ingroup sync_blk + * + * Takes in enough samples to create a full output frame. The frame is + * prepended with the GRSF_SYNC (defind in + * digital_simple_framer_sync.h) and an 8-bit sequence number. + * + * \param payload_bytesize The size of the payload in bytes. + */ +class DIGITAL_API digital_simple_framer : public gr_block +{ + int d_seqno; + int d_payload_bytesize; + int d_input_block_size; // bytes + int d_output_block_size; // bytes + + friend DIGITAL_API digital_simple_framer_sptr + digital_make_simple_framer(int payload_bytesize); + digital_simple_framer(int payload_bytesize); + + public: + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + + +#endif /* INCLUDED_GR_SIMPLE_FRAMER_H */ diff --git a/gr-digital/include/digital_simple_framer_sync.h b/gr-digital/include/digital_simple_framer_sync.h new file mode 100644 index 0000000000..4120035827 --- /dev/null +++ b/gr-digital/include/digital_simple_framer_sync.h @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2005,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_SIMPLE_FRAMER_SYNC_H +#define INCLUDED_GR_SIMPLE_FRAMER_SYNC_H + +/*! + * \brief Here are a couple of maximum length sequences (m-sequences) + * that were generated by the the "mseq" matlab/octave code downloaded + * from: <a href="http://www.mathworks.com/matlabcentral/fileexchange/990">http://www.mathworks.com/matlabcentral/fileexchange/990</a> + * + * <pre> + * 31-bit m-sequence: + * 0110100100001010111011000111110 + * 0x690AEC76 (padded on right with a zero) + * + * 63-bit m-sequence: + * 101011001101110110100100111000101111001010001100001000001111110 + * 0xACDDA4E2F28C20FC (padded on right with a zero) + * </pre> + */ + +static const unsigned long long GRSF_SYNC = 0xacdda4e2f28c20fcULL; + +static const int GRSF_BITS_PER_BYTE = 8; +static const int GRSF_SYNC_OVERHEAD = sizeof(GRSF_SYNC); +static const int GRSF_PAYLOAD_OVERHEAD = 1; // 1 byte seqno +static const int GRSF_TAIL_PAD = 1; // one byte trailing padding +static const int GRSF_OVERHEAD = GRSF_SYNC_OVERHEAD + GRSF_PAYLOAD_OVERHEAD + GRSF_TAIL_PAD; + + +#endif /* INCLUDED_GR_SIMPLE_FRAMER_SYNC_H */ diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index 779972ff3a..bd4f1a5004 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,29 +23,102 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${GR_DIGITAL_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR}/../include ) include_directories(${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) + +######################################################################## +# generate helper scripts to expand templated files +######################################################################## +include(GrPython) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " +#!${PYTHON_EXECUTABLE} + +import sys, os, re +sys.path.append('${GR_CORE_PYTHONPATH}') +os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' +os.chdir('${CMAKE_CURRENT_BINARY_DIR}') + +if __name__ == '__main__': + import build_utils + root, inp = sys.argv[1:3] + for sig in sys.argv[3:]: + name = re.sub ('X+', sig, root) + d = build_utils.standard_dict(name, sig, 'digital') + build_utils.expand_template(d, inp) + +") + +macro(expand_cc root) + #make a list of all the generated files + unset(expanded_files_cc) + unset(expanded_files_h) + foreach(sig ${ARGN}) + string(REGEX REPLACE "X+" ${sig} name ${root}) + list(APPEND expanded_files_cc ${CMAKE_CURRENT_BINARY_DIR}/${name}.cc) + list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/../include/${name}.h) + endforeach(sig) + + #create a command to generate the files + add_custom_command( + OUTPUT ${expanded_files_cc} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.cc.t + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py + ${root} ${root}.cc.t ${ARGN} + ) + + #make source files depends on headers to force generation + set_source_files_properties(${expanded_files_cc} + PROPERTIES OBJECT_DEPENDS "${expanded_files_h}" + ) + + #install rules for the generated cc files + list(APPEND generated_sources ${expanded_files_cc}) +endmacro(expand_cc) + +######################################################################## +# Invoke macro to generate various sources +######################################################################## +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 digital_impl_mpsk_snr_est.cc + digital_additive_scrambler_bb.cc digital_binary_slicer_fb.cc + digital_bytes_to_syms.cc digital_clock_recovery_mm_cc.cc digital_clock_recovery_mm_ff.cc + digital_cma_equalizer_cc.cc digital_constellation.cc digital_constellation_receiver_cb.cc digital_constellation_decoder_cb.cc digital_correlate_access_code_bb.cc + digital_correlate_access_code_tag_bb.cc digital_costas_loop_cc.cc - digital_cma_equalizer_cc.cc + digital_cpmmod_bc.cc digital_crc32.cc + digital_descrambler_bb.cc + digital_diff_decoder_bb.cc + digital_diff_encoder_bb.cc + digital_diff_phasor_cc.cc digital_fll_band_edge_cc.cc + digital_framer_sink_1.cc + digital_glfsr_source_b.cc + digital_glfsr_source_f.cc + digital_gmskmod_bc.cc digital_lms_dd_equalizer_cc.cc digital_kurtotic_equalizer_cc.cc + digital_map_bb.cc digital_mpsk_receiver_cc.cc digital_mpsk_snr_est_cc.cc digital_ofdm_cyclic_prefixer.cc @@ -54,9 +127,14 @@ list(APPEND gr_digital_sources digital_ofdm_insert_preamble.cc digital_ofdm_mapper_bcv.cc digital_ofdm_sampler.cc + digital_packet_sink.cc + digital_pfb_clock_sync_ccf.cc + digital_pfb_clock_sync_fff.cc + digital_pn_correlator_cc.cc + digital_probe_density_b.cc digital_probe_mpsk_snr_est_c.cc - digital_gmskmod_bc.cc - digital_cpmmod_bc.cc + digital_scrambler_bb.cc + digital_simple_framer.cc ) list(APPEND digital_libs @@ -67,3 +145,5 @@ list(APPEND digital_libs add_library(gnuradio-digital SHARED ${gr_digital_sources}) target_link_libraries(gnuradio-digital ${digital_libs}) GR_LIBRARY_FOO(gnuradio-digital RUNTIME_COMPONENT "digital_runtime" DEVEL_COMPONENT "digital_devel") + +add_dependencies(gnuradio-digital digital_generated_includes digital_generated_swigs) diff --git a/gr-digital/lib/digital_additive_scrambler_bb.cc b/gr-digital/lib/digital_additive_scrambler_bb.cc new file mode 100644 index 0000000000..a8affaa78f --- /dev/null +++ b/gr-digital/lib/digital_additive_scrambler_bb.cc @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_additive_scrambler_bb.h> +#include <gr_io_signature.h> + +digital_additive_scrambler_bb_sptr +digital_make_additive_scrambler_bb(int mask, int seed, int len, int count) +{ + return gnuradio::get_initial_sptr(new digital_additive_scrambler_bb + (mask, seed, len, count)); +} + +digital_additive_scrambler_bb::digital_additive_scrambler_bb(int mask, + int seed, + int len, + int count) + : gr_sync_block("additive_scrambler_bb", + gr_make_io_signature (1, 1, sizeof (unsigned char)), + gr_make_io_signature (1, 1, sizeof (unsigned char))), + d_lfsr(mask, seed, len), + d_count(count), + d_bits(0) +{ +} + +int +digital_additive_scrambler_bb::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] = in[i]^d_lfsr.next_bit(); + if (d_count > 0) { + if (++d_bits == d_count) { + d_lfsr.reset(); + d_bits = 0; + } + } + } + + return noutput_items; +} diff --git a/gr-digital/lib/digital_bytes_to_syms.cc b/gr-digital/lib/digital_bytes_to_syms.cc new file mode 100644 index 0000000000..f8bd82d5b8 --- /dev/null +++ b/gr-digital/lib/digital_bytes_to_syms.cc @@ -0,0 +1,74 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_bytes_to_syms.h> +#include <gr_io_signature.h> +#include <assert.h> + +static const int BITS_PER_BYTE = 8; + +digital_bytes_to_syms_sptr +digital_make_bytes_to_syms () +{ + return gnuradio::get_initial_sptr(new digital_bytes_to_syms ()); +} + +digital_bytes_to_syms::digital_bytes_to_syms () + : gr_sync_interpolator ("bytes_to_syms", + gr_make_io_signature (1, 1, sizeof (unsigned char)), + gr_make_io_signature (1, 1, sizeof (float)), + BITS_PER_BYTE) +{ +} + +int +digital_bytes_to_syms::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const unsigned char *in = (unsigned char *) input_items[0]; + float *out = (float *) output_items[0]; + + assert (noutput_items % BITS_PER_BYTE == 0); + + for (int i = 0; i < noutput_items / BITS_PER_BYTE; i++) { + int x = in[i]; + + *out++ = (((x >> 7) & 0x1) << 1) - 1; + *out++ = (((x >> 6) & 0x1) << 1) - 1; + *out++ = (((x >> 5) & 0x1) << 1) - 1; + *out++ = (((x >> 4) & 0x1) << 1) - 1; + *out++ = (((x >> 3) & 0x1) << 1) - 1; + *out++ = (((x >> 2) & 0x1) << 1) - 1; + *out++ = (((x >> 1) & 0x1) << 1) - 1; + *out++ = (((x >> 0) & 0x1) << 1) - 1; + } + + return noutput_items; +} + + + diff --git a/gr-digital/lib/digital_chunks_to_symbols_XX.cc.t b/gr-digital/lib/digital_chunks_to_symbols_XX.cc.t new file mode 100644 index 0000000000..399a474a62 --- /dev/null +++ b/gr-digital/lib/digital_chunks_to_symbols_XX.cc.t @@ -0,0 +1,74 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME@.h> +#include <gr_io_signature.h> +#include <assert.h> +#include <iostream> +#include <string.h> + +@SPTR_NAME@ +digital_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D) +{ + return gnuradio::get_initial_sptr (new @NAME@ (symbol_table,D)); +} + +@NAME@::@NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D) + : gr_sync_interpolator ("@BASE_NAME@", + gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), + gr_make_io_signature (1, -1, sizeof (@O_TYPE@)), + D), + d_D (D), + d_symbol_table (symbol_table) +{ +} + +int +@NAME@::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + assert (noutput_items % d_D == 0); + assert (input_items.size() == output_items.size()); + int nstreams = input_items.size(); + + for (int m=0;m<nstreams;m++) { + const @I_TYPE@ *in = (@I_TYPE@ *) input_items[m]; + @O_TYPE@ *out = (@O_TYPE@ *) output_items[m]; + + // per stream processing + for (int i = 0; i < noutput_items / d_D; i++){ + assert (((unsigned int)in[i]*d_D+d_D) <= d_symbol_table.size()); + memcpy(out, &d_symbol_table[(unsigned int)in[i]*d_D], d_D*sizeof(@O_TYPE@)); + out+=d_D; + } + // end of per stream processing + + } + return noutput_items; +} diff --git a/gr-digital/lib/digital_correlate_access_code_tag_bb.cc b/gr-digital/lib/digital_correlate_access_code_tag_bb.cc new file mode 100644 index 0000000000..95f06534e3 --- /dev/null +++ b/gr-digital/lib/digital_correlate_access_code_tag_bb.cc @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006,2010-2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_correlate_access_code_tag_bb.h> +#include <gr_io_signature.h> +#include <stdexcept> +#include <gr_count_bits.h> +#include <cstdio> +#include <iostream> + +#define VERBOSE 0 + + +digital_correlate_access_code_tag_bb_sptr +digital_make_correlate_access_code_tag_bb (const std::string &access_code, + int threshold, + const std::string &tag_name) +{ + return gnuradio::get_initial_sptr(new digital_correlate_access_code_tag_bb + (access_code, threshold, tag_name)); +} + + +digital_correlate_access_code_tag_bb::digital_correlate_access_code_tag_bb ( + const std::string &access_code, int threshold, const std::string &tag_name) + : gr_sync_block ("correlate_access_code_tag_bb", + gr_make_io_signature (1, 1, sizeof(char)), + gr_make_io_signature (1, 1, sizeof(char))), + d_data_reg(0), d_mask(0), + d_threshold(threshold), d_len(0) +{ + if (!set_access_code(access_code)) { + fprintf(stderr, "digital_correlate_access_code_tag_bb: access_code is > 64 bits\n"); + throw std::out_of_range ("access_code is > 64 bits"); + } + + std::stringstream str; + str << name() << unique_id(); + d_me = pmt::pmt_string_to_symbol(str.str()); + d_key = pmt::pmt_string_to_symbol(tag_name); +} + +digital_correlate_access_code_tag_bb::~digital_correlate_access_code_tag_bb () +{ +} + +bool +digital_correlate_access_code_tag_bb::set_access_code( + const std::string &access_code) +{ + d_len = access_code.length(); // # of bytes in string + if (d_len > 64) + return false; + + // set len top bits to 1. + d_mask = ((~0ULL) >> (64 - d_len)) << (64 - d_len); + + d_access_code = 0; + for (unsigned i=0; i < 64; i++){ + d_access_code <<= 1; + if (i < d_len) + d_access_code |= access_code[i] & 1; // look at LSB only + } + + return true; +} + +int +digital_correlate_access_code_tag_bb::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]; + + uint64_t abs_out_sample_cnt = nitems_written(0); + + for (int i = 0; i < noutput_items; i++){ + + out[i] = in[i]; + + // compute hamming distance between desired access code and current data + unsigned long long wrong_bits = 0; + unsigned int nwrong = d_threshold+1; + int new_flag = 0; + + wrong_bits = (d_data_reg ^ d_access_code) & d_mask; + nwrong = gr_count_bits64(wrong_bits); + + // test for access code with up to threshold errors + new_flag = (nwrong <= d_threshold); + + // shift in new data and new flag + d_data_reg = (d_data_reg << 1) | (in[i] & 0x1); + if (new_flag) { + if(VERBOSE) std::cout << "writing tag at sample " << abs_out_sample_cnt + i << std::endl; + add_item_tag(0, //stream ID + abs_out_sample_cnt + i - 64 + d_len, //sample + d_key, //frame info + pmt::pmt_t(), //data (unused) + d_me //block src id + ); + } + } + + return noutput_items; +} + diff --git a/gr-digital/lib/digital_descrambler_bb.cc b/gr-digital/lib/digital_descrambler_bb.cc new file mode 100644 index 0000000000..68cba7145e --- /dev/null +++ b/gr-digital/lib/digital_descrambler_bb.cc @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_descrambler_bb.h> +#include <gr_io_signature.h> + +digital_descrambler_bb_sptr +digital_make_descrambler_bb(int mask, int seed, int len) +{ + return gnuradio::get_initial_sptr(new digital_descrambler_bb(mask, seed, len)); +} + +digital_descrambler_bb::digital_descrambler_bb(int mask, int seed, int len) + : gr_sync_block("descrambler_bb", + gr_make_io_signature (1, 1, sizeof (unsigned char)), + gr_make_io_signature (1, 1, sizeof (unsigned char))), + d_lfsr(mask, seed, len) +{ +} + +int +digital_descrambler_bb::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] = d_lfsr.next_bit_descramble(in[i]); + + return noutput_items; +} diff --git a/gr-digital/lib/digital_diff_decoder_bb.cc b/gr-digital/lib/digital_diff_decoder_bb.cc new file mode 100644 index 0000000000..7b8e8726ac --- /dev/null +++ b/gr-digital/lib/digital_diff_decoder_bb.cc @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_diff_decoder_bb.h> +#include <gr_io_signature.h> + +digital_diff_decoder_bb_sptr +digital_make_diff_decoder_bb (unsigned int modulus) +{ + return gnuradio::get_initial_sptr(new digital_diff_decoder_bb(modulus)); +} + +digital_diff_decoder_bb::digital_diff_decoder_bb (unsigned int modulus) + : gr_sync_block ("diff_decoder_bb", + gr_make_io_signature (1, 1, sizeof (unsigned char)), + gr_make_io_signature (1, 1, sizeof (unsigned char))), + d_modulus(modulus) +{ + set_history(2); // need to look at two inputs +} + +int +digital_diff_decoder_bb::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]; + in += 1; // ensure that in[-1] is valid + + unsigned modulus = d_modulus; + + for (int i = 0; i < noutput_items; i++) { + out[i] = (in[i] - in[i-1]) % modulus; + } + + return noutput_items; +} diff --git a/gr-digital/lib/digital_diff_encoder_bb.cc b/gr-digital/lib/digital_diff_encoder_bb.cc new file mode 100644 index 0000000000..bfbaba98fb --- /dev/null +++ b/gr-digital/lib/digital_diff_encoder_bb.cc @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_diff_encoder_bb.h> +#include <gr_io_signature.h> + +digital_diff_encoder_bb_sptr +digital_make_diff_encoder_bb (unsigned int modulus) +{ + return gnuradio::get_initial_sptr(new digital_diff_encoder_bb(modulus)); +} + +digital_diff_encoder_bb::digital_diff_encoder_bb (unsigned int modulus) + : gr_sync_block ("diff_encoder_bb", + gr_make_io_signature (1, 1, sizeof (unsigned char)), + gr_make_io_signature (1, 1, sizeof (unsigned char))), + d_last_out(0), d_modulus(modulus) +{ +} + +int +digital_diff_encoder_bb::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]; + + unsigned last_out = d_last_out; + unsigned modulus = d_modulus; + + for (int i = 0; i < noutput_items; i++) { + out[i] = (in[i] + last_out) % modulus; + last_out = out[i]; + } + + d_last_out = last_out; + return noutput_items; +} diff --git a/gr-digital/lib/digital_diff_phasor_cc.cc b/gr-digital/lib/digital_diff_phasor_cc.cc new file mode 100644 index 0000000000..8313a4de89 --- /dev/null +++ b/gr-digital/lib/digital_diff_phasor_cc.cc @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_diff_phasor_cc.h> +#include <gr_io_signature.h> + +digital_diff_phasor_cc_sptr +digital_make_diff_phasor_cc () +{ + return gnuradio::get_initial_sptr(new digital_diff_phasor_cc()); +} + +digital_diff_phasor_cc::digital_diff_phasor_cc () + : gr_sync_block ("diff_phasor_cc", + gr_make_io_signature (1, 1, sizeof (gr_complex)), + gr_make_io_signature (1, 1, sizeof (gr_complex))) +{ + set_history(2); +} + + +digital_diff_phasor_cc::~digital_diff_phasor_cc(){} + +int +digital_diff_phasor_cc::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + gr_complex const *in = (const gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + in += 1; // ensure that i - 1 is valid. + + for(int i = 0; i < noutput_items; i++) { + out[i] = in[i] * conj(in[i-1]); + } + + return noutput_items; +} diff --git a/gr-digital/lib/digital_framer_sink_1.cc b/gr-digital/lib/digital_framer_sink_1.cc new file mode 100644 index 0000000000..ba1c5bd50e --- /dev/null +++ b/gr-digital/lib/digital_framer_sink_1.cc @@ -0,0 +1,192 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_framer_sink_1.h> +#include <gr_io_signature.h> +#include <cstdio> +#include <stdexcept> +#include <string.h> + +#define VERBOSE 0 + +inline void +digital_framer_sink_1::enter_search() +{ + if (VERBOSE) + fprintf(stderr, "@ enter_search\n"); + + d_state = STATE_SYNC_SEARCH; +} + +inline void +digital_framer_sink_1::enter_have_sync() +{ + if (VERBOSE) + fprintf(stderr, "@ enter_have_sync\n"); + + d_state = STATE_HAVE_SYNC; + d_header = 0; + d_headerbitlen_cnt = 0; +} + +inline void +digital_framer_sink_1::enter_have_header(int payload_len, + int whitener_offset) +{ + if (VERBOSE) + fprintf(stderr, "@ enter_have_header (payload_len = %d) (offset = %d)\n", + payload_len, whitener_offset); + + d_state = STATE_HAVE_HEADER; + d_packetlen = payload_len; + d_packet_whitener_offset = whitener_offset; + d_packetlen_cnt = 0; + d_packet_byte = 0; + d_packet_byte_index = 0; +} + +digital_framer_sink_1_sptr +digital_make_framer_sink_1(gr_msg_queue_sptr target_queue) +{ + return gnuradio::get_initial_sptr(new digital_framer_sink_1(target_queue)); +} + + +digital_framer_sink_1::digital_framer_sink_1(gr_msg_queue_sptr target_queue) + : gr_sync_block ("framer_sink_1", + gr_make_io_signature (1, 1, sizeof(unsigned char)), + gr_make_io_signature (0, 0, 0)), + d_target_queue(target_queue) +{ + enter_search(); +} + +digital_framer_sink_1::~digital_framer_sink_1 () +{ +} + +int +digital_framer_sink_1::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]; + int count=0; + + if (VERBOSE) + fprintf(stderr,">>> Entering state machine\n"); + + while (count < noutput_items){ + switch(d_state) { + + case STATE_SYNC_SEARCH: // Look for flag indicating beginning of pkt + if (VERBOSE) + fprintf(stderr,"SYNC Search, noutput=%d\n", noutput_items); + + while (count < noutput_items) { + if (in[count] & 0x2){ // Found it, set up for header decode + enter_have_sync(); + break; + } + count++; + } + break; + + case STATE_HAVE_SYNC: + if (VERBOSE) + fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", + d_headerbitlen_cnt, d_header); + + while (count < noutput_items) { // Shift bits one at a time into header + d_header = (d_header << 1) | (in[count++] & 0x1); + if (++d_headerbitlen_cnt == HEADERBITLEN) { + + if (VERBOSE) + fprintf(stderr, "got header: 0x%08x\n", d_header); + + // we have a full header, check to see if it has been received properly + if (header_ok()){ + int payload_len; + int whitener_offset; + header_payload(&payload_len, &whitener_offset); + enter_have_header(payload_len, whitener_offset); + + if (d_packetlen == 0){ // check for zero-length payload + // build a zero-length message + // NOTE: passing header field as arg1 is not scalable + gr_message_sptr msg = + gr_make_message(0, d_packet_whitener_offset, 0, 0); + + d_target_queue->insert_tail(msg); // send it + msg.reset(); // free it up + + enter_search(); + } + } + else + enter_search(); // bad header + break; // we're in a new state + } + } + break; + + case STATE_HAVE_HEADER: + if (VERBOSE) + fprintf(stderr,"Packet Build\n"); + + while (count < noutput_items) { // shift bits into bytes of packet one at a time + d_packet_byte = (d_packet_byte << 1) | (in[count++] & 0x1); + if (d_packet_byte_index++ == 7) { // byte is full so move to next byte + d_packet[d_packetlen_cnt++] = d_packet_byte; + d_packet_byte_index = 0; + + if (d_packetlen_cnt == d_packetlen){ // packet is filled + + // build a message + // NOTE: passing header field as arg1 is not scalable + gr_message_sptr msg = + gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen_cnt); + memcpy(msg->msg(), d_packet, d_packetlen_cnt); + + d_target_queue->insert_tail(msg); // send it + msg.reset(); // free it up + + enter_search(); + break; + } + } + } + break; + + default: + assert(0); + + } // switch + + } // while + + return noutput_items; +} diff --git a/gr-digital/lib/digital_glfsr_source_b.cc b/gr-digital/lib/digital_glfsr_source_b.cc new file mode 100644 index 0000000000..e557e475a8 --- /dev/null +++ b/gr-digital/lib/digital_glfsr_source_b.cc @@ -0,0 +1,86 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <digital_glfsr_source_b.h> +#include <gri_glfsr.h> +#include <gr_io_signature.h> +#include <stdexcept> + +digital_glfsr_source_b_sptr +digital_make_glfsr_source_b(int degree, bool repeat, int mask, int seed) +{ + return gnuradio::get_initial_sptr(new digital_glfsr_source_b + (degree, repeat, mask, seed)); +} + +digital_glfsr_source_b::digital_glfsr_source_b(int degree, bool repeat, + int mask, int seed) + : gr_sync_block ("glfsr_source_b", + gr_make_io_signature (0, 0, 0), + gr_make_io_signature (1, 1, sizeof(unsigned char))), + d_repeat(repeat), + d_index(0) +{ + if (degree < 1 || degree > 32) + throw std::runtime_error("digital_glfsr_source_b: degree must be between 1 and 32 inclusive"); + d_length = (unsigned int)((1ULL << degree)-1); + + if (mask == 0) + mask = gri_glfsr::glfsr_mask(degree); + d_glfsr = new gri_glfsr(mask, seed); +} + +digital_glfsr_source_b::~digital_glfsr_source_b() +{ + delete d_glfsr; +} + +int +digital_glfsr_source_b::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + char *out = (char *) output_items[0]; + if ((d_index > d_length) && d_repeat == false) + return -1; /* once through the sequence */ + + int i; + for (i = 0; i < noutput_items; i++) { + out[i] = d_glfsr->next_bit(); + d_index++; + if (d_index > d_length && d_repeat == false) + break; + } + + return i; +} + +int +digital_glfsr_source_b::mask() const +{ + return d_glfsr->mask(); +} diff --git a/gr-digital/lib/digital_glfsr_source_f.cc b/gr-digital/lib/digital_glfsr_source_f.cc new file mode 100644 index 0000000000..5a7736ef8d --- /dev/null +++ b/gr-digital/lib/digital_glfsr_source_f.cc @@ -0,0 +1,86 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <digital_glfsr_source_f.h> +#include <gri_glfsr.h> +#include <gr_io_signature.h> +#include <stdexcept> + +digital_glfsr_source_f_sptr +digital_make_glfsr_source_f(int degree, bool repeat, int mask, int seed) +{ + return gnuradio::get_initial_sptr(new digital_glfsr_source_f + (degree, repeat, mask, seed)); +} + +digital_glfsr_source_f::digital_glfsr_source_f(int degree, bool repeat, + int mask, int seed) + : gr_sync_block ("glfsr_source_f", + gr_make_io_signature (0, 0, 0), + gr_make_io_signature (1, 1, sizeof(float))), + d_repeat(repeat), + d_index(0) +{ + if (degree < 1 || degree > 32) + throw std::runtime_error("digital_glfsr_source_f: degree must be between 1 and 32 inclusive"); + d_length = (unsigned int)((1ULL << degree)-1); + + if (mask == 0) + mask = gri_glfsr::glfsr_mask(degree); + d_glfsr = new gri_glfsr(mask, seed); +} + +digital_glfsr_source_f::~digital_glfsr_source_f() +{ + delete d_glfsr; +} + +int +digital_glfsr_source_f::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + float *out = (float *) output_items[0]; + if ((d_index > d_length) && d_repeat == false) + return -1; /* once through the sequence */ + + int i; + for (i = 0; i < noutput_items; i++) { + out[i] = (float)d_glfsr->next_bit()*2.0-1.0; + d_index++; + if (d_index > d_length && d_repeat == false) + break; + } + + return i; +} + +int +digital_glfsr_source_f::mask() const +{ + return d_glfsr->mask(); +} diff --git a/gr-digital/lib/digital_impl_glfsr.cc b/gr-digital/lib/digital_impl_glfsr.cc new file mode 100644 index 0000000000..342980e535 --- /dev/null +++ b/gr-digital/lib/digital_impl_glfsr.cc @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +#include <digital_impl_glfsr.h> +#include <stdexcept> + +static int s_polynomial_masks[] = { + 0x00000000, + 0x00000001, // x^1 + 1 + 0x00000003, // x^2 + x^1 + 1 + 0x00000005, // x^3 + x^1 + 1 + 0x00000009, // x^4 + x^1 + 1 + 0x00000012, // x^5 + x^2 + 1 + 0x00000021, // x^6 + x^1 + 1 + 0x00000041, // x^7 + x^1 + 1 + 0x0000008E, // x^8 + x^4 + x^3 + x^2 + 1 + 0x00000108, // x^9 + x^4 + 1 + 0x00000204, // x^10 + x^4 + 1 + 0x00000402, // x^11 + x^2 + 1 + 0x00000829, // x^12 + x^6 + x^4 + x^1 + 1 + 0x0000100D, // x^13 + x^4 + x^3 + x^1 + 1 + 0x00002015, // x^14 + x^5 + x^3 + x^1 + 1 + 0x00004001, // x^15 + x^1 + 1 + 0x00008016, // x^16 + x^5 + x^3 + x^2 + 1 + 0x00010004, // x^17 + x^3 + 1 + 0x00020013, // x^18 + x^5 + x^2 + x^1 + 1 + 0x00040013, // x^19 + x^5 + x^2 + x^1 + 1 + 0x00080004, // x^20 + x^3 + 1 + 0x00100002, // x^21 + x^2 + 1 + 0x00200001, // x^22 + x^1 + 1 + 0x00400010, // x^23 + x^5 + 1 + 0x0080000D, // x^24 + x^4 + x^3 + x^1 + 1 + 0x01000004, // x^25 + x^3 + 1 + 0x02000023, // x^26 + x^6 + x^2 + x^1 + 1 + 0x04000013, // x^27 + x^5 + x^2 + x^1 + 1 + 0x08000004, // x^28 + x^3 + 1 + 0x10000002, // x^29 + x^2 + 1 + 0x20000029, // x^30 + x^4 + x^1 + 1 + 0x40000004, // x^31 + x^3 + 1 + 0x80000057 // x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + 1 +}; + +int digital_impl_glfsr::glfsr_mask(int degree) +{ + if (degree < 1 || degree > 32) + throw std::runtime_error("digital_impl_glfsr::glfsr_mask(): degree must be between 1 and 32 inclusive"); + return s_polynomial_masks[degree]; +} diff --git a/gr-digital/lib/digital_map_bb.cc b/gr-digital/lib/digital_map_bb.cc new file mode 100644 index 0000000000..1d8444a405 --- /dev/null +++ b/gr-digital/lib/digital_map_bb.cc @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2007,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_map_bb.h> +#include <gr_io_signature.h> + +digital_map_bb_sptr +digital_make_map_bb (const std::vector<int> &map) +{ + return gnuradio::get_initial_sptr(new digital_map_bb (map)); +} + +digital_map_bb::digital_map_bb (const std::vector<int> &map) + : gr_sync_block ("map_bb", + gr_make_io_signature (1, 1, sizeof (unsigned char)), + gr_make_io_signature (1, 1, sizeof (unsigned char))) +{ + for (int i = 0; i < 0x100; i++) + d_map[i] = i; + + unsigned int size = std::min((size_t) 0x100, map.size()); + for (unsigned int i = 0; i < size; i++) + d_map[i] = map[i]; +} + +int +digital_map_bb::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] = d_map[in[i]]; + + return noutput_items; +} diff --git a/gr-digital/lib/digital_ofdm_insert_preamble.cc b/gr-digital/lib/digital_ofdm_insert_preamble.cc index a46133643d..72b9e82a82 100644 --- a/gr-digital/lib/digital_ofdm_insert_preamble.cc +++ b/gr-digital/lib/digital_ofdm_insert_preamble.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2010,2011 Free Software Foundation, Inc. + * Copyright 2007,2010-2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -41,7 +41,7 @@ digital_ofdm_insert_preamble::digital_ofdm_insert_preamble (int fft_length, const std::vector<std::vector<gr_complex> > &preamble) : gr_block("ofdm_insert_preamble", - gr_make_io_signature2(2, 2, + gr_make_io_signature2(1, 2, sizeof(gr_complex)*fft_length, sizeof(char)), gr_make_io_signature2(1, 2, @@ -54,8 +54,8 @@ digital_ofdm_insert_preamble::digital_ofdm_insert_preamble d_pending_flag(0) { // sanity check preamble symbols - for (size_t i = 0; i < d_preamble.size(); i++){ - if (d_preamble[i].size() != (size_t) d_fft_length) + for(size_t i = 0; i < d_preamble.size(); i++) { + if(d_preamble[i].size() != (size_t) d_fft_length) throw std::invalid_argument("digital_ofdm_insert_preamble: invalid length for preamble symbol"); } @@ -67,15 +67,22 @@ digital_ofdm_insert_preamble::~digital_ofdm_insert_preamble() { } +void digital_ofdm_insert_preamble::forecast (int noutput_items, gr_vector_int &ninput_items_required) +{ + ninput_items_required[0] = noutput_items; +} + int -digital_ofdm_insert_preamble::general_work (int noutput_items, - gr_vector_int &ninput_items_v, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +digital_ofdm_insert_preamble::general_work(int noutput_items, + gr_vector_int &ninput_items_v, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { - int ninput_items = std::min(ninput_items_v[0], ninput_items_v[1]); + int ninput_items = ninput_items_v.size()==2?std::min(ninput_items_v[0], ninput_items_v[1]):ninput_items_v[0]; const gr_complex *in_sym = (const gr_complex *) input_items[0]; - const unsigned char *in_flag = (const unsigned char *) input_items[1]; + const unsigned char *in_flag = 0; + if (input_items.size() == 2) + in_flag = (const unsigned char *) input_items[1]; gr_complex *out_sym = (gr_complex *) output_items[0]; unsigned char *out_flag = 0; @@ -97,14 +104,14 @@ digital_ofdm_insert_preamble::general_work (int noutput_items, while (no < noutput_items && ni < ninput_items){ switch(d_state){ case ST_IDLE: - if (in_flag[ni] & 0x1) // this is first symbol of new payload + if (in_flag && in_flag[ni] & 0x1) // this is first symbol of new payload enter_preamble(); else ni++; // eat one input symbol break; case ST_PREAMBLE: - assert(in_flag[ni] & 0x1); + assert(!in_flag || in_flag[ni] & 0x1); if (d_nsymbols_output >= (int) d_preamble.size()){ // we've output all the preamble enter_first_payload(); @@ -133,7 +140,7 @@ digital_ofdm_insert_preamble::general_work (int noutput_items, break; case ST_PAYLOAD: - if (in_flag[ni] & 0x1){ // this is first symbol of a new payload + if (in_flag && in_flag[ni] & 0x1){ // this is first symbol of a new payload enter_preamble(); break; } diff --git a/gr-digital/lib/digital_packet_sink.cc b/gr-digital/lib/digital_packet_sink.cc new file mode 100644 index 0000000000..92521376fd --- /dev/null +++ b/gr-digital/lib/digital_packet_sink.cc @@ -0,0 +1,207 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_packet_sink.h> +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <gr_count_bits.h> +#include <string.h> + +#define VERBOSE 0 + +static const int DEFAULT_THRESHOLD = 12; // detect access code with up to DEFAULT_THRESHOLD bits wrong + +inline void +digital_packet_sink::enter_search() +{ + if (VERBOSE) + fprintf(stderr, "@ enter_search\n"); + + d_state = STATE_SYNC_SEARCH; + d_shift_reg = 0; +} + +inline void +digital_packet_sink::enter_have_sync() +{ + if (VERBOSE) + fprintf(stderr, "@ enter_have_sync\n"); + + d_state = STATE_HAVE_SYNC; + d_header = 0; + d_headerbitlen_cnt = 0; +} + +inline void +digital_packet_sink::enter_have_header(int payload_len) +{ + if (VERBOSE) + fprintf(stderr, "@ enter_have_header (payload_len = %d)\n", payload_len); + + d_state = STATE_HAVE_HEADER; + d_packetlen = payload_len; + d_packetlen_cnt = 0; + d_packet_byte = 0; + d_packet_byte_index = 0; +} + +digital_packet_sink_sptr +digital_make_packet_sink (const std::vector<unsigned char>& sync_vector, + gr_msg_queue_sptr target_queue, int threshold) +{ + return gnuradio::get_initial_sptr(new digital_packet_sink (sync_vector, target_queue, threshold)); +} + + +digital_packet_sink::digital_packet_sink (const std::vector<unsigned char>& sync_vector, + gr_msg_queue_sptr target_queue, int threshold) + : gr_sync_block ("packet_sink", + gr_make_io_signature (1, 1, sizeof(float)), + gr_make_io_signature (0, 0, 0)), + d_target_queue(target_queue), d_threshold(threshold == -1 ? DEFAULT_THRESHOLD : threshold) +{ + d_sync_vector = 0; + for(int i=0;i<8;i++){ + d_sync_vector <<= 8; + d_sync_vector |= sync_vector[i]; + } + + enter_search(); +} + +digital_packet_sink::~digital_packet_sink () +{ +} + +int +digital_packet_sink::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + float *inbuf = (float *) input_items[0]; + int count=0; + + if (VERBOSE) + fprintf(stderr,">>> Entering state machine\n"),fflush(stderr); + + while (count<noutput_items) { + switch(d_state) { + + case STATE_SYNC_SEARCH: // Look for sync vector + if (VERBOSE) + fprintf(stderr,"SYNC Search, noutput=%d\n",noutput_items),fflush(stderr); + + while (count < noutput_items) { + if(slice(inbuf[count++])) + d_shift_reg = (d_shift_reg << 1) | 1; + else + d_shift_reg = d_shift_reg << 1; + + // Compute popcnt of putative sync vector + if(gr_count_bits64 (d_shift_reg ^ d_sync_vector) <= d_threshold) { + // Found it, set up for header decode + enter_have_sync(); + break; + } + } + break; + + case STATE_HAVE_SYNC: + if (VERBOSE) + fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", d_headerbitlen_cnt, d_header), + fflush(stderr); + + while (count < noutput_items) { // Shift bits one at a time into header + if(slice(inbuf[count++])) + d_header = (d_header << 1) | 1; + else + d_header = d_header << 1; + + if (++d_headerbitlen_cnt == HEADERBITLEN) { + + if (VERBOSE) + fprintf(stderr, "got header: 0x%08x\n", d_header); + + // we have a full header, check to see if it has been received properly + if (header_ok()){ + int payload_len = header_payload_len(); + if (payload_len <= MAX_PKT_LEN) // reasonable? + enter_have_header(payload_len); // yes. + else + enter_search(); // no. + } + else + enter_search(); // no. + break; // we're in a new state + } + } + break; + + case STATE_HAVE_HEADER: + if (VERBOSE) + fprintf(stderr,"Packet Build\n"),fflush(stderr); + + while (count < noutput_items) { // shift bits into bytes of packet one at a time + if(slice(inbuf[count++])) + d_packet_byte = (d_packet_byte << 1) | 1; + else + d_packet_byte = d_packet_byte << 1; + + if (d_packet_byte_index++ == 7) { // byte is full so move to next byte + d_packet[d_packetlen_cnt++] = d_packet_byte; + d_packet_byte_index = 0; + + if (d_packetlen_cnt == d_packetlen){ // packet is filled + + // build a message + gr_message_sptr msg = gr_make_message(0, 0, 0, d_packetlen_cnt); + memcpy(msg->msg(), d_packet, d_packetlen_cnt); + + d_target_queue->insert_tail(msg); // send it + msg.reset(); // free it up + + enter_search(); + break; + } + } + } + break; + + default: + assert(0); + + } // switch + + } // while + + return noutput_items; +} + diff --git a/gr-digital/lib/digital_pfb_clock_sync_ccf.cc b/gr-digital/lib/digital_pfb_clock_sync_ccf.cc new file mode 100644 index 0000000000..1a2d5970ba --- /dev/null +++ b/gr-digital/lib/digital_pfb_clock_sync_ccf.cc @@ -0,0 +1,440 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009-2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <cstdio> +#include <cmath> + +#include <digital_pfb_clock_sync_ccf.h> +#include <gr_fir_ccf.h> +#include <gr_fir_util.h> +#include <gr_io_signature.h> +#include <gr_math.h> + +digital_pfb_clock_sync_ccf_sptr +digital_make_pfb_clock_sync_ccf(double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps) +{ + return gnuradio::get_initial_sptr(new digital_pfb_clock_sync_ccf + (sps, loop_bw, taps, + filter_size, + init_phase, + max_rate_deviation, + osps)); +} + +static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)}; +static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); +digital_pfb_clock_sync_ccf::digital_pfb_clock_sync_ccf (double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps) + : gr_block ("pfb_clock_sync_ccf", + gr_make_io_signature (1, 1, sizeof(gr_complex)), + gr_make_io_signaturev (1, 4, iosig)), + d_updated (false), d_nfilters(filter_size), + d_max_dev(max_rate_deviation), + d_osps(osps), d_error(0), d_out_idx(0) +{ + d_nfilters = filter_size; + d_sps = floor(sps); + + // Set the damping factor for a critically damped system + d_damping = sqrtf(2.0f)/2.0f; + + // Set the bandwidth, which will then call update_gains() + set_loop_bandwidth(loop_bw); + + // Store the last filter between calls to work + // The accumulator keeps track of overflow to increment the stride correctly. + // set it here to the fractional difference based on the initial phaes + d_k = init_phase; + d_rate = (sps-floor(sps))*(double)d_nfilters; + d_rate_i = (int)floor(d_rate); + d_rate_f = d_rate - (float)d_rate_i; + d_filtnum = (int)floor(d_k); + + d_filters = std::vector<gr_fir_ccf*>(d_nfilters); + d_diff_filters = std::vector<gr_fir_ccf*>(d_nfilters); + + // Create an FIR filter for each channel and zero out the taps + std::vector<float> vtaps(0, d_nfilters); + for(int i = 0; i < d_nfilters; i++) { + d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); + d_diff_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); + } + + // Now, actually set the filters' taps + std::vector<float> dtaps; + create_diff_taps(taps, dtaps); + set_taps(taps, d_taps, d_filters); + set_taps(dtaps, d_dtaps, d_diff_filters); +} + +digital_pfb_clock_sync_ccf::~digital_pfb_clock_sync_ccf () +{ + for(int i = 0; i < d_nfilters; i++) { + delete d_filters[i]; + delete d_diff_filters[i]; + } +} + +bool +digital_pfb_clock_sync_ccf::check_topology(int ninputs, int noutputs) +{ + return noutputs == 1 || noutputs == 4; +} + + + +/******************************************************************* + SET FUNCTIONS +*******************************************************************/ + + +void +digital_pfb_clock_sync_ccf::set_loop_bandwidth(float bw) +{ + if(bw < 0) { + throw std::out_of_range ("digital_pfb_clock_sync_cc: invalid bandwidth. Must be >= 0."); + } + + d_loop_bw = bw; + update_gains(); +} + +void +digital_pfb_clock_sync_ccf::set_damping_factor(float df) +{ + if(df < 0 || df > 1.0) { + throw std::out_of_range ("digital_pfb_clock_sync_cc: invalid damping factor. Must be in [0,1]."); + } + + d_damping = df; + update_gains(); +} + +void +digital_pfb_clock_sync_ccf::set_alpha(float alpha) +{ + if(alpha < 0 || alpha > 1.0) { + throw std::out_of_range ("digital_pfb_clock_sync_cc: invalid alpha. Must be in [0,1]."); + } + d_alpha = alpha; +} + +void +digital_pfb_clock_sync_ccf::set_beta(float beta) +{ + if(beta < 0 || beta > 1.0) { + throw std::out_of_range ("digital_pfb_clock_sync_cc: invalid beta. Must be in [0,1]."); + } + d_beta = beta; +} + +/******************************************************************* + GET FUNCTIONS +*******************************************************************/ + + +float +digital_pfb_clock_sync_ccf::get_loop_bandwidth() const +{ + return d_loop_bw; +} + +float +digital_pfb_clock_sync_ccf::get_damping_factor() const +{ + return d_damping; +} + +float +digital_pfb_clock_sync_ccf::get_alpha() const +{ + return d_alpha; +} + +float +digital_pfb_clock_sync_ccf::get_beta() const +{ + return d_beta; +} + +float +digital_pfb_clock_sync_ccf::get_clock_rate() const +{ + return d_rate_f; +} + +/******************************************************************* +*******************************************************************/ + +void +digital_pfb_clock_sync_ccf::update_gains() +{ + float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); + d_alpha = (4*d_damping*d_loop_bw) / denom; + d_beta = (4*d_loop_bw*d_loop_bw) / denom; +} + + +void +digital_pfb_clock_sync_ccf::set_taps (const std::vector<float> &newtaps, + std::vector< std::vector<float> > &ourtaps, + std::vector<gr_fir_ccf*> &ourfilter) +{ + int i,j; + + unsigned int ntaps = newtaps.size(); + d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters); + + // Create d_numchan vectors to store each channel's taps + ourtaps.resize(d_nfilters); + + // Make a vector of the taps plus fill it out with 0's to fill + // each polyphase filter with exactly d_taps_per_filter + std::vector<float> tmp_taps; + tmp_taps = newtaps; + while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) { + tmp_taps.push_back(0.0); + } + + // Partition the filter + for(i = 0; i < d_nfilters; i++) { + // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out + ourtaps[i] = std::vector<float>(d_taps_per_filter, 0); + for(j = 0; j < d_taps_per_filter; j++) { + ourtaps[i][j] = tmp_taps[i + j*d_nfilters]; + } + + // Build a filter for each channel and add it's taps to it + ourfilter[i]->set_taps(ourtaps[i]); + } + + // Set the history to ensure enough input items for each filter + set_history (d_taps_per_filter + d_sps); + + // Make sure there is enough output space for d_osps outputs/input. + set_output_multiple(d_osps); + + d_updated = true; +} + +void +digital_pfb_clock_sync_ccf::create_diff_taps(const std::vector<float> &newtaps, + std::vector<float> &difftaps) +{ + std::vector<float> diff_filter(3); + diff_filter[0] = -1; + diff_filter[1] = 0; + diff_filter[2] = 1; + + float pwr = 0; + difftaps.push_back(0); + for(unsigned int i = 0; i < newtaps.size()-2; i++) { + float tap = 0; + for(int j = 0; j < 3; j++) { + tap += diff_filter[j]*newtaps[i+j]; + pwr += fabsf(tap); + } + difftaps.push_back(tap); + } + difftaps.push_back(0); + + for(unsigned int i = 0; i < difftaps.size(); i++) { + difftaps[i] *= pwr; + } +} + +std::string +digital_pfb_clock_sync_ccf::get_taps_as_string() +{ + int i, j; + std::stringstream str; + str.precision(4); + str.setf(std::ios::scientific); + + str << "[ "; + for(i = 0; i < d_nfilters; i++) { + str << "[" << d_taps[i][0] << ", "; + for(j = 1; j < d_taps_per_filter-1; j++) { + str << d_taps[i][j] << ", "; + } + str << d_taps[i][j] << "],"; + } + str << " ]" << std::endl; + + return str.str(); +} + +std::string +digital_pfb_clock_sync_ccf::get_diff_taps_as_string() +{ + int i, j; + std::stringstream str; + str.precision(4); + str.setf(std::ios::scientific); + + str << "[ "; + for(i = 0; i < d_nfilters; i++) { + str << "[" << d_dtaps[i][0] << ", "; + for(j = 1; j < d_taps_per_filter-1; j++) { + str << d_dtaps[i][j] << ", "; + } + str << d_dtaps[i][j] << "],"; + } + str << " ]" << std::endl; + + return str.str(); +} + +std::vector< std::vector<float> > +digital_pfb_clock_sync_ccf::get_taps() +{ + return d_taps; +} + +std::vector< std::vector<float> > +digital_pfb_clock_sync_ccf::get_diff_taps() +{ + return d_dtaps; +} + +std::vector<float> +digital_pfb_clock_sync_ccf::get_channel_taps(int channel) +{ + std::vector<float> taps; + for(int i = 0; i < d_taps_per_filter; i++) { + taps.push_back(d_taps[channel][i]); + } + return taps; +} + +std::vector<float> +digital_pfb_clock_sync_ccf::get_diff_channel_taps(int channel) +{ + std::vector<float> taps; + for(int i = 0; i < d_taps_per_filter; i++) { + taps.push_back(d_dtaps[channel][i]); + } + return taps; +} + + +int +digital_pfb_clock_sync_ccf::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + gr_complex *in = (gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + + float *err = NULL, *outrate = NULL, *outk = NULL; + if(output_items.size() == 4) { + err = (float *) output_items[1]; + outrate = (float*)output_items[2]; + outk = (float*)output_items[3]; + } + + if (d_updated) { + d_updated = false; + return 0; // history requirements may have changed. + } + + // We need this many to process one output + int nrequired = ninput_items[0] - d_taps_per_filter - d_osps; + + int i = 0, count = 0; + float error_r, error_i; + + // produce output as long as we can and there are enough input samples + while((i < noutput_items) && (count < nrequired)) { + while(d_out_idx < d_osps) { + d_filtnum = (int)floor(d_k); + + // Keep the current filter number in [0, d_nfilters] + // If we've run beyond the last filter, wrap around and go to next sample + // If we've go below 0, wrap around and go to previous sample + while(d_filtnum >= d_nfilters) { + d_k -= d_nfilters; + d_filtnum -= d_nfilters; + count += 1; + } + while(d_filtnum < 0) { + d_k += d_nfilters; + d_filtnum += d_nfilters; + count -= 1; + } + + out[i+d_out_idx] = d_filters[d_filtnum]->filter(&in[count+d_out_idx]); + d_k = d_k + d_rate_i + d_rate_f; // update phase + d_out_idx++; + + if(output_items.size() == 4) { + err[i] = d_error; + outrate[i] = d_rate_f; + outk[i] = d_k; + } + + // We've run out of output items we can create; return now. + if(i+d_out_idx >= noutput_items) { + consume_each(count); + return i; + } + } + + // reset here; if we didn't complete a full osps samples last time, + // the early return would take care of it. + d_out_idx = 0; + + // Update the phase and rate estimates for this symbol + gr_complex diff = d_diff_filters[d_filtnum]->filter(&in[count]); + error_r = out[i].real() * diff.real(); + error_i = out[i].imag() * diff.imag(); + d_error = (error_i + error_r) / 2.0; // average error from I&Q channel + + // Run the control loop to update the current phase (k) and + // tracking rate estimates based on the error value + d_rate_f = d_rate_f + d_beta*d_error; + d_k = d_k + d_alpha*d_error; + + // Keep our rate within a good range + d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev); + + i+=d_osps; + count += (int)floor(d_sps); + } + + consume_each(count); + return i; +} diff --git a/gr-digital/lib/digital_pfb_clock_sync_fff.cc b/gr-digital/lib/digital_pfb_clock_sync_fff.cc new file mode 100644 index 0000000000..0e7d2a52da --- /dev/null +++ b/gr-digital/lib/digital_pfb_clock_sync_fff.cc @@ -0,0 +1,434 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <cstdio> +#include <cmath> + +#include <digital_pfb_clock_sync_fff.h> +#include <gr_fir_fff.h> +#include <gr_fir_util.h> +#include <gr_io_signature.h> +#include <gr_math.h> + +digital_pfb_clock_sync_fff_sptr +digital_make_pfb_clock_sync_fff(double sps, float gain, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps) +{ + return gnuradio::get_initial_sptr(new digital_pfb_clock_sync_fff + (sps, gain, taps, + filter_size, + init_phase, + max_rate_deviation, + osps)); +} + +static int ios[] = {sizeof(float), sizeof(float), sizeof(float), sizeof(float)}; +static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); +digital_pfb_clock_sync_fff::digital_pfb_clock_sync_fff (double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps) + : gr_block ("pfb_clock_sync_fff", + gr_make_io_signature (1, 1, sizeof(float)), + gr_make_io_signaturev (1, 4, iosig)), + d_updated (false), d_nfilters(filter_size), + d_max_dev(max_rate_deviation), + d_osps(osps), d_error(0), d_out_idx(0) +{ + d_nfilters = filter_size; + d_sps = floor(sps); + + // Set the damping factor for a critically damped system + d_damping = sqrtf(2.0f)/2.0f; + + // Set the bandwidth, which will then call update_gains() + set_loop_bandwidth(loop_bw); + + // Store the last filter between calls to work + // The accumulator keeps track of overflow to increment the stride correctly. + // set it here to the fractional difference based on the initial phaes + d_k = init_phase; + d_rate = (sps-floor(sps))*(double)d_nfilters; + d_rate_i = (int)floor(d_rate); + d_rate_f = d_rate - (float)d_rate_i; + d_filtnum = (int)floor(d_k); + + d_filters = std::vector<gr_fir_fff*>(d_nfilters); + d_diff_filters = std::vector<gr_fir_fff*>(d_nfilters); + + // Create an FIR filter for each channel and zero out the taps + std::vector<float> vtaps(0, d_nfilters); + for(int i = 0; i < d_nfilters; i++) { + d_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); + d_diff_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); + } + + // Now, actually set the filters' taps + std::vector<float> dtaps; + create_diff_taps(taps, dtaps); + set_taps(taps, d_taps, d_filters); + set_taps(dtaps, d_dtaps, d_diff_filters); +} + +digital_pfb_clock_sync_fff::~digital_pfb_clock_sync_fff () +{ + for(int i = 0; i < d_nfilters; i++) { + delete d_filters[i]; + delete d_diff_filters[i]; + } +} + +bool +digital_pfb_clock_sync_fff::check_topology(int ninputs, int noutputs) +{ + return noutputs == 1 || noutputs == 4; +} + +/******************************************************************* + SET FUNCTIONS +*******************************************************************/ + + +void +digital_pfb_clock_sync_fff::set_loop_bandwidth(float bw) +{ + if(bw < 0) { + throw std::out_of_range ("digital_pfb_clock_sync_fff: invalid bandwidth. Must be >= 0."); + } + + d_loop_bw = bw; + update_gains(); +} + +void +digital_pfb_clock_sync_fff::set_damping_factor(float df) +{ + if(df < 0 || df > 1.0) { + throw std::out_of_range ("digital_pfb_clock_sync_fff: invalid damping factor. Must be in [0,1]."); + } + + d_damping = df; + update_gains(); +} + +void +digital_pfb_clock_sync_fff::set_alpha(float alpha) +{ + if(alpha < 0 || alpha > 1.0) { + throw std::out_of_range ("digital_pfb_clock_sync_fff: invalid alpha. Must be in [0,1]."); + } + d_alpha = alpha; +} + +void +digital_pfb_clock_sync_fff::set_beta(float beta) +{ + if(beta < 0 || beta > 1.0) { + throw std::out_of_range ("digital_pfb_clock_sync_fff: invalid beta. Must be in [0,1]."); + } + d_beta = beta; +} + +/******************************************************************* + GET FUNCTIONS +*******************************************************************/ + + +float +digital_pfb_clock_sync_fff::get_loop_bandwidth() const +{ + return d_loop_bw; +} + +float +digital_pfb_clock_sync_fff::get_damping_factor() const +{ + return d_damping; +} + +float +digital_pfb_clock_sync_fff::get_alpha() const +{ + return d_alpha; +} + +float +digital_pfb_clock_sync_fff::get_beta() const +{ + return d_beta; +} + +float +digital_pfb_clock_sync_fff::get_clock_rate() const +{ + return d_rate_f; +} + +/******************************************************************* +*******************************************************************/ + +void +digital_pfb_clock_sync_fff::update_gains() +{ + float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); + d_alpha = (4*d_damping*d_loop_bw) / denom; + d_beta = (4*d_loop_bw*d_loop_bw) / denom; +} + + +void +digital_pfb_clock_sync_fff::set_taps (const std::vector<float> &newtaps, + std::vector< std::vector<float> > &ourtaps, + std::vector<gr_fir_fff*> &ourfilter) +{ + int i,j; + + unsigned int ntaps = newtaps.size(); + d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters); + + // Create d_numchan vectors to store each channel's taps + ourtaps.resize(d_nfilters); + + // Make a vector of the taps plus fill it out with 0's to fill + // each polyphase filter with exactly d_taps_per_filter + std::vector<float> tmp_taps; + tmp_taps = newtaps; + while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) { + tmp_taps.push_back(0.0); + } + + // Partition the filter + for(i = 0; i < d_nfilters; i++) { + // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out + ourtaps[i] = std::vector<float>(d_taps_per_filter, 0); + for(j = 0; j < d_taps_per_filter; j++) { + ourtaps[i][j] = tmp_taps[i + j*d_nfilters]; + } + + // Build a filter for each channel and add it's taps to it + ourfilter[i]->set_taps(ourtaps[i]); + } + + // Set the history to ensure enough input items for each filter + set_history (d_taps_per_filter + d_sps); + + // Make sure there is enough output space for d_osps outputs/input. + set_output_multiple(d_osps); + + d_updated = true; +} + +void +digital_pfb_clock_sync_fff::create_diff_taps(const std::vector<float> &newtaps, + std::vector<float> &difftaps) +{ + std::vector<float> diff_filter(3); + diff_filter[0] = -1; + diff_filter[1] = 0; + diff_filter[2] = 1; + + float pwr = 0; + difftaps.push_back(0); + for(unsigned int i = 0; i < newtaps.size()-2; i++) { + float tap = 0; + for(int j = 0; j < 3; j++) { + tap += diff_filter[j]*newtaps[i+j]; + pwr += fabsf(tap); + } + difftaps.push_back(tap); + } + difftaps.push_back(0); + + for(unsigned int i = 0; i < difftaps.size(); i++) { + difftaps[i] *= pwr; + } +} + +std::string +digital_pfb_clock_sync_fff::get_taps_as_string() +{ + int i, j; + std::stringstream str; + str.precision(4); + str.setf(std::ios::scientific); + + str << "[ "; + for(i = 0; i < d_nfilters; i++) { + str << "[" << d_taps[i][0] << ", "; + for(j = 1; j < d_taps_per_filter-1; j++) { + str << d_taps[i][j] << ", "; + } + str << d_taps[i][j] << "],"; + } + str << " ]" << std::endl; + + return str.str(); +} + +std::string +digital_pfb_clock_sync_fff::get_diff_taps_as_string() +{ + int i, j; + std::stringstream str; + str.precision(4); + str.setf(std::ios::scientific); + + str << "[ "; + for(i = 0; i < d_nfilters; i++) { + str << "[" << d_dtaps[i][0] << ", "; + for(j = 1; j < d_taps_per_filter-1; j++) { + str << d_dtaps[i][j] << ", "; + } + str << d_dtaps[i][j] << "],"; + } + str << " ]" << std::endl; + + return str.str(); +} + +std::vector< std::vector<float> > +digital_pfb_clock_sync_fff::get_taps() +{ + return d_taps; +} + +std::vector< std::vector<float> > +digital_pfb_clock_sync_fff::get_diff_taps() +{ + return d_dtaps; +} + +std::vector<float> +digital_pfb_clock_sync_fff::get_channel_taps(int channel) +{ + std::vector<float> taps; + for(int i = 0; i < d_taps_per_filter; i++) { + taps.push_back(d_taps[channel][i]); + } + return taps; +} + +std::vector<float> +digital_pfb_clock_sync_fff::get_diff_channel_taps(int channel) +{ + std::vector<float> taps; + for(int i = 0; i < d_taps_per_filter; i++) { + taps.push_back(d_dtaps[channel][i]); + } + return taps; +} + +int +digital_pfb_clock_sync_fff::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + float *in = (float *) input_items[0]; + float *out = (float *) output_items[0]; + + float *err = NULL, *outrate = NULL, *outk = NULL; + if(output_items.size() == 4) { + err = (float *) output_items[1]; + outrate = (float*)output_items[2]; + outk = (float*)output_items[3]; + } + + if (d_updated) { + d_updated = false; + return 0; // history requirements may have changed. + } + + // We need this many to process one output + int nrequired = ninput_items[0] - d_taps_per_filter - d_osps; + + int i = 0, count = 0; + + // produce output as long as we can and there are enough input samples + while((i < noutput_items) && (count < nrequired)) { + while(d_out_idx < d_osps) { + d_filtnum = (int)floor(d_k); + + // Keep the current filter number in [0, d_nfilters] + // If we've run beyond the last filter, wrap around and go to next sample + // If we've go below 0, wrap around and go to previous sample + while(d_filtnum >= d_nfilters) { + d_k -= d_nfilters; + d_filtnum -= d_nfilters; + count += 1; + } + while(d_filtnum < 0) { + d_k += d_nfilters; + d_filtnum += d_nfilters; + count -= 1; + } + + out[i+d_out_idx] = d_filters[d_filtnum]->filter(&in[count+d_out_idx]); + d_k = d_k + d_rate_i + d_rate_f; // update phase + d_out_idx++; + + if(output_items.size() == 4) { + err[i] = d_error; + outrate[i] = d_rate_f; + outk[i] = d_k; + } + + // We've run out of output items we can create; return now. + if(i+d_out_idx >= noutput_items) { + consume_each(count); + return i; + } + } + + // reset here; if we didn't complete a full osps samples last time, + // the early return would take care of it. + d_out_idx = 0; + + // Update the phase and rate estimates for this symbol + float diff = d_diff_filters[d_filtnum]->filter(&in[count]); + d_error = out[i] * diff; + + // Run the control loop to update the current phase (k) and + // tracking rate estimates based on the error value + d_rate_f = d_rate_f + d_beta*d_error; + d_k = d_k + d_alpha*d_error; + + // Keep our rate within a good range + d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev); + + i+=d_osps; + count += (int)floor(d_sps); + } + + consume_each(count); + return i; +} diff --git a/gr-digital/lib/digital_pn_correlator_cc.cc b/gr-digital/lib/digital_pn_correlator_cc.cc new file mode 100644 index 0000000000..43a3ddbd1f --- /dev/null +++ b/gr-digital/lib/digital_pn_correlator_cc.cc @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_pn_correlator_cc.h> +#include <gr_io_signature.h> + +digital_pn_correlator_cc_sptr +digital_make_pn_correlator_cc(int degree, int mask, int seed) +{ + return gnuradio::get_initial_sptr(new digital_pn_correlator_cc + (degree, mask, seed)); +} + +digital_pn_correlator_cc::digital_pn_correlator_cc(int degree, + int mask, + int seed) + : gr_sync_decimator ("pn_correlator_cc", + gr_make_io_signature (1, 1, sizeof(gr_complex)), + gr_make_io_signature (1, 1, sizeof(gr_complex)), + (unsigned int)((1ULL << degree)-1)) // PN code length +{ + d_len = (unsigned int)((1ULL << degree)-1); + if (mask == 0) + mask = gri_glfsr::glfsr_mask(degree); + d_reference = new gri_glfsr(mask, seed); + for (int i = 0; i < d_len; i++) // initialize to last value in sequence + d_pn = 2.0*d_reference->next_bit()-1.0; +} + +digital_pn_correlator_cc::~digital_pn_correlator_cc() +{ + delete d_reference; +} + +int +digital_pn_correlator_cc::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const gr_complex *in = (const gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + gr_complex sum; + + for (int i = 0; i < noutput_items; i++) { + sum = 0.0; + + for (int j = 0; j < d_len; j++) { + if (j != 0) // retard PN generator one sample per period + d_pn = 2.0*d_reference->next_bit()-1.0; // no conditionals + sum += *in++ * d_pn; + } + + *out++ = sum*gr_complex(1.0/d_len, 0.0); + } + + return noutput_items; +} diff --git a/gr-digital/lib/digital_probe_density_b.cc b/gr-digital/lib/digital_probe_density_b.cc new file mode 100644 index 0000000000..6b83d2ddb7 --- /dev/null +++ b/gr-digital/lib/digital_probe_density_b.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 Free Software Foundation, Inc. + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <digital_probe_density_b.h> +#include <gr_io_signature.h> +#include <stdexcept> +#include <iostream> + +digital_probe_density_b_sptr +digital_make_probe_density_b(double alpha) +{ + return gnuradio::get_initial_sptr(new digital_probe_density_b(alpha)); +} + +digital_probe_density_b::digital_probe_density_b(double alpha) + : gr_sync_block("density_b", + gr_make_io_signature(1, 1, sizeof(char)), + gr_make_io_signature(0, 0, 0)) +{ + set_alpha(alpha); + d_density = 1.0; +} + +digital_probe_density_b::~digital_probe_density_b() +{ +} + +int +digital_probe_density_b::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]; + + for (int i = 0; i < noutput_items; i++) + d_density = d_alpha*(double)in[i] + d_beta*d_density; + + return noutput_items; +} + +void +digital_probe_density_b::set_alpha(double alpha) +{ + d_alpha = alpha; + d_beta = 1.0-d_alpha; +} + diff --git a/gr-digital/lib/digital_scrambler_bb.cc b/gr-digital/lib/digital_scrambler_bb.cc new file mode 100644 index 0000000000..c81b09d8c3 --- /dev/null +++ b/gr-digital/lib/digital_scrambler_bb.cc @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_scrambler_bb.h> +#include <gr_io_signature.h> + +digital_scrambler_bb_sptr +digital_make_scrambler_bb(int mask, int seed, int len) +{ + return gnuradio::get_initial_sptr(new digital_scrambler_bb + (mask, seed, len)); +} + +digital_scrambler_bb::digital_scrambler_bb(int mask, int seed, int len) + : gr_sync_block("scrambler_bb", + gr_make_io_signature (1, 1, sizeof (unsigned char)), + gr_make_io_signature (1, 1, sizeof (unsigned char))), + d_lfsr(mask, seed, len) +{ +} + +int +digital_scrambler_bb::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] = d_lfsr.next_bit_scramble(in[i]); + + return noutput_items; +} diff --git a/gr-digital/lib/digital_simple_framer.cc b/gr-digital/lib/digital_simple_framer.cc new file mode 100644 index 0000000000..5c194543ca --- /dev/null +++ b/gr-digital/lib/digital_simple_framer.cc @@ -0,0 +1,102 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital_simple_framer.h> +#include <digital_simple_framer_sync.h> +#include <gr_io_signature.h> +#include <assert.h> +#include <stdexcept> +#include <string.h> + + +digital_simple_framer_sptr +digital_make_simple_framer (int payload_bytesize) +{ + return gnuradio::get_initial_sptr(new digital_simple_framer + (payload_bytesize)); +} + +digital_simple_framer::digital_simple_framer (int payload_bytesize) + : gr_block ("simple_framer", + gr_make_io_signature (1, 1, sizeof (unsigned char)), + gr_make_io_signature (1, 1, sizeof (unsigned char))), + d_seqno (0), d_payload_bytesize (payload_bytesize), + d_input_block_size (payload_bytesize), + d_output_block_size (payload_bytesize + GRSF_OVERHEAD) +{ + set_output_multiple (d_output_block_size); +} + +void +digital_simple_framer::forecast (int noutput_items, gr_vector_int &ninput_items_required) +{ + assert (noutput_items % d_output_block_size == 0); + + int nblocks = noutput_items / d_output_block_size; + int input_required = nblocks * d_input_block_size; + + unsigned ninputs = ninput_items_required.size(); + for (unsigned int i = 0; i < ninputs; i++) + ninput_items_required[i] = input_required; +} + +int +digital_simple_framer::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const unsigned char *in = (const unsigned char *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + + int n = 0; + int nblocks = 0; + + memset (out, 0x55, noutput_items); + + while (n < noutput_items) { + out[0] = (GRSF_SYNC >> 56) & 0xff; + out[1] = (GRSF_SYNC >> 48) & 0xff; + out[2] = (GRSF_SYNC >> 40) & 0xff; + out[3] = (GRSF_SYNC >> 32) & 0xff; + out[4] = (GRSF_SYNC >> 24) & 0xff; + out[5] = (GRSF_SYNC >> 16) & 0xff; + out[6] = (GRSF_SYNC >> 8) & 0xff; + out[7] = (GRSF_SYNC >> 0) & 0xff; + out[8] = d_seqno++; + + memcpy (&out[9], in, d_input_block_size); + in += d_input_block_size; + out += d_output_block_size; + n += d_output_block_size; + nblocks++; + } + + assert (n == noutput_items); + + consume_each (nblocks * d_input_block_size); + return n; +} diff --git a/gr-digital/python/generic_mod_demod.py b/gr-digital/python/generic_mod_demod.py index ae876e1086..a6c4f3445a 100644 --- a/gr-digital/python/generic_mod_demod.py +++ b/gr-digital/python/generic_mod_demod.py @@ -28,7 +28,7 @@ Generic modulation and demodulation. from gnuradio import gr from modulation_utils import extract_kwargs_from_options_for_class from utils import mod_codes -import digital_swig +import digital_swig as digital import math # default values (used in __init__ and add_options) @@ -121,12 +121,12 @@ class generic_mod(gr.hier_block2): gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) if gray_coded == True: - self.symbol_mapper = gr.map_bb(self._constellation.pre_diff_code()) + self.symbol_mapper = digital.map_bb(self._constellation.pre_diff_code()) if differential: - self.diffenc = gr.diff_encoder_bb(arity) + self.diffenc = digital.diff_encoder_bb(arity) - self.chunks2symbols = gr.chunks_to_symbols_bc(self._constellation.points()) + self.chunks2symbols = digital.chunks_to_symbols_bc(self._constellation.points()) # pulse shaping filter nfilts = 32 @@ -269,28 +269,28 @@ class generic_demod(gr.hier_block2): # Frequency correction fll_ntaps = 55 - self.freq_recov = digital_swig.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw, - fll_ntaps, self._freq_bw) + self.freq_recov = digital.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw, + fll_ntaps, self._freq_bw) # symbol timing recovery with RRC data filter taps = gr.firdes.root_raised_cosine(nfilts, nfilts*self._samples_per_symbol, 1.0, self._excess_bw, ntaps) - self.time_recov = gr.pfb_clock_sync_ccf(self._samples_per_symbol, - self._timing_bw, taps, - nfilts, nfilts//2, self._timing_max_dev) + self.time_recov = digital.pfb_clock_sync_ccf(self._samples_per_symbol, + self._timing_bw, taps, + nfilts, nfilts//2, self._timing_max_dev) fmin = -0.25 fmax = 0.25 - self.receiver = digital_swig.constellation_receiver_cb( + self.receiver = digital.constellation_receiver_cb( self._constellation, self._phase_bw, fmin, fmax) # Do differential decoding based on phase change of symbols if differential: - self.diffdec = gr.diff_decoder_bb(arity) + self.diffdec = digital.diff_decoder_bb(arity) if gray_coded: - self.symbol_mapper = gr.map_bb( + self.symbol_mapper = digital.map_bb( mod_codes.invert_code(self._constellation.pre_diff_code())) # unpack the k bit vector into a stream of bits diff --git a/gr-digital/python/qa_bytes_to_syms.py b/gr-digital/python/qa_bytes_to_syms.py new file mode 100755 index 0000000000..75475a95b2 --- /dev/null +++ b/gr-digital/python/qa_bytes_to_syms.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# +# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital +import math + +class test_bytes_to_syms (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_bytes_to_syms_001 (self): + src_data = (0x01, 0x80, 0x03) + expected_result = (-1, -1, -1, -1, -1, -1, -1, +1, + +1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, +1, +1) + src = gr.vector_source_b (src_data) + op = digital.bytes_to_syms () + dst = gr.vector_sink_f () + self.tb.connect (src, op) + self.tb.connect (op, dst) + self.tb.run () + result_data = dst.data () + self.assertEqual (expected_result, result_data) + +if __name__ == '__main__': + gr_unittest.run(test_bytes_to_syms, "test_bytes_to_syms.xml") + diff --git a/gr-digital/python/qa_chunks_to_symbols.py b/gr-digital/python/qa_chunks_to_symbols.py new file mode 100755 index 0000000000..63af10d8ff --- /dev/null +++ b/gr-digital/python/qa_chunks_to_symbols.py @@ -0,0 +1,140 @@ +#!/usr/bin/env python +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital + +class test_chunks_to_symbols(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_bc_001(self): + const = [ 1+0j, 0+1j, + -1+0j, 0-1j] + src_data = (0, 1, 2, 3, 3, 2, 1, 0) + expected_result = (1+0j, 0+1j, -1+0j, 0-1j, + 0-1j, -1+0j, 0+1j, 1+0j) + + src = gr.vector_source_b(src_data) + op = digital.chunks_to_symbols_bc(const) + + dst = gr.vector_sink_c() + self.tb.connect(src, op) + self.tb.connect(op, dst) + self.tb.run() + + actual_result = dst.data() + self.assertEqual(expected_result, actual_result) + + def test_bf_002(self): + const = [-3, -1, 1, 3] + src_data = (0, 1, 2, 3, 3, 2, 1, 0) + expected_result = (-3, -1, 1, 3, + 3, 1, -1, -3) + + src = gr.vector_source_b(src_data) + op = digital.chunks_to_symbols_bf(const) + + dst = gr.vector_sink_f() + self.tb.connect(src, op) + self.tb.connect(op, dst) + self.tb.run() + + actual_result = dst.data() + self.assertEqual(expected_result, actual_result) + + def test_ic_003(self): + const = [ 1+0j, 0+1j, + -1+0j, 0-1j] + src_data = (0, 1, 2, 3, 3, 2, 1, 0) + expected_result = (1+0j, 0+1j, -1+0j, 0-1j, + 0-1j, -1+0j, 0+1j, 1+0j) + + src = gr.vector_source_i(src_data) + op = digital.chunks_to_symbols_ic(const) + + dst = gr.vector_sink_c() + self.tb.connect(src, op) + self.tb.connect(op, dst) + self.tb.run() + + actual_result = dst.data() + self.assertEqual(expected_result, actual_result) + + def test_if_004(self): + const = [-3, -1, 1, 3] + src_data = (0, 1, 2, 3, 3, 2, 1, 0) + expected_result = (-3, -1, 1, 3, + 3, 1, -1, -3) + + src = gr.vector_source_i(src_data) + op = digital.chunks_to_symbols_if(const) + + dst = gr.vector_sink_f() + self.tb.connect(src, op) + self.tb.connect(op, dst) + self.tb.run() + + actual_result = dst.data() + self.assertEqual(expected_result, actual_result) + + def test_sc_005(self): + const = [ 1+0j, 0+1j, + -1+0j, 0-1j] + src_data = (0, 1, 2, 3, 3, 2, 1, 0) + expected_result = (1+0j, 0+1j, -1+0j, 0-1j, + 0-1j, -1+0j, 0+1j, 1+0j) + + src = gr.vector_source_s(src_data) + op = digital.chunks_to_symbols_sc(const) + + dst = gr.vector_sink_c() + self.tb.connect(src, op) + self.tb.connect(op, dst) + self.tb.run() + + actual_result = dst.data() + self.assertEqual(expected_result, actual_result) + + def test_sf_006(self): + const = [-3, -1, 1, 3] + src_data = (0, 1, 2, 3, 3, 2, 1, 0) + expected_result = (-3, -1, 1, 3, + 3, 1, -1, -3) + + src = gr.vector_source_s(src_data) + op = digital.chunks_to_symbols_sf(const) + + dst = gr.vector_sink_f() + self.tb.connect(src, op) + self.tb.connect(op, dst) + self.tb.run() + + actual_result = dst.data() + self.assertEqual(expected_result, actual_result) + +if __name__ == '__main__': + gr_unittest.run(test_chunks_to_symbols, "test_chunks_to_symbols.xml") diff --git a/gr-digital/python/qa_correlate_access_code.py b/gr-digital/python/qa_correlate_access_code.py index 6b6f25051e..96246dcfb9 100755 --- a/gr-digital/python/qa_correlate_access_code.py +++ b/gr-digital/python/qa_correlate_access_code.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import digital_swig +import digital_swig as digital import math default_access_code = '\xAC\xDD\xA4\xE2\xF2\x8C\x20\xFC' @@ -53,7 +53,7 @@ class test_correlate_access_code(gr_unittest.TestCase): src_data = (1, 0, 1, 1, 1, 1, 0, 1, 1) + pad + (0,) * 7 expected_result = pad + (1, 0, 1, 1, 3, 1, 0, 1, 1, 2) + (0,) * 6 src = gr.vector_source_b (src_data) - op = digital_swig.correlate_access_code_bb("1011", 0) + op = digital.correlate_access_code_bb("1011", 0) dst = gr.vector_sink_b () self.tb.connect (src, op, dst) self.tb.run () @@ -70,13 +70,28 @@ class test_correlate_access_code(gr_unittest.TestCase): src_data = code + (1, 0, 1, 1) + pad expected_result = pad + code + (3, 0, 1, 1) src = gr.vector_source_b (src_data) - op = digital_swig.correlate_access_code_bb(access_code, 0) + op = digital.correlate_access_code_bb(access_code, 0) dst = gr.vector_sink_b () self.tb.connect (src, op, dst) self.tb.run () result_data = dst.data () self.assertEqual (expected_result, result_data) + def test_003(self): + code = tuple(string_to_1_0_list(default_access_code)) + access_code = to_1_0_string(code) + pad = (0,) * 64 + #print code + #print access_code + src_data = code + (1, 0, 1, 1) + pad + expected_result = code + (1, 0, 1, 1) + pad + src = gr.vector_source_b (src_data) + op = digital.correlate_access_code_tag_bb(access_code, 0, "test") + dst = gr.vector_sink_b () + self.tb.connect (src, op, dst) + self.tb.run () + result_data = dst.data () + self.assertEqual (expected_result, result_data) if __name__ == '__main__': diff --git a/gr-digital/python/qa_diff_encoder.py b/gr-digital/python/qa_diff_encoder.py new file mode 100755 index 0000000000..e4f5470af5 --- /dev/null +++ b/gr-digital/python/qa_diff_encoder.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# +# Copyright 2006,2007,2010,2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital +import math +import random + +def make_random_int_tuple(L, min, max): + result = [] + for x in range(L): + result.append(random.randint(min, max)) + return tuple(result) + + +class test_diff_encoder (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_diff_encdec_000(self): + random.seed(0) + modulus = 2 + src_data = make_random_int_tuple(1000, 0, modulus-1) + expected_result = src_data + src = gr.vector_source_b(src_data) + enc = digital.diff_encoder_bb(modulus) + dec = digital.diff_decoder_bb(modulus) + dst = gr.vector_sink_b() + self.tb.connect(src, enc, dec, dst) + self.tb.run() # run the graph and wait for it to finish + actual_result = dst.data() # fetch the contents of the sink + self.assertEqual(expected_result, actual_result) + + def test_diff_encdec_001(self): + random.seed(0) + modulus = 4 + src_data = make_random_int_tuple(1000, 0, modulus-1) + expected_result = src_data + src = gr.vector_source_b(src_data) + enc = digital.diff_encoder_bb(modulus) + dec = digital.diff_decoder_bb(modulus) + dst = gr.vector_sink_b() + self.tb.connect(src, enc, dec, dst) + self.tb.run() # run the graph and wait for it to finish + actual_result = dst.data() # fetch the contents of the sink + self.assertEqual(expected_result, actual_result) + + def test_diff_encdec_002(self): + random.seed(0) + modulus = 8 + src_data = make_random_int_tuple(40000, 0, modulus-1) + expected_result = src_data + src = gr.vector_source_b(src_data) + enc = digital.diff_encoder_bb(modulus) + dec = digital.diff_decoder_bb(modulus) + dst = gr.vector_sink_b() + self.tb.connect(src, enc, dec, dst) + self.tb.run() # run the graph and wait for it to finish + actual_result = dst.data() # fetch the contents of the sink + self.assertEqual(expected_result, actual_result) + +if __name__ == '__main__': + gr_unittest.run(test_diff_encoder, "test_diff_encoder.xml") + diff --git a/gr-digital/python/qa_diff_phasor_cc.py b/gr-digital/python/qa_diff_phasor_cc.py new file mode 100755 index 0000000000..3e7617fe47 --- /dev/null +++ b/gr-digital/python/qa_diff_phasor_cc.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# +# Copyright 2004,2007,2010 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital +import math + +class test_diff_phasor (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_diff_phasor_cc (self): + src_data = (0+0j, 1+0j, -1+0j, 3+4j, -3-4j, -3+4j) + expected_result = (0+0j, 0+0j, -1+0j, -3-4j, -25+0j, -7-24j) + src = gr.vector_source_c (src_data) + op = digital.diff_phasor_cc () + dst = gr.vector_sink_c () + self.tb.connect (src, op) + self.tb.connect (op, dst) + self.tb.run () # run the graph and wait for it to finish + actual_result = dst.data () # fetch the contents of the sink + self.assertComplexTuplesAlmostEqual (expected_result, actual_result) + +if __name__ == '__main__': + gr_unittest.run(test_diff_phasor, "test_diff_phasor.xml") + diff --git a/gr-digital/python/qa_framer_sink.py b/gr-digital/python/qa_framer_sink.py new file mode 100755 index 0000000000..bccc86dc78 --- /dev/null +++ b/gr-digital/python/qa_framer_sink.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital + +default_access_code = '\xAC\xDD\xA4\xE2\xF2\x8C\x20\xFC' + +def string_to_1_0_list(s): + r = [] + for ch in s: + x = ord(ch) + for i in range(8): + t = (x >> i) & 0x1 + r.append(t) + return r + +def to_1_0_string(L): + return ''.join(map(lambda x: chr(x + ord('0')), L)) + +class test_framker_sink(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + + code = (1, 1, 0, 1) + access_code = to_1_0_string(code) + header = tuple(2*[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]) # len=1 + pad = (0,) * 100 + src_data = code + header + (0,1,0,0,0,0,0,1) + pad + expected_data = 'A' + + rcvd_pktq = gr.msg_queue() + + src = gr.vector_source_b(src_data) + correlator = digital.correlate_access_code_bb(access_code, 0) + framer_sink = digital.framer_sink_1(rcvd_pktq) + vsnk = gr.vector_sink_b() + + self.tb.connect(src, correlator, framer_sink) + self.tb.connect(correlator, vsnk) + self.tb.run () + + result_data = rcvd_pktq.delete_head() + result_data = result_data.to_string() + self.assertEqual (expected_data, result_data) + + def test_002(self): + + code = tuple(string_to_1_0_list(default_access_code)) + access_code = to_1_0_string(code) + header = tuple(2*[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0]) # len=2 + pad = (0,) * 100 + src_data = code + header + (0,1,0,0,1,0,0,0) + (0,1,0,0,1,0,0,1) + pad + expected_data = 'HI' + + rcvd_pktq = gr.msg_queue() + + src = gr.vector_source_b(src_data) + correlator = digital.correlate_access_code_bb(access_code, 0) + framer_sink = digital.framer_sink_1(rcvd_pktq) + vsnk = gr.vector_sink_b() + + self.tb.connect(src, correlator, framer_sink) + self.tb.connect(correlator, vsnk) + self.tb.run () + + result_data = rcvd_pktq.delete_head() + result_data = result_data.to_string() + self.assertEqual (expected_data, result_data) + +if __name__ == '__main__': + gr_unittest.run(test_framker_sink, "test_framker_sink.xml") + diff --git a/gr-digital/python/qa_glfsr_source.py b/gr-digital/python/qa_glfsr_source.py new file mode 100755 index 0000000000..157520d7f8 --- /dev/null +++ b/gr-digital/python/qa_glfsr_source.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python +# +# Copyright 2007,2010,2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital + +class test_glfsr_source(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_000_make_b(self): + src = digital.glfsr_source_b(16) + self.assertEquals(src.mask(), 0x8016) + self.assertEquals(src.period(), 2**16-1) + + def test_001_degree_b(self): + self.assertRaises(RuntimeError, + lambda: gr.glfsr_source_b(0)) + self.assertRaises(RuntimeError, + lambda: gr.glfsr_source_b(33)) + + def test_002_correlation_b(self): + for degree in range(1,11): # Higher degrees take too long to correlate + src = digital.glfsr_source_b(degree, False) + b2f = digital.chunks_to_symbols_bf((-1.0,1.0), 1) + dst = gr.vector_sink_f() + del self.tb # Discard existing top block + self.tb = gr.top_block() + self.tb.connect(src, b2f, dst) + self.tb.run() + self.tb.disconnect_all() + actual_result = dst.data() + R = auto_correlate(actual_result) + self.assertEqual(R[0], float(len(R))) # Auto-correlation peak at origin + for i in range(len(R)-1): + self.assertEqual(R[i+1], -1.0) # Auto-correlation minimum everywhere else + + def test_003_make_f(self): + src = digital.glfsr_source_f(16) + self.assertEquals(src.mask(), 0x8016) + self.assertEquals(src.period(), 2**16-1) + + def test_004_degree_f(self): + self.assertRaises(RuntimeError, + lambda: gr.glfsr_source_f(0)) + self.assertRaises(RuntimeError, + lambda: gr.glfsr_source_f(33)) + def test_005_correlation_f(self): + for degree in range(1,11): # Higher degrees take too long to correlate + src = digital.glfsr_source_f(degree, False) + dst = gr.vector_sink_f() + del self.tb # Discard existing top block + self.tb = gr.top_block() + self.tb.connect(src, dst) + self.tb.run() + + actual_result = dst.data() + R = auto_correlate(actual_result) + self.assertEqual(R[0], float(len(R))) # Auto-correlation peak at origin + for i in range(len(R)-1): + self.assertEqual(R[i+1], -1.0) # Auto-correlation minimum everywhere else + +def auto_correlate(data): + l = len(data) + R = [0,]*l + for lag in range(l): + for i in range(l): + R[lag] += data[i]*data[i-lag] + return R + +if __name__ == '__main__': + gr_unittest.run(test_glfsr_source, "test_glfsr_source.xml") diff --git a/gr-digital/python/qa_map.py b/gr-digital/python/qa_map.py new file mode 100755 index 0000000000..3ad99a2c12 --- /dev/null +++ b/gr-digital/python/qa_map.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital + +class test_map(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def helper(self, symbols): + src_data = [0, 1, 2, 3, 0, 1, 2, 3] + expected_data = map(lambda x: symbols[x], src_data) + src = gr.vector_source_b (src_data) + op = digital.map_bb(symbols) + dst = gr.vector_sink_b () + self.tb.connect (src, op, dst) + self.tb.run () + + result_data = list(dst.data()) + self.assertEqual (expected_data, result_data) + + def test_001(self): + symbols = [0, 0, 0, 0] + self.helper(symbols) + + def test_002(self): + symbols = [3, 2, 1, 0] + self.helper(symbols) + + def test_003(self): + symbols = [8-1, 32-1, 128, 256-1] + self.helper(symbols) + +if __name__ == '__main__': + gr_unittest.run(test_map, "test_map.xml") + diff --git a/gr-digital/python/qa_pfb_clock_sync.py b/gr-digital/python/qa_pfb_clock_sync.py new file mode 100755 index 0000000000..06c8a60ba7 --- /dev/null +++ b/gr-digital/python/qa_pfb_clock_sync.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python +# +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital +import random, cmath + +class test_pfb_clock_sync(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test01 (self): + # Test BPSK sync + excess_bw = 0.35 + + sps = 4 + loop_bw = cmath.pi/100.0 + nfilts = 32 + init_phase = nfilts/2 + max_rate_deviation = 1.5 + osps = 1 + + ntaps = 11 * int(sps*nfilts) + taps = gr.firdes.root_raised_cosine(nfilts, nfilts*sps, + 1.0, excess_bw, ntaps) + + self.test = digital.pfb_clock_sync_ccf(sps, loop_bw, taps, + nfilts, init_phase, + max_rate_deviation, + osps) + + data = 1000*[complex(1,0), complex(-1,0)] + self.src = gr.vector_source_c(data, False) + + # pulse shaping interpolation filter + rrc_taps = gr.firdes.root_raised_cosine( + nfilts, # gain + nfilts, # sampling rate based on 32 filters in resampler + 1.0, # symbol rate + excess_bw, # excess bandwidth (roll-off factor) + ntaps) + self.rrc_filter = gr.pfb_arb_resampler_ccf(sps, rrc_taps) + + self.snk = gr.vector_sink_c() + + self.tb.connect(self.src, self.rrc_filter, self.test, self.snk) + self.tb.run() + + expected_result = 1000*[complex(-1,0), complex(1,0)] + dst_data = self.snk.data() + + # Only compare last Ncmp samples + Ncmp = 100 + len_e = len(expected_result) + len_d = len(dst_data) + expected_result = expected_result[len_e - Ncmp:] + dst_data = dst_data[len_d - Ncmp:] + + #for e,d in zip(expected_result, dst_data): + # print e, d + + self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 1) + + + def test02 (self): + # Test real BPSK sync + excess_bw = 0.35 + + sps = 4 + loop_bw = cmath.pi/100.0 + nfilts = 32 + init_phase = nfilts/2 + max_rate_deviation = 1.5 + osps = 1 + + ntaps = 11 * int(sps*nfilts) + taps = gr.firdes.root_raised_cosine(nfilts, nfilts*sps, + 1.0, excess_bw, ntaps) + + self.test = digital.pfb_clock_sync_fff(sps, loop_bw, taps, + nfilts, init_phase, + max_rate_deviation, + osps) + + data = 1000*[1, -1] + self.src = gr.vector_source_f(data, False) + + # pulse shaping interpolation filter + rrc_taps = gr.firdes.root_raised_cosine( + nfilts, # gain + nfilts, # sampling rate based on 32 filters in resampler + 1.0, # symbol rate + excess_bw, # excess bandwidth (roll-off factor) + ntaps) + self.rrc_filter = gr.pfb_arb_resampler_fff(sps, rrc_taps) + + self.snk = gr.vector_sink_f() + + self.tb.connect(self.src, self.rrc_filter, self.test, self.snk) + self.tb.run() + + expected_result = 1000*[-1, 1] + dst_data = self.snk.data() + + # Only compare last Ncmp samples + Ncmp = 100 + len_e = len(expected_result) + len_d = len(dst_data) + expected_result = expected_result[len_e - Ncmp:] + dst_data = dst_data[len_d - Ncmp:] + + #for e,d in zip(expected_result, dst_data): + # print e, d + + self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 1) + + +if __name__ == '__main__': + gr_unittest.run(test_pfb_clock_sync, "test_pfb_clock_sync.xml") diff --git a/gr-digital/python/qa_pn_correlator_cc.py b/gr-digital/python/qa_pn_correlator_cc.py new file mode 100755 index 0000000000..377bef5feb --- /dev/null +++ b/gr-digital/python/qa_pn_correlator_cc.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# +# Copyright 2007,2010,2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital + +class test_pn_correlator_cc(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block () + + def tearDown(self): + self.tb = None + + def test_000_make(self): + c = digital.pn_correlator_cc(10) + + def test_001_correlate(self): + degree = 10 + length = 2**degree-1 + src = digital.glfsr_source_f(degree) + head = gr.head(gr.sizeof_float, length*length) + f2c = gr.float_to_complex() + corr = digital.pn_correlator_cc(degree) + dst = gr.vector_sink_c() + self.tb.connect(src, head, f2c, corr, dst) + self.tb.run() + data = dst.data() + self.assertEqual(data[-1], (1.0+0j)) + +if __name__ == '__main__': + gr_unittest.run(test_pn_correlator_cc, "test_pn_correlator_cc.xml") diff --git a/gr-digital/python/qa_probe_density.py b/gr-digital/python/qa_probe_density.py new file mode 100755 index 0000000000..c5b7e0e7c2 --- /dev/null +++ b/gr-digital/python/qa_probe_density.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital + +class test_probe_density(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = [0, 1, 0, 1] + expected_data = 1 + src = gr.vector_source_b (src_data) + op = digital.probe_density_b(1) + self.tb.connect (src, op) + self.tb.run () + + result_data = op.density() + self.assertEqual (expected_data, result_data) + + + def test_002(self): + src_data = [1, 1, 1, 1] + expected_data = 1 + src = gr.vector_source_b (src_data) + op = digital.probe_density_b(0.01) + self.tb.connect (src, op) + self.tb.run () + + result_data = op.density() + self.assertEqual (expected_data, result_data) + + def test_003(self): + src_data = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1] + expected_data = 0.95243 + src = gr.vector_source_b (src_data) + op = digital.probe_density_b(0.01) + self.tb.connect (src, op) + self.tb.run () + + result_data = op.density() + print result_data + self.assertAlmostEqual (expected_data, result_data, 5) + +if __name__ == '__main__': + gr_unittest.run(test_probe_density, "test_probe_density.xml") + diff --git a/gr-digital/python/qa_scrambler.py b/gr-digital/python/qa_scrambler.py new file mode 100755 index 0000000000..f5bd612429 --- /dev/null +++ b/gr-digital/python/qa_scrambler.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +# +# Copyright 2008,2010,2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital + +class test_scrambler(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_scrambler_descrambler(self): + src_data = (1,)*1000 + src = gr.vector_source_b(src_data, False) + scrambler = digital.scrambler_bb(0x8a, 0x7F, 7) # CCSDS 7-bit scrambler + descrambler = digital.descrambler_bb(0x8a, 0x7F, 7) + dst = gr.vector_sink_b() + self.tb.connect(src, scrambler, descrambler, dst) + self.tb.run() + self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage during synchronization + + def test_additive_scrambler(self): + src_data = (1,)*1000 + src = gr.vector_source_b(src_data, False) + scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7) + descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7) + dst = gr.vector_sink_b() + self.tb.connect(src, scrambler, descrambler, dst) + self.tb.run() + self.assertEqual(src_data, dst.data()) + + def test_additive_scrambler_reset(self): + src_data = (1,)*1000 + src = gr.vector_source_b(src_data, False) + scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100) + descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100) + dst = gr.vector_sink_b() + self.tb.connect(src, scrambler, descrambler, dst) + self.tb.run() + self.assertEqual(src_data, dst.data()) + +if __name__ == '__main__': + gr_unittest.run(test_scrambler, "test_scrambler.xml") diff --git a/gr-digital/python/qa_simple_framer.py b/gr-digital/python/qa_simple_framer.py new file mode 100755 index 0000000000..09b2d329b2 --- /dev/null +++ b/gr-digital/python/qa_simple_framer.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital +import math + +class test_simple_framer (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_simple_framer_001 (self): + src_data = (0x00, 0x11, 0x22, 0x33, + 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, + 0xcc, 0xdd, 0xee, 0xff) + + expected_result = ( + 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x00, 0x00, 0x11, 0x22, 0x33, 0x55, + 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x01, 0x44, 0x55, 0x66, 0x77, 0x55, + 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x02, 0x88, 0x99, 0xaa, 0xbb, 0x55, + 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x03, 0xcc, 0xdd, 0xee, 0xff, 0x55) + + src = gr.vector_source_b (src_data) + op = digital.simple_framer (4) + dst = gr.vector_sink_b () + self.tb.connect (src, op) + self.tb.connect (op, dst) + self.tb.run () + result_data = dst.data () + self.assertEqual (expected_result, result_data) + + +if __name__ == '__main__': + gr_unittest.run(test_simple_framer, "test_simple_framer.xml") + diff --git a/gr-digital/swig/CMakeLists.txt b/gr-digital/swig/CMakeLists.txt index 6f2c2251ad..0c129e181e 100644 --- a/gr-digital/swig/CMakeLists.txt +++ b/gr-digital/swig/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -18,23 +18,107 @@ # Boston, MA 02110-1301, USA. ######################################################################## -# Setup swig generation +# generate helper scripts to expand templated files ######################################################################## include(GrPython) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " +#!${PYTHON_EXECUTABLE} + +import sys, os, re +sys.path.append('${GR_CORE_PYTHONPATH}') +os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' +os.chdir('${CMAKE_CURRENT_BINARY_DIR}') + +if __name__ == '__main__': + import build_utils + root, inp = sys.argv[1:3] + for sig in sys.argv[3:]: + name = re.sub ('X+', sig, root) + d = build_utils.standard_dict(name, sig, 'digital') + build_utils.expand_template(d, inp) + +") + +macro(expand_i root) + # make a list of the .i generated files + unset(expanded_files_i) + foreach(sig ${ARGN}) + string(REGEX REPLACE "X+" ${sig} name ${root}) + list(APPEND expanded_files_i ${CMAKE_CURRENT_BINARY_DIR}/${name}.i) + endforeach(sig) + + #create a command to generate the .i files + add_custom_command( + OUTPUT ${expanded_files_i} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.i.t + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py + ${root} ${root}.i.t ${ARGN} + ) + + # Lists of generated i files + list(APPEND generated_swigs ${expanded_files_i}) +endmacro(expand_i) + + +######################################################################## +# Invoke macro to generate various sources +######################################################################## +expand_i(digital_chunks_to_symbols_XX bf bc sf sc if ic) + +add_custom_target(digital_generated_swigs DEPENDS + ${generated_swigs} +) + +######################################################################## +# Setup swig generation +######################################################################## include(GrSwig) -set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/digital_swig_doc.i) -set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include) +######################################################################## +# Create the master gengen swig include files +######################################################################## +set(generated_index ${CMAKE_CURRENT_BINARY_DIR}/digital_generated.i.in) +file(WRITE ${generated_index} " +// +// This file is machine generated. All edits will be overwritten +// +") + +file(APPEND ${generated_index} "%include \"gnuradio.i\"\n\n") +file(APPEND ${generated_index} "%{\n") + +foreach(swig_file ${generated_swigs}) + get_filename_component(name ${swig_file} NAME_WE) + file(APPEND ${generated_index} "#include<${name}.h>\n") +endforeach(swig_file) +file(APPEND ${generated_index} "%}\n") + +foreach(swig_file ${generated_swigs}) + get_filename_component(name ${swig_file} NAME) + file(APPEND ${generated_index} "%include<${name}>\n") +endforeach(swig_file) + +execute_process( + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${generated_index} ${CMAKE_CURRENT_BINARY_DIR}/digital_generated.i +) set(GR_SWIG_INCLUDE_DIRS ${GR_DIGITAL_INCLUDE_DIRS} ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/../include ) +# Setup swig docs to depend on includes and pull in from build directory set(GR_SWIG_LIBRARIES gnuradio-digital) - +set(GR_SWIG_TARGET_DEPS digital_generated_includes) +set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/digital_swig_doc.i) +set(GR_SWIG_DOC_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/../include + ${CMAKE_CURRENT_BINARY_DIR}/../include) GR_SWIG_MAKE(digital_swig digital_swig.i) - GR_SWIG_INSTALL( TARGETS digital_swig DESTINATION ${GR_PYTHON_DIR}/gnuradio/digital @@ -45,19 +129,34 @@ install( FILES digital_swig.i ${CMAKE_CURRENT_BINARY_DIR}/digital_swig_doc.i + ${CMAKE_CURRENT_BINARY_DIR}/digital_generated.i + ${generated_swigs} + digital_additive_scrambler_bb.i digital_binary_slicer_fb.i + digital_bytes_to_syms.i digital_clock_recovery_mm_cc.i digital_clock_recovery_mm_ff.i + digital_cma_equalizer_cc.i digital_constellation.i digital_constellation_receiver_cb.i digital_constellation_decoder_cb.i digital_correlate_access_code_bb.i + digital_correlate_access_code_tag_bb.i digital_costas_loop_cc.i - digital_cma_equalizer_cc.i + digital_cpmmod_bc.i digital_crc32.i + digital_descrambler_bb.i + digital_diff_decoder_bb.i + digital_diff_encoder_bb.i + digital_diff_phasor_cc.i digital_fll_band_edge_cc.i + digital_framer_sink_1.i + digital_glfsr_source_b.i + digital_glfsr_source_f.i + digital_gmskmod_bc.i digital_lms_dd_equalizer_cc.i digital_kurtotic_equalizer_cc.i + digital_map_bb.i digital_mpsk_receiver_cc.i digital_mpsk_snr_est_cc.i digital_ofdm_cyclic_prefixer.i @@ -66,9 +165,14 @@ install( digital_ofdm_insert_preamble.i digital_ofdm_mapper_bcv.i digital_ofdm_sampler.i + digital_packet_sink.i + digital_pfb_clock_sync_ccf.i + digital_pfb_clock_sync_fff.i + digital_pn_correlator_cc.i + digital_probe_density_b.i digital_probe_mpsk_snr_est_c.i - digital_gmskmod_bc.i - digital_cpmmod_bc.i + digital_scrambler_bb.i + digital_simple_framer.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "digital_swig" ) diff --git a/gr-digital/swig/digital_additive_scrambler_bb.i b/gr-digital/swig/digital_additive_scrambler_bb.i new file mode 100644 index 0000000000..b063f06725 --- /dev/null +++ b/gr-digital/swig/digital_additive_scrambler_bb.i @@ -0,0 +1,31 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,additive_scrambler_bb); + +digital_additive_scrambler_bb_sptr +digital_make_additive_scrambler_bb(int mask, int seed, + int len, int count=0); + +class digital_additive_scrambler_bb : public gr_sync_block +{ +}; diff --git a/gr-digital/swig/digital_bytes_to_syms.i b/gr-digital/swig/digital_bytes_to_syms.i new file mode 100644 index 0000000000..cf23f035c4 --- /dev/null +++ b/gr-digital/swig/digital_bytes_to_syms.i @@ -0,0 +1,29 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,bytes_to_syms); + +digital_bytes_to_syms_sptr digital_make_bytes_to_syms(); + +class digital_bytes_to_syms : public gr_sync_interpolator +{ +}; diff --git a/gr-digital/swig/digital_chunks_to_symbols_XX.i.t b/gr-digital/swig/digital_chunks_to_symbols_XX.i.t new file mode 100644 index 0000000000..a80ba2af11 --- /dev/null +++ b/gr-digital/swig/digital_chunks_to_symbols_XX.i.t @@ -0,0 +1,38 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +GR_SWIG_BLOCK_MAGIC(digital,@BASE_NAME@); + +@SPTR_NAME@ digital_make_@BASE_NAME@ +(const std::vector<@O_TYPE@> &symbol_table, const int D = 1); + +class @NAME@ : public gr_sync_interpolator +{ +private: + @NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); + +public: + int D () const { return d_D; } + std::vector<@O_TYPE@> symbol_table () const { return d_symbol_table; } +}; diff --git a/gr-digital/swig/digital_constellation_decoder_cb.i b/gr-digital/swig/digital_constellation_decoder_cb.i index 53d3fe8e0d..547f57ee6a 100644 --- a/gr-digital/swig/digital_constellation_decoder_cb.i +++ b/gr-digital/swig/digital_constellation_decoder_cb.i @@ -31,7 +31,7 @@ class digital_constellation_decoder_cb : public gr_sync_block digital_constellation_decoder_cb (digital_constellation_sptr constellation); friend digital_constellation_decoder_cb_sptr - gr_make_constellation_decoder_cb (digital_constellation_sptr constellation); + digital_make_constellation_decoder_cb (digital_constellation_sptr constellation); public: ~digital_constellation_decoder_cb(); diff --git a/gr-digital/swig/digital_correlate_access_code_tag_bb.i b/gr-digital/swig/digital_correlate_access_code_tag_bb.i new file mode 100644 index 0000000000..03f20148a1 --- /dev/null +++ b/gr-digital/swig/digital_correlate_access_code_tag_bb.i @@ -0,0 +1,35 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,correlate_access_code_tag_bb); + +digital_correlate_access_code_tag_bb_sptr +digital_make_correlate_access_code_tag_bb(const std::string &access_code, + int threshold, + const std::string &tag_name) + throw(std::out_of_range); + +class digital_correlate_access_code_tag_bb : public gr_sync_block +{ + public: + bool set_access_code(const std::string &access_code); +}; diff --git a/gr-digital/swig/digital_descrambler_bb.i b/gr-digital/swig/digital_descrambler_bb.i new file mode 100644 index 0000000000..59de806fba --- /dev/null +++ b/gr-digital/swig/digital_descrambler_bb.i @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,descrambler_bb); + +digital_descrambler_bb_sptr +digital_make_descrambler_bb(int mask, int seed, int len); + +class digital_descrambler_bb : public gr_sync_block +{ +}; diff --git a/gr-digital/swig/digital_diff_decoder_bb.i b/gr-digital/swig/digital_diff_decoder_bb.i new file mode 100644 index 0000000000..f9741c771f --- /dev/null +++ b/gr-digital/swig/digital_diff_decoder_bb.i @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,diff_decoder_bb) + +digital_diff_decoder_bb_sptr +digital_make_diff_decoder_bb(unsigned int modulus); + +class digital_diff_decoder_bb : public gr_sync_block +{ +}; diff --git a/gr-digital/swig/digital_diff_encoder_bb.i b/gr-digital/swig/digital_diff_encoder_bb.i new file mode 100644 index 0000000000..45a4589bf1 --- /dev/null +++ b/gr-digital/swig/digital_diff_encoder_bb.i @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,diff_encoder_bb) + +digital_diff_encoder_bb_sptr +digital_make_diff_encoder_bb(unsigned int modulus); + +class digital_diff_encoder_bb : public gr_sync_block +{ +}; diff --git a/gr-digital/swig/digital_diff_phasor_cc.i b/gr-digital/swig/digital_diff_phasor_cc.i new file mode 100644 index 0000000000..b1e20eb997 --- /dev/null +++ b/gr-digital/swig/digital_diff_phasor_cc.i @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,diff_phasor_cc) + +digital_diff_phasor_cc_sptr +digital_make_diff_phasor_cc(); + +class digital_diff_phasor_cc : public gr_sync_block +{ +}; diff --git a/gr-digital/swig/digital_framer_sink_1.i b/gr-digital/swig/digital_framer_sink_1.i new file mode 100644 index 0000000000..a5c56560d3 --- /dev/null +++ b/gr-digital/swig/digital_framer_sink_1.i @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,framer_sink_1); + +digital_framer_sink_1_sptr +digital_make_framer_sink_1(gr_msg_queue_sptr target_queue); + +class digital_framer_sink_1 : public gr_sync_block +{ +}; diff --git a/gr-digital/swig/digital_glfsr_source_b.i b/gr-digital/swig/digital_glfsr_source_b.i new file mode 100644 index 0000000000..b1c487209e --- /dev/null +++ b/gr-digital/swig/digital_glfsr_source_b.i @@ -0,0 +1,35 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,glfsr_source_b); + +digital_glfsr_source_b_sptr +digital_make_glfsr_source_b(int degree, bool repeat=true, + int mask=0, int seed=1) + throw (std::runtime_error); + +class digital_glfsr_source_b : public gr_sync_block +{ +public: + unsigned int period() const; + int mask() const; +}; diff --git a/gr-digital/swig/digital_glfsr_source_f.i b/gr-digital/swig/digital_glfsr_source_f.i new file mode 100644 index 0000000000..4d94d8cd49 --- /dev/null +++ b/gr-digital/swig/digital_glfsr_source_f.i @@ -0,0 +1,35 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,glfsr_source_f); + +digital_glfsr_source_f_sptr +digital_make_glfsr_source_f(int degree, bool repeat=true, + int mask=0, int seed=1) + throw (std::runtime_error); + +class digital_glfsr_source_f : public gr_sync_block +{ +public: + unsigned int period() const; + int mask() const; +}; diff --git a/gr-digital/swig/digital_map_bb.i b/gr-digital/swig/digital_map_bb.i new file mode 100644 index 0000000000..50117d4f58 --- /dev/null +++ b/gr-digital/swig/digital_map_bb.i @@ -0,0 +1,31 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,map_bb); + +digital_map_bb_sptr +digital_make_map_bb(const std::vector<int> &map); + +class digital_map_bb : public gr_sync_block +{ +}; + diff --git a/gr-digital/swig/digital_ofdm_insert_preamble.i b/gr-digital/swig/digital_ofdm_insert_preamble.i index 5f7b163698..0273c7fa75 100644 --- a/gr-digital/swig/digital_ofdm_insert_preamble.i +++ b/gr-digital/swig/digital_ofdm_insert_preamble.i @@ -32,4 +32,6 @@ class digital_ofdm_insert_preamble : public gr_block protected: digital_ofdm_insert_preamble(int fft_length, const std::vector<std::vector<gr_complex> > &preamble); + public: + void enter_preamble(); }; diff --git a/gr-digital/swig/digital_packet_sink.i b/gr-digital/swig/digital_packet_sink.i new file mode 100644 index 0000000000..84f81f75cc --- /dev/null +++ b/gr-digital/swig/digital_packet_sink.i @@ -0,0 +1,34 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,packet_sink) + +digital_packet_sink_sptr +digital_make_packet_sink(const std::vector<unsigned char>& sync_vector, + gr_msg_queue_sptr target_queue, + int threshold = -1); // -1 -> use default + +class digital_packet_sink : public gr_sync_block +{ + public: + bool carrier_sensed() const; +}; diff --git a/gr-digital/swig/digital_pfb_clock_sync_ccf.i b/gr-digital/swig/digital_pfb_clock_sync_ccf.i new file mode 100644 index 0000000000..dbba614cc1 --- /dev/null +++ b/gr-digital/swig/digital_pfb_clock_sync_ccf.i @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,pfb_clock_sync_ccf); + +digital_pfb_clock_sync_ccf_sptr +digital_make_pfb_clock_sync_ccf(double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size=32, + float init_phase=0, + float max_rate_deviation=1.5, + int osps=1); + +class digital_pfb_clock_sync_ccf : public gr_block +{ + public: + void set_taps(const std::vector<float> &taps, + std::vector< std::vector<float> > &ourtaps, + std::vector<gr_fir_ccf*> &ourfilter); + + std::vector< std::vector<float> > get_taps(); + std::vector< std::vector<float> > get_diff_taps(); + std::vector<float> get_channel_taps(int channel); + std::vector<float> get_diff_channel_taps(int channel); + std::string get_taps_as_string(); + std::string get_diff_taps_as_string(); + + void set_loop_bandwidth(float bw); + void set_damping_factor(float df); + void set_alpha(float alpha); + void set_beta(float beta); + void set_max_rate_deviation(float m); + + float get_loop_bandwidth() const; + float get_damping_factor() const; + float get_alpha() const; + float get_beta() const; + float get_clock_rate() const; +}; diff --git a/gr-digital/swig/digital_pfb_clock_sync_fff.i b/gr-digital/swig/digital_pfb_clock_sync_fff.i new file mode 100644 index 0000000000..956495e5dd --- /dev/null +++ b/gr-digital/swig/digital_pfb_clock_sync_fff.i @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,pfb_clock_sync_fff); + +digital_pfb_clock_sync_fff_sptr +digital_make_pfb_clock_sync_fff(double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size=32, + float init_phase=0, + float max_rate_deviation=1.5, + int osps=1); + +class digital_pfb_clock_sync_fff : public gr_block +{ + public: + void set_taps (const std::vector<float> &taps, + std::vector< std::vector<float> > &ourtaps, + std::vector<gr_fir_fff*> &ourfilter); + + std::vector< std::vector<float> > get_taps(); + std::vector< std::vector<float> > get_diff_taps(); + std::vector<float> get_channel_taps(int channel); + std::vector<float> get_diff_channel_taps(int channel); + std::string get_taps_as_string(); + std::string get_diff_taps_as_string(); + + void set_loop_bandwidth(float bw); + void set_damping_factor(float df); + void set_alpha(float alpha); + void set_beta(float beta); + void set_max_rate_deviation(float m); + + float get_loop_bandwidth() const; + float get_damping_factor() const; + float get_alpha() const; + float get_beta() const; + float get_clock_rate() const; +}; diff --git a/gr-digital/swig/digital_pn_correlator_cc.i b/gr-digital/swig/digital_pn_correlator_cc.i new file mode 100644 index 0000000000..11ccf12c2f --- /dev/null +++ b/gr-digital/swig/digital_pn_correlator_cc.i @@ -0,0 +1,32 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,pn_correlator_cc) + +digital_pn_correlator_cc_sptr +digital_make_pn_correlator_cc(int degree, int mask=0, int seed=1); + +class digital_pn_correlator_cc : public gr_sync_decimator +{ + protected: + digital_pn_correlator_cc(); +}; diff --git a/gr-digital/swig/digital_probe_density_b.i b/gr-digital/swig/digital_probe_density_b.i new file mode 100644 index 0000000000..b0c8a119ad --- /dev/null +++ b/gr-digital/swig/digital_probe_density_b.i @@ -0,0 +1,33 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,probe_density_b); + +digital_probe_density_b_sptr +digital_make_probe_density_b(double alpha); + +class digital_probe_density_b : public gr_sync_block +{ +public: + double density() const; + void set_alpha(double alpha); +}; diff --git a/gr-digital/swig/digital_scrambler_bb.i b/gr-digital/swig/digital_scrambler_bb.i new file mode 100644 index 0000000000..ac9abef920 --- /dev/null +++ b/gr-digital/swig/digital_scrambler_bb.i @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,scrambler_bb); + +digital_scrambler_bb_sptr +digital_make_scrambler_bb(int mask, int seed, int len); + +class digital_scrambler_bb : public gr_sync_block +{ +}; diff --git a/gr-digital/swig/digital_simple_framer.i b/gr-digital/swig/digital_simple_framer.i new file mode 100644 index 0000000000..a376317c5c --- /dev/null +++ b/gr-digital/swig/digital_simple_framer.i @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(digital,simple_framer); + +digital_simple_framer_sptr +digital_make_simple_framer(int payload_bytesize); + +class digital_simple_framer : public gr_block +{ +}; diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i index 4e9c660bc1..191076d75c 100644 --- a/gr-digital/swig/digital_swig.i +++ b/gr-digital/swig/digital_swig.i @@ -35,8 +35,13 @@ enum snr_est_type_t { %include <gri_control_loop.i> +// Bring in generated blocks +%include "digital_generated.i" + %{ +#include "digital_additive_scrambler_bb.h" #include "digital_binary_slicer_fb.h" +#include "digital_bytes_to_syms.h" #include "digital_clock_recovery_mm_cc.h" #include "digital_clock_recovery_mm_ff.h" #include "digital_cma_equalizer_cc.h" @@ -44,11 +49,22 @@ enum snr_est_type_t { #include "digital_constellation_decoder_cb.h" #include "digital_constellation_receiver_cb.h" #include "digital_correlate_access_code_bb.h" +#include "digital_correlate_access_code_tag_bb.h" #include "digital_costas_loop_cc.h" +#include "digital_cpmmod_bc.h" #include "digital_crc32.h" +#include "digital_descrambler_bb.h" +#include "digital_diff_decoder_bb.h" +#include "digital_diff_encoder_bb.h" +#include "digital_diff_phasor_cc.h" #include "digital_fll_band_edge_cc.h" +#include "digital_framer_sink_1.h" +#include "digital_glfsr_source_b.h" +#include "digital_glfsr_source_f.h" +#include "digital_gmskmod_bc.h" #include "digital_kurtotic_equalizer_cc.h" #include "digital_lms_dd_equalizer_cc.h" +#include "digital_map_bb.h" #include "digital_mpsk_receiver_cc.h" #include "digital_mpsk_snr_est_cc.h" #include "digital_ofdm_cyclic_prefixer.h" @@ -57,11 +73,18 @@ enum snr_est_type_t { #include "digital_ofdm_insert_preamble.h" #include "digital_ofdm_mapper_bcv.h" #include "digital_ofdm_sampler.h" +#include "digital_packet_sink.h" +#include "digital_pfb_clock_sync_ccf.h" +#include "digital_pfb_clock_sync_fff.h" +#include "digital_pn_correlator_cc.h" +#include "digital_probe_density_b.h" #include "digital_probe_mpsk_snr_est_c.h" -#include "digital_cpmmod_bc.h" -#include "digital_gmskmod_bc.h" +#include "digital_scrambler_bb.h" +#include "digital_simple_framer.h" %} +%include "digital_additive_scrambler_bb.i" +%include "digital_bytes_to_syms.i" %include "digital_binary_slicer_fb.i" %include "digital_clock_recovery_mm_cc.i" %include "digital_clock_recovery_mm_ff.i" @@ -70,11 +93,22 @@ enum snr_est_type_t { %include "digital_constellation_decoder_cb.i" %include "digital_constellation_receiver_cb.i" %include "digital_correlate_access_code_bb.i" +%include "digital_correlate_access_code_tag_bb.i" %include "digital_costas_loop_cc.i" +%include "digital_cpmmod_bc.i" %include "digital_crc32.i" +%include "digital_descrambler_bb.i" +%include "digital_diff_decoder_bb.i" +%include "digital_diff_encoder_bb.i" +%include "digital_diff_phasor_cc.i" %include "digital_fll_band_edge_cc.i" +%include "digital_framer_sink_1.i" +%include "digital_glfsr_source_b.i" +%include "digital_glfsr_source_f.i" +%include "digital_gmskmod_bc.i" %include "digital_kurtotic_equalizer_cc.i" %include "digital_lms_dd_equalizer_cc.i" +%include "digital_map_bb.i" %include "digital_mpsk_receiver_cc.i" %include "digital_mpsk_snr_est_cc.i" %include "digital_ofdm_cyclic_prefixer.i" @@ -83,6 +117,11 @@ enum snr_est_type_t { %include "digital_ofdm_insert_preamble.i" %include "digital_ofdm_mapper_bcv.i" %include "digital_ofdm_sampler.i" +%include "digital_packet_sink.i" +%include "digital_pfb_clock_sync_ccf.i" +%include "digital_pfb_clock_sync_fff.i" +%include "digital_pn_correlator_cc.i" +%include "digital_probe_density_b.i" %include "digital_probe_mpsk_snr_est_c.i" -%include "digital_cpmmod_bc.i" -%include "digital_gmskmod_bc.i" +%include "digital_scrambler_bb.i" +%include "digital_simple_framer.i" diff --git a/gr-fcd/grc/fcd_source_c.xml b/gr-fcd/grc/fcd_source_c.xml index 1b83cba7fb..f1726f88f2 100644 --- a/gr-fcd/grc/fcd_source_c.xml +++ b/gr-fcd/grc/fcd_source_c.xml @@ -12,7 +12,7 @@ self.$(id).set_lna_gain($lna) #if $mixer() != +12.0 self.$(id).set_mixer_gain($mixer) #end if -#if $ppm() != 115 +#if $ppm() != -120 self.$(id).set_freq_corr($ppm) #end if #if ($dci() != 0.0) or ($dcq() != 0.0) diff --git a/gr-fft/include/fft/fft_vcc.h b/gr-fft/include/fft/fft_vcc.h index 561ae858d2..cb07b166d2 100644 --- a/gr-fft/include/fft/fft_vcc.h +++ b/gr-fft/include/fft/fft_vcc.h @@ -40,7 +40,7 @@ namespace gr { * \brief Compute forward or reverse FFT. complex vector in / complex vector out. * \ingroup dft_blk */ - static FFT_API sptr make(int fft_size, bool forward, + static sptr make(int fft_size, bool forward, const std::vector<float> &window, bool shift=false, int nthreads=1); diff --git a/gr-fft/include/fft/fft_vfc.h b/gr-fft/include/fft/fft_vfc.h index fc48ceefea..ec441d66a8 100644 --- a/gr-fft/include/fft/fft_vfc.h +++ b/gr-fft/include/fft/fft_vfc.h @@ -40,7 +40,7 @@ namespace gr { * \brief Compute forward or reverse FFT. float vector in / complex vector out. * \ingroup dft_blk */ - static FFT_API sptr make(int fft_size, bool forward, + static sptr make(int fft_size, bool forward, const std::vector<float> &window, int nthreads=1); diff --git a/gr-fft/include/fft/goertzel_fc.h b/gr-fft/include/fft/goertzel_fc.h index 4d3fa8dcf8..5b3c8f1c49 100644 --- a/gr-fft/include/fft/goertzel_fc.h +++ b/gr-fft/include/fft/goertzel_fc.h @@ -40,7 +40,7 @@ namespace gr { * \brief Goertzel single-bin DFT calculation. * \ingroup dft_blk */ - static FFT_API sptr make(int rate, int len, float freq); + static sptr make(int rate, int len, float freq); virtual void set_freq (float freq) = 0; diff --git a/gr-fft/swig/CMakeLists.txt b/gr-fft/swig/CMakeLists.txt index 63f5dfb0e2..7ea41f220e 100644 --- a/gr-fft/swig/CMakeLists.txt +++ b/gr-fft/swig/CMakeLists.txt @@ -30,7 +30,7 @@ set(GR_SWIG_INCLUDE_DIRS ) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/fft_swig_doc.i) -set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../lib) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include/fft) set(GR_SWIG_LIBRARIES gnuradio-fft) diff --git a/gr-pager/apps/usrp_flex_all b/gr-pager/apps/usrp_flex_all index 75c4c1e737..8ecf5a41ff 100755 --- a/gr-pager/apps/usrp_flex_all +++ b/gr-pager/apps/usrp_flex_all @@ -98,9 +98,9 @@ class app_top_block(gr.top_block): mid_chan = int(self.nchan/2) for i in range(self.nchan): if i < mid_chan: - freq = 930.5e6+i*25e3 + freq = options.freq+i*25e3 else: - freq = 930.5e6-(self.nchan-i)*25e3 + freq = options.freq-(self.nchan-i)*25e3 if (freq < 929.0e6 or freq > 932.0e6): self.connect((self.bank, i), gr.null_sink(gr.sizeof_gr_complex)) diff --git a/gr-uhd/gnuradio-uhd.pc.in b/gr-uhd/gnuradio-uhd.pc.in index 383ad6011b..721141c520 100644 --- a/gr-uhd/gnuradio-uhd.pc.in +++ b/gr-uhd/gnuradio-uhd.pc.in @@ -3,7 +3,7 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ -Name: gnuradio-qtgui +Name: gnuradio-uhd Description: GNU Radio blocks for UHD Requires: gnuradio-core Version: @LIBVER@ diff --git a/gr-wavelet/lib/CMakeLists.txt b/gr-wavelet/lib/CMakeLists.txt index 3247c17b53..9594f6a6ac 100644 --- a/gr-wavelet/lib/CMakeLists.txt +++ b/gr-wavelet/lib/CMakeLists.txt @@ -32,6 +32,7 @@ include_directories( link_directories(${WAVELET_LIBRARY_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) link_directories(${GSL_LIBRARY_DIRS}) +add_definitions(${GSL_DEFINITIONS}) ######################################################################## # Setup library diff --git a/gr-wavelet/python/CMakeLists.txt b/gr-wavelet/python/CMakeLists.txt index 650299672e..f118683954 100644 --- a/gr-wavelet/python/CMakeLists.txt +++ b/gr-wavelet/python/CMakeLists.txt @@ -41,7 +41,7 @@ foreach(py_qa_test_file ${py_qa_test_files}) ${CMAKE_BINARY_DIR}/gr-wavelet/python ${CMAKE_BINARY_DIR}/gr-wavelet/swig ) - set(GR_TEST_TARGET_DEPS gruel gnuradio-core gnuradio-wavelet) - GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${py_qa_test_file}) + set(GR_TEST_TARGET_DEPS volk gruel gnuradio-core gnuradio-wavelet) + GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) endforeach(py_qa_test_file) endif(ENABLE_TESTING) diff --git a/gr-wavelet/swig/CMakeLists.txt b/gr-wavelet/swig/CMakeLists.txt index 82d083dea2..2c5f433ebb 100644 --- a/gr-wavelet/swig/CMakeLists.txt +++ b/gr-wavelet/swig/CMakeLists.txt @@ -30,7 +30,7 @@ set(GR_SWIG_INCLUDE_DIRS ) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/wavelet_swig_doc.i) -set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../lib) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include/wavelet) set(GR_SWIG_LIBRARIES gnuradio-wavelet ${GSL_LDFLAGS}) diff --git a/gr-wxgui/CMakeLists.txt b/gr-wxgui/CMakeLists.txt index 0fc26dee1c..8150c7d802 100644 --- a/gr-wxgui/CMakeLists.txt +++ b/gr-wxgui/CMakeLists.txt @@ -76,7 +76,7 @@ install( ######################################################################## install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr-wxgui.conf - DESTINATION ${GR_PKG_CONF_DIR} + DESTINATION ${GR_PREFSDIR} COMPONENT "wxgui" ) diff --git a/gr-wxgui/grc/top_block_gui.py b/gr-wxgui/grc/top_block_gui.py index 333ccf1c12..479f55a302 100644 --- a/gr-wxgui/grc/top_block_gui.py +++ b/gr-wxgui/grc/top_block_gui.py @@ -48,7 +48,7 @@ class top_block_gui(gr.top_block): def SetIcon(self, *args, **kwargs): self._frame.SetIcon(*args, **kwargs) - def Run(self, start=True): + def Run(self, start=True, max_nouts=0): """ Setup the wx gui elements. Start the gr top block. @@ -69,6 +69,10 @@ class top_block_gui(gr.top_block): self._frame.Show(True) self._app.SetTopWindow(self._frame) #start flow graph - if start: self.start() + if start: + if max_nouts != 0: + self.start(max_nouts) + else: + self.start() #blocking main loop self._app.MainLoop() diff --git a/gr-wxgui/grc/wxgui_fftsink2.xml b/gr-wxgui/grc/wxgui_fftsink2.xml index ec5501838a..74ee5b173e 100644 --- a/gr-wxgui/grc/wxgui_fftsink2.xml +++ b/gr-wxgui/grc/wxgui_fftsink2.xml @@ -36,6 +36,12 @@ fftsink2.$(type.fcn)( $(parent).Add(self.$(id).win) #else $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos())))) +#end if +#if $freqvar() is not None +def $(id)_callback(x, y): + self.set_$(freqvar)(x) + +self.$(id).set_callback($(id)_callback) #end if</make> <callback>set_baseband_freq($baseband_freq)</callback> <callback>set_sample_rate($samp_rate)</callback> @@ -216,6 +222,12 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos())))) <value></value> <type>notebook</type> </param> + <param> + <name>Freq Set Varname</name> + <key>freqvar</key> + <value>None</value> + <type>raw</type> + </param> <check>not $win_size or len($win_size) == 2</check> <sink> <name>in</name> diff --git a/gr-wxgui/grc/wxgui_waterfallsink2.xml b/gr-wxgui/grc/wxgui_waterfallsink2.xml index da6a8a3d1a..8921e87f9a 100644 --- a/gr-wxgui/grc/wxgui_waterfallsink2.xml +++ b/gr-wxgui/grc/wxgui_waterfallsink2.xml @@ -34,6 +34,12 @@ waterfallsink2.$(type.fcn)( $(parent).Add(self.$(id).win) #else $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos())))) +#end if +#if $freqvar() is not None +def $(id)_callback(x, y): + self.set_$(freqvar)(x) + +self.$(id).set_callback($(id)_callback) #end if</make> <callback>set_baseband_freq($baseband_freq)</callback> <callback>set_sample_rate($samp_rate)</callback> @@ -173,6 +179,12 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos())))) <value></value> <type>notebook</type> </param> + <param> + <name>Freq Set Varname</name> + <key>freqvar</key> + <value>None</value> + <type>raw</type> + </param> <check>not $win_size or len($win_size) == 2</check> <sink> <name>in</name> diff --git a/gr-wxgui/src/python/fft_window.py b/gr-wxgui/src/python/fft_window.py index 99c1cf6e1a..fac83a4a34 100644 --- a/gr-wxgui/src/python/fft_window.py +++ b/gr-wxgui/src/python/fft_window.py @@ -300,6 +300,8 @@ class fft_window(wx.Panel, pubsub.pubsub): #initial update self.update_grid() + def set_callback(self,callb): + self.plotter.set_callback(callb) def autoscale(self, *args): """ diff --git a/gr-wxgui/src/python/fftsink_gl.py b/gr-wxgui/src/python/fftsink_gl.py index 6b268f6cb2..dc31e84a10 100644 --- a/gr-wxgui/src/python/fftsink_gl.py +++ b/gr-wxgui/src/python/fftsink_gl.py @@ -127,6 +127,9 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): setattr(self.win, 'set_peak_hold', getattr(self, 'set_peak_hold')) #BACKWARDS #connect self.wxgui_connect(self, fft, sink) + + def set_callback(self,callb): + self.win.set_callback(callb) class fft_sink_f(_fft_sink_base): _fft_chain = blks2.logpwrfft_f diff --git a/gr-wxgui/src/python/plotter/channel_plotter.py b/gr-wxgui/src/python/plotter/channel_plotter.py index a3a2b64519..4bcc36fd4c 100644 --- a/gr-wxgui/src/python/plotter/channel_plotter.py +++ b/gr-wxgui/src/python/plotter/channel_plotter.py @@ -56,6 +56,7 @@ class channel_plotter(grid_plotter_base): self._channels = dict() #init channel plotter self.register_init(self._init_channel_plotter) + self.callback = None def _init_channel_plotter(self): """ @@ -150,6 +151,13 @@ class channel_plotter(grid_plotter_base): label_str += '\n%s: %s'%(channel, common.eng_format(y_value, self.y_units)) return label_str + def _call_callback (self, x_val, y_val): + if self.callback != None: + self.callback(x_val, y_val) + + def set_callback (self, callback): + self.callback = callback + def _draw_legend(self): """ Draw the legend in the upper right corner. diff --git a/gr-wxgui/src/python/plotter/common.py b/gr-wxgui/src/python/plotter/common.py index 6775b70571..88215e039a 100644 --- a/gr-wxgui/src/python/plotter/common.py +++ b/gr-wxgui/src/python/plotter/common.py @@ -103,6 +103,7 @@ class point_label_thread(threading.Thread, mutex): self._plotter.Bind(wx.EVT_MOTION, lambda evt: self.enqueue(evt.GetPosition())) self._plotter.Bind(wx.EVT_LEAVE_WINDOW, lambda evt: self.enqueue(None)) self._plotter.Bind(wx.EVT_RIGHT_DOWN, lambda evt: plotter.enable_point_label(not plotter.enable_point_label())) + self._plotter.Bind(wx.EVT_LEFT_DOWN, lambda evt: plotter.call_freq_callback(evt.GetPosition())) #start the thread threading.Thread.__init__(self) self.start() diff --git a/gr-wxgui/src/python/plotter/grid_plotter_base.py b/gr-wxgui/src/python/plotter/grid_plotter_base.py index 5eaa76bc0e..f1bc8f546d 100644 --- a/gr-wxgui/src/python/plotter/grid_plotter_base.py +++ b/gr-wxgui/src/python/plotter/grid_plotter_base.py @@ -85,7 +85,19 @@ class grid_plotter_base(plotter_base): self._point_label_cache.changed(True) self.update() self.unlock() - + + def call_freq_callback(self, coor): + x, y = self._point_label_coordinate + if x < self.padding_left or x > self.width-self.padding_right: return + if y < self.padding_top or y > self.height-self.padding_bottom: return + #scale to window bounds + x_win_scalar = float(x - self.padding_left)/(self.width-self.padding_left-self.padding_right) + y_win_scalar = float((self.height - y) - self.padding_bottom)/(self.height-self.padding_top-self.padding_bottom) + #scale to grid bounds + x_val = x_win_scalar*(self.x_max-self.x_min) + self.x_min + y_val = y_win_scalar*(self.y_max-self.y_min) + self.y_min + self._call_callback(x_val, y_val) + def enable_grid_aspect_ratio(self, enable=None): """ Enable/disable the grid aspect ratio. diff --git a/gr-wxgui/src/python/plotter/plotter_base.py b/gr-wxgui/src/python/plotter/plotter_base.py index 5af5803392..2fdd0f20ab 100644 --- a/gr-wxgui/src/python/plotter/plotter_base.py +++ b/gr-wxgui/src/python/plotter/plotter_base.py @@ -189,7 +189,10 @@ class plotter_base(wx.glcanvas.GLCanvas, common.mutex): if self.use_persistence: if self.clear_accum: #GL.glClear(GL.GL_ACCUM_BUFFER_BIT) - GL.glAccum(GL.GL_LOAD, 1.0) + try: + GL.glAccum(GL.GL_LOAD, 1.0) + except: + pass self.clear_accum=False GL.glAccum(GL.GL_MULT, 1.0-self.persist_alpha) diff --git a/gr-wxgui/src/python/plotter/waterfall_plotter.py b/gr-wxgui/src/python/plotter/waterfall_plotter.py index f2456241c0..6a6bf6330e 100644 --- a/gr-wxgui/src/python/plotter/waterfall_plotter.py +++ b/gr-wxgui/src/python/plotter/waterfall_plotter.py @@ -110,6 +110,7 @@ class waterfall_plotter(grid_plotter_base): self._counter = 0 self.set_num_lines(0) self.set_color_mode(COLORS.keys()[0]) + self.callback = None def _init_waterfall(self): """ @@ -172,6 +173,13 @@ class waterfall_plotter(grid_plotter_base): """ return '%s: %s'%(self.x_label, common.eng_format(x_val, self.x_units)) + def _call_callback(self, x_val, y_val): + if self.callback != None: + self.callback(x_val,y_val) + + def set_callback(self,callback): + self.callback = callback + def _draw_legend(self): """ Draw the color scale legend. diff --git a/gr-wxgui/src/python/waterfall_window.py b/gr-wxgui/src/python/waterfall_window.py index c78244f042..cd60104d7a 100644 --- a/gr-wxgui/src/python/waterfall_window.py +++ b/gr-wxgui/src/python/waterfall_window.py @@ -238,6 +238,9 @@ class waterfall_window(wx.Panel, pubsub.pubsub): #initial update self.update_grid() + def set_callback(self,callb): + self.plotter.set_callback(callb) + def autoscale(self, *args): """ Autoscale the waterfall plot to the last frame. diff --git a/gr-wxgui/src/python/waterfallsink_gl.py b/gr-wxgui/src/python/waterfallsink_gl.py index c2c4e8df7a..b69c5dda0c 100644 --- a/gr-wxgui/src/python/waterfallsink_gl.py +++ b/gr-wxgui/src/python/waterfallsink_gl.py @@ -113,6 +113,9 @@ class _waterfall_sink_base(gr.hier_block2, common.wxgui_hb): #connect self.wxgui_connect(self, fft, sink) + def set_callback(self,callb): + self.win.set_callback(callb) + class waterfall_sink_f(_waterfall_sink_base): _fft_chain = blks2.logpwrfft_f _item_size = gr.sizeof_float diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index f54aa4f809..219bbe1642 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -75,7 +75,7 @@ configure_file( install( FILES ${CMAKE_CURRENT_BINARY_DIR}/grc.conf - DESTINATION ${GR_PKG_CONF_DIR} + DESTINATION ${GR_PREFSDIR} COMPONENT "grc" ) diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index 18bc050bac..0b0b6854ec 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -61,6 +61,7 @@ <block>gr_fft_vxx</block> <block>blks2_logpwrfft_x</block> + <block>gr_vector_insert_x</block> </cat> <cat> <name>Type Conversions</name> @@ -114,6 +115,7 @@ <block>gr_unpacked_to_packed_xx</block> <block>gr_packed_to_unpacked_xx</block> <block>gr_unpack_k_bits_bb</block> + <block>gr_pack_k_bits_bb</block> <block>gr_chunks_to_symbols_xx</block> <block>gr_map_bb</block> </cat> @@ -183,6 +185,7 @@ <block>blks2_rational_resampler_xxx</block> <block>gr_fractional_interpolator_xx</block> <block>gr_keep_one_in_n</block> + <block>gr_keep_m_in_n</block> <block>gr_moving_average_xx</block> <block>gr_iqcomp_cc</block> <block>gr_dc_blocker</block> diff --git a/grc/blocks/gr_keep_m_in_n.xml b/grc/blocks/gr_keep_m_in_n.xml new file mode 100644 index 0000000000..35a1561764 --- /dev/null +++ b/grc/blocks/gr_keep_m_in_n.xml @@ -0,0 +1,76 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Keep M in N +################################################### + --> +<block> + <name>Keep M in N</name> + <key>gr_keep_m_in_n</key> + <import>from gnuradio import gr</import> + <make>gr.keep_m_in_n($type.size, $m, $n, $offset)</make> + <callback>set_offset($offset)</callback> + <callback>set_m($m)</callback> + <callback>set_n($n)</callback> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>M</name> + <key>m</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>N</name> + <key>n</key> + <value>2</value> + <type>int</type> + </param> + <param> + <name>initial offset</name> + <key>offset</key> + <value>0</value> + <type>int</type> + </param> + <check>$n > 0</check> + <check>$m > 0</check> + <check>$m < $n</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>1</vlen> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>1</vlen> + </source> +</block> diff --git a/grc/blocks/gr_pack_k_bits_bb.xml b/grc/blocks/gr_pack_k_bits_bb.xml new file mode 100644 index 0000000000..34e64a5d96 --- /dev/null +++ b/grc/blocks/gr_pack_k_bits_bb.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Pack K Bits +################################################### + --> +<block> + <name>Pack K Bits</name> + <key>gr_pack_k_bits_bb</key> + <import>from gnuradio import gr</import> + <make>gr.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/grc/blocks/gr_vector_insert_x.xml b/grc/blocks/gr_vector_insert_x.xml new file mode 100644 index 0000000000..f9ce1f6544 --- /dev/null +++ b/grc/blocks/gr_vector_insert_x.xml @@ -0,0 +1,80 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Vector Source +################################################### + --> +<block> + <name>Vector Insert</name> + <key>gr_vector_insert_x</key> + <import>from gnuradio import gr</import> + <make>gr.vector_insert_$(type.fcn)($vector, $period, $offset)</make> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:b</opt> + <opt>vec_type:int_vector</opt> + </option> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:c</opt> + <opt>vec_type:complex_vector</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + <opt>vec_type:real_vector</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:i</opt> + <opt>vec_type:int_vector</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:s</opt> + <opt>vec_type:int_vector</opt> + </option> + </param> + <param> + <name>Vector</name> + <key>vector</key> + <value>0, 0, 0</value> + <type>$type.vec_type</type> + </param> + <param> + <name>Periodicity</name> + <key>period</key> + <value>100</value> + <type>int</type> + </param> + <param> + <name>Offset</name> + <key>offset</key> + <value>0</value> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> + + <doc> + Periodicity, the length of the periodicity at which the vector should be inserted at the output. + (i.e. one vector for every N output items) + + Offset sepcifies where in the cycle period we should begin at. + </doc> +</block> diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml index b27ea900cc..1cf0b77079 100644 --- a/grc/blocks/options.xml +++ b/grc/blocks/options.xml @@ -125,6 +125,19 @@ else: self.stop(); self.wait()</callback> </option> </param> <param> + <name>Max Number of Output</name> + <key>max_nouts</key> + <value>0</value> + <type>int</type> + <hide>#if $generate_options() == 'hb' +all#slurp +#elif $max_nouts() +none#slurp +#else +part#slurp +#end if</hide> + </param> + <param> <name>Realtime Scheduling</name> <key>realtime_scheduling</key> <value></value> @@ -169,5 +182,9 @@ For example, an id of my_block will generate the file my_block.py and class my_b The category parameter determines the placement of the block in the block selection window. \ The category only applies when creating hier blocks. \ To put hier blocks into the root category, enter / for the category. + +The Max Number of Output is the maximum number of output items allowed for any block \ +in the flowgraph; to disable this set the max_nouts equal to 0.\ +Use this to adjust the maximum latency a flowgraph can exhibit. </doc> </block> diff --git a/grc/python/Port.py b/grc/python/Port.py index d0ef51b483..9f8b50d052 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -139,6 +139,10 @@ class Port(_Port, _GUIPort): self._type = '' self._vlen = '' + def resolve_virtual_source(self): + if self.get_parent().is_virtual_sink(): return _get_source_from_virtual_sink_port(self) + if self.get_parent().is_virtual_source(): return _get_source_from_virtual_source_port(self) + def resolve_empty_type(self): if self.is_sink(): try: diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 0878be4ba3..17feb01f65 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -244,12 +244,20 @@ if __name__ == '__main__': #end if #if $generate_options == 'wx_gui' tb = $(class_name)($(', '.join($params_eq_list))) + #if $flow_graph.get_option('max_nouts') + tb.Run($flow_graph.get_option('run'), $flow_graph.get_option('max_nouts')) + #else tb.Run($flow_graph.get_option('run')) + #end if #elif $generate_options == 'qt_gui' qapp = Qt.QApplication(sys.argv) tb = $(class_name)($(', '.join($params_eq_list))) #if $flow_graph.get_option('run') + #if $flow_graph.get_option('max_nouts') + tb.start($flow_graph.get_option('max_nouts')) + #else tb.start() + #end if #end if tb.show() qapp.exec_() @@ -258,11 +266,19 @@ if __name__ == '__main__': tb = $(class_name)($(', '.join($params_eq_list))) #set $run_options = $flow_graph.get_option('run_options') #if $run_options == 'prompt' + #if $flow_graph.get_option('max_nouts') + tb.start($flow_graph.get_option('max_nouts')) + #else tb.start() + #end if raw_input('Press Enter to quit: ') tb.stop() #elif $run_options == 'run' + #if $flow_graph.get_option('max_nouts') + tb.run($flow_graph.get_option('max_nouts')) + #else tb.run() + #end if #end if #end if #end if diff --git a/gruel/src/lib/CMakeLists.txt b/gruel/src/lib/CMakeLists.txt index 2a96163ce1..e7713536ce 100644 --- a/gruel/src/lib/CMakeLists.txt +++ b/gruel/src/lib/CMakeLists.txt @@ -80,8 +80,14 @@ list(APPEND gruel_sources thread_group.cc ) +list(APPEND gruel_libs ${Boost_LIBRARIES}) + +if(HAVE_PTHREAD_SETSCHEDPARAM) + list(APPEND gruel_libs pthread) +endif() + add_library(gruel SHARED ${gruel_sources}) -target_link_libraries(gruel ${Boost_LIBRARIES} -lpthread) +target_link_libraries(gruel ${gruel_libs}) GR_LIBRARY_FOO(gruel RUNTIME_COMPONENT "gruel_runtime" DEVEL_COMPONENT "gruel_devel") ######################################################################## diff --git a/gruel/src/lib/pmt/pmt-serial-tags.scm b/gruel/src/lib/pmt/pmt-serial-tags.scm index ca25a43a8a..4f06bf75f8 100644 --- a/gruel/src/lib/pmt/pmt-serial-tags.scm +++ b/gruel/src/lib/pmt/pmt-serial-tags.scm @@ -33,6 +33,8 @@ (define pst-dict #x09) ; untagged-int32 n; followed by n key/value tuples (define pst-uniform-vector #x0a) +(define pst-uint64 #x0b) +(define pst-tuple #x0c) ;; u8, s8, u16, s16, u32, s32, u64, s64, f32, f64, c32, c64 ;; diff --git a/gruel/src/lib/pmt/pmt_serialize.cc b/gruel/src/lib/pmt/pmt_serialize.cc index de9644c3c6..a19809a667 100644 --- a/gruel/src/lib/pmt/pmt_serialize.cc +++ b/gruel/src/lib/pmt/pmt_serialize.cc @@ -79,7 +79,6 @@ serialize_untagged_f64(double i, std::streambuf &sb) } -#if 0 // always writes big-endian static bool serialize_untagged_u64(uint64_t i, std::streambuf &sb) @@ -93,7 +92,6 @@ serialize_untagged_u64(uint64_t i, std::streambuf &sb) sb.sputc((i >> 8) & 0xff); return sb.sputc((i >> 0) & 0xff) != std::streambuf::traits_type::eof(); } -#endif // ---------------------------------------------------------------- // input primitives @@ -152,7 +150,6 @@ deserialize_untagged_u32(uint32_t *ip, std::streambuf &sb) return t != std::streambuf::traits_type::eof(); } -#if 0 // always reads big-endian static bool deserialize_untagged_u64(uint64_t *ip, std::streambuf &sb) @@ -181,7 +178,6 @@ deserialize_untagged_u64(uint64_t *ip, std::streambuf &sb) *ip = i; return t != std::streambuf::traits_type::eof(); } -#endif static bool deserialize_untagged_f64(double *ip, std::streambuf &sb) @@ -217,6 +213,24 @@ deserialize_untagged_f64(double *ip, std::streambuf &sb) return t != std::streambuf::traits_type::eof(); } +static bool +deserialize_tuple(pmt_t *tuple, std::streambuf &sb) +{ + uint32_t nitems; + bool ok = deserialize_untagged_u32(&nitems, sb); + pmt_t list(PMT_NIL); + for(uint32_t i=0; i<nitems; i++){ + pmt_t item = pmt_deserialize( sb ); + if(pmt_eq(list, PMT_NIL)){ + list = pmt_list1(item); + } else { + list = pmt_list_add(list, item); + } + } + (*tuple) = pmt_to_tuple(list); + return ok; +} + /* * Write portable byte-serial representation of \p obj to \p sb @@ -260,7 +274,13 @@ pmt_serialize(pmt_t obj, std::streambuf &sb) } if (pmt_is_number(obj)){ - + + if (pmt_is_uint64(obj)){ + uint64_t i = pmt_to_uint64(obj); + ok = serialize_untagged_u8(PST_UINT64, sb); + ok &= serialize_untagged_u64(i, sb); + return ok; + } else if (pmt_is_integer(obj)){ long i = pmt_to_long(obj); if (sizeof(long) > 4){ @@ -298,6 +318,16 @@ pmt_serialize(pmt_t obj, std::streambuf &sb) if (pmt_is_dict(obj)) throw pmt_notimplemented("pmt_serialize (dict)", obj); + if (pmt_is_tuple(obj)){ + size_t tuple_len = pmt::pmt_length(obj); + ok = serialize_untagged_u8(PST_TUPLE, sb); + ok &= serialize_untagged_u32(tuple_len, sb); + for(size_t i=0; i<tuple_len; i++){ + ok &= pmt_serialize(pmt_tuple_ref(obj, i), sb); + } + return ok; + } + //throw pmt_notimplemented("pmt_serialize (tuple)", obj); throw pmt_notimplemented("pmt_serialize (?)", obj); } @@ -315,7 +345,7 @@ pmt_deserialize(std::streambuf &sb) //uint8_t u8; uint16_t u16; uint32_t u32; - //uint32_t u64; + uint64_t u64; double f64; static char tmpbuf[1024]; @@ -347,6 +377,11 @@ pmt_deserialize(std::streambuf &sb) goto error; return pmt_from_long((int32_t) u32); + case PST_UINT64: + if(!deserialize_untagged_u64(&u64, sb)) + goto error; + return pmt_from_uint64(u64); + case PST_PAIR: return parse_pair(sb); @@ -362,6 +397,15 @@ pmt_deserialize(std::streambuf &sb) goto error; return pmt_make_rectangular( r,i ); } + + case PST_TUPLE: + { + pmt_t tuple; + if(!deserialize_tuple(&tuple, sb)){ + goto error; + } + return tuple; + } case PST_VECTOR: case PST_DICT: diff --git a/volk/apps/volk_profile.cc b/volk/apps/volk_profile.cc index 09ee8410c4..6244abb357 100644 --- a/volk/apps/volk_profile.cc +++ b/volk/apps/volk_profile.cc @@ -16,6 +16,7 @@ int main(int argc, char *argv[]) { //VOLK_PROFILE(volk_16i_x5_add_quad_16i_x4_a, 1e-4, 2046, 10000, &results); //VOLK_PROFILE(volk_16i_branch_4_state_8_a, 1e-4, 2046, 10000, &results); + VOLK_PUPPET_PROFILE(volk_32fc_s32fc_rotatorpuppet_32fc_a, volk_32fc_s32fc_x2_rotator_32fc_a, 1e-2, (lv_32fc_t)lv_cmake(.95393, .3), 20460, 10000, &results); VOLK_PROFILE(volk_16ic_s32f_deinterleave_real_32f_a, 1e-5, 32768.0, 204600, 10000, &results); VOLK_PROFILE(volk_16ic_deinterleave_real_8i_a, 0, 0, 204600, 10000, &results); VOLK_PROFILE(volk_16ic_deinterleave_16i_x2_a, 0, 0, 204600, 10000, &results); diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml index 2c9ab41a55..a18455801d 100644 --- a/volk/gen/archs.xml +++ b/volk/gen/archs.xml @@ -2,6 +2,7 @@ <grammar> <arch name="generic"> <!-- name is required--> + <alignment>1</alignment> </arch> <arch name="altivec"> diff --git a/volk/include/volk/volk_32f_x2_dot_prod_32f_a.h b/volk/include/volk/volk_32f_x2_dot_prod_32f_a.h index c26fd5e7cc..067c33ad89 100644 --- a/volk/include/volk/volk_32f_x2_dot_prod_32f_a.h +++ b/volk/include/volk/volk_32f_x2_dot_prod_32f_a.h @@ -226,6 +226,8 @@ static inline void volk_32f_x2_dot_prod_32f_a_sse4_1(float * result, const float #ifdef LV_HAVE_AVX +#include <immintrin.h> + static inline void volk_32f_x2_dot_prod_32f_a_avx( float* result, const float* input, const float* taps, unsigned int num_points) { unsigned int number = 0; diff --git a/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h b/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h index f9ae150942..ab33a25876 100644 --- a/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h +++ b/volk/include/volk/volk_32f_x2_dot_prod_32f_u.h @@ -229,6 +229,8 @@ static inline void volk_32f_x2_dot_prod_32f_u_sse4_1(float * result, const float #ifdef LV_HAVE_AVX +#include <immintrin.h> + static inline void volk_32f_x2_dot_prod_32f_u_avx( float* result, const float* input, const float* taps, unsigned int num_points) { unsigned int number = 0; diff --git a/volk/include/volk/volk_32fc_s32fc_rotatorpuppet_32fc_a.h b/volk/include/volk/volk_32fc_s32fc_rotatorpuppet_32fc_a.h new file mode 100644 index 0000000000..eee9f0064f --- /dev/null +++ b/volk/include/volk/volk_32fc_s32fc_rotatorpuppet_32fc_a.h @@ -0,0 +1,74 @@ +#ifndef INCLUDED_volk_32fc_s32fc_rotatorpuppet_32fc_a_H +#define INCLUDED_volk_32fc_s32fc_rotatorpuppet_32fc_a_H + + +#include <volk/volk_complex.h> +#include <stdio.h> +#include <volk/volk_32fc_s32fc_x2_rotator_32fc_a.h> + + +#ifdef LV_HAVE_GENERIC + +/*! + \brief rotate input vector at fixed rate per sample from initial phase offset + \param outVector The vector where the results will be stored + \param inVector Vector to be rotated + \param phase_inc rotational velocity + \param phase initial phase offset + \param num_points The number of values in inVector to be rotated and stored into cVector +*/ + + +static inline void volk_32fc_s32fc_rotatorpuppet_32fc_a_generic(lv_32fc_t* outVector, const lv_32fc_t* inVector, const lv_32fc_t phase_inc, unsigned int num_points){ + lv_32fc_t phase[1] = {lv_cmake(.3, 0.95393)}; + volk_32fc_s32fc_x2_rotator_32fc_a_generic(outVector, inVector, phase_inc, phase, num_points); + +} +#endif /* LV_HAVE_GENERIC */ + + +#ifdef LV_HAVE_SSE4_1 +#include <smmintrin.h> + +static inline void volk_32fc_s32fc_rotatorpuppet_32fc_a_sse4_1(lv_32fc_t* outVector, const lv_32fc_t* inVector, const lv_32fc_t phase_inc, unsigned int num_points){ + lv_32fc_t phase[1] = {lv_cmake(.3, .95393)}; + volk_32fc_s32fc_x2_rotator_32fc_a_sse4_1(outVector, inVector, phase_inc, phase, num_points); + +} + + + + +#endif /* LV_HAVE_SSE4_1 */ + +#ifdef LV_HAVE_AVX +#include <immintrin.h> + +/*! + \brief rotate input vector at fixed rate per sample from initial phase offset + \param outVector The vector where the results will be stored + \param inVector Vector to be rotated + \param phase_inc rotational velocity + \param phase initial phase offset + \param num_points The number of values in inVector to be rotated and stored into cVector +*/ + + + + +static inline void volk_32fc_s32fc_rotatorpuppet_32fc_a_avx(lv_32fc_t* outVector, const lv_32fc_t* inVector, const lv_32fc_t phase_inc, unsigned int num_points){ + lv_32fc_t phase[1] = {lv_cmake(.3, .95393)}; + volk_32fc_s32fc_x2_rotator_32fc_a_avx(outVector, inVector, phase_inc, phase, num_points); + +} + +#endif /* LV_HAVE_AVX */ + + + + + + + + +#endif /* INCLUDED_volk_32fc_s32fc_rotatorpuppet_32fc_a_H */ diff --git a/volk/include/volk/volk_32fc_s32fc_x2_rotator_32fc_a.h b/volk/include/volk/volk_32fc_s32fc_x2_rotator_32fc_a.h new file mode 100644 index 0000000000..80c55e75f3 --- /dev/null +++ b/volk/include/volk/volk_32fc_s32fc_x2_rotator_32fc_a.h @@ -0,0 +1,262 @@ +#ifndef INCLUDED_volk_32fc_s32fc_rotator_32fc_a_H +#define INCLUDED_volk_32fc_s32fc_rotator_32fc_a_H + + +#include <volk/volk_complex.h> +#include <stdio.h> +#include <stdlib.h> +#define ROTATOR_RELOAD 512 + + +#ifdef LV_HAVE_GENERIC + +/*! + \brief rotate input vector at fixed rate per sample from initial phase offset + \param outVector The vector where the results will be stored + \param inVector Vector to be rotated + \param phase_inc rotational velocity + \param phase initial phase offset + \param num_points The number of values in inVector to be rotated and stored into cVector +*/ + + +static inline void volk_32fc_s32fc_x2_rotator_32fc_a_generic(lv_32fc_t* outVector, const lv_32fc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points){ + *phase = lv_cmake(1.0, 0.0); + unsigned int i = 0; + int j = 0; + for(i = 0; i < (unsigned int)(num_points/ROTATOR_RELOAD); ++i) { + for(j = 0; j < ROTATOR_RELOAD; ++j) { + *outVector++ = *inVector++ * (*phase); + (*phase) *= phase_inc; + } + (*phase) /= abs((*phase)); + } + for(i = 0; i < num_points%ROTATOR_RELOAD; ++i) { + *outVector++ = *inVector++ * (*phase); + (*phase) *= phase_inc; + } + +} +#endif /* LV_HAVE_GENERIC */ + + +#ifdef LV_HAVE_SSE4_1 +#include <smmintrin.h> + +static inline void volk_32fc_s32fc_x2_rotator_32fc_a_sse4_1(lv_32fc_t* outVector, const lv_32fc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points){ + *phase = lv_cmake(1.0, 0.0); + lv_32fc_t* cPtr = outVector; + const lv_32fc_t* aPtr = inVector; + lv_32fc_t incr = 1; + lv_32fc_t phase_Ptr[2] = {(*phase), (*phase)}; + + unsigned int i, j = 0; + + for(i = 0; i < 2; ++i) { + phase_Ptr[i] *= incr; + incr *= (phase_inc); + } + + /*printf("%f, %f\n", lv_creal(phase_Ptr[0]), lv_cimag(phase_Ptr[0])); + printf("%f, %f\n", lv_creal(phase_Ptr[1]), lv_cimag(phase_Ptr[1])); + printf("%f, %f\n", lv_creal(phase_Ptr[2]), lv_cimag(phase_Ptr[2])); + printf("%f, %f\n", lv_creal(phase_Ptr[3]), lv_cimag(phase_Ptr[3])); + printf("incr: %f, %f\n", lv_creal(incr), lv_cimag(incr));*/ + __m128 aVal, phase_Val, inc_Val, yl, yh, tmp1, tmp2, z, ylp, yhp, tmp1p, tmp2p; + + phase_Val = _mm_loadu_ps((float*)phase_Ptr); + inc_Val = _mm_set_ps(lv_cimag(incr), lv_creal(incr),lv_cimag(incr), lv_creal(incr)); + + const unsigned int halfPoints = num_points / 2; + + + for(i = 0; i < (unsigned int)(halfPoints/ROTATOR_RELOAD); i++) { + for(j = 0; j < ROTATOR_RELOAD; ++j) { + + aVal = _mm_load_ps((float*)aPtr); + + yl = _mm_moveldup_ps(phase_Val); + yh = _mm_movehdup_ps(phase_Val); + ylp = _mm_moveldup_ps(inc_Val); + yhp = _mm_movehdup_ps(inc_Val); + + tmp1 = _mm_mul_ps(aVal, yl); + tmp1p = _mm_mul_ps(phase_Val, ylp); + + aVal = _mm_shuffle_ps(aVal, aVal, 0xB1); + phase_Val = _mm_shuffle_ps(phase_Val, phase_Val, 0xB1); + tmp2 = _mm_mul_ps(aVal, yh); + tmp2p = _mm_mul_ps(phase_Val, yhp); + + z = _mm_addsub_ps(tmp1, tmp2); + phase_Val = _mm_addsub_ps(tmp1p, tmp2p); + + _mm_store_ps((float*)cPtr, z); + + aPtr += 2; + cPtr += 2; + } + tmp1 = _mm_mul_ps(phase_Val, phase_Val); + tmp2 = _mm_hadd_ps(tmp1, tmp1); + tmp1 = _mm_shuffle_ps(tmp2, tmp2, 0xD8); + phase_Val = _mm_div_ps(phase_Val, tmp1); + } + for(i = 0; i < halfPoints%ROTATOR_RELOAD; ++i) { + aVal = _mm_load_ps((float*)aPtr); + + yl = _mm_moveldup_ps(phase_Val); + yh = _mm_movehdup_ps(phase_Val); + ylp = _mm_moveldup_ps(inc_Val); + yhp = _mm_movehdup_ps(inc_Val); + + tmp1 = _mm_mul_ps(aVal, yl); + + tmp1p = _mm_mul_ps(phase_Val, ylp); + + aVal = _mm_shuffle_ps(aVal, aVal, 0xB1); + phase_Val = _mm_shuffle_ps(phase_Val, phase_Val, 0xB1); + tmp2 = _mm_mul_ps(aVal, yh); + tmp2p = _mm_mul_ps(phase_Val, yhp); + + z = _mm_addsub_ps(tmp1, tmp2); + phase_Val = _mm_addsub_ps(tmp1p, tmp2p); + + _mm_store_ps((float*)cPtr, z); + + aPtr += 2; + cPtr += 2; + } + + _mm_storeu_ps((float*)phase_Ptr, phase_Val); + for(i = 0; i < num_points%2; ++i) { + *cPtr++ = *aPtr++ * phase_Ptr[0]; + phase_Ptr[0] *= (phase_inc); + } + + (*phase) = phase_Ptr[0]; + +} + +#endif /* LV_HAVE_SSE4_1 */ + + +#ifdef LV_HAVE_AVX +#include <immintrin.h> + +/*! + \brief rotate input vector at fixed rate per sample from initial phase offset + \param outVector The vector where the results will be stored + \param inVector Vector to be rotated + \param phase_inc rotational velocity + \param phase initial phase offset + \param num_points The number of values in inVector to be rotated and stored into cVector +*/ + + + + +static inline void volk_32fc_s32fc_x2_rotator_32fc_a_avx(lv_32fc_t* outVector, const lv_32fc_t* inVector, const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points){ + *phase = lv_cmake(1.0, 0.0); + lv_32fc_t* cPtr = outVector; + const lv_32fc_t* aPtr = inVector; + lv_32fc_t incr = 1; + lv_32fc_t phase_Ptr[4] = {(*phase), (*phase), (*phase), (*phase)}; + + unsigned int i, j = 0; + + for(i = 0; i < 4; ++i) { + phase_Ptr[i] *= incr; + incr *= (phase_inc); + } + + /*printf("%f, %f\n", lv_creal(phase_Ptr[0]), lv_cimag(phase_Ptr[0])); + printf("%f, %f\n", lv_creal(phase_Ptr[1]), lv_cimag(phase_Ptr[1])); + printf("%f, %f\n", lv_creal(phase_Ptr[2]), lv_cimag(phase_Ptr[2])); + printf("%f, %f\n", lv_creal(phase_Ptr[3]), lv_cimag(phase_Ptr[3])); + printf("incr: %f, %f\n", lv_creal(incr), lv_cimag(incr));*/ + __m256 aVal, phase_Val, inc_Val, yl, yh, tmp1, tmp2, z, ylp, yhp, tmp1p, tmp2p, negated, zeros; + + phase_Val = _mm256_loadu_ps((float*)phase_Ptr); + inc_Val = _mm256_set_ps(lv_cimag(incr), lv_creal(incr),lv_cimag(incr), lv_creal(incr),lv_cimag(incr), lv_creal(incr),lv_cimag(incr), lv_creal(incr)); + zeros = _mm256_set1_ps(0.0); + negated = _mm256_set1_ps(-1.0); + const unsigned int fourthPoints = num_points / 4; + + + for(i = 0; i < (unsigned int)(fourthPoints/ROTATOR_RELOAD); i++) { + for(j = 0; j < ROTATOR_RELOAD; ++j) { + + aVal = _mm256_load_ps((float*)aPtr); + + yl = _mm256_moveldup_ps(phase_Val); + yh = _mm256_movehdup_ps(phase_Val); + ylp = _mm256_moveldup_ps(inc_Val); + yhp = _mm256_movehdup_ps(inc_Val); + + tmp1 = _mm256_mul_ps(aVal, yl); + tmp1p = _mm256_mul_ps(phase_Val, ylp); + + aVal = _mm256_shuffle_ps(aVal, aVal, 0xB1); + phase_Val = _mm256_shuffle_ps(phase_Val, phase_Val, 0xB1); + tmp2 = _mm256_mul_ps(aVal, yh); + tmp2p = _mm256_mul_ps(phase_Val, yhp); + + z = _mm256_addsub_ps(tmp1, tmp2); + phase_Val = _mm256_addsub_ps(tmp1p, tmp2p); + + _mm256_store_ps((float*)cPtr, z); + + aPtr += 4; + cPtr += 4; + } + tmp1 = _mm256_mul_ps(phase_Val, phase_Val); + tmp2 = _mm256_hadd_ps(tmp1, tmp1); + tmp1 = _mm256_shuffle_ps(tmp2, tmp2, 0xD8); + phase_Val = _mm256_div_ps(phase_Val, tmp1); + } + for(i = 0; i < fourthPoints%ROTATOR_RELOAD; ++i) { + aVal = _mm256_load_ps((float*)aPtr); + + yl = _mm256_moveldup_ps(phase_Val); + yh = _mm256_movehdup_ps(phase_Val); + ylp = _mm256_moveldup_ps(inc_Val); + yhp = _mm256_movehdup_ps(inc_Val); + + tmp1 = _mm256_mul_ps(aVal, yl); + + tmp1p = _mm256_mul_ps(phase_Val, ylp); + + aVal = _mm256_shuffle_ps(aVal, aVal, 0xB1); + phase_Val = _mm256_shuffle_ps(phase_Val, phase_Val, 0xB1); + tmp2 = _mm256_mul_ps(aVal, yh); + tmp2p = _mm256_mul_ps(phase_Val, yhp); + + z = _mm256_addsub_ps(tmp1, tmp2); + phase_Val = _mm256_addsub_ps(tmp1p, tmp2p); + + _mm256_store_ps((float*)cPtr, z); + + aPtr += 4; + cPtr += 4; + } + + _mm256_storeu_ps((float*)phase_Ptr, phase_Val); + for(i = 0; i < num_points%4; ++i) { + *cPtr++ = *aPtr++ * phase_Ptr[0]; + phase_Ptr[0] *= (phase_inc); + } + + (*phase) = phase_Ptr[0]; + +} + +#endif /* LV_HAVE_AVX */ + + + + + + + + +#endif /* INCLUDED_volk_32fc_s32fc_rotator_32fc_a_H */ diff --git a/volk/include/volk/volk_64u_popcnt_a.h b/volk/include/volk/volk_64u_popcnt_a.h index 7d7359ccf6..5e68ed2083 100644 --- a/volk/include/volk/volk_64u_popcnt_a.h +++ b/volk/include/volk/volk_64u_popcnt_a.h @@ -14,7 +14,7 @@ static inline void volk_64u_popcnt_a_generic(uint64_t* ret, const uint64_t value // This is faster than a lookup table //uint32_t retVal = valueVector[0]; - uint32_t retVal = (uint32_t)(value && 0x00000000FFFFFFFF); + uint32_t retVal = (uint32_t)(value & 0x00000000FFFFFFFF); retVal = (retVal & 0x55555555) + (retVal >> 1 & 0x55555555); retVal = (retVal & 0x33333333) + (retVal >> 2 & 0x33333333); @@ -24,7 +24,7 @@ static inline void volk_64u_popcnt_a_generic(uint64_t* ret, const uint64_t value uint64_t retVal64 = retVal; //retVal = valueVector[1]; - retVal = (uint32_t)((value && 0xFFFFFFFF00000000) >> 31); + retVal = (uint32_t)((value & 0xFFFFFFFF00000000) >> 31); retVal = (retVal & 0x55555555) + (retVal >> 1 & 0x55555555); retVal = (retVal & 0x33333333) + (retVal >> 2 & 0x33333333); retVal = (retVal + (retVal >> 4)) & 0x0F0F0F0F; diff --git a/volk/lib/qa_utils.cc b/volk/lib/qa_utils.cc index c15979b3f2..4e361aece2 100644 --- a/volk/lib/qa_utils.cc +++ b/volk/lib/qa_utils.cc @@ -15,6 +15,7 @@ #include <volk/volk_common.h> #include <boost/typeof/typeof.hpp> #include <boost/type_traits.hpp> +#include <stdio.h> float uniform() { return 2.0 * ((float) rand() / RAND_MAX - 0.5); // uniformly (-1, 1) @@ -168,6 +169,7 @@ static void get_signatures_from_name(std::vector<volk_type_t> &inputsig, } //we don't need an output signature (some fn's operate on the input data, "in place"), but we do need at least one input! assert(inputsig.size() != 0); + } inline void run_cast_test1(volk_fn_1arg func, std::vector<void *> &buffs, unsigned int vlen, unsigned int iter, std::string arch) { @@ -261,7 +263,8 @@ bool run_volk_tests(struct volk_func_desc desc, lv_32fc_t scalar, int vlen, int iter, - std::vector<std::string> *best_arch_vector = 0 + std::vector<std::string> *best_arch_vector = 0, + std::string puppet_master_name = "NULL" ) { std::cout << "RUN_VOLK_TESTS: " << name << std::endl; @@ -279,16 +282,16 @@ bool run_volk_tests(struct volk_func_desc desc, //now we have to get a function signature by parsing the name std::vector<volk_type_t> inputsig, outputsig; get_signatures_from_name(inputsig, outputsig, name); - + //pull the input scalars into their own vector std::vector<volk_type_t> inputsc; for(size_t i=0; i<inputsig.size(); i++) { if(inputsig[i].is_scalar) { inputsc.push_back(inputsig[i]); inputsig.erase(inputsig.begin() + i); + i -= 1; } } - //for(int i=0; i<inputsig.size(); i++) std::cout << "Input: " << inputsig[i].str << std::endl; //for(int i=0; i<outputsig.size(); i++) std::cout << "Output: " << outputsig[i].str << std::endl; std::vector<void *> inbuffs; @@ -450,7 +453,12 @@ bool run_volk_tests(struct volk_func_desc desc, std::cout << "Best arch: " << best_arch << std::endl; if(best_arch_vector) { - best_arch_vector->push_back(name + std::string(" ") + best_arch); + if(puppet_master_name == "NULL") { + best_arch_vector->push_back(name + std::string(" ") + best_arch); + } + else { + best_arch_vector->push_back(puppet_master_name + std::string(" ") + best_arch); + } } return fail_global; diff --git a/volk/lib/qa_utils.h b/volk/lib/qa_utils.h index b998df852e..1e639ac3c6 100644 --- a/volk/lib/qa_utils.h +++ b/volk/lib/qa_utils.h @@ -21,10 +21,12 @@ volk_type_t volk_type_from_string(std::string); float uniform(void); void random_floats(float *buf, unsigned n); -bool run_volk_tests(struct volk_func_desc, void(*)(), std::string, float, lv_32fc_t, int, int, std::vector<std::string> *); +bool run_volk_tests(struct volk_func_desc, void(*)(), std::string, float, lv_32fc_t, int, int, std::vector<std::string> *, std::string); -#define VOLK_RUN_TESTS(func, tol, scalar, len, iter) BOOST_AUTO_TEST_CASE(func##_test) { BOOST_CHECK_EQUAL(run_volk_tests(func##_get_func_desc(), (void (*)())func##_manual, std::string(#func), tol, scalar, len, iter, 0), 0); } -#define VOLK_PROFILE(func, tol, scalar, len, iter, results) run_volk_tests(func##_get_func_desc(), (void (*)())func##_manual, std::string(#func), tol, scalar, len, iter, results) + +#define VOLK_RUN_TESTS(func, tol, scalar, len, iter) BOOST_AUTO_TEST_CASE(func##_test) { BOOST_CHECK_EQUAL(run_volk_tests(func##_get_func_desc(), (void (*)())func##_manual, std::string(#func), tol, scalar, len, iter, 0, "NULL"), 0); } +#define VOLK_PROFILE(func, tol, scalar, len, iter, results) run_volk_tests(func##_get_func_desc(), (void (*)())func##_manual, std::string(#func), tol, scalar, len, iter, results, "NULL") +#define VOLK_PUPPET_PROFILE(func, puppet_master_func, tol, scalar, len, iter, results) run_volk_tests(func##_get_func_desc(), (void (*)())func##_manual, std::string(#func), tol, scalar, len, iter, results, std::string(#puppet_master_func)) typedef void (*volk_fn_1arg)(void *, unsigned int, const char*); //one input, operate in place typedef void (*volk_fn_2arg)(void *, void *, unsigned int, const char*); typedef void (*volk_fn_3arg)(void *, void *, void *, unsigned int, const char*); diff --git a/volk/lib/testqa.cc b/volk/lib/testqa.cc index cfa8a91959..813e622172 100644 --- a/volk/lib/testqa.cc +++ b/volk/lib/testqa.cc @@ -104,3 +104,4 @@ VOLK_RUN_TESTS(volk_32fc_s32fc_multiply_32fc_a, 1e-4, 0, 20460, 1); VOLK_RUN_TESTS(volk_32fc_s32fc_multiply_32fc_u, 1e-4, 0, 20460, 1); VOLK_RUN_TESTS(volk_32f_s32f_multiply_32f_a, 1e-4, 0, 20460, 1); VOLK_RUN_TESTS(volk_32f_s32f_multiply_32f_u, 1e-4, 0, 20460, 1); +VOLK_RUN_TESTS(volk_32fc_s32fc_rotatorpuppet_32fc_a, 1e-2, (lv_32fc_t)lv_cmake(0.953939201, 0.3), 20460, 1); |