diff options
author | Johnathan Corgan | 2009-11-13 11:28:58 -0800 |
---|---|---|
committer | Johnathan Corgan | 2009-11-13 11:28:58 -0800 |
commit | baac64c9f1ff5fd5eaf9c24159d56567fd4c6fca (patch) | |
tree | 33ed69583ffd3b1b0ec630d3383ca0935719857f | |
parent | 5787a2c4f9dbaca94f7b2e7d43f677a64209e5f7 (diff) | |
parent | df8b099a4b96ad41369a750d48a8576b95ecf454 (diff) | |
download | gnuradio-baac64c9f1ff5fd5eaf9c24159d56567fd4c6fca.tar.gz gnuradio-baac64c9f1ff5fd5eaf9c24159d56567fd4c6fca.tar.bz2 gnuradio-baac64c9f1ff5fd5eaf9c24159d56567fd4c6fca.zip |
Merge branch 'wip/howto' of git@gnuradio.org:jcorgan
* 'wip/howto' of git@gnuradio.org:jcorgan:
howto: cleanup for merge
howto: add README.hacking
howto: added howto application
howto: add GRC wrappers to squaring blocks
howto: move limbo'd docs into toplevel doc dir for preservation
howto: create howto_swig.*, use constructed Python namespace
howto: adds C++ QA code
40 files changed, 1014 insertions, 59 deletions
diff --git a/docs/howto-write-a-block/.gitignore b/docs/howto-write-a-block/.gitignore index 719ea5d4f..f65ab6cf7 100644 --- a/docs/howto-write-a-block/.gitignore +++ b/docs/howto-write-a-block/.gitignore @@ -1 +1,18 @@ +/Makefile +/Makefile.in +/.deps +/.libs +/*.la +/*.lo +/autom4te.cache +/*.cache /howto-write-a-block.html +/gr_block.h.xml +/howto_1.i.xml +/howto_square_ff.cc.xml +/howto_square_ff.h.xml +/qa_howto_1.py.xml +/src_lib_Makefile_1.am.xml +/src_lib_Makefile_2.am.xml +/howto_square2_ff.cc.xml +/howto_square2_ff.h.xml diff --git a/gr-howto-write-a-block/limbo/doc/Makefile.am b/docs/howto-write-a-block/Makefile.am index 5f58a21e9..5f58a21e9 100644 --- a/gr-howto-write-a-block/limbo/doc/Makefile.am +++ b/docs/howto-write-a-block/Makefile.am diff --git a/docs/howto-write-a-block/README b/docs/howto-write-a-block/README index 73b8e6028..ff3b75e57 100644 --- a/docs/howto-write-a-block/README +++ b/docs/howto-write-a-block/README @@ -1,3 +1 @@ -If you're looking for howto-write-a-block, it was moved into it's own -tarball: gr-howto-write-a-block. It includes the document source -and a full build tree, Makefiles, examples, etc. +The contents of this directory are obsolete. diff --git a/gr-howto-write-a-block/limbo/doc/howto-write-a-block.xml b/docs/howto-write-a-block/howto-write-a-block.xml index f8027b456..f8027b456 100644 --- a/gr-howto-write-a-block/limbo/doc/howto-write-a-block.xml +++ b/docs/howto-write-a-block/howto-write-a-block.xml diff --git a/gr-howto-write-a-block/limbo/doc/howto_1.i b/docs/howto-write-a-block/howto_1.i index 640d0897b..640d0897b 100644 --- a/gr-howto-write-a-block/limbo/doc/howto_1.i +++ b/docs/howto-write-a-block/howto_1.i diff --git a/gr-howto-write-a-block/limbo/doc/make_numbered_listing.py b/docs/howto-write-a-block/make_numbered_listing.py index 889c2d78d..889c2d78d 100755 --- a/gr-howto-write-a-block/limbo/doc/make_numbered_listing.py +++ b/docs/howto-write-a-block/make_numbered_listing.py diff --git a/gr-howto-write-a-block/limbo/doc/qa_howto_1.py b/docs/howto-write-a-block/qa_howto_1.py index 3173110f8..3173110f8 100755 --- a/gr-howto-write-a-block/limbo/doc/qa_howto_1.py +++ b/docs/howto-write-a-block/qa_howto_1.py diff --git a/gr-howto-write-a-block/limbo/doc/src_lib_Makefile_1.am b/docs/howto-write-a-block/src_lib_Makefile_1.am index e97d70d1c..e97d70d1c 100644 --- a/gr-howto-write-a-block/limbo/doc/src_lib_Makefile_1.am +++ b/docs/howto-write-a-block/src_lib_Makefile_1.am diff --git a/gr-howto-write-a-block/limbo/doc/src_lib_Makefile_2.am b/docs/howto-write-a-block/src_lib_Makefile_2.am index dca236e20..dca236e20 100644 --- a/gr-howto-write-a-block/limbo/doc/src_lib_Makefile_2.am +++ b/docs/howto-write-a-block/src_lib_Makefile_2.am diff --git a/gr-howto-write-a-block/Makefile.am b/gr-howto-write-a-block/Makefile.am index ce2e4e8ca..98368c211 100644 --- a/gr-howto-write-a-block/Makefile.am +++ b/gr-howto-write-a-block/Makefile.am @@ -29,9 +29,11 @@ EXTRA_DIST = \ config.h.in \ Makefile.swig \ Makefile.swig.gen.t \ - version.sh + version.sh \ + README \ + README.hacking -SUBDIRS = config lib swig python +SUBDIRS = config lib swig python grc apps pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = diff --git a/gr-howto-write-a-block/Makefile.common b/gr-howto-write-a-block/Makefile.common index 4b8081125..c81bc780d 100644 --- a/gr-howto-write-a-block/Makefile.common +++ b/gr-howto-write-a-block/Makefile.common @@ -50,6 +50,9 @@ swigincludedir = $(grincludedir)/swig grpythondir = $(pythondir)/gnuradio grpyexecdir = $(pyexecdir)/gnuradio +# Data directory for grc block wrappers +grc_blocksdir = $(prefix)/share/gnuradio/grc/blocks + # Don't assume that make predefines $(RM), because BSD make does # not. We define it now in configure.ac using AM_PATH_PROG, but now # here have to add a -f to be like GNU make. diff --git a/gr-howto-write-a-block/README b/gr-howto-write-a-block/README index 29c1e99b1..368e71994 100644 --- a/gr-howto-write-a-block/README +++ b/gr-howto-write-a-block/README @@ -1,5 +1,5 @@ # -# Copyright 2005, 2006 Free Software Foundation, Inc. +# Copyright 2005,2006,2009 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -27,7 +27,8 @@ rest of GNU Radio in order to avoid problems for people who have begun to write blocks with a modified copy of gr-howto-write-a-block. This package requires that gnuradio-core is already installed. It -also depends on some GNU Radio prerequisites, such as boost. +also depends on some GNU Radio prerequisites, such as Boost and +cppunit. To build the examples from the tarball use the normal recipe: @@ -35,16 +36,10 @@ To build the examples from the tarball use the normal recipe: $ make $ make check -If you're building from CVS, you'll need to use this sequence, since -CVS doesn't contain configure or the generated Makefiles. +If you're building from git, you'll need to use this sequence, since +git doesn't contain configure or the generated Makefiles. $ ./bootstrap $ ./configure $ make $ make check - - -The doc directory is not built by default. This is to avoid spurious -build problems on systems that don't have xmlto installed. If you -have xmlto and its dependencies installed, you can build the html -version of the howto article by cd'ing to doc and invoking make. diff --git a/gr-howto-write-a-block/README.hacking b/gr-howto-write-a-block/README.hacking new file mode 100644 index 000000000..c670fd19e --- /dev/null +++ b/gr-howto-write-a-block/README.hacking @@ -0,0 +1,95 @@ +# +# Copyright 2009 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +The layout of this tree is as follows. The top-level directory contains +the autoconf/automake build definition files: + +bootstrap +config.guess +config.sub +configure.ac +Makefile.am +Makefile.common +Makefile.swig +Makefile.swig.gen.t +version.sh + +Of these files, only configure.ac, Makefile.am, and Makefile.common would +likely need changing in order to customize this into a new out-of-tree +project. + +Subdirectory Layout +------------------- + +config - autoconf configuration macros +lib - GNU Radio blocks C++ API, shared lib and headers and QA code +swig - Generates Python API from C++ blocks +python - Pure Python modules (hierarchical blocks, other classes) +grc - GNU Radio Companion block wrappers +apps - GRC applications, scripts, or other executables installed to bin + +The 'config' directory contains autoconf configuration files which help the +configuration script discover various things about the software development +environment during the execution of the 'configure' script. These files +would likely not need any changing to customize this tree. + +The 'lib' directory contains those files needed to generate GNU Radio +signal processing blocks. These take the form of a shared library that one +dynamically links against, and header files that one would include in +their C++ GNU Radio application. This directory also contains the framework +for adding QA tests that are executed during 'make check' using the cppunit +unit testing framework. The generated shared library is installed into +$prefix/lib and the header files are installed into $prefix/include/gnuradio. + +Adding new blocks starts here, by adding new .cc and new .h files for each +new block, and modifying Makefile.am to add them to the build and link. If +desired, one can add unit tests to the QA framework that get executed during +'make check'. + +The 'swig' directory contains the SWIG machinery to create a Python module +that exports the C++ API into a Python namespace. Each GNU Radio block gets a +.i file (using SWIG syntax). The master howto.i file must also have a line +to include the block header file and a line to import the block .i file. The +resulting _howto_swig.so and _howto_swig.py files are installed into the +system Python lib directory under gnuradio/howto and become part of the +gnuradio.howto Python namespace. The Makefile.am must be customized to +recognize new files created here. + +The 'python' directory contains pure Python modules that get installed into +the system Python lib directory under gnuradio/howto and the __init__.py +module needed to turn the directory into the gnuradio.howto namespace. +This is the appropriate place to put hierarchical blocks and utility classes. +Be sure to edit the __init__.py to add your module/symbol imports as +necessary, and to modify the Makefile.am accordingly. + +This directory also contains Python-based QA code, which is executed during +'make check'. + +The 'grc' directory contains the XML-based wrappers that describe your blocks +to the GNU Radio Companion graphical flowgraph editor. These get installed +into the $prefix/share/gnuradio/grc/blocks directory and require modification +of the Makefile.am to recognize new files put here. Note: GRC only scans the +system directory for wrapper files, so you must do a 'make install' before +GRC will see your new files or modifications to existing ones. + +The 'apps' directory contains those Python and C++ programs which are to be +installed into the system $prefix/bin directory. (FIXME: there is not +currently an example of building a C++ binary in this directory.) diff --git a/gr-howto-write-a-block/apps/.gitignore b/gr-howto-write-a-block/apps/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-howto-write-a-block/apps/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-howto-write-a-block/apps/Makefile.am b/gr-howto-write-a-block/apps/Makefile.am new file mode 100644 index 000000000..85ed222cf --- /dev/null +++ b/gr-howto-write-a-block/apps/Makefile.am @@ -0,0 +1,32 @@ +# +# Copyright 2009 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +if PYTHON + +dist_bin_SCRIPTS = \ + howto_square.py + +EXTRA_DIST = \ + howto_square.grc + +endif diff --git a/gr-howto-write-a-block/apps/howto_square.grc b/gr-howto-write-a-block/apps/howto_square.grc new file mode 100644 index 000000000..a8563698b --- /dev/null +++ b/gr-howto-write-a-block/apps/howto_square.grc @@ -0,0 +1,325 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Thu Nov 12 11:26:07 2009</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>howto_square</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value></value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></value> + </param> + <param> + <key>window_size</key> + <value>1280, 1024</value> + </param> + <param> + <key>generate_options</key> + <value>wx_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 10)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>10e3</value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 170)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_scopesink2</key> + <param> + <key>id</key> + <value>sink</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>title</key> + <value>Input</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>v_scale</key> + <value>20</value> + </param> + <param> + <key>v_offset</key> + <value>0</value> + </param> + <param> + <key>t_scale</key> + <value>0.002</value> + </param> + <param> + <key>ac_couple</key> + <value>False</value> + </param> + <param> + <key>xy_mode</key> + <value>False</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(691, 222)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>howto_square_ff</key> + <param> + <key>id</key> + <value>sqr</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(709, 344)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_throttle</key> + <param> + <key>id</key> + <value>thr</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>samples_per_second</key> + <value>samp_rate</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(497, 340)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_vector_source_x</key> + <param> + <key>id</key> + <value>src</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>vector</key> + <value>[float(n)-50 for n in range(100)]</value> + </param> + <param> + <key>repeat</key> + <value>True</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(246, 332)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_scopesink2</key> + <param> + <key>id</key> + <value>sink2</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>title</key> + <value>Output</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>v_scale</key> + <value>0</value> + </param> + <param> + <key>v_offset</key> + <value>0</value> + </param> + <param> + <key>t_scale</key> + <value>0.002</value> + </param> + <param> + <key>ac_couple</key> + <value>False</value> + </param> + <param> + <key>xy_mode</key> + <value>False</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(869, 324)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>thr</source_block_id> + <sink_block_id>sqr</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>src</source_block_id> + <sink_block_id>thr</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>thr</source_block_id> + <sink_block_id>sink</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>sqr</source_block_id> + <sink_block_id>sink2</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-howto-write-a-block/apps/howto_square.py b/gr-howto-write-a-block/apps/howto_square.py new file mode 100755 index 000000000..8d3d870d8 --- /dev/null +++ b/gr-howto-write-a-block/apps/howto_square.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: Howto Square +# Generated: Thu Nov 12 11:26:07 2009 +################################################## + +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import howto +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from gnuradio.wxgui import scopesink2 +from grc_gnuradio import wxgui as grc_wxgui +from optparse import OptionParser +import wx + +class howto_square(grc_wxgui.top_block_gui): + + def __init__(self): + grc_wxgui.top_block_gui.__init__(self, title="Howto Square") + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 10e3 + + ################################################## + # Blocks + ################################################## + self.sink = scopesink2.scope_sink_f( + self.GetWin(), + title="Input", + sample_rate=samp_rate, + v_scale=20, + v_offset=0, + t_scale=0.002, + ac_couple=False, + xy_mode=False, + num_inputs=1, + ) + self.Add(self.sink.win) + self.sink2 = scopesink2.scope_sink_f( + self.GetWin(), + title="Output", + sample_rate=samp_rate, + v_scale=0, + v_offset=0, + t_scale=0.002, + ac_couple=False, + xy_mode=False, + num_inputs=1, + ) + self.Add(self.sink2.win) + self.sqr = howto.square_ff() + self.src = gr.vector_source_f(([float(n)-50 for n in range(100)]), True, 1) + self.thr = gr.throttle(gr.sizeof_float*1, samp_rate) + + ################################################## + # Connections + ################################################## + self.connect((self.thr, 0), (self.sqr, 0)) + self.connect((self.src, 0), (self.thr, 0)) + self.connect((self.thr, 0), (self.sink, 0)) + self.connect((self.sqr, 0), (self.sink2, 0)) + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.sink.set_sample_rate(self.samp_rate) + self.sink2.set_sample_rate(self.samp_rate) + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + (options, args) = parser.parse_args() + tb = howto_square() + tb.Run(True) + diff --git a/gr-howto-write-a-block/config/gr_standalone.m4 b/gr-howto-write-a-block/config/gr_standalone.m4 index 593583e2d..3f8ddf1d6 100644 --- a/gr-howto-write-a-block/config/gr_standalone.m4 +++ b/gr-howto-write-a-block/config/gr_standalone.m4 @@ -124,4 +124,12 @@ m4_define([GR_STANDALONE], [enable_python=yes] ) AM_CONDITIONAL([PYTHON], [test x$enable_python = xyes]) + + dnl Define where to look for cppunit includes and libs + dnl sets CPPUNIT_CFLAGS and CPPUNIT_LIBS + dnl Try using pkg-config first, then fall back to cppunit-config. + PKG_CHECK_EXISTS(cppunit, + [PKG_CHECK_MODULES(CPPUNIT, cppunit >= 1.9.14)], + [AM_PATH_CPPUNIT([1.9.14],[], + [AC_MSG_ERROR([GNU Radio requires cppunit. Stop])])]) ]) diff --git a/gr-howto-write-a-block/configure.ac b/gr-howto-write-a-block/configure.ac index 8241f7ec1..52c4639bb 100644 --- a/gr-howto-write-a-block/configure.ac +++ b/gr-howto-write-a-block/configure.ac @@ -71,7 +71,9 @@ dnl AX_BOOST_WSERIALIZATION AC_CONFIG_FILES([\ Makefile \ + apps/Makefile \ config/Makefile \ + grc/Makefile \ lib/Makefile \ python/Makefile \ python/run_tests \ diff --git a/gr-howto-write-a-block/grc/.gitignore b/gr-howto-write-a-block/grc/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-howto-write-a-block/grc/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-howto-write-a-block/grc/Makefile.am b/gr-howto-write-a-block/grc/Makefile.am new file mode 100644 index 000000000..32dcf1b9e --- /dev/null +++ b/gr-howto-write-a-block/grc/Makefile.am @@ -0,0 +1,29 @@ +# +# Copyright 2009 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +grcblocksdir = $(grc_blocksdir) + +dist_grcblocks_DATA = \ + howto_square_ff.xml \ + howto_square2_ff.xml + diff --git a/gr-howto-write-a-block/grc/howto_square2_ff.xml b/gr-howto-write-a-block/grc/howto_square2_ff.xml new file mode 100644 index 000000000..2b46106e8 --- /dev/null +++ b/gr-howto-write-a-block/grc/howto_square2_ff.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<block> + <name>Square2</name> + <key>howto_square2_ff</key> + <category>HOWTO</category> + <import>from gnuradio import howto</import> + <make>howto.square2_ff()</make> + + <sink> + <name>in</name> + <type>float</type> + </sink> + + <source> + <name>out</name> + <type>float</type> + </source> +</block> diff --git a/gr-howto-write-a-block/grc/howto_square_ff.xml b/gr-howto-write-a-block/grc/howto_square_ff.xml new file mode 100644 index 000000000..ed318bfc6 --- /dev/null +++ b/gr-howto-write-a-block/grc/howto_square_ff.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<block> + <name>Square</name> + <key>howto_square_ff</key> + <category>HOWTO</category> + <import>from gnuradio import howto</import> + <make>howto.square_ff()</make> + + <sink> + <name>in</name> + <type>float</type> + </sink> + + <source> + <name>out</name> + <type>float</type> + </source> +</block> diff --git a/gr-howto-write-a-block/lib/.gitignore b/gr-howto-write-a-block/lib/.gitignore index d957a6821..b1e56d39e 100644 --- a/gr-howto-write-a-block/lib/.gitignore +++ b/gr-howto-write-a-block/lib/.gitignore @@ -9,3 +9,4 @@ /*.pyc /howto.cc /howto.py +/test_all
\ No newline at end of file diff --git a/gr-howto-write-a-block/lib/Makefile.am b/gr-howto-write-a-block/lib/Makefile.am index e553c193d..336cb8a20 100644 --- a/gr-howto-write-a-block/lib/Makefile.am +++ b/gr-howto-write-a-block/lib/Makefile.am @@ -21,8 +21,12 @@ include $(top_srcdir)/Makefile.common -################################### -# howto C++ library +# list of programs run by "make check" and "make distcheck" +TESTS = test_all + +# ---------------------------------------------------------------- +# howto C++ library: libgnuradio-howto.so +# ---------------------------------------------------------------- # C/C++ headers get installed in ${prefix}/include/gnuradio grinclude_HEADERS = \ @@ -40,3 +44,37 @@ libgnuradio_howto_la_LIBADD = \ libgnuradio_howto_la_LDFLAGS = \ $(NO_UNDEFINED) + +# ---------------------------------------------------------------- +# howto C++ QA library: libgnuradio-howto-qa.so (not installed) +# ---------------------------------------------------------------- + +noinst_LTLIBRARIES = libgnuradio-howto-qa.la + +libgnuradio_howto_qa_la_SOURCES = \ + qa_howto.cc \ + qa_howto_square_ff.cc \ + qa_howto_square2_ff.cc + +libgnuradio_howto_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 + +libgnuradio_howto_qa_la_LIBADD = \ + libgnuradio-howto.la \ + $(CPPUNIT_LIBS) + +# ---------------------------------------------------------------- +# headers that don't get installed +# ---------------------------------------------------------------- +noinst_HEADERS = \ + qa_howto.h \ + qa_howto_square_ff.h \ + qa_howto_square2_ff.h + +# ---------------------------------------------------------------- +# test program +# ---------------------------------------------------------------- +noinst_PROGRAMS = \ + test_all + +test_all_SOURCES = test_all.cc +test_all_LDADD = libgnuradio-howto-qa.la diff --git a/gr-howto-write-a-block/lib/qa_howto.cc b/gr-howto-write-a-block/lib/qa_howto.cc new file mode 100644 index 000000000..f1411a388 --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto.cc @@ -0,0 +1,41 @@ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +/* + * This class gathers together all the test cases for the example + * directory into a single test suite. As you create new test cases, + * add them here. + */ + +#include <qa_howto.h> +#include <qa_howto_square_ff.h> +#include <qa_howto_square2_ff.h> + +CppUnit::TestSuite * +qa_howto::suite() +{ + CppUnit::TestSuite *s = new CppUnit::TestSuite("howto"); + + s->addTest(qa_howto_square_ff::suite()); + s->addTest(qa_howto_square2_ff::suite()); + + return s; +} diff --git a/gr-howto-write-a-block/lib/qa_howto.h b/gr-howto-write-a-block/lib/qa_howto.h new file mode 100644 index 000000000..fa5a42fd3 --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto.h @@ -0,0 +1,36 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU Example Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Example Public License for more details. + * + * You should have received a copy of the GNU Example Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_QA_HOWTO_H +#define INCLUDED_QA_HOWTO_H + +#include <cppunit/TestSuite.h> + +//! collect all the tests for the example directory + +class qa_howto { + public: + //! return suite of tests for all of example directory + static CppUnit::TestSuite *suite (); +}; + +#endif /* INCLUDED_QA_HOWTO_H */ diff --git a/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc b/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc new file mode 100644 index 000000000..a37465104 --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc @@ -0,0 +1,35 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <qa_howto_square2_ff.h> +#include <cppunit/TestAssert.h> + +void +qa_howto_square2_ff::t1() +{ + // Insert CPPUNIT tests/asserts here +} + +void +qa_howto_square2_ff::t2() +{ + // Insert CPPUNIT tests/asserts here +} diff --git a/gr-howto-write-a-block/lib/qa_howto_square2_ff.h b/gr-howto-write-a-block/lib/qa_howto_square2_ff.h new file mode 100644 index 000000000..c74d0866f --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto_square2_ff.h @@ -0,0 +1,39 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_QA_HOWTO_SQUARE2_FF_H +#define INCLUDED_QA_HOWTO_SQUARE2_FF_H + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCase.h> + +class qa_howto_square2_ff : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_howto_square2_ff); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST_SUITE_END (); + + private: + void t1 (); + void t2 (); +}; + +#endif /* INCLUDED_QA_HOWTO_SQUARE2_FF_H */ diff --git a/gr-howto-write-a-block/lib/qa_howto_square_ff.cc b/gr-howto-write-a-block/lib/qa_howto_square_ff.cc new file mode 100644 index 000000000..2f0b59773 --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto_square_ff.cc @@ -0,0 +1,35 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <qa_howto_square_ff.h> +#include <cppunit/TestAssert.h> + +void +qa_howto_square_ff::t1() +{ + // Insert CPPUNIT tests/asserts here +} + +void +qa_howto_square_ff::t2() +{ + // Insert CPPUNIT tests/asserts here +} diff --git a/gr-howto-write-a-block/lib/qa_howto_square_ff.h b/gr-howto-write-a-block/lib/qa_howto_square_ff.h new file mode 100644 index 000000000..1b7c5e99f --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto_square_ff.h @@ -0,0 +1,39 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_QA_HOWTO_SQUARE_FF_H +#define INCLUDED_QA_HOWTO_SQUARE_FF_H + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCase.h> + +class qa_howto_square_ff : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_howto_square_ff); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST_SUITE_END (); + + private: + void t1 (); + void t2 (); +}; + +#endif /* INCLUDED_QA_HOWTO_SQUARE_FF_H */ diff --git a/gr-howto-write-a-block/lib/test_all.cc b/gr-howto-write-a-block/lib/test_all.cc new file mode 100644 index 000000000..192c537bc --- /dev/null +++ b/gr-howto-write-a-block/lib/test_all.cc @@ -0,0 +1,38 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <cppunit/TextTestRunner.h> + +#include <qa_howto.h> + +int +main (int argc, char **argv) +{ + + CppUnit::TextTestRunner runner; + + runner.addTest(qa_howto::suite ()); + + bool was_successful = runner.run("", false); + + return was_successful ? 0 : 1; +} diff --git a/gr-howto-write-a-block/limbo/doc/.gitignore b/gr-howto-write-a-block/limbo/doc/.gitignore deleted file mode 100644 index f65ab6cf7..000000000 --- a/gr-howto-write-a-block/limbo/doc/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -/Makefile -/Makefile.in -/.deps -/.libs -/*.la -/*.lo -/autom4te.cache -/*.cache -/howto-write-a-block.html -/gr_block.h.xml -/howto_1.i.xml -/howto_square_ff.cc.xml -/howto_square_ff.h.xml -/qa_howto_1.py.xml -/src_lib_Makefile_1.am.xml -/src_lib_Makefile_2.am.xml -/howto_square2_ff.cc.xml -/howto_square2_ff.h.xml diff --git a/gr-howto-write-a-block/limbo/doc/README b/gr-howto-write-a-block/limbo/doc/README deleted file mode 100644 index ff3b75e57..000000000 --- a/gr-howto-write-a-block/limbo/doc/README +++ /dev/null @@ -1 +0,0 @@ -The contents of this directory are obsolete. diff --git a/gr-howto-write-a-block/python/Makefile.am b/gr-howto-write-a-block/python/Makefile.am index 79f44019d..4ef5fc964 100644 --- a/gr-howto-write-a-block/python/Makefile.am +++ b/gr-howto-write-a-block/python/Makefile.am @@ -21,12 +21,13 @@ include $(top_srcdir)/Makefile.common -EXTRA_DIST = run_tests.in - +ourpythondir = $(grpythondir)/howto -TESTS = \ - run_tests +EXTRA_DIST = run_tests.in +TESTS = run_tests +ourpython_PYTHON = \ + __init__.py -noinst_PYTHON = \ +noinst_PYTHON = \ qa_howto.py diff --git a/gr-howto-write-a-block/python/__init__.py b/gr-howto-write-a-block/python/__init__.py new file mode 100644 index 000000000..d4a41c271 --- /dev/null +++ b/gr-howto-write-a-block/python/__init__.py @@ -0,0 +1,49 @@ +# +# Copyright 2008,2009 Free Software Foundation, Inc. +# +# This application is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This application is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +# The presence of this file turns this directory into a Python package + +# ---------------------------------------------------------------- +# Temporary workaround for ticket:181 (swig+python problem) +import sys +_RTLD_GLOBAL = 0 +try: + from dl import RTLD_GLOBAL as _RTLD_GLOBAL +except ImportError: + try: + from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL + except ImportError: + pass + +if _RTLD_GLOBAL != 0: + _dlopenflags = sys.getdlopenflags() + sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL) +# ---------------------------------------------------------------- + + +# import swig generated symbols into the howto namespace +from howto_swig import * + +# import any pure python here +# + +# ---------------------------------------------------------------- +# Tail of workaround +if _RTLD_GLOBAL != 0: + sys.setdlopenflags(_dlopenflags) # Restore original flags +# ---------------------------------------------------------------- diff --git a/gr-howto-write-a-block/python/qa_howto.py b/gr-howto-write-a-block/python/qa_howto.py index 0abe0e244..630f57bf4 100755 --- a/gr-howto-write-a-block/python/qa_howto.py +++ b/gr-howto-write-a-block/python/qa_howto.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import howto +import howto_swig class qa_howto (gr_unittest.TestCase): @@ -35,7 +35,7 @@ class qa_howto (gr_unittest.TestCase): src_data = (-3, 4, -5.5, 2, 3) expected_result = (9, 16, 30.25, 4, 9) src = gr.vector_source_f (src_data) - sqr = howto.square_ff () + sqr = howto_swig.square_ff () dst = gr.vector_sink_f () self.tb.connect (src, sqr) self.tb.connect (sqr, dst) @@ -47,7 +47,7 @@ class qa_howto (gr_unittest.TestCase): src_data = (-3, 4, -5.5, 2, 3) expected_result = (9, 16, 30.25, 4, 9) src = gr.vector_source_f (src_data) - sqr = howto.square2_ff () + sqr = howto_swig.square2_ff () dst = gr.vector_sink_f () self.tb.connect (src, sqr) self.tb.connect (sqr, dst) diff --git a/gr-howto-write-a-block/swig/.gitignore b/gr-howto-write-a-block/swig/.gitignore index 916527317..7f4c478d9 100644 --- a/gr-howto-write-a-block/swig/.gitignore +++ b/gr-howto-write-a-block/swig/.gitignore @@ -2,5 +2,5 @@ /.libs /Makefile.in /Makefile -/howto.cc -/howto.py +/howto_swig.cc +/howto_swig.py diff --git a/gr-howto-write-a-block/swig/Makefile.am b/gr-howto-write-a-block/swig/Makefile.am index 8c94f5041..fc40109d0 100644 --- a/gr-howto-write-a-block/swig/Makefile.am +++ b/gr-howto-write-a-block/swig/Makefile.am @@ -34,8 +34,7 @@ TOP_SWIG_IFILES = \ # import gnuradio.howto # This ends up at: # ${prefix}/lib/python${python_version}/site-packages/gnuradio -howto_pythondir_category = \ - gnuradio +howto_pythondir_category = gnuradio/howto howto_la_swig_libadd = \ $(top_builddir)/lib/libgnuradio-howto.la diff --git a/gr-howto-write-a-block/swig/Makefile.swig.gen b/gr-howto-write-a-block/swig/Makefile.swig.gen index f76cc6371..c62e5aa3e 100644 --- a/gr-howto-write-a-block/swig/Makefile.swig.gen +++ b/gr-howto-write-a-block/swig/Makefile.swig.gen @@ -72,42 +72,42 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* ## .h file is sometimes built, but not always ... so that one has to ## be added manually by the including Makefile.am . -swig_built_sources += howto.py howto.cc +swig_built_sources += howto_swig.py howto_swig.cc ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including ## Makefile.swig . howto_swiginclude_HEADERS = \ - howto.i \ + howto.i \ $(howto_swiginclude_headers) howto_pylib_LTLIBRARIES = \ - _howto.la + _howto_swig.la -_howto_la_SOURCES = \ - howto.cc \ +_howto_swig_la_SOURCES = \ + howto_swig.cc \ $(howto_la_swig_sources) -_howto_la_LIBADD = \ +_howto_swig_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ $(howto_la_swig_libadd) -_howto_la_LDFLAGS = \ +_howto_swig_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ $(howto_la_swig_ldflags) -_howto_la_CXXFLAGS = \ +_howto_swig_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ $(howto_la_swig_cxxflags) howto_python_PYTHON = \ - howto.py \ + howto_swig.py \ $(howto_python) ## Entry rule for running SWIG -howto.h howto.py howto.cc: howto.i +howto.h howto_swig.py howto_swig.cc: howto.i ## This rule will get called only when MAKE decides that one of the ## targets needs to be created or re-created, because: ## @@ -202,7 +202,7 @@ $(DEPDIR)/howto-generate-stamp: ## if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(howto_swig_args) \ -MD -MF $(DEPDIR)/howto.Std \ - -module howto -o howto.cc $(WHAT); then \ + -module howto_swig -o howto_swig.cc $(WHAT); then \ if test $(host_os) = mingw32; then \ $(RM) $(DEPDIR)/howto.Sd; \ $(SED) 's,\\\\,/,g' < $(DEPDIR)/howto.Std \ |