├── LICENSE ├── README.md ├── doc └── darcdec.odt └── src ├── gr-darc ├── .gitignore ├── CMakeLists.txt ├── apps │ ├── CMakeLists.txt │ ├── darc_rx.grc │ ├── darc_tx.grc │ ├── darc_tx_TEST.grc │ └── testbench.grc ├── cmake │ ├── Modules │ │ ├── CMakeParseArgumentsCopy.cmake │ │ ├── FindCppUnit.cmake │ │ ├── FindGnuradioRuntime.cmake │ │ ├── GrMiscUtils.cmake │ │ ├── GrPlatform.cmake │ │ ├── GrPython.cmake │ │ ├── GrSwig.cmake │ │ ├── GrTest.cmake │ │ ├── UseSWIG.cmake │ │ └── darcConfig.cmake │ └── cmake_uninstall.cmake.in ├── docs │ ├── CMakeLists.txt │ ├── README.darc │ └── 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 │ └── README ├── grc │ ├── CMakeLists.txt │ ├── darc_layer2.xml │ ├── darc_layer2_format.xml │ └── darc_layer2_sync.xml ├── include │ └── darc │ │ ├── CMakeLists.txt │ │ ├── api.h │ │ ├── layer2.h │ │ ├── layer2_format.h │ │ └── layer2_sync.h ├── lib │ ├── CMakeLists.txt │ ├── Makefile │ ├── bitarray │ │ ├── .gitignore │ │ ├── COPYING │ │ ├── COPYING.LESSER │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README │ │ ├── bitarray.cpp │ │ ├── bitarray.h │ │ ├── bitarraycrc.cpp │ │ ├── bitarraycrc.h │ │ └── sample.cpp │ ├── darc_constants.h │ ├── layer2_format_impl.cc │ ├── layer2_format_impl.h │ ├── layer2_impl.cc │ ├── layer2_impl.h │ ├── layer2_sync_impl.cc │ ├── layer2_sync_impl.h │ ├── qa_darc.cc │ ├── qa_darc.h │ └── test_darc.cc ├── python │ ├── CMakeLists.txt │ ├── __init__.py │ ├── build_utils.py │ ├── build_utils_codes.py │ ├── qa_layer2.py │ └── qa_layer2_sync.py └── swig │ ├── CMakeLists.txt │ └── darc_swig.i └── py ├── .gitignore ├── __init__.py ├── create_frame.py ├── darc_prototype.py ├── darc_syndrome_generator.py ├── darc_udp.py ├── darccrc.py └── darcstack.py /README.md: -------------------------------------------------------------------------------- 1 | # Data Radio Channel (DARC) 2 | Implementation for python and gnuradio, following ETSI EN 300 751 v1.2.1 3 | 4 | ## Contents 5 | 6 | `./docs/` 7 | 8 | Documentation about the MVG Layer 6 Protocol, gained from reverse engineering 9 | 10 | `./src/gr-darc/` 11 | 12 | Gnuradio implementation of Layer 1 and Layer 2 13 | 14 | `./src/py/` 15 | 16 | Python implementation of Layer 2-5 17 | 18 | ## Operation 19 | 20 | There are several possibilities to use the DARC implementation: 21 | 22 | ### Offline 23 | 24 | Receive and demodulate the DARC signal and dump the bitstream to a file, then open it using 25 | 26 | `python darc_prototype.py ` 27 | 28 | ### Online 29 | 30 | You can find the Gnurado Flowgraph here: 31 | 32 | `src/gr-darc/apps/darc_rx.grc` 33 | 34 | Receive and demodulate the DARC signal and process it using the DARC Layer2 block. Use the UDP sink to provide the Layer 2 data on the network. Process the other layers using 35 | 36 | `python darc_udp.py` 37 | 38 | ## Installation of the gr-darc out of tree module 39 | 40 | Info Used GnuRadio-Version: 3.7.5.1 41 | 42 | In the gr-darc folder: 43 | 44 | ``` 45 | mkdir build 46 | cd build 47 | cmake .. 48 | sudo make install 49 | sudo ldconfig 50 | ``` 51 | 52 | ## Station IDs in Munich 53 | 54 | | ID | ID (Hex) | Stop | Direction/Destination | 55 | | ---- |:--------:| :-----|:----------------------| 56 | | 1509 | 0x05E5 | Schluesselbergstr | Tram 19 -> Pasing | 57 | | 1510 | 0x05E6 | Schluesselbergstr | Tram 19 -> StVeitstr | 58 | | 1549 | 0x060D | Grillparzer | Bus 187 -> Ruemelinstr | Bus 190 -> Messe Ost | 59 | | 1625 | 0x0659 | Adunistr | Bus 53 -> Aidenbachstr | 60 | | 1626 | 0x065A | Adunistr | Bus 53 -> Muenchner Freiheit | 61 | | 1642 | 0x066A | Lehel | Tram 18 -> Gondrellplatz | 62 | | 1701 | 0x06A5 | Einsteinstr | Bus 144 -> Ackermannbogen | 63 | | 1761 | 0x06E1 | Sendlinger Tor | Bus 62 -> Ostbahnhof | 64 | | 1775 | 0x06EF | Waltherstr | Bus 62 -> Rotkreuzplatz | 65 | | 1800 | 0x0708 | Mariannenplatz | Gondrellplatz | 66 | | 1814 | 0x0716 | Maxmonument | Tram 19 -> StVeitstr | 67 | | 1818 | 0x071A | Maxmonument | Tram 19 -> Pasing | 68 | | 1840 | 0x0730 | Mariannenplatz | Effnerplatz | 69 | | 1923 | 0x0783 | Waltherstr | Bus 62 -> Ostbahnhof | 70 | | 1927 | 0x0787 | Isator/Zweibrueckenstr | Bus 132 -> Forstenrieder Park | 71 | 72 | ## Ressources 73 | 74 | ### Official 75 | 76 | * https://www.axentia.se/en/products/ibus-displays/battery-operated 77 | 78 | * http://www.etsi.org/deliver/etsi_en/300700_300799/300751/01.02.01_60/en_300751v010201p.pdf 79 | 80 | ### Projects 81 | 82 | * http://www.windytan.com/2013/11/broadcast-messages-on-darc-side.html 83 | 84 | * https://apollo.open-resource.org/mission:log:2014:08:08:darc-side-of-munich-hunting-fm-broadcasts-for-bus-and-tram-display-information-on-90-mhz 85 | 86 | * http://www.tramgeschichten.de/2009/09/19/auf-der-spur-des-geheimen-dfi-datensignals/ 87 | -------------------------------------------------------------------------------- /doc/darcdec.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muccc/darc/eb48fcb9f038dd1119681c653e186ac71ee9a9a8/doc/darcdec.odt -------------------------------------------------------------------------------- /src/gr-darc/.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | -------------------------------------------------------------------------------- /src/gr-darc/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-darc 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 darc") 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/darc) 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 darc") 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_DARC_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE INTERNAL "" FORCE) 150 | set(GR_DARC_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/darc) 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/darcConfig.cmake 183 | DESTINATION ${CMAKE_MODULES_DIR}/darc 184 | ) 185 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/apps/testbench.grc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mon Mar 16 18:46:32 2015 5 | 6 | options 7 | 8 | id 9 | top_block 10 | 11 | 12 | _enabled 13 | True 14 | 15 | 16 | title 17 | 18 | 19 | 20 | author 21 | 22 | 23 | 24 | description 25 | 26 | 27 | 28 | window_size 29 | 1280, 1024 30 | 31 | 32 | generate_options 33 | wx_gui 34 | 35 | 36 | category 37 | Custom 38 | 39 | 40 | run_options 41 | prompt 42 | 43 | 44 | run 45 | True 46 | 47 | 48 | max_nouts 49 | 0 50 | 51 | 52 | realtime_scheduling 53 | 54 | 55 | 56 | alias 57 | 58 | 59 | 60 | _coordinate 61 | (10, 10) 62 | 63 | 64 | _rotation 65 | 0 66 | 67 | 68 | 69 | variable 70 | 71 | id 72 | samp_rate 73 | 74 | 75 | _enabled 76 | True 77 | 78 | 79 | value 80 | 16000 81 | 82 | 83 | alias 84 | 85 | 86 | 87 | _coordinate 88 | (10, 170) 89 | 90 | 91 | _rotation 92 | 0 93 | 94 | 95 | 96 | blocks_file_source 97 | 98 | id 99 | blocks_file_source_0 100 | 101 | 102 | _enabled 103 | True 104 | 105 | 106 | file 107 | /home/chris/Desktop/testfile.gnuradio 108 | 109 | 110 | type 111 | byte 112 | 113 | 114 | repeat 115 | False 116 | 117 | 118 | vlen 119 | 1 120 | 121 | 122 | alias 123 | 124 | 125 | 126 | affinity 127 | 128 | 129 | 130 | minoutbuf 131 | 0 132 | 133 | 134 | maxoutbuf 135 | 0 136 | 137 | 138 | _coordinate 139 | (104, 315) 140 | 141 | 142 | _rotation 143 | 0 144 | 145 | 146 | 147 | blocks_throttle 148 | 149 | id 150 | blocks_throttle_0 151 | 152 | 153 | _enabled 154 | True 155 | 156 | 157 | type 158 | byte 159 | 160 | 161 | samples_per_second 162 | samp_rate 163 | 164 | 165 | vlen 166 | 1 167 | 168 | 169 | ignoretag 170 | True 171 | 172 | 173 | alias 174 | 175 | 176 | 177 | affinity 178 | 179 | 180 | 181 | minoutbuf 182 | 0 183 | 184 | 185 | maxoutbuf 186 | 0 187 | 188 | 189 | _coordinate 190 | (368, 323) 191 | 192 | 193 | _rotation 194 | 0 195 | 196 | 197 | 198 | blocks_null_sink 199 | 200 | id 201 | blocks_null_sink_0 202 | 203 | 204 | _enabled 205 | True 206 | 207 | 208 | type 209 | byte 210 | 211 | 212 | vlen 213 | 24 214 | 215 | 216 | num_inputs 217 | 1 218 | 219 | 220 | bus_conns 221 | [[0,],] 222 | 223 | 224 | alias 225 | 226 | 227 | 228 | affinity 229 | 230 | 231 | 232 | _coordinate 233 | (744, 323) 234 | 235 | 236 | _rotation 237 | 0 238 | 239 | 240 | 241 | blocks_udp_sink 242 | 243 | id 244 | blocks_udp_sink_0 245 | 246 | 247 | _enabled 248 | False 249 | 250 | 251 | type 252 | byte 253 | 254 | 255 | ipaddr 256 | 127.0.0.1 257 | 258 | 259 | port 260 | 51337 261 | 262 | 263 | psize 264 | 24 265 | 266 | 267 | eof 268 | True 269 | 270 | 271 | vlen 272 | 24 273 | 274 | 275 | alias 276 | 277 | 278 | 279 | affinity 280 | 281 | 282 | 283 | _coordinate 284 | (744, 195) 285 | 286 | 287 | _rotation 288 | 0 289 | 290 | 291 | 292 | darc_layer2_sync 293 | 294 | id 295 | darc_layer2_sync_0 296 | 297 | 298 | _enabled 299 | True 300 | 301 | 302 | log 303 | 0 304 | 305 | 306 | debug 307 | 0 308 | 309 | 310 | alias 311 | 312 | 313 | 314 | affinity 315 | 316 | 317 | 318 | minoutbuf 319 | 0 320 | 321 | 322 | maxoutbuf 323 | 0 324 | 325 | 326 | _coordinate 327 | (424, 219) 328 | 329 | 330 | _rotation 331 | 0 332 | 333 | 334 | 335 | darc_layer2_format 336 | 337 | id 338 | darc_layer2_format_0 339 | 340 | 341 | _enabled 342 | True 343 | 344 | 345 | log 346 | 1 347 | 348 | 349 | debug 350 | 1 351 | 352 | 353 | crc 354 | 1 355 | 356 | 357 | repair 358 | 1 359 | 360 | 361 | alias 362 | 363 | 364 | 365 | affinity 366 | 367 | 368 | 369 | minoutbuf 370 | 0 371 | 372 | 373 | maxoutbuf 374 | 0 375 | 376 | 377 | _coordinate 378 | (568, 203) 379 | 380 | 381 | _rotation 382 | 0 383 | 384 | 385 | 386 | blocks_file_source_0 387 | blocks_throttle_0 388 | 0 389 | 0 390 | 391 | 392 | blocks_throttle_0 393 | darc_layer2_sync_0 394 | 0 395 | 0 396 | 397 | 398 | darc_layer2_sync_0 399 | darc_layer2_format_0 400 | 0 401 | 0 402 | 403 | 404 | darc_layer2_format_0 405 | blocks_null_sink_0 406 | 0 407 | 0 408 | 409 | 410 | darc_layer2_format_0 411 | blocks_udp_sink_0 412 | 0 413 | 0 414 | 415 | 416 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | #################################################################### 190 | elseif(GR_PYTHON_INSTALL_PROGRAMS) 191 | #################################################################### 192 | file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native) 193 | 194 | if (CMAKE_CROSSCOMPILING) 195 | set(pyexe_native "/usr/bin/env python") 196 | endif() 197 | 198 | foreach(pyfile ${GR_PYTHON_INSTALL_PROGRAMS}) 199 | get_filename_component(pyfile_name ${pyfile} NAME) 200 | get_filename_component(pyfile ${pyfile} ABSOLUTE) 201 | string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pyexefile "${pyfile}.exe") 202 | list(APPEND python_install_gen_targets ${pyexefile}) 203 | 204 | get_filename_component(pyexefile_path ${pyexefile} PATH) 205 | file(MAKE_DIRECTORY ${pyexefile_path}) 206 | 207 | add_custom_command( 208 | OUTPUT ${pyexefile} DEPENDS ${pyfile} 209 | COMMAND ${PYTHON_EXECUTABLE} -c 210 | "open('${pyexefile}','w').write('\#!${pyexe_native}\\n'+open('${pyfile}').read())" 211 | COMMENT "Shebangin ${pyfile_name}" 212 | VERBATIM 213 | ) 214 | 215 | #on windows, python files need an extension to execute 216 | get_filename_component(pyfile_ext ${pyfile} EXT) 217 | if(WIN32 AND NOT pyfile_ext) 218 | set(pyfile_name "${pyfile_name}.py") 219 | endif() 220 | 221 | install(PROGRAMS ${pyexefile} RENAME ${pyfile_name} 222 | DESTINATION ${GR_PYTHON_INSTALL_DESTINATION} 223 | COMPONENT ${GR_PYTHON_INSTALL_COMPONENT} 224 | ) 225 | endforeach(pyfile) 226 | 227 | endif() 228 | 229 | GR_UNIQUE_TARGET("pygen" ${python_install_gen_targets}) 230 | 231 | endfunction(GR_PYTHON_INSTALL) 232 | 233 | ######################################################################## 234 | # Write the python helper script that generates byte code files 235 | ######################################################################## 236 | file(WRITE ${CMAKE_BINARY_DIR}/python_compile_helper.py " 237 | import sys, py_compile 238 | files = sys.argv[1:] 239 | srcs, gens = files[:len(files)/2], files[len(files)/2:] 240 | for src, gen in zip(srcs, gens): 241 | py_compile.compile(file=src, cfile=gen, doraise=True) 242 | ") 243 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/cmake/Modules/darcConfig.cmake: -------------------------------------------------------------------------------- 1 | INCLUDE(FindPkgConfig) 2 | PKG_CHECK_MODULES(PC_DARC darc) 3 | 4 | FIND_PATH( 5 | DARC_INCLUDE_DIRS 6 | NAMES darc/api.h 7 | HINTS $ENV{DARC_DIR}/include 8 | ${PC_DARC_INCLUDEDIR} 9 | PATHS ${CMAKE_INSTALL_PREFIX}/include 10 | /usr/local/include 11 | /usr/include 12 | ) 13 | 14 | FIND_LIBRARY( 15 | DARC_LIBRARIES 16 | NAMES gnuradio-darc 17 | HINTS $ENV{DARC_DIR}/lib 18 | ${PC_DARC_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(DARC DEFAULT_MSG DARC_LIBRARIES DARC_INCLUDE_DIRS) 29 | MARK_AS_ADVANCED(DARC_LIBRARIES DARC_INCLUDE_DIRS) 30 | 31 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/docs/README.darc: -------------------------------------------------------------------------------- 1 | This is the darc-write-a-block package meant as a guide to building 2 | out-of-tree packages. To use the darc blocks, the Python namespaces 3 | is in 'darc', which is imported as: 4 | 5 | import darc 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(darc) 12 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/docs/doxygen/other/group_defs.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | * \defgroup block GNU Radio DARC C++ Signal Processing Blocks 3 | * \brief All C++ blocks that can be used from the DARC GNU Radio 4 | * module are listed here or in the subcategories below. 5 | * 6 | */ 7 | 8 | -------------------------------------------------------------------------------- /src/gr-darc/docs/doxygen/other/main_page.dox: -------------------------------------------------------------------------------- 1 | /*! \mainpage 2 | 3 | Welcome to the GNU Radio DARC Block 4 | 5 | This is the intro page for the Doxygen manual generated for the DARC 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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/examples/README: -------------------------------------------------------------------------------- 1 | It is considered good practice to add examples in here to demonstrate the 2 | functionality of your OOT module. Python scripts, GRC flow graphs or other 3 | code can go here. 4 | 5 | -------------------------------------------------------------------------------- /src/gr-darc/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 | darc_layer2.xml 22 | darc_layer2_sync.xml 23 | darc_layer2_format.xml DESTINATION share/gnuradio/grc/blocks 24 | ) 25 | -------------------------------------------------------------------------------- /src/gr-darc/grc/darc_layer2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DARC Layer 2 4 | darc_layer2 5 | [DARC] 6 | import darc 7 | darc.layer2($log, $debug, $crc, $repair, $errorwidth) 8 | 13 | 14 | Log Output 15 | log 16 | True 17 | enum 18 | 19 | 20 | 21 | 22 | Debug Output 23 | debug 24 | True 25 | enum 26 | 27 | 28 | 29 | 30 | Check CRC 31 | crc 32 | True 33 | enum 34 | 35 | 36 | 37 | 38 | Repair Layer 2 39 | repair 40 | True 41 | enum 42 | 43 | 44 | 45 | 46 | Errorwidth 47 | errorwidth 48 | 10 49 | raw 50 | 51 | 52 | in 53 | byte 54 | 55 | 56 | out 57 | byte 58 | 24 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/gr-darc/grc/darc_layer2_format.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DARC Layer 2 Format 4 | darc_layer2_format 5 | [DARC] 6 | import darc 7 | darc.layer2_format($log, $debug, $crc, $repair, $errorwidth) 8 | 9 | Log Output 10 | log 11 | True 12 | enum 13 | 14 | 15 | 16 | 17 | Debug Output 18 | debug 19 | True 20 | enum 21 | 22 | 23 | 24 | 25 | Check CRC 26 | crc 27 | True 28 | enum 29 | 30 | 31 | 32 | 33 | Repair Layer 2 34 | repair 35 | True 36 | enum 37 | 38 | 39 | 40 | 41 | Errorwidth 42 | errorwidth 43 | 10 44 | raw 45 | 46 | 47 | in 48 | byte 49 | 36 50 | 51 | 52 | out 53 | byte 54 | 24 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/gr-darc/grc/darc_layer2_sync.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DARC Layer 2 Sync 4 | darc_layer2_sync 5 | [DARC] 6 | import darc 7 | darc.layer2_sync($log, $debug) 8 | 9 | Log Output 10 | log 11 | True 12 | enum 13 | 14 | 15 | 16 | 17 | Debug Output 18 | debug 19 | True 20 | enum 21 | 22 | 23 | 24 | 25 | in 26 | byte 27 | 28 | 29 | out 30 | byte 31 | 36 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/gr-darc/include/darc/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 | layer2.h 26 | layer2_sync.h 27 | layer2_format.h DESTINATION include/darc 28 | ) 29 | -------------------------------------------------------------------------------- /src/gr-darc/include/darc/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_DARC_API_H 23 | #define INCLUDED_DARC_API_H 24 | 25 | #include 26 | 27 | #ifdef gnuradio_darc_EXPORTS 28 | # define DARC_API __GR_ATTR_EXPORT 29 | #else 30 | # define DARC_API __GR_ATTR_IMPORT 31 | #endif 32 | 33 | #endif /* INCLUDED_DARC_API_H */ 34 | -------------------------------------------------------------------------------- /src/gr-darc/include/darc/layer2.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 <+YOU OR YOUR COMPANY+>. 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_DARC_LAYER2_H 23 | #define INCLUDED_DARC_LAYER2_H 24 | 25 | #include 26 | #include 27 | 28 | namespace gr { 29 | namespace darc { 30 | 31 | /*! 32 | * \brief <+description of block+> 33 | * \ingroup darc 34 | * 35 | */ 36 | class DARC_API layer2 : virtual public gr::hier_block2 37 | { 38 | public: 39 | typedef boost::shared_ptr sptr; 40 | 41 | /*! 42 | * \brief Return a shared_ptr to a new instance of darc::layer2. 43 | * 44 | * To avoid accidental use of raw pointers, darc::layer2's 45 | * constructor is in a private implementation 46 | * class. darc::layer2::make is the public interface for 47 | * creating new instances. 48 | */ 49 | static sptr make(bool log, 50 | bool debug, 51 | bool crc, 52 | bool repair, 53 | unsigned char errorwidth); 54 | }; 55 | 56 | } // namespace darc 57 | } // namespace gr 58 | 59 | #endif /* INCLUDED_DARC_LAYER2_H */ 60 | 61 | -------------------------------------------------------------------------------- /src/gr-darc/include/darc/layer2_format.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 <+YOU OR YOUR COMPANY+>. 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_DARC_LAYER2_FORMAT_H 23 | #define INCLUDED_DARC_LAYER2_FORMAT_H 24 | 25 | #include 26 | #include 27 | 28 | namespace gr { 29 | namespace darc { 30 | 31 | /*! 32 | * \brief <+description of block+> 33 | * \ingroup darc 34 | * 35 | */ 36 | class DARC_API layer2_format : 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 darc::layer2_format. 43 | * 44 | * To avoid accidental use of raw pointers, darc::layer2_format's 45 | * constructor is in a private implementation 46 | * class. darc::layer2_format::make is the public interface for 47 | * creating new instances. 48 | */ 49 | static sptr make(bool log, 50 | bool debug, 51 | bool crc, 52 | bool repair, 53 | unsigned char errorwidth); 54 | }; 55 | 56 | } // namespace darc 57 | } // namespace gr 58 | 59 | #endif /* INCLUDED_DARC_LAYER2_FORMAT_H */ 60 | 61 | -------------------------------------------------------------------------------- /src/gr-darc/include/darc/layer2_sync.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 <+YOU OR YOUR COMPANY+>. 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_DARC_LAYER2_SYNC_H 23 | #define INCLUDED_DARC_LAYER2_SYNC_H 24 | 25 | #include 26 | #include 27 | 28 | namespace gr { 29 | namespace darc { 30 | 31 | /*! 32 | * \brief <+description of block+> 33 | * \ingroup darc 34 | * 35 | */ 36 | class DARC_API layer2_sync : 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 darc::layer2_sync. 43 | * 44 | * To avoid accidental use of raw pointers, darc::layer2_sync's 45 | * constructor is in a private implementation 46 | * class. darc::layer2_sync::make is the public interface for 47 | * creating new instances. 48 | */ 49 | static sptr make(bool log, bool debug); 50 | }; 51 | 52 | } // namespace darc 53 | } // namespace gr 54 | 55 | #endif /* INCLUDED_DARC_LAYER2_SYNC_H */ 56 | 57 | -------------------------------------------------------------------------------- /src/gr-darc/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 darc_sources 29 | layer2_impl.cc 30 | layer2_sync_impl.cc 31 | layer2_format_impl.cc 32 | bitarray/bitarray.cpp 33 | bitarray/bitarraycrc.cpp 34 | ) 35 | 36 | set(darc_sources "${darc_sources}" PARENT_SCOPE) 37 | if(NOT darc_sources) 38 | MESSAGE(STATUS "No C++ sources... skipping lib/") 39 | return() 40 | endif(NOT darc_sources) 41 | 42 | add_library(gnuradio-darc SHARED ${darc_sources}) 43 | target_link_libraries(gnuradio-darc ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES}) 44 | set_target_properties(gnuradio-darc PROPERTIES DEFINE_SYMBOL "gnuradio_darc_EXPORTS") 45 | 46 | if(APPLE) 47 | set_target_properties(gnuradio-darc PROPERTIES 48 | INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" 49 | ) 50 | endif(APPLE) 51 | 52 | ######################################################################## 53 | # Install built library files 54 | ######################################################################## 55 | install(TARGETS gnuradio-darc 56 | LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file 57 | ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file 58 | RUNTIME DESTINATION bin # .dll file 59 | ) 60 | 61 | ######################################################################## 62 | # Build and register unit test 63 | ######################################################################## 64 | include(GrTest) 65 | 66 | include_directories(${CPPUNIT_INCLUDE_DIRS}) 67 | 68 | list(APPEND test_darc_sources 69 | ${CMAKE_CURRENT_SOURCE_DIR}/test_darc.cc 70 | ${CMAKE_CURRENT_SOURCE_DIR}/qa_darc.cc 71 | ) 72 | 73 | add_executable(test-darc ${test_darc_sources}) 74 | 75 | target_link_libraries( 76 | test-darc 77 | ${GNURADIO_RUNTIME_LIBRARIES} 78 | ${Boost_LIBRARIES} 79 | ${CPPUNIT_LIBRARIES} 80 | gnuradio-darc 81 | ) 82 | 83 | GR_ADD_TEST(test_darc test-darc) 84 | -------------------------------------------------------------------------------- /src/gr-darc/lib/bitarray/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | -------------------------------------------------------------------------------- /src/gr-darc/lib/bitarray/COPYING.LESSER: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /src/gr-darc/lib/bitarray/LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | 167 | -------------------------------------------------------------------------------- /src/gr-darc/lib/bitarray/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################ 2 | # Makefile for bitarray class library and sample 3 | # 4 | # $Id: Makefile,v 1.2 2007/07/16 02:00:19 michael Exp $ 5 | # $Log: Makefile,v $ 6 | # Revision 1.2 2007/07/16 02:00:19 michael 7 | # Use -pedantic option when compiling. 8 | # 9 | # Revision 1.1.1.1 2004/08/04 13:28:20 michael 10 | # bit_array_c 11 | # 12 | ############################################################################ 13 | 14 | CPP = g++ 15 | LD = g++ 16 | CPPFLAGS = -O2 -Wall -pedantic -c 17 | LDFLAGS = -O2 -o 18 | 19 | # Treat NT and non-NT windows the same 20 | ifeq ($(OS),Windows_NT) 21 | OS = Windows 22 | endif 23 | 24 | ifeq ($(OS),Windows) 25 | EXE = .exe 26 | DEL = del 27 | else #assume Linux/Unix 28 | EXE = 29 | DEL = rm 30 | endif 31 | 32 | all: sample$(EXE) 33 | 34 | sample$(EXE): sample.o bitarray.o 35 | $(LD) $^ $(LDFLAGS) $@ 36 | 37 | sample.o: sample.cpp bitarray.h 38 | $(CPP) $(CPPFLAGS) $< 39 | 40 | bitarray.o: bitarray.cpp bitarray.h 41 | $(CPP) $(CPPFLAGS) $< 42 | 43 | clean: 44 | $(DEL) *.o 45 | $(DEL) sample$(EXE) 46 | -------------------------------------------------------------------------------- /src/gr-darc/lib/bitarray/README: -------------------------------------------------------------------------------- 1 | THIS LIB IS TAKEN FROM 2 | https://github.com/chris007de/bitarray-cpp 3 | 4 | FEEL FREE TO CONTRIBUTE 5 | 6 | DESCRIPTION 7 | ----------- 8 | This archive contains an ISO C++ class implementing arbitrary length arrays 9 | of bits. The class is intended to be easy to follow and expand upon, 10 | though it may be used without an understanding of its implementation. 11 | 12 | FILES 13 | ----- 14 | bitarray.cpp - Class providing operations on arbitrary length arrays 15 | of bits. 16 | bitarray.h - Header for bitarray class. 17 | sample.cpp - Program demonstrating how to use the bitarray class. 18 | COPYING - GNU General Public License 19 | COPYING.LESSER - GNU Lesser General Public License 20 | Makefile - makefile for this project (assumes gcc compiler and GNU make) 21 | README - this file 22 | 23 | BUILDING 24 | -------- 25 | To build these files with GNU make and gcc, simply enter "make" from the 26 | command line. 27 | 28 | USAGE 29 | ----- 30 | sample.cpp demonstrates usage of each of the bitarray functions. 31 | 32 | HISTORY 33 | ------- 34 | 08/03/04 - Initial release 35 | 04/30/06 - Improved performance by incorporating Benjamin Schindler's 36 | changes to pass arguments as a 37 | reference. 38 | 08/02/07 - All methods that don't modify object have been made const to 39 | increase functionality of const bit_array_c. 40 | All assignment operators return a reference to the object being 41 | assigned a value so that operator chaining will work. 42 | Add >> and << operators. 43 | 02/03/10 - Replaced vector with an array of unsigned char. 44 | If you want to use STL and vector you might as well use 45 | vector. Nothing from STL is used in this version. 46 | 47 | TODO 48 | ---- 49 | - Test on platforms with character lengths other than 8 bits. 50 | - Consider implementing overloads that return const bit_array_c 51 | 52 | AUTHOR 53 | ------ 54 | Michael Dipperstein (mdipper@alumni.engr.ucsb.edu) 55 | -------------------------------------------------------------------------------- /src/gr-darc/lib/bitarray/bitarray.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Arrays of Arbitrary Bit Length 3 | * 4 | * File : bitarray.h 5 | * Purpose : Header file for class supporting the creation and 6 | * manipulation of arbitrary length arrays of bits. 7 | * Author : Michael Dipperstein 8 | * Date : July 23, 2004 9 | * 10 | **************************************************************************** 11 | * HISTORY 12 | * 13 | * $Id: bitarray.h,v 1.5 2010/02/04 03:31:43 michael Exp $ 14 | * $Log: bitarray.h,v $ 15 | * Revision 1.5 2010/02/04 03:31:43 michael 16 | * Replaced vector with an array of unsigned char. 17 | * 18 | * Made updates for GCC 4.4. 19 | * 20 | * Revision 1.4 2007/08/06 05:23:12 michael 21 | * Updated for LGPL Version 3. 22 | * 23 | * All methods that don't modify object have been made 24 | * const to increase functionality of const bit_array_c. 25 | * 26 | * All assignment operators return a reference to the object being assigned a value so that operator chaining will work. 27 | * 28 | * Added >> and << operators. 29 | * 30 | * Revision 1.3 2006/04/30 23:34:07 michael 31 | * Improved performance by incorporating Benjamin Schindler's 32 | * changes to pass arguments as a reference. 33 | * 34 | * Revision 1.2 2004/08/05 22:17:04 michael 35 | * Add overloads for bitwise operators returning values. 36 | * Add a more natural looking way to set bit values. 37 | * 38 | * Revision 1.1.1.1 2004/08/04 13:28:20 michael 39 | * bit_array_c 40 | * 41 | **************************************************************************** 42 | * 43 | * Bitarray: An ANSI C++ class for manipulating arbitrary length bit arrays 44 | * Copyright (C) 2004, 2006-2007, 2010 by 45 | * Michael Dipperstein (mdipper@alumni.engr.ucsb.edu) 46 | * 47 | * This file is part of the bit array library. 48 | * 49 | * The bit array library is free software; you can redistribute it and/or 50 | * modify it under the terms of the GNU Lesser General Public License as 51 | * published by the Free Software Foundation; either version 3 of the 52 | * License, or (at your option) any later version. 53 | * 54 | * The bit array library is distributed in the hope that it will be useful, 55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 57 | * General Public License for more details. 58 | * 59 | * You should have received a copy of the GNU Lesser General Public License 60 | * along with this program. If not, see . 61 | * 62 | ***************************************************************************/ 63 | #ifndef BIT_ARRAY_H 64 | #define BIT_ARRAY_H 65 | 66 | /*************************************************************************** 67 | * INCLUDED FILES 68 | ***************************************************************************/ 69 | #include 70 | 71 | /*************************************************************************** 72 | * TYPE DEFINITIONS 73 | ***************************************************************************/ 74 | class bit_array_c; 75 | 76 | class bit_array_index_c 77 | { 78 | public: 79 | bit_array_index_c(bit_array_c *array, const unsigned int index); 80 | 81 | /* assignment */ 82 | void operator=(const bool src); 83 | 84 | private: 85 | bit_array_c *m_BitArray; /* array index applies to */ 86 | unsigned int m_Index; /* index of bit in array */ 87 | }; 88 | 89 | class bit_array_c 90 | { 91 | public: 92 | bit_array_c(const int numBits); 93 | bit_array_c(unsigned char *array, const int numBits); 94 | bit_array_c(const unsigned char *array, const int numBits); 95 | bit_array_c(const bit_array_c &source); 96 | bit_array_c(const bit_array_c &source, 97 | const unsigned int startBit, 98 | const unsigned int numBits); 99 | 100 | virtual ~bit_array_c(void); 101 | 102 | void Dump(std::ostream &outStream) const; 103 | 104 | const unsigned int Size() const { return m_NumBits; }; 105 | 106 | /* set/clear functions */ 107 | void SetAll(void); 108 | void ClearAll(void); 109 | void SetBit(const unsigned int bit); 110 | void ClearBit(const unsigned int bit); 111 | 112 | bit_array_index_c operator()(const unsigned int bit); 113 | 114 | /* boolean operator */ 115 | bool operator[](const unsigned int bit) const; 116 | bool operator==(const bit_array_c &other) const; 117 | bool operator!=(const bit_array_c &other) const; 118 | bool operator<(const bit_array_c &other) const; 119 | bool operator<=(const bit_array_c &other) const; 120 | bool operator>(const bit_array_c &other) const; 121 | bool operator>=(const bit_array_c &other) const; 122 | 123 | /* bitwise operators */ 124 | bit_array_c operator&(const bit_array_c &other) const; 125 | bit_array_c operator^(const bit_array_c &other) const; 126 | bit_array_c operator|(const bit_array_c &other) const; 127 | bit_array_c operator~(void) const; 128 | 129 | bit_array_c operator<<(const unsigned int count) const; 130 | bit_array_c operator>>(const unsigned int count) const; 131 | 132 | /* increment/decrement */ 133 | bit_array_c& operator++(void); /* prefix */ 134 | bit_array_c& operator++(int dummy); /* postfix */ 135 | bit_array_c& operator--(void); /* prefix */ 136 | bit_array_c& operator--(int dummy); /* postfix */ 137 | 138 | /* assignments */ 139 | bit_array_c& operator=(const bit_array_c &src); 140 | 141 | bit_array_c& operator&=(const bit_array_c &src); 142 | bit_array_c& operator^=(const bit_array_c &src); 143 | bit_array_c& operator|=(const bit_array_c &src); 144 | bit_array_c& Not(void); /* negate (~=) */ 145 | 146 | bit_array_c& operator<<=(unsigned const int shifts); 147 | bit_array_c& operator>>=(unsigned const int shifts); 148 | 149 | void Copy(const unsigned int target, 150 | const bit_array_c &other, 151 | const unsigned int source, 152 | const unsigned int count ); 153 | void FromInt(const unsigned int value); 154 | 155 | unsigned char* GetArray(void) const; 156 | 157 | protected: 158 | unsigned int m_NumBits; /* number of bits in the array */ 159 | unsigned char *m_Array; /* vector of characters */ 160 | }; 161 | 162 | #endif /* ndef BIT_ARRAY_H */ 163 | -------------------------------------------------------------------------------- /src/gr-darc/lib/bitarray/bitarraycrc.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Arrays of Arbitrary Bit Length 3 | * 4 | * File : bitarraycrc.cpp 5 | * Purpose : 6 | * 7 | * Author : 8 | * Date : 9 | * 10 | **************************************************************************** 11 | * HISTORY 12 | * 13 | * 14 | **************************************************************************** 15 | * 16 | * 17 | * 18 | ***************************************************************************/ 19 | 20 | /*************************************************************************** 21 | * INCLUDED FILES 22 | ***************************************************************************/ 23 | #include 24 | #include 25 | #include "bitarraycrc.h" 26 | using namespace std; 27 | 28 | /*************************************************************************** 29 | * MACROS 30 | ***************************************************************************/ 31 | 32 | /*************************************************************************** 33 | * METHODS 34 | ***************************************************************************/ 35 | 36 | /*************************************************************************** 37 | * Method : 38 | * Description: 39 | * Parameters : 40 | * Effects : 41 | * Returned : 42 | ***************************************************************************/ 43 | void 44 | bit_array_crc(bit_array_c &crc, 45 | const bit_array_c &input, 46 | const bit_array_c &polynom, 47 | const bit_array_c &code) 48 | { 49 | // TODO Check for Codelength and CRC Len to be polynomLen-1 50 | 51 | // Concatenate input and code to be tested to a tmp bit array 52 | bit_array_c tmp(input.Size()+crc.Size()); 53 | tmp.Copy(0, input, 0, input.Size()); 54 | tmp.Copy(input.Size(), code, 0, code.Size()); 55 | 56 | /* Step through input data 57 | * if a bit is true, XOR the polynom to the tmp bit array 58 | */ 59 | for(unsigned int cnt=0; cnt 17 | * 18 | ***************************************************************************/ 19 | #ifndef BIT_ARRAY_CRC_H 20 | #define BIT_ARRAY_CRC_H 21 | 22 | /*************************************************************************** 23 | * INCLUDED FILES 24 | ***************************************************************************/ 25 | #include 26 | #include "bitarray.h" 27 | 28 | /*************************************************************************** 29 | * TYPE DEFINITIONS 30 | ***************************************************************************/ 31 | void bit_array_crc(bit_array_c &crc, 32 | const bit_array_c &input, 33 | const bit_array_c &polynom, 34 | const bit_array_c &code); 35 | 36 | #endif /* ndef BIT_ARRAY_CRC_H */ 37 | -------------------------------------------------------------------------------- /src/gr-darc/lib/bitarray/sample.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Bit Array Class Usage Sample 3 | * 4 | * File : sample.cpp 5 | * Purpose : Demonstrates usage of bit array class. 6 | * Author : Michael Dipperstein 7 | * Date : July 23, 2004 8 | * 9 | **************************************************************************** 10 | * HISTORY 11 | * 12 | * $Id: sample.cpp,v 1.6 2010/02/04 03:31:43 michael Exp $ 13 | * $Log: sample.cpp,v $ 14 | * Revision 1.6 2010/02/04 03:31:43 michael 15 | * Replaced vector with an array of unsigned char. 16 | * 17 | * Made updates for GCC 4.4. 18 | * 19 | * Revision 1.4 2007/08/06 05:21:00 michael 20 | * Updated for LGPL Version 3. 21 | * Verifies new >> and << functions. 22 | * Corrects printed comment for setting bits by array index. 23 | * 24 | * Revision 1.2 2004/08/05 22:17:31 michael 25 | * Test new methods. 26 | * 27 | * Revision 1.1.1.1 2004/08/04 13:28:20 michael 28 | * bit_array_c 29 | * 30 | **************************************************************************** 31 | * 32 | * Sample: A bit array class sample usage program 33 | * Copyright (C) 2004, 2006-2007, 2010 by 34 | * Michael Dipperstein (mdipper@alumni.engr.ucsb.edu) 35 | * 36 | * This file is part of the bit array library. 37 | * 38 | * The bit array library is free software; you can redistribute it and/or 39 | * modify it under the terms of the GNU Lesser General Public License as 40 | * published by the Free Software Foundation; either version 3 of the 41 | * License, or (at your option) any later version. 42 | * 43 | * The bit array library is distributed in the hope that it will be useful, 44 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 45 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 46 | * General Public License for more details. 47 | * 48 | * You should have received a copy of the GNU Lesser General Public License 49 | * along with this program. If not, see . 50 | * 51 | ***************************************************************************/ 52 | 53 | #include 54 | #include 55 | #include 56 | #include "bitarray.h" 57 | 58 | using namespace std; 59 | 60 | /*************************************************************************** 61 | * MACROS 62 | ***************************************************************************/ 63 | #define NUM_BITS 128 /* size of bit array */ 64 | 65 | /*************************************************************************** 66 | * FUNCTIONS 67 | ***************************************************************************/ 68 | 69 | /*************************************************************************** 70 | * Function : ShowArray 71 | * Description: This is a wrapper for bit_array_t::Dump that shows the 72 | * array name as well as its contents. 73 | * Parameters : name - name of array 74 | * ba - pointer to bit array 75 | * Effects : Writes array to stdout. 76 | * Returned : None 77 | ***************************************************************************/ 78 | void ShowArray(const char *name, bit_array_c *ba) 79 | { 80 | cout << name << ": "; 81 | ba->Dump(cout); 82 | cout << endl; 83 | } 84 | 85 | /*************************************************************************** 86 | * Function : main 87 | * Description: This function demonstrates the usage of each of the bit 88 | * array method. 89 | * Parameters : argc - the number command line arguements (not used) 90 | * Parameters : argv - array of command line arguements (not used) 91 | * Effects : Writes results of bit operations to stdout. 92 | * Returned : EXIT_SUCCESS 93 | ***************************************************************************/ 94 | int main(int argc, char *argv[]) 95 | { 96 | bit_array_c ba1(NUM_BITS), ba2(NUM_BITS); 97 | int i; 98 | 99 | cout << "ba1 has " << ba1.Size() << " bits" << endl; 100 | cout << "ba2 has " << ba2.Size() << " bits" << endl << endl; 101 | 102 | cout << "set all bits in ba1" << endl; 103 | ba1.SetAll(); 104 | ShowArray("ba1", &ba1); 105 | 106 | cout << endl << "clear all bits in ba1" << endl; 107 | ba1.ClearAll(); 108 | ShowArray("ba1", &ba1); 109 | 110 | cout << endl << "set 8 bits on each end of ba1 from the outside in" << endl; 111 | for (i = 0; i < 8; i++) 112 | { 113 | ba1.SetBit(i); 114 | ba1.SetBit(NUM_BITS - i - 1); 115 | ShowArray("ba1", &ba1); 116 | } 117 | 118 | cout << endl << "ba2 = ba1" << endl; 119 | ba2 = ba1; 120 | ShowArray("ba2", &ba2); 121 | 122 | cout << endl << "ba2 = ~(ba2)" << endl; 123 | ba2.Not(); 124 | ShowArray("ba2", &ba2); 125 | 126 | cout << endl << "ba2 |= ba1" << endl; 127 | ba2 |= ba1; 128 | ShowArray("ba2", &ba2); 129 | 130 | cout << endl << "ba2 ^= ba1" << endl; 131 | ba2 ^= ba1; 132 | ShowArray("ba2", &ba2); 133 | 134 | cout << endl << "ba2 &= ba1" << endl; 135 | ba2 &= ba1; 136 | ShowArray("ba2", &ba2); 137 | 138 | cout << endl << "testing some bits in ba1" << endl; 139 | for (; i > 6; i--) 140 | { 141 | if(ba1[i]) 142 | { 143 | cout << "ba1 bit " << i << " is set." << endl; 144 | } 145 | else 146 | { 147 | cout << "ba1 bit " << i << " is clear." << endl; 148 | } 149 | 150 | if(ba1[NUM_BITS - i - 1]) 151 | { 152 | cout << "ba1 bit " << NUM_BITS - i - 1 << " is set." << endl; 153 | } 154 | else 155 | { 156 | cout << "ba1 bit " << NUM_BITS - i - 1 << " is clear." << endl; 157 | } 158 | } 159 | 160 | cout << endl << "clear 8 bits on each end of ba1 from the outside in" << endl; 161 | for (i = 0; i < 8; i++) 162 | { 163 | ba1.ClearBit(i); 164 | ba1.ClearBit(NUM_BITS - i - 1); 165 | ShowArray("ba1", &ba1); 166 | } 167 | 168 | cout << endl << "set all bits in ba1 and shift right by 20" << endl; 169 | ba1.SetAll(); 170 | ba1 >>= 20; 171 | ShowArray("ba1", &ba1); 172 | 173 | cout << endl << "shift ba1 left by 20" << endl; 174 | ba1 <<= 20; 175 | ShowArray("ba1", &ba1); 176 | 177 | cout << endl << "set all bits in ba1 and increment" << endl; 178 | ba1.SetAll(); 179 | ++ba1; 180 | ShowArray("ba1", &ba1); 181 | 182 | cout << endl << "increment ba1" << endl; 183 | ba1++; 184 | ShowArray("ba1", &ba1); 185 | 186 | cout << endl << "increment ba1" << endl; 187 | ++ba1; 188 | ShowArray("ba1", &ba1); 189 | 190 | cout << endl << "decrement ba1" << endl; 191 | --ba1; 192 | ShowArray("ba1", &ba1); 193 | 194 | cout << endl << "decrement ba1" << endl; 195 | ba1--; 196 | ShowArray("ba1", &ba1); 197 | 198 | cout << endl << "decrement ba1" << endl; 199 | --ba1; 200 | ShowArray("ba1", &ba1); 201 | 202 | /* == */ 203 | cout << endl << "check ba1 == ba1" << endl; 204 | if (ba1 == ba1) 205 | { 206 | cout << "ba1 == ba1" << endl; 207 | } 208 | else 209 | { 210 | cout << "ba1 != ba1" << endl; 211 | } 212 | 213 | cout << endl << "check ba1 == ba2" << endl; 214 | if (ba1 == ba2) 215 | { 216 | cout << "ba1 == ba2" << endl; 217 | } 218 | else 219 | { 220 | cout << "ba1 != ba2" << endl; 221 | } 222 | 223 | /* != */ 224 | cout << endl << "check ba1 != ba1" << endl; 225 | if (ba1 != ba1) 226 | { 227 | cout << "ba1 != ba1" << endl; 228 | } 229 | else 230 | { 231 | cout << "ba1 == ba1" << endl; 232 | } 233 | 234 | cout << endl << "check ba1 != ba2" << endl; 235 | if (ba1 != ba2) 236 | { 237 | cout << "ba1 != ba2" << endl; 238 | } 239 | else 240 | { 241 | cout << "Comparison error." << endl; 242 | } 243 | 244 | /* < */ 245 | cout << endl << "check ba1 < ba1" << endl; 246 | if (ba1 < ba1) 247 | { 248 | cout << "ba1 < ba1" << endl; 249 | } 250 | else 251 | { 252 | cout << "ba1 >= ba1" << endl; 253 | } 254 | 255 | cout << endl << "check ba1 < ba2" << endl; 256 | if (ba1 < ba2) 257 | { 258 | cout << "ba1 < ba2" << endl; 259 | } 260 | else 261 | { 262 | cout << "ba1 >= ba2" << endl; 263 | } 264 | 265 | cout << endl << "check ba2 < ba1" << endl; 266 | if (ba2 < ba1) 267 | { 268 | cout << "ba2 < ba1" << endl; 269 | } 270 | else 271 | { 272 | cout << "ba2 >= ba1" << endl; 273 | } 274 | 275 | /* <= */ 276 | cout << endl << "check ba1 <= ba1" << endl; 277 | if (ba1 <= ba1) 278 | { 279 | cout << "ba1 <= ba1" << endl; 280 | } 281 | else 282 | { 283 | cout << "ba1 > ba1" << endl; 284 | } 285 | 286 | cout << endl << "check ba1 <= ba2" << endl; 287 | if (ba1 <= ba2) 288 | { 289 | cout << "ba1 <= ba2" << endl; 290 | } 291 | else 292 | { 293 | cout << "ba1 > ba2" << endl; 294 | } 295 | 296 | cout << endl << "check ba2 <= ba1" << endl; 297 | if (ba2 < ba1) 298 | { 299 | cout << "ba2 <= ba1" << endl; 300 | } 301 | else 302 | { 303 | cout << "ba2 > ba1" << endl; 304 | } 305 | 306 | /* > */ 307 | cout << endl << "check ba1 > ba1" << endl; 308 | if (ba1 > ba1) 309 | { 310 | cout << "ba1 > ba1" << endl; 311 | } 312 | else 313 | { 314 | cout << "ba1 <= ba1" << endl; 315 | } 316 | 317 | cout << endl << "check ba1 > ba2" << endl; 318 | if (ba1 > ba2) 319 | { 320 | cout << "ba1 > ba2" << endl; 321 | } 322 | else 323 | { 324 | cout << "ba1 <= ba2" << endl; 325 | } 326 | 327 | cout << endl << "check ba2 > ba1" << endl; 328 | if (ba2 > ba1) 329 | { 330 | cout << "ba2 > ba1" << endl; 331 | } 332 | else 333 | { 334 | cout << "ba2 <= ba1" << endl; 335 | } 336 | 337 | /* >= */ 338 | cout << endl << "check ba1 >= ba1" << endl; 339 | if (ba1 >= ba1) 340 | { 341 | cout << "ba1 >= ba1" << endl; 342 | } 343 | else 344 | { 345 | cout << "ba1 < ba1" << endl; 346 | } 347 | 348 | cout << endl << "check ba1 >= ba2" << endl; 349 | if (ba1 >= ba2) 350 | { 351 | cout << "ba1 >= ba2" << endl; 352 | } 353 | else 354 | { 355 | cout << "ba1 < ba2" << endl; 356 | } 357 | 358 | cout << endl << "check ba2 >= ba1" << endl; 359 | if (ba2 >= ba1) 360 | { 361 | cout << "ba2 >= ba1" << endl; 362 | } 363 | else 364 | { 365 | cout << "ba2 < ba1" << endl; 366 | } 367 | 368 | /* test construction from existing: create an array, fill it with values */ 369 | unsigned char* vect; 370 | vect = new unsigned char[(NUM_BITS / CHAR_BIT)]; 371 | 372 | vect[0] = 0x00; 373 | for (i = 1; i < NUM_BITS / CHAR_BIT; i++) 374 | { 375 | vect[i] = vect[i -1] + 0x11; 376 | } 377 | 378 | cout << endl << "construct a bit array from existing array" << endl; 379 | bit_array_c ba3(vect, NUM_BITS); 380 | ShowArray("ba3", &ba3); 381 | 382 | cout << endl << "ba3 = ~(ba3)" << endl; 383 | ba3 = ~ba3; 384 | ShowArray("ba3", &ba3); 385 | 386 | ba1.SetAll(); 387 | for (i = 0; i < NUM_BITS; i += 2) 388 | { 389 | ba2.SetBit(i); 390 | 391 | if (i < NUM_BITS - 1) 392 | { 393 | ba2.ClearBit(i + 1); 394 | } 395 | } 396 | 397 | cout << endl; 398 | ShowArray("ba1", &ba1); 399 | ShowArray("ba2", &ba2); 400 | 401 | cout << endl << "ba3 = ba1 | ba2" << endl; 402 | ba3 = ba1 | ba2; 403 | ShowArray("ba3", &ba3); 404 | 405 | cout << endl << "ba3 = ba1 ^ ba2" << endl; 406 | ba3 = ba1 ^ ba2; 407 | ShowArray("ba3", &ba3); 408 | 409 | cout << endl << "ba3 = ba1 & ba2" << endl; 410 | ba3 = ba1 & ba2; 411 | ShowArray("ba3", &ba3); 412 | 413 | cout << endl << "ba3 = ba2 >> 1" << endl; 414 | ba3 = ba2 >> 1; 415 | ShowArray("ba3", &ba3); 416 | 417 | cout << endl << "ba3 = ba1 << 1" << endl; 418 | ba3 = ba1 << 1; 419 | ShowArray("ba3", &ba3); 420 | 421 | cout << endl << "ba3(0) .. ba3(7) = false" << endl; 422 | for(i = 0; i < 8; i++) 423 | { 424 | ba3(i) = false; 425 | ShowArray("ba3", &ba3); 426 | } 427 | 428 | return(EXIT_SUCCESS); 429 | } 430 | -------------------------------------------------------------------------------- /src/gr-darc/lib/darc_constants.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #ifndef DARC_CONSTANTS_H 5 | #define DARC_CONSTANTS_H 6 | 7 | 8 | #define dout debug && std::cout 9 | #define lout log && std::cout 10 | 11 | /* Protocol Constants, Lengths given in Bit */ 12 | /* Layer 2 */ 13 | #define L2_INFO_LEN 176 14 | #define L2_CRC_LEN 14 15 | #define L2_PARITY_LEN 82 16 | #define L2_BODY_LEN 272 /* 272 */ 17 | #define BIC_LEN 16 18 | #define BLOCK_LENGTH 288 /* 288 */ 19 | 20 | 21 | static const unsigned int bic[4] = {0x135e,0x74a6,0xa791,0xc875}; 22 | 23 | static const unsigned short scramble_table[17] = { 0xAFAA, 24 | 0x814A, 25 | 0xF2EE, 26 | 0x073A, 27 | 0x4F5D, 28 | 0x4486, 29 | 0x70BD, 30 | 0xB343, 31 | 0xBC3F, 32 | 0xE0F7, 33 | 0xC5CC, 34 | 0x8253, 35 | 0xB479, 36 | 0xF362, 37 | 0xA471, 38 | 0xB571, 39 | 0x3110}; 40 | 41 | 42 | 43 | #endif // DARC_CONSTANTS_H -------------------------------------------------------------------------------- /src/gr-darc/lib/layer2_format_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 <+YOU OR YOUR COMPANY+>. 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 28 | #include 29 | #include 30 | #include "darc_constants.h" 31 | #include "layer2_format_impl.h" 32 | 33 | #include "bitarray/bitarray.h" 34 | #include "bitarray/bitarraycrc.h" 35 | 36 | 37 | using namespace std; 38 | 39 | namespace gr { 40 | namespace darc { 41 | 42 | layer2_format::sptr 43 | layer2_format::make(bool log, 44 | bool debug, 45 | bool crc, 46 | bool repair, 47 | unsigned char errorwidth) 48 | { 49 | return gnuradio::get_initial_sptr 50 | (new layer2_format_impl(log, debug,crc,repair, errorwidth)); 51 | } 52 | 53 | /* 54 | * The private constructor 55 | */ 56 | layer2_format_impl::layer2_format_impl(bool log, 57 | bool debug, 58 | bool crc, 59 | bool repair, 60 | unsigned char errorwidth) 61 | : gr::block("layer2_format", 62 | gr::io_signature::make(1, 1, 36*sizeof(char)), 63 | gr::io_signature::make(1, 1, 24*sizeof(char))), 64 | log(log), 65 | debug(debug), 66 | m_crc(crc), 67 | m_repair(repair), 68 | m_errorwidth(errorwidth) 69 | { 70 | if(m_repair) 71 | { 72 | syndrome_generator(false); // Do not generate syndrome export file 73 | } 74 | 75 | m_stats_total = 0; 76 | m_stats_crcok = 0; 77 | m_stats_repaired = 0; 78 | } 79 | 80 | /* 81 | * Our virtual destructor. 82 | */ 83 | layer2_format_impl::~layer2_format_impl() 84 | { 85 | } 86 | 87 | void 88 | layer2_format_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) 89 | { 90 | ninput_items_required[0] = noutput_items+1; 91 | } 92 | 93 | bool 94 | layer2_format_impl::crc14 (const bit_array_c &data, 95 | const bit_array_c &crc) 96 | { 97 | /* x^14 + x^11 + x^2 +1 (1001 0000 0000 101|0)*/ 98 | unsigned char *poly = new unsigned char[2]; 99 | poly[0] = 0x90; 100 | poly[1] = 0x0A; 101 | 102 | bit_array_c result(14); 103 | bit_array_c polynom(poly, 15); 104 | 105 | bit_array_crc(result, data, polynom, crc); 106 | 107 | // Check if result is zero, if yes, CRC was ok 108 | bit_array_c zero(14); 109 | if(zero == result) 110 | { 111 | return true; 112 | } 113 | return false; 114 | } 115 | 116 | void 117 | layer2_format_impl::crc82(bit_array_c &result, 118 | const bit_array_c &data, 119 | const bit_array_c &code) 120 | { 121 | /* Chapter 11.1 122 | * 10000110 00010001 10000000 00100010 123 | * 00100000 00100010 10000000 00101000 124 | * 10000000 10000010 001 125 | */ 126 | unsigned char *poly = new unsigned char[11]; 127 | poly[0] = 0x86; 128 | poly[1] = 0x11; 129 | poly[2] = 0x80; 130 | poly[3] = 0x22; 131 | poly[4] = 0x20; 132 | poly[5] = 0x22; 133 | poly[6] = 0x80; 134 | poly[7] = 0x28; 135 | poly[8] = 0x80; 136 | poly[9] = 0x82; 137 | poly[10] = 0x20; 138 | bit_array_c polynom(poly, 83); 139 | 140 | bit_array_crc(result, data, polynom, code); 141 | } 142 | 143 | int 144 | layer2_format_impl::general_work (int noutput_items, 145 | gr_vector_int &ninput_items, 146 | gr_vector_const_void_star &input_items, 147 | gr_vector_void_star &output_items) 148 | { 149 | const char *in = (const char *) input_items[0]; 150 | char *out = (char *) output_items[0]; 151 | 152 | unsigned int _items_consumed = 0; 153 | unsigned int _noutput_items = 0; 154 | 155 | while(_items_consumed<1) 156 | { 157 | bool success = false; 158 | 159 | bit_array_c block((const unsigned char*)&in[0], \ 160 | BLOCK_LENGTH); 161 | 162 | unsigned short bic = in[0]<<8 | in[1]; 163 | if( 0xc875 != bic ) // Ignore Parity BIC 164 | { 165 | m_stats_total++; 166 | 167 | if(!m_crc) 168 | { 169 | success = true; 170 | } 171 | else 172 | { 173 | bit_array_c data(L2_INFO_LEN); 174 | data.Copy(0, block, BIC_LEN, L2_INFO_LEN); 175 | bit_array_c crc(L2_CRC_LEN); 176 | crc.Copy(0, block, BIC_LEN+L2_INFO_LEN, L2_CRC_LEN); 177 | 178 | if(crc14(data, crc)) 179 | { 180 | m_stats_crcok++; 181 | success = true; 182 | } 183 | else if(m_repair) 184 | { 185 | bit_array_c data_and_crc(L2_INFO_LEN+L2_CRC_LEN); 186 | data_and_crc.Copy(0, block, BIC_LEN, L2_INFO_LEN+L2_CRC_LEN); 187 | 188 | bit_array_c parity(L2_PARITY_LEN); 189 | parity.Copy(0, block, BIC_LEN+L2_INFO_LEN+L2_CRC_LEN, L2_PARITY_LEN); 190 | 191 | bit_array_c result(L2_PARITY_LEN); 192 | crc82(result, data_and_crc, parity); 193 | 194 | for(unsigned int x = 0; x < m_paritylist.size(); x++) 195 | { // Searching for the parity value 196 | if(result == *m_paritylist[x]) 197 | { 198 | // Found the right value in the parity list, 199 | // applying syndrome 200 | data_and_crc = data_and_crc ^ *m_syndromelist[x]; 201 | 202 | // Checking CRC again 203 | data.Copy(0, data_and_crc, 0, L2_INFO_LEN); 204 | crc.Copy(0, data_and_crc, L2_INFO_LEN, L2_CRC_LEN); 205 | if(crc14(data, crc)) 206 | { 207 | m_stats_repaired++; 208 | success = true; 209 | block.Copy(BIC_LEN, data_and_crc, 0, L2_INFO_LEN+L2_CRC_LEN); 210 | } 211 | } 212 | } 213 | } 214 | } 215 | 216 | if(success) 217 | { 218 | memcpy(&out[0], (block.GetArray()), ((BIC_LEN+L2_INFO_LEN)/8)*sizeof(char)); 219 | } 220 | else 221 | { 222 | // Providing packet informatio to the other layers anyway 223 | memcpy(&out[0], (block.GetArray()), ((BIC_LEN+L2_INFO_LEN)/8)*sizeof(char)); 224 | //memset(&out[0], 0, ((BIC_LEN+L2_INFO_LEN)/8)*sizeof(char)); 225 | } 226 | _noutput_items++; 227 | 228 | if( m_stats_total%100000 == 0) 229 | { 230 | int crc_rate = (m_stats_crcok*100)/m_stats_total; 231 | int repair_rate = (m_stats_repaired*100)/(m_stats_total-m_stats_crcok); 232 | lout << "[Log][L2 Stats]"; 233 | lout << " CRC OK: " << crc_rate << "%"; 234 | lout << " Repaired: " << repair_rate << "%"; 235 | lout << " TotalRx: " << m_stats_total << endl; 236 | } 237 | } 238 | _items_consumed++; 239 | } 240 | 241 | consume_each (_items_consumed); 242 | // Tell runtime system how many output items we produced. 243 | return _noutput_items; 244 | } 245 | 246 | void 247 | layer2_format_impl::syndrome_generator(bool generateFile) 248 | { 249 | ofstream fhandle; 250 | if(generateFile) 251 | { 252 | fhandle.open("/home/chris/Desktop/mysyndrome"); 253 | } 254 | 255 | bit_array_c data(L2_INFO_LEN + L2_CRC_LEN); //190 256 | bit_array_c parity(L2_PARITY_LEN); //82 257 | bit_array_c code(L2_PARITY_LEN); // stays zero 258 | 259 | bit_array_c pattern(m_errorwidth); 260 | bit_array_c counter(m_errorwidth); 261 | 262 | cout << "Generating syndrome table"; 263 | for(unsigned char bits=1; bits<=m_errorwidth; bits++) 264 | { 265 | cout << "."; 266 | // Create bit error pattern 267 | // First and last bit of pattern is always set 268 | // otherwise the pattern would be the same as shorter patterns 269 | // looked before 270 | // Bits in between are simply counted up 271 | pattern.ClearAll(); 272 | pattern.SetBit(0); 273 | pattern.SetBit(bits-1); 274 | 275 | counter.ClearAll(); 276 | 277 | for(unsigned int cnt=0; cnt 2) 280 | { 281 | counter.FromInt(cnt); 282 | pattern.Copy(1, counter, 0, bits-2); 283 | } 284 | 285 | // Iterate pattern through every 286 | // possible position in datastream 287 | for(unsigned char pos=0; pos<=data.Size()-bits; pos++) 288 | { 289 | data.ClearAll(); 290 | data.Copy(pos, pattern, 0, bits); 291 | 292 | // Calculate CRC82 293 | crc82(parity, data, code); 294 | 295 | // Storing parity/syndrome list on the heap 296 | m_paritylist.push_back(new bit_array_c(parity)); 297 | m_syndromelist.push_back(new bit_array_c(data)); 298 | 299 | if(generateFile) 300 | { 301 | //dump to file 302 | parity.Dump(fhandle); 303 | fhandle << " "; 304 | data.Dump(fhandle); 305 | fhandle << std::endl; 306 | } 307 | } 308 | } 309 | } 310 | fhandle.close(); 311 | cout << "done" << endl; 312 | } 313 | 314 | } /* namespace darc */ 315 | } /* namespace gr */ 316 | -------------------------------------------------------------------------------- /src/gr-darc/lib/layer2_format_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 <+YOU OR YOUR COMPANY+>. 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_DARC_LAYER2_FORMAT_IMPL_H 22 | #define INCLUDED_DARC_LAYER2_FORMAT_IMPL_H 23 | 24 | #include 25 | 26 | #include "bitarray/bitarray.h" 27 | 28 | namespace gr { 29 | namespace darc { 30 | 31 | class layer2_format_impl : public layer2_format 32 | { 33 | private: 34 | bool log; 35 | bool debug; 36 | bool m_crc; 37 | bool m_repair; 38 | unsigned char m_errorwidth; 39 | 40 | std::vector m_paritylist; 41 | std::vector m_syndromelist; 42 | 43 | // Performance logging 44 | unsigned long m_stats_total; 45 | unsigned long m_stats_crcok; 46 | unsigned long m_stats_repaired; 47 | 48 | public: 49 | layer2_format_impl(bool log, 50 | bool debug, 51 | bool crc, 52 | bool repair, 53 | unsigned char errorwidth); 54 | ~layer2_format_impl(); 55 | 56 | // Where all the action really happens 57 | void forecast (int noutput_items, gr_vector_int &ninput_items_required); 58 | 59 | int general_work(int noutput_items, 60 | gr_vector_int &ninput_items, 61 | gr_vector_const_void_star &input_items, 62 | gr_vector_void_star &output_items); 63 | 64 | bool crc14(const bit_array_c &data, 65 | const bit_array_c &crc); 66 | void crc82(bit_array_c &result, 67 | const bit_array_c &data, 68 | const bit_array_c &code); 69 | 70 | void syndrome_generator(bool generateFile); 71 | }; 72 | 73 | } // namespace darc 74 | } // namespace gr 75 | 76 | #endif /* INCLUDED_DARC_LAYER2_FORMAT_IMPL_H */ 77 | 78 | -------------------------------------------------------------------------------- /src/gr-darc/lib/layer2_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 <+YOU OR YOUR COMPANY+>. 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 "layer2_impl.h" 27 | #include "layer2_sync_impl.h" 28 | #include "layer2_format_impl.h" 29 | 30 | namespace gr { 31 | namespace darc { 32 | 33 | layer2::sptr 34 | layer2::make(bool log, 35 | bool debug, 36 | bool crc, 37 | bool repair, 38 | unsigned char errorwidth) 39 | { 40 | return gnuradio::get_initial_sptr 41 | (new layer2_impl(log, debug, crc, repair, errorwidth)); 42 | } 43 | 44 | /* 45 | * The private constructor 46 | */ 47 | layer2_impl::layer2_impl(bool log, 48 | bool debug, 49 | bool crc, 50 | bool repair, 51 | unsigned char errorwidth) 52 | : gr::hier_block2("layer2", 53 | gr::io_signature::make(1, 1, sizeof(char)), 54 | gr::io_signature::make(1, 1, 24*sizeof(char))) 55 | { 56 | gr::darc::layer2_sync::sptr layer2_sync(gr::darc::layer2_sync::make(log, debug)); 57 | gr::darc::layer2_format::sptr layer2_format(gr::darc::layer2_format::make(log, 58 | debug, 59 | crc, 60 | repair, 61 | errorwidth)); 62 | 63 | 64 | connect(self(), 0, layer2_sync, 0); 65 | connect(layer2_sync, 0, layer2_format, 0); 66 | connect(layer2_format, 0, self(), 0); 67 | } 68 | 69 | /* 70 | * Our virtual destructor. 71 | */ 72 | layer2_impl::~layer2_impl() 73 | { 74 | } 75 | 76 | 77 | } /* namespace darc */ 78 | } /* namespace gr */ 79 | 80 | -------------------------------------------------------------------------------- /src/gr-darc/lib/layer2_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 <+YOU OR YOUR COMPANY+>. 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_DARC_LAYER2_IMPL_H 22 | #define INCLUDED_DARC_LAYER2_IMPL_H 23 | 24 | #include 25 | 26 | namespace gr { 27 | namespace darc { 28 | 29 | class layer2_impl : public layer2 30 | { 31 | private: 32 | // Nothing to declare in this block. 33 | 34 | public: 35 | layer2_impl(bool log, 36 | bool debug, 37 | bool crc, 38 | bool repair, 39 | unsigned char errorwidth); 40 | ~layer2_impl(); 41 | 42 | // Where all the action really happens 43 | }; 44 | 45 | } // namespace darc 46 | } // namespace gr 47 | 48 | #endif /* INCLUDED_DARC_LAYER2_IMPL_H */ 49 | 50 | -------------------------------------------------------------------------------- /src/gr-darc/lib/layer2_sync_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 <+YOU OR YOUR COMPANY+>. 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 "darc_constants.h" 27 | #include "layer2_sync_impl.h" 28 | 29 | namespace gr { 30 | namespace darc { 31 | 32 | layer2_sync::sptr 33 | layer2_sync::make(bool log, bool debug) 34 | { 35 | return gnuradio::get_initial_sptr 36 | (new layer2_sync_impl(log, debug)); 37 | } 38 | 39 | /* 40 | * The private constructor 41 | */ 42 | layer2_sync_impl::layer2_sync_impl(bool log, bool debug) 43 | : gr::block("layer2_sync", 44 | gr::io_signature::make(1, 1, sizeof(char)), 45 | gr::io_signature::make(1, 1, 36*sizeof(char))), 46 | log(log), 47 | debug(debug) 48 | { 49 | } 50 | 51 | /* 52 | * Our virtual destructor. 53 | */ 54 | layer2_sync_impl::~layer2_sync_impl() 55 | { 56 | } 57 | 58 | void 59 | layer2_sync_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) 60 | { 61 | ninput_items_required[0] = BLOCK_LENGTH*(noutput_items+1); 62 | } 63 | 64 | int 65 | layer2_sync_impl::general_work (int noutput_items, 66 | gr_vector_int &ninput_items, 67 | gr_vector_const_void_star &input_items, 68 | gr_vector_void_star &output_items) 69 | { 70 | /********************************** 71 | TODO: 72 | Implement Search Window (2Bits up/dwn) 73 | What shall we do if in Sync, but no BIC found in search Window? --> To get a flull frame! 74 | **********************************/ 75 | const char *in = (const char *) input_items[0]; 76 | char *out = (char *) output_items[0]; 77 | 78 | int _noutput_items = 0; 79 | unsigned short bic = 0x00; 80 | unsigned int items_consumed = 0; 81 | 82 | dout << "ninput_items: " << ninput_items[0] << std::endl; 83 | dout << "noutput_items: " << noutput_items << std::endl; 84 | 85 | // Take care to have enough bits to form a packet 86 | while(items_consumed<(ninput_items[0]-BLOCK_LENGTH)) 87 | { 88 | bic=(bic<<1)|in[items_consumed]; // BIC Input shift register 89 | 90 | // BICs = (['0x135e', '0x74a6', '0xa791', '0xc875']) 91 | if ( 0x135e == bic 92 | || 0x74a6 == bic 93 | || 0xa791 == bic 94 | || 0xc875 == bic ) 95 | { 96 | //dout << "[DBG] BIC found" << std::endl; 97 | 98 | // Assign L2 Body 99 | unsigned int index = _noutput_items*(BLOCK_LENGTH/8); 100 | 101 | out[index++] = (char)((bic>>8) & 0xFF); 102 | out[index++] = (char)(bic & 0xFF); 103 | for(unsigned int cnt=0; cnt>8) & 0xFF); 118 | out[index+(idx*2)+1] = (char)(l2data[idx] & 0xFF); 119 | } 120 | } 121 | _noutput_items++; 122 | 123 | if(noutput_items <= _noutput_items) 124 | { 125 | dout << "Reached max noutput_items" << std::endl; 126 | break; 127 | } 128 | } 129 | else 130 | items_consumed++; //if no BIC found, take one more bit 131 | } 132 | dout << "consumed_items: " << _noutput_items * BLOCK_LENGTH << std::endl; 133 | dout << "_noutput_items: " << _noutput_items << std::endl; 134 | dout << std::endl; 135 | consume_each(items_consumed); 136 | return _noutput_items; 137 | } 138 | 139 | } /* namespace darc */ 140 | } /* namespace gr */ 141 | -------------------------------------------------------------------------------- /src/gr-darc/lib/layer2_sync_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 <+YOU OR YOUR COMPANY+>. 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_DARC_LAYER2_SYNC_IMPL_H 22 | #define INCLUDED_DARC_LAYER2_SYNC_IMPL_H 23 | 24 | #include 25 | 26 | namespace gr { 27 | namespace darc { 28 | 29 | class layer2_sync_impl : public layer2_sync 30 | { 31 | private: 32 | bool log; 33 | bool debug; 34 | 35 | unsigned short l2data[18]; 36 | 37 | public: 38 | layer2_sync_impl(bool log, bool debug); 39 | ~layer2_sync_impl(); 40 | 41 | // Where all the action really happens 42 | void forecast (int noutput_items, gr_vector_int &ninput_items_required); 43 | 44 | int general_work(int noutput_items, 45 | gr_vector_int &ninput_items, 46 | gr_vector_const_void_star &input_items, 47 | gr_vector_void_star &output_items); 48 | }; 49 | 50 | } // namespace darc 51 | } // namespace gr 52 | 53 | #endif /* INCLUDED_DARC_LAYER2_SYNC_IMPL_H */ 54 | 55 | -------------------------------------------------------------------------------- /src/gr-darc/lib/qa_darc.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_darc.h" 29 | 30 | CppUnit::TestSuite * 31 | qa_darc::suite() 32 | { 33 | CppUnit::TestSuite *s = new CppUnit::TestSuite("darc"); 34 | 35 | return s; 36 | } 37 | -------------------------------------------------------------------------------- /src/gr-darc/lib/qa_darc.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_DARC_H_ 24 | #define _QA_DARC_H_ 25 | 26 | #include 27 | #include 28 | 29 | //! collect all the tests for the gr-filter directory 30 | 31 | class __GR_ATTR_EXPORT qa_darc 32 | { 33 | public: 34 | //! return suite of tests for all of gr-filter directory 35 | static CppUnit::TestSuite *suite(); 36 | }; 37 | 38 | #endif /* _QA_DARC_H_ */ 39 | -------------------------------------------------------------------------------- /src/gr-darc/lib/test_darc.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_darc.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("darc.xml").c_str()); 40 | CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); 41 | 42 | runner.addTest(qa_darc::suite()); 43 | runner.setOutputter(xmlout); 44 | 45 | bool was_successful = runner.run("", false); 46 | 47 | return was_successful ? 0 : 1; 48 | } 49 | -------------------------------------------------------------------------------- /src/gr-darc/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}/darc 35 | ) 36 | 37 | ######################################################################## 38 | # Handle the unit tests 39 | ######################################################################## 40 | include(GrTest) 41 | 42 | set(GR_TEST_TARGET_DEPS gnuradio-darc) 43 | set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig) 44 | GR_ADD_TEST(qa_layer2 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_layer2.py) 45 | -------------------------------------------------------------------------------- /src/gr-darc/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 DARC module. Place your Python package 23 | description here (python/__init__.py). 24 | ''' 25 | 26 | # import swig generated symbols into the darc namespace 27 | try: 28 | # this might fail if the module is python-only 29 | from darc_swig import * 30 | except ImportError: 31 | pass 32 | 33 | # import any pure python here 34 | # 35 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/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 | -------------------------------------------------------------------------------- /src/gr-darc/python/qa_layer2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2015 <+YOU OR YOUR COMPANY+>. 5 | # 6 | # This 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 | # This software 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 this software; 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 | from gnuradio import gr, gr_unittest 23 | from gnuradio import blocks 24 | import darc_swig as darc 25 | 26 | class qa_layer2 (gr_unittest.TestCase): 27 | 28 | def setUp (self): 29 | self.tb = gr.top_block () 30 | 31 | def tearDown (self): 32 | self.tb = None 33 | 34 | def test_001_layer2(self): 35 | pass 36 | 37 | 38 | if __name__ == '__main__': 39 | gr_unittest.run(qa_layer2, "qa_layer2.xml") 40 | -------------------------------------------------------------------------------- /src/gr-darc/python/qa_layer2_sync.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2015 <+YOU OR YOUR COMPANY+>. 5 | # 6 | # This 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 | # This software 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 this software; 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 | from gnuradio import gr, gr_unittest 23 | from gnuradio import blocks 24 | import darc_swig as darc 25 | 26 | class qa_layer2_sync (gr_unittest.TestCase): 27 | 28 | 29 | from gnuradio import gr, gr_unittest 30 | from gnuradio import blocks 31 | import darc_swig as darc 32 | 33 | class qa_layer2 (gr_unittest.TestCase): 34 | 35 | def setUp (self): 36 | self.tb = gr.top_block () 37 | 38 | def tearDown (self): 39 | self.tb = None 40 | 41 | def test_001_layer2(self): 42 | pass 43 | 44 | if __name__ == '__main__': 45 | gr_unittest.run(qa_layer2_sync, "qa_layer2_sync.xml")) 46 | -------------------------------------------------------------------------------- /src/gr-darc/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 darc_sources) 24 | MESSAGE(STATUS "No C++ sources... skipping swig/") 25 | return() 26 | endif(NOT darc_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-darc) 47 | set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/darc_swig_doc.i) 48 | set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include) 49 | 50 | GR_SWIG_MAKE(darc_swig darc_swig.i) 51 | 52 | ######################################################################## 53 | # Install the build swig module 54 | ######################################################################## 55 | GR_SWIG_INSTALL(TARGETS darc_swig DESTINATION ${GR_PYTHON_DIR}/darc) 56 | 57 | ######################################################################## 58 | # Install swig .i files for development 59 | ######################################################################## 60 | install( 61 | FILES 62 | darc_swig.i 63 | ${CMAKE_CURRENT_BINARY_DIR}/darc_swig_doc.i 64 | DESTINATION ${GR_INCLUDE_DIR}/darc/swig 65 | ) 66 | -------------------------------------------------------------------------------- /src/gr-darc/swig/darc_swig.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | 3 | #define DARC_API 4 | 5 | %include "gnuradio.i" // the common stuff 6 | 7 | //load generated python docstrings 8 | %include "darc_swig_doc.i" 9 | 10 | %{ 11 | #include "darc/layer2.h" 12 | #include "darc/layer2_sync.h" 13 | #include "darc/layer2_format.h" 14 | %} 15 | 16 | 17 | %include "darc/layer2.h" 18 | GR_SWIG_BLOCK_MAGIC2(darc, layer2); 19 | %include "darc/layer2_sync.h" 20 | GR_SWIG_BLOCK_MAGIC2(darc, layer2_sync); 21 | %include "darc/layer2_format.h" 22 | GR_SWIG_BLOCK_MAGIC2(darc, layer2_format); 23 | -------------------------------------------------------------------------------- /src/py/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.pyc 3 | syndrome* 4 | -------------------------------------------------------------------------------- /src/py/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muccc/darc/eb48fcb9f038dd1119681c653e186ac71ee9a9a8/src/py/__init__.py -------------------------------------------------------------------------------- /src/py/darc_prototype.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: latin-1 -*- 3 | # 4 | 5 | # usage: 6 | # darc_prototype.py 7 | # 8 | 9 | from sys import argv 10 | from bitstring import Bits 11 | from bitstring import BitArray 12 | 13 | from darcstack import DarcStack 14 | 15 | if __name__ == '__main__': 16 | 17 | darcstack = DarcStack() 18 | 19 | filename = argv[1] 20 | f = Bits(filename=filename) 21 | 22 | x = 0 23 | while x < len(f): 24 | valid = darcstack.layer2(f[x:x+288]) 25 | 26 | if valid: 27 | # if CRC/Parity check is successful, 28 | # make a jump of x+288 to increase processing speed 29 | x += 288 30 | else: 31 | x += 1 32 | 33 | -------------------------------------------------------------------------------- /src/py/darc_syndrome_generator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # this script will win the prize for the slowest 4 | # script ever. 5 | from __future__ import print_function 6 | from bitstring import BitArray 7 | from sys import argv 8 | 9 | from darccrc import Crc 10 | 11 | def gen_syndrome(pBits): 12 | errorfield = ([BitArray('0b1'), \ 13 | BitArray('0b11')]) 14 | 15 | # build all possible error combinations as 16 | # block errors 17 | for length in range(3,pBits+1): 18 | # set first and last bit of errorstring and 19 | # count up in between 20 | for i in range(2**(length-2)): 21 | error = BitArray('0b1') 22 | error.append(BitArray(uint=i, length=length-2)) 23 | error.append('0b1') 24 | errorfield.append(error) 25 | 26 | for i in errorfield: 27 | 28 | error = i 29 | length = len(error) 30 | 31 | print(error) 32 | fh = open('syndrome82','a+') 33 | # place block errors in every possible position in 34 | # data string 35 | for pos in range(190-length+1): 36 | datastring = BitArray(length=190-length-pos) 37 | datastring.append(error) 38 | datastring.append(BitArray(length=pos)) 39 | # generate syndrome from datastring 40 | syndrome = crc.crc82(datastring) 41 | 42 | # make strings a multiple of 4 bit for nicer printing 43 | datastring.prepend('0b00') 44 | syndrome.prepend('0b00') 45 | 46 | fh.write(str(syndrome) + ' ' + str(datastring) + '\n') 47 | 48 | fh.close() 49 | 50 | 51 | if __name__ == '__main__': 52 | 53 | crc = Crc() 54 | 55 | amount_of_bits = int(argv[1]) 56 | gen_syndrome(amount_of_bits) 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/py/darc_udp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: latin-1 -*- 3 | # 4 | 5 | # usage: 6 | # darc_prototype.py 7 | # 8 | 9 | from sys import argv 10 | from bitstring import Bits 11 | 12 | from darcstack import DarcStack 13 | import socket 14 | 15 | 16 | if __name__ == '__main__': 17 | #UDP_IP = "192.168.1.152" 18 | UDP_IP = "127.0.0.1" 19 | UDP_PORT = 51337 20 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP 21 | sock.bind((UDP_IP, UDP_PORT)) 22 | 23 | darcstack = DarcStack() 24 | 25 | while True: 26 | data, addr = sock.recvfrom(24) 27 | #darcstack.layer2(Bits(bytes=data),False) 28 | darcstack.layer3a(Bits(bytes=data)) 29 | -------------------------------------------------------------------------------- /src/py/darccrc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from bitstring import BitArray 4 | 5 | # Generic implementation of Crc 6 | # plus darc-specific crc methods with 7 | # polynoms as stated in ETSI EN 300 751 Chapter 10 8 | class Crc: 9 | def __init__(self): 10 | pass 11 | 12 | # @input1 BitArray of Input Message 13 | # @input2 BitArray of CRC Polynom 14 | # @input3 BitArray of CRC Start Value 15 | # @return BitArray of CRC Result Value 16 | def crc(self, pMsg, pPolynom, pCode): 17 | 18 | crclen = len(pPolynom)-1 19 | #print(pPolynom) 20 | msg = pMsg + pCode 21 | for i in range(len(msg)-crclen): 22 | if msg[i] == True: 23 | for j in range(len(pPolynom)): 24 | msg[i+j] = msg[i+j] ^ pPolynom[j] 25 | #print msg[-crclen:] 26 | return msg[-crclen:] 27 | 28 | # L3 Short Message, Long Message 29 | # L4 Long Message 30 | def crc6(self, pMsg, pCode=BitArray(length=6)): 31 | # x^6 + x^4 + x^3 + 1 32 | return self.crc(pMsg, \ 33 | BitArray('0b1011001'), \ 34 | pCode) 35 | 36 | # L4 Short Message 37 | def crc8(self, pMsg, pCode=BitArray(length=8)): 38 | # x^8 + x^5 + x^4 + x^3 + 1 39 | return self.crc(pMsg, \ 40 | BitArray('0b100111001'), \ 41 | pCode) 42 | 43 | # L2 44 | def crc14(self, pMsg, pCode=BitArray(length=14)): 45 | # x^14 + x^11 + x^2 +1 46 | return self.crc(pMsg, \ 47 | BitArray('0b100100000000101'), \ 48 | pCode) 49 | 50 | # L5 data group 51 | # some specialties with data inversion as defined in standard 52 | def crc16(self, pMsg, pCode=BitArray(length=16)): 53 | # invert first 16 bit of input data 54 | pMsg[:16] = ~pMsg[:16] 55 | # x^16 + x^12 + x^5 +1 56 | # invert CRC before output 57 | return ~(self.crc(pMsg, \ 58 | BitArray('0b10001000000100001'), \ 59 | pCode)) 60 | 61 | # L2 parity 62 | def crc82(self, pMsg, pCode=BitArray(length=82)): 63 | # 11.1 64 | return self.crc(pMsg, \ 65 | BitArray('0b10000110000100011000000000100010001000000010001010000000001010001000000010000010001'), \ 66 | pCode) 67 | --------------------------------------------------------------------------------