summaryrefslogtreecommitdiff
path: root/gr-howto-write-a-block
diff options
context:
space:
mode:
Diffstat (limited to 'gr-howto-write-a-block')
-rw-r--r--gr-howto-write-a-block/CMakeLists.txt15
-rw-r--r--gr-howto-write-a-block/apps/howto_square.grc36
-rwxr-xr-xgr-howto-write-a-block/apps/howto_square.py36
-rw-r--r--gr-howto-write-a-block/apps/howto_square_qt.grc285
-rwxr-xr-xgr-howto-write-a-block/apps/howto_square_qt.py100
-rw-r--r--gr-howto-write-a-block/cmake/Modules/FindCppUnit.cmake36
-rw-r--r--gr-howto-write-a-block/docs/README.howto11
-rw-r--r--gr-howto-write-a-block/include/howto/CMakeLists.txt (renamed from gr-howto-write-a-block/include/CMakeLists.txt)8
-rw-r--r--gr-howto-write-a-block/include/howto/api.h (renamed from gr-howto-write-a-block/include/howto_api.h)0
-rw-r--r--gr-howto-write-a-block/include/howto/square2_ff.h68
-rw-r--r--gr-howto-write-a-block/include/howto/square_ff.h68
-rw-r--r--gr-howto-write-a-block/include/howto_square2_ff.h78
-rw-r--r--gr-howto-write-a-block/include/howto_square_ff.h82
-rw-r--r--gr-howto-write-a-block/lib/CMakeLists.txt42
-rw-r--r--gr-howto-write-a-block/lib/howto_square2_ff.cc92
-rw-r--r--gr-howto-write-a-block/lib/howto_square_ff.cc98
-rw-r--r--gr-howto-write-a-block/lib/qa_howto.cc41
-rw-r--r--gr-howto-write-a-block/lib/qa_howto.h (renamed from gr-howto-write-a-block/lib/qa_howto_square2_ff.cc)32
-rw-r--r--gr-howto-write-a-block/lib/qa_howto_square_ff.cc32
-rw-r--r--gr-howto-write-a-block/lib/qa_square2_ff.cc63
-rw-r--r--gr-howto-write-a-block/lib/qa_square2_ff.h46
-rw-r--r--gr-howto-write-a-block/lib/qa_square_ff.cc63
-rw-r--r--gr-howto-write-a-block/lib/qa_square_ff.h46
-rw-r--r--gr-howto-write-a-block/lib/square2_ff_impl.cc98
-rw-r--r--gr-howto-write-a-block/lib/square2_ff_impl.h51
-rw-r--r--gr-howto-write-a-block/lib/square_ff_impl.cc105
-rw-r--r--gr-howto-write-a-block/lib/square_ff_impl.h52
-rw-r--r--gr-howto-write-a-block/lib/test_howto.cc43
-rw-r--r--[-rwxr-xr-x]gr-howto-write-a-block/python/qa_howto.py50
-rw-r--r--gr-howto-write-a-block/swig/howto_swig.i13
30 files changed, 1321 insertions, 469 deletions
diff --git a/gr-howto-write-a-block/CMakeLists.txt b/gr-howto-write-a-block/CMakeLists.txt
index 02b13c6b69..f86fd91488 100644
--- a/gr-howto-write-a-block/CMakeLists.txt
+++ b/gr-howto-write-a-block/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -57,7 +57,7 @@ set(Boost_ADDITIONAL_VERSIONS
"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"
"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"
)
-find_package(Boost "1.35")
+find_package(Boost "1.35" COMPONENTS filesystem system)
if(NOT Boost_FOUND)
message(FATAL_ERROR "Boost required to compile howto")
@@ -69,7 +69,7 @@ endif()
include(GrPlatform) #define LIB_SUFFIX
set(GR_RUNTIME_DIR bin)
set(GR_LIBRARY_DIR lib${LIB_SUFFIX})
-set(GR_INCLUDE_DIR include)
+set(GR_INCLUDE_DIR include/howto)
set(GR_DATA_DIR share)
set(GR_PKG_DATA_DIR ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME})
set(GR_DOC_DIR ${GR_DATA_DIR}/doc)
@@ -85,6 +85,7 @@ set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks)
########################################################################
find_package(Gruel)
find_package(GnuradioCore)
+find_package(CppUnit)
if(NOT GRUEL_FOUND)
message(FATAL_ERROR "Gruel required to compile howto")
@@ -94,6 +95,10 @@ if(NOT GNURADIO_CORE_FOUND)
message(FATAL_ERROR "GnuRadio Core required to compile howto")
endif()
+if(NOT CPPUNIT_FOUND)
+ message(FATAL_ERROR "CppUnit required to compile howto")
+endif()
+
########################################################################
# Setup the include and linker paths
########################################################################
@@ -102,12 +107,14 @@ include_directories(
${GNURADIO_CORE_INCLUDE_DIRS}
${GRUEL_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
+ ${CPPUNIT_INCLUDE_DIRS}
)
link_directories(
${GNURADIO_CORE_LIBRARY_DIRS}
${GRUEL_LIBRARY_DIRS}
${Boost_LIBRARY_DIRS}
+ ${CPPUNIT_LIBRARY_DIRS}
)
# Set component parameters
@@ -129,7 +136,7 @@ add_custom_target(uninstall
########################################################################
# Add subdirectories
########################################################################
-add_subdirectory(include)
+add_subdirectory(include/howto)
add_subdirectory(lib)
add_subdirectory(swig)
add_subdirectory(python)
diff --git a/gr-howto-write-a-block/apps/howto_square.grc b/gr-howto-write-a-block/apps/howto_square.grc
index a8563698b8..1f3324e4eb 100644
--- a/gr-howto-write-a-block/apps/howto_square.grc
+++ b/gr-howto-write-a-block/apps/howto_square.grc
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='ASCII'?>
<flow_graph>
- <timestamp>Thu Nov 12 11:26:07 2009</timestamp>
+ <timestamp>Sun Sep 30 13:32:27 2012</timestamp>
<block>
<key>options</key>
<param>
@@ -44,6 +44,10 @@
<value>True</value>
</param>
<param>
+ <key>max_nouts</key>
+ <value>0</value>
+ </param>
+ <param>
<key>realtime_scheduling</key>
<value></value>
</param>
@@ -72,7 +76,7 @@
</param>
<param>
<key>_coordinate</key>
- <value>(10, 170)</value>
+ <value>(176, 11)</value>
</param>
<param>
<key>_rotation</key>
@@ -138,8 +142,16 @@
<value></value>
</param>
<param>
+ <key>trig_mode</key>
+ <value>gr.gr_TRIG_MODE_AUTO</value>
+ </param>
+ <param>
+ <key>y_axis_label</key>
+ <value>Counts</value>
+ </param>
+ <param>
<key>_coordinate</key>
- <value>(691, 222)</value>
+ <value>(645, 11)</value>
</param>
<param>
<key>_rotation</key>
@@ -158,7 +170,7 @@
</param>
<param>
<key>_coordinate</key>
- <value>(709, 344)</value>
+ <value>(484, 163)</value>
</param>
<param>
<key>_rotation</key>
@@ -166,7 +178,7 @@
</param>
</block>
<block>
- <key>gr_throttle</key>
+ <key>blocks_throttle</key>
<param>
<key>id</key>
<value>thr</value>
@@ -189,7 +201,7 @@
</param>
<param>
<key>_coordinate</key>
- <value>(497, 340)</value>
+ <value>(272, 159)</value>
</param>
<param>
<key>_rotation</key>
@@ -224,7 +236,7 @@
</param>
<param>
<key>_coordinate</key>
- <value>(246, 332)</value>
+ <value>(21, 151)</value>
</param>
<param>
<key>_rotation</key>
@@ -290,8 +302,16 @@
<value></value>
</param>
<param>
+ <key>trig_mode</key>
+ <value>gr.gr_TRIG_MODE_AUTO</value>
+ </param>
+ <param>
+ <key>y_axis_label</key>
+ <value>Counts</value>
+ </param>
+ <param>
<key>_coordinate</key>
- <value>(869, 324)</value>
+ <value>(644, 150)</value>
</param>
<param>
<key>_rotation</key>
diff --git a/gr-howto-write-a-block/apps/howto_square.py b/gr-howto-write-a-block/apps/howto_square.py
index f14e28325d..140067b59f 100755
--- a/gr-howto-write-a-block/apps/howto_square.py
+++ b/gr-howto-write-a-block/apps/howto_square.py
@@ -2,17 +2,18 @@
##################################################
# Gnuradio Python Flow Graph
# Title: Howto Square
-# Generated: Thu Nov 12 11:26:07 2009
+# Generated: Sun Sep 30 13:32:52 2012
##################################################
-import howto
from gnuradio import eng_notation
from gnuradio import gr
+from gnuradio import blocks
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 howto
import wx
class howto_square(grc_wxgui.top_block_gui):
@@ -28,33 +29,37 @@ class howto_square(grc_wxgui.top_block_gui):
##################################################
# Blocks
##################################################
- self.sink = scopesink2.scope_sink_f(
+ self.thr = blocks.throttle(gr.sizeof_float*1, samp_rate)
+ self.src = gr.vector_source_f(([float(n)-50 for n in range(100)]), True, 1)
+ self.sqr = howto.square_ff()
+ self.sink2 = scopesink2.scope_sink_f(
self.GetWin(),
- title="Input",
+ title="Output",
sample_rate=samp_rate,
- v_scale=20,
+ v_scale=0,
v_offset=0,
t_scale=0.002,
ac_couple=False,
xy_mode=False,
num_inputs=1,
+ trig_mode=gr.gr_TRIG_MODE_AUTO,
+ y_axis_label="Counts",
)
- self.Add(self.sink.win)
- self.sink2 = scopesink2.scope_sink_f(
+ self.Add(self.sink2.win)
+ self.sink = scopesink2.scope_sink_f(
self.GetWin(),
- title="Output",
+ title="Input",
sample_rate=samp_rate,
- v_scale=0,
+ v_scale=20,
v_offset=0,
t_scale=0.002,
ac_couple=False,
xy_mode=False,
num_inputs=1,
+ trig_mode=gr.gr_TRIG_MODE_AUTO,
+ y_axis_label="Counts",
)
- 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)
+ self.Add(self.sink.win)
##################################################
# Connections
@@ -64,6 +69,11 @@ class howto_square(grc_wxgui.top_block_gui):
self.connect((self.thr, 0), (self.sink, 0))
self.connect((self.sqr, 0), (self.sink2, 0))
+# QT sink close method reimplementation
+
+ def get_samp_rate(self):
+ return self.samp_rate
+
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.sink.set_sample_rate(self.samp_rate)
diff --git a/gr-howto-write-a-block/apps/howto_square_qt.grc b/gr-howto-write-a-block/apps/howto_square_qt.grc
new file mode 100644
index 0000000000..c4c72adca0
--- /dev/null
+++ b/gr-howto-write-a-block/apps/howto_square_qt.grc
@@ -0,0 +1,285 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+ <timestamp>Sat Nov 10 15:23:43 2012</timestamp>
+ <block>
+ <key>options</key>
+ <param>
+ <key>id</key>
+ <value>howto_square_qt</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>qt_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>max_nouts</key>
+ <value>0</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>32000</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(183, 12)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>howto_square2_ff</key>
+ <param>
+ <key>id</key>
+ <value>howto_square2_ff_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(445, 100)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>howto_square_ff</key>
+ <param>
+ <key>id</key>
+ <value>howto_square_ff_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(445, 168)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>qtgui_time_sink_x</key>
+ <param>
+ <key>id</key>
+ <value>qtgui_time_sink_x_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>name</key>
+ <value>QT GUI Plot</value>
+ </param>
+ <param>
+ <key>size</key>
+ <value>1024</value>
+ </param>
+ <param>
+ <key>srate</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>ymin</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>ymax</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>nconnections</key>
+ <value>3</value>
+ </param>
+ <param>
+ <key>gui_hint</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(608, 100)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_throttle</key>
+ <param>
+ <key>id</key>
+ <value>blocks_throttle_0</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>(212, 130)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>analog_sig_source_x</key>
+ <param>
+ <key>id</key>
+ <value>analog_sig_source_x_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>waveform</key>
+ <value>analog.GR_COS_WAVE</value>
+ </param>
+ <param>
+ <key>freq</key>
+ <value>1000</value>
+ </param>
+ <param>
+ <key>amp</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>offset</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(15, 98)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <connection>
+ <source_block_id>howto_square2_ff_0</source_block_id>
+ <sink_block_id>qtgui_time_sink_x_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_throttle_0</source_block_id>
+ <sink_block_id>howto_square2_ff_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_throttle_0</source_block_id>
+ <sink_block_id>howto_square_ff_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_throttle_0</source_block_id>
+ <sink_block_id>qtgui_time_sink_x_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>1</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>howto_square_ff_0</source_block_id>
+ <sink_block_id>qtgui_time_sink_x_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>2</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>analog_sig_source_x_0</source_block_id>
+ <sink_block_id>blocks_throttle_0</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_qt.py b/gr-howto-write-a-block/apps/howto_square_qt.py
new file mode 100755
index 0000000000..3215ea8ab4
--- /dev/null
+++ b/gr-howto-write-a-block/apps/howto_square_qt.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+##################################################
+# Gnuradio Python Flow Graph
+# Title: Howto Square Qt
+# Generated: Sat Nov 10 15:23:43 2012
+##################################################
+
+from PyQt4 import Qt
+from gnuradio import analog
+from gnuradio import blocks
+from gnuradio import eng_notation
+from gnuradio import gr
+from gnuradio import qtgui
+from gnuradio.eng_option import eng_option
+from gnuradio.gr import firdes
+from optparse import OptionParser
+import howto
+import sip
+import sys
+
+class howto_square_qt(gr.top_block, Qt.QWidget):
+
+ def __init__(self):
+ gr.top_block.__init__(self, "Howto Square Qt")
+ Qt.QWidget.__init__(self)
+ self.setWindowTitle("Howto Square Qt")
+ self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
+ self.top_scroll_layout = Qt.QVBoxLayout()
+ self.setLayout(self.top_scroll_layout)
+ self.top_scroll = Qt.QScrollArea()
+ self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
+ self.top_scroll_layout.addWidget(self.top_scroll)
+ self.top_scroll.setWidgetResizable(True)
+ self.top_widget = Qt.QWidget()
+ self.top_scroll.setWidget(self.top_widget)
+ self.top_layout = Qt.QVBoxLayout(self.top_widget)
+ self.top_grid_layout = Qt.QGridLayout()
+ self.top_layout.addLayout(self.top_grid_layout)
+
+ self.settings = Qt.QSettings("GNU Radio", "howto_square_qt")
+ self.restoreGeometry(self.settings.value("geometry").toByteArray())
+
+
+ ##################################################
+ # Variables
+ ##################################################
+ self.samp_rate = samp_rate = 32000
+
+ ##################################################
+ # Blocks
+ ##################################################
+ self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
+ 1024, #size
+ samp_rate, #samp_rate
+ "QT GUI Plot", #name
+ 3 #number of inputs
+ )
+ self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
+ self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
+ self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
+ self.howto_square_ff_0 = howto.square_ff()
+ self.howto_square2_ff_0 = howto.square2_ff()
+ self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate)
+ self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
+
+ ##################################################
+ # Connections
+ ##################################################
+ self.connect((self.howto_square2_ff_0, 0), (self.qtgui_time_sink_x_0, 0))
+ self.connect((self.blocks_throttle_0, 0), (self.howto_square2_ff_0, 0))
+ self.connect((self.blocks_throttle_0, 0), (self.howto_square_ff_0, 0))
+ self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 1))
+ self.connect((self.howto_square_ff_0, 0), (self.qtgui_time_sink_x_0, 2))
+ self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0))
+
+# QT sink close method reimplementation
+ def closeEvent(self, event):
+ self.settings = Qt.QSettings("GNU Radio", "howto_square_qt")
+ self.settings.setValue("geometry", self.saveGeometry())
+ event.accept()
+
+ def get_samp_rate(self):
+ return self.samp_rate
+
+ def set_samp_rate(self, samp_rate):
+ self.samp_rate = samp_rate
+ self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate)
+ self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
+
+if __name__ == '__main__':
+ parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
+ (options, args) = parser.parse_args()
+ qapp = Qt.QApplication(sys.argv)
+ tb = howto_square_qt()
+ tb.start()
+ tb.show()
+ qapp.exec_()
+ tb.stop()
+ tb = None #to clean up Qt widgets
+
diff --git a/gr-howto-write-a-block/cmake/Modules/FindCppUnit.cmake b/gr-howto-write-a-block/cmake/Modules/FindCppUnit.cmake
new file mode 100644
index 0000000000..9af308f84b
--- /dev/null
+++ b/gr-howto-write-a-block/cmake/Modules/FindCppUnit.cmake
@@ -0,0 +1,36 @@
+# http://www.cmake.org/pipermail/cmake/2006-October/011446.html
+# Modified to use pkg config and use standard var names
+
+#
+# Find the CppUnit includes and library
+#
+# This module defines
+# CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc.
+# CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit.
+# CPPUNIT_FOUND, If false, do not try to use CppUnit.
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PC_CPPUNIT "cppunit")
+
+FIND_PATH(CPPUNIT_INCLUDE_DIRS
+ NAMES cppunit/TestCase.h
+ HINTS ${PC_CPPUNIT_INCLUDE_DIR}
+ PATHS
+ /usr/local/include
+ /usr/include
+)
+
+FIND_LIBRARY(CPPUNIT_LIBRARIES
+ NAMES cppunit
+ HINTS ${PC_CPPUNIT_LIBDIR}
+ PATHS
+ ${CPPUNIT_INCLUDE_DIRS}/../lib
+ /usr/local/lib
+ /usr/lib
+)
+
+LIST(APPEND CPPUNIT_LIBRARIES ${CMAKE_DL_LIBS})
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPUNIT DEFAULT_MSG CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS)
+MARK_AS_ADVANCED(CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS)
diff --git a/gr-howto-write-a-block/docs/README.howto b/gr-howto-write-a-block/docs/README.howto
new file mode 100644
index 0000000000..a0a6c0f19d
--- /dev/null
+++ b/gr-howto-write-a-block/docs/README.howto
@@ -0,0 +1,11 @@
+This is the howto-write-a-block package meant as a guide to building
+out-of-tree packages. To use the howto blocks, the Python namespaces
+is in 'howto', which is imported as:
+
+ import howto
+
+See the Doxygen documentation for details about the blocks available
+in this package. A quick listing of the details can be found in Python
+after importing by using:
+
+ help(howto)
diff --git a/gr-howto-write-a-block/include/CMakeLists.txt b/gr-howto-write-a-block/include/howto/CMakeLists.txt
index 475cc73c65..7cd6325543 100644
--- a/gr-howto-write-a-block/include/CMakeLists.txt
+++ b/gr-howto-write-a-block/include/howto/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -21,8 +21,8 @@
# Install public header files
########################################################################
install(FILES
- howto_api.h
- howto_square_ff.h
- howto_square2_ff.h
+ api.h
+ square_ff.h
+ square2_ff.h
DESTINATION include/howto
)
diff --git a/gr-howto-write-a-block/include/howto_api.h b/gr-howto-write-a-block/include/howto/api.h
index 5263a1cf70..5263a1cf70 100644
--- a/gr-howto-write-a-block/include/howto_api.h
+++ b/gr-howto-write-a-block/include/howto/api.h
diff --git a/gr-howto-write-a-block/include/howto/square2_ff.h b/gr-howto-write-a-block/include/howto/square2_ff.h
new file mode 100644
index 0000000000..2e22bb7997
--- /dev/null
+++ b/gr-howto-write-a-block/include/howto/square2_ff.h
@@ -0,0 +1,68 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_HOWTO_SQUARE2_FF_H
+#define INCLUDED_HOWTO_SQUARE2_FF_H
+
+#include <howto/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace howto {
+
+ /*!
+ * \brief square2 a stream of floats.
+ * \ingroup block
+ *
+ * This uses the preferred technique: subclassing gr_sync_block.
+ */
+ class HOWTO_API square2_ff : virtual public gr_sync_block
+ {
+ public:
+ /*
+ * We use boost::shared_ptr's instead of raw pointers for all
+ * access to gr_blocks (and many other data structures). The
+ * shared_ptr gets us transparent reference counting, which
+ * greatly simplifies storage management issues. This is
+ * especially helpful in our hybrid C++ / Python system.
+ *
+ * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
+ *
+ * gr::howto::square2_ff::sptr
+ */
+ typedef boost::shared_ptr<square2_ff> sptr;
+
+ /*!
+ * \brief Return a shared_ptr to a new instance of howto::square2_ff.
+ *
+ * To avoid accidental use of raw pointers, howto::square2_ff's
+ * constructor is in a private implementation
+ * class. howto::square2_ff::make is the public interface for
+ * creating new instances.
+ */
+ static sptr make();
+ };
+
+ } // namespace howto
+} // namespace gr
+
+#endif /* INCLUDED_HOWTO_SQUARE2_FF_H */
diff --git a/gr-howto-write-a-block/include/howto/square_ff.h b/gr-howto-write-a-block/include/howto/square_ff.h
new file mode 100644
index 0000000000..ce971afb6b
--- /dev/null
+++ b/gr-howto-write-a-block/include/howto/square_ff.h
@@ -0,0 +1,68 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_HOWTO_SQUARE_FF_H
+#define INCLUDED_HOWTO_SQUARE_FF_H
+
+#include <howto/api.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace howto {
+
+ /*!
+ * \brief square a stream of floats.
+ * \ingroup block
+ *
+ * \sa howto_square2_ff for a version that subclasses gr_sync_block.
+ */
+ class HOWTO_API square_ff : virtual public gr_block
+ {
+ public:
+ /*
+ * We use boost::shared_ptr's instead of raw pointers for all
+ * access to gr_blocks (and many other data structures). The
+ * shared_ptr gets us transparent reference counting, which
+ * greatly simplifies storage management issues. This is
+ * especially helpful in our hybrid C++ / Python system.
+ *
+ * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
+ *
+ * gr::howto::square_ff::sptr
+ */
+ typedef boost::shared_ptr<square_ff> sptr;
+
+ /*!
+ * \brief Return a shared_ptr to a new instance of howto::square_ff.
+ *
+ * To avoid accidental use of raw pointers, howto::square_ff's
+ * constructor is in a private implementation
+ * class. howto::square_ff::make is the public interface for
+ * creating new instances.
+ */
+ static sptr make();
+ };
+
+ } // namespace howto
+} // namespace gr
+
+#endif /* INCLUDED_HOWTO_SQUARE_FF_H */
diff --git a/gr-howto-write-a-block/include/howto_square2_ff.h b/gr-howto-write-a-block/include/howto_square2_ff.h
deleted file mode 100644
index 2d6c7938bd..0000000000
--- a/gr-howto-write-a-block/include/howto_square2_ff.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-#ifndef INCLUDED_HOWTO_SQUARE2_FF_H
-#define INCLUDED_HOWTO_SQUARE2_FF_H
-
-#include <howto_api.h>
-#include <gr_sync_block.h>
-
-class howto_square2_ff;
-
-/*
- * We use boost::shared_ptr's instead of raw pointers for all access
- * to gr_blocks (and many other data structures). The shared_ptr gets
- * us transparent reference counting, which greatly simplifies storage
- * management issues. This is especially helpful in our hybrid
- * C++ / Python system.
- *
- * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
- *
- * As a convention, the _sptr suffix indicates a boost::shared_ptr
- */
-typedef boost::shared_ptr<howto_square2_ff> howto_square2_ff_sptr;
-
-/*!
- * \brief Return a shared_ptr to a new instance of howto_square2_ff.
- *
- * To avoid accidental use of raw pointers, howto_square2_ff's
- * constructor is private. howto_make_square2_ff is the public
- * interface for creating new instances.
- */
-HOWTO_API howto_square2_ff_sptr howto_make_square2_ff ();
-
-/*!
- * \brief square2 a stream of floats.
- * \ingroup block
- *
- * This uses the preferred technique: subclassing gr_sync_block.
- */
-class HOWTO_API howto_square2_ff : public gr_sync_block
-{
-private:
- // The friend declaration allows howto_make_square2_ff to
- // access the private constructor.
-
- friend HOWTO_API howto_square2_ff_sptr howto_make_square2_ff ();
-
- howto_square2_ff (); // private constructor
-
- public:
- ~howto_square2_ff (); // public destructor
-
- // Where all the action really happens
-
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-#endif /* INCLUDED_HOWTO_SQUARE2_FF_H */
diff --git a/gr-howto-write-a-block/include/howto_square_ff.h b/gr-howto-write-a-block/include/howto_square_ff.h
deleted file mode 100644
index 2efc7fc714..0000000000
--- a/gr-howto-write-a-block/include/howto_square_ff.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-#ifndef INCLUDED_HOWTO_SQUARE_FF_H
-#define INCLUDED_HOWTO_SQUARE_FF_H
-
-#include <howto_api.h>
-#include <gr_block.h>
-
-class howto_square_ff;
-
-/*
- * We use boost::shared_ptr's instead of raw pointers for all access
- * to gr_blocks (and many other data structures). The shared_ptr gets
- * us transparent reference counting, which greatly simplifies storage
- * management issues. This is especially helpful in our hybrid
- * C++ / Python system.
- *
- * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
- *
- * As a convention, the _sptr suffix indicates a boost::shared_ptr
- */
-typedef boost::shared_ptr<howto_square_ff> howto_square_ff_sptr;
-
-/*!
- * \brief Return a shared_ptr to a new instance of howto_square_ff.
- *
- * To avoid accidental use of raw pointers, howto_square_ff's
- * constructor is private. howto_make_square_ff is the public
- * interface for creating new instances.
- */
-HOWTO_API howto_square_ff_sptr howto_make_square_ff ();
-
-/*!
- * \brief square a stream of floats.
- * \ingroup block
- *
- * \sa howto_square2_ff for a version that subclasses gr_sync_block.
- */
-class HOWTO_API howto_square_ff : public gr_block
-{
-private:
- // The friend declaration allows howto_make_square_ff to
- // access the private constructor.
-
- friend HOWTO_API howto_square_ff_sptr howto_make_square_ff ();
-
- /*!
- * \brief square a stream of floats.
- */
- howto_square_ff (); // private constructor
-
- public:
- ~howto_square_ff (); // public destructor
-
- // Where all the action really happens
-
- int general_work (int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-#endif /* INCLUDED_HOWTO_SQUARE_FF_H */
diff --git a/gr-howto-write-a-block/lib/CMakeLists.txt b/gr-howto-write-a-block/lib/CMakeLists.txt
index 835ae02d60..f847d757f6 100644
--- a/gr-howto-write-a-block/lib/CMakeLists.txt
+++ b/gr-howto-write-a-block/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -22,10 +22,18 @@
########################################################################
include(GrPlatform) #define LIB_SUFFIX
-add_library(gnuradio-howto SHARED howto_square_ff.cc howto_square2_ff.cc)
+include_directories(${Boost_INCLUDE_DIR})
+link_directories(${Boost_LIBRARY_DIRS})
+
+add_library(gnuradio-howto SHARED square_ff_impl.cc square2_ff_impl.cc)
target_link_libraries(gnuradio-howto ${Boost_LIBRARIES} ${GRUEL_LIBRARIES} ${GNURADIO_CORE_LIBRARIES})
set_target_properties(gnuradio-howto PROPERTIES DEFINE_SYMBOL "gnuradio_howto_EXPORTS")
+if(ENABLE_GR_CTRLPORT)
+ ADD_DEFINITIONS(-DGR_CTRLPORT)
+ include_directories(${ICE_INCLUDE_DIR})
+endif(ENABLE_GR_CTRLPORT)
+
########################################################################
# Install built library files
########################################################################
@@ -38,17 +46,25 @@ install(TARGETS gnuradio-howto
########################################################################
# Build and register unit test
########################################################################
-find_package(Boost COMPONENTS unit_test_framework)
-
include(GrTest)
-set(GR_TEST_TARGET_DEPS gnuradio-howto)
-#turn each test cpp file into an executable with an int main() function
-add_definitions(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
-add_executable(qa_howto_square_ff qa_howto_square_ff.cc)
-target_link_libraries(qa_howto_square_ff gnuradio-howto ${Boost_LIBRARIES})
-GR_ADD_TEST(qa_howto_square_ff qa_howto_square_ff)
+include_directories(${CPPUNIT_INCLUDE_DIRS})
+
+list(APPEND test_howto_sources
+ ${CMAKE_CURRENT_SOURCE_DIR}/test_howto.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/qa_howto.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/qa_square_ff.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/qa_square2_ff.cc
+)
+
+add_executable(test-howto ${test_howto_sources})
+
+target_link_libraries(
+ test-howto
+ ${GNURADIO_CORE_LIBRARIES}
+ ${Boost_LIBRARIES}
+ ${CPPUNIT_LIBRARIES}
+ gnuradio-howto
+)
-add_executable(qa_howto_square2_ff qa_howto_square2_ff.cc)
-target_link_libraries(qa_howto_square2_ff gnuradio-howto ${Boost_LIBRARIES})
-GR_ADD_TEST(qa_howto_square2_ff qa_howto_square2_ff)
+GR_ADD_TEST(test_howto test-howto)
diff --git a/gr-howto-write-a-block/lib/howto_square2_ff.cc b/gr-howto-write-a-block/lib/howto_square2_ff.cc
deleted file mode 100644
index 3586559ffa..0000000000
--- a/gr-howto-write-a-block/lib/howto_square2_ff.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2010 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-/*
- * config.h is generated by configure. It contains the results
- * of probing for features, options etc. It should be the first
- * file included in your .cc file.
- */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <howto_square2_ff.h>
-#include <gr_io_signature.h>
-
-/*
- * Create a new instance of howto_square2_ff and return
- * a boost shared_ptr. This is effectively the public constructor.
- */
-howto_square2_ff_sptr
-howto_make_square2_ff ()
-{
- return gnuradio::get_initial_sptr(new howto_square2_ff ());
-}
-
-/*
- * Specify constraints on number of input and output streams.
- * This info is used to construct the input and output signatures
- * (2nd & 3rd args to gr_block's constructor). The input and
- * output signatures are used by the runtime system to
- * check that a valid number and type of inputs and outputs
- * are connected to this block. In this case, we accept
- * only 1 input and 1 output.
- */
-static const int MIN_IN = 1; // mininum number of input streams
-static const int MAX_IN = 1; // maximum number of input streams
-static const int MIN_OUT = 1; // minimum number of output streams
-static const int MAX_OUT = 1; // maximum number of output streams
-
-/*
- * The private constructor
- */
-howto_square2_ff::howto_square2_ff ()
- : gr_sync_block ("square2_ff",
- gr_make_io_signature (MIN_IN, MAX_IN, sizeof (float)),
- gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (float)))
-{
- // nothing else required in this example
-}
-
-/*
- * Our virtual destructor.
- */
-howto_square2_ff::~howto_square2_ff ()
-{
- // nothing else required in this example
-}
-
-int
-howto_square2_ff::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- const float *in = (const float *) input_items[0];
- float *out = (float *) output_items[0];
-
- for (int i = 0; i < noutput_items; i++){
- out[i] = in[i] * in[i];
- }
-
- // Tell runtime system how many output items we produced.
- return noutput_items;
-}
diff --git a/gr-howto-write-a-block/lib/howto_square_ff.cc b/gr-howto-write-a-block/lib/howto_square_ff.cc
deleted file mode 100644
index f0d2e1f869..0000000000
--- a/gr-howto-write-a-block/lib/howto_square_ff.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2010 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-/*
- * config.h is generated by configure. It contains the results
- * of probing for features, options etc. It should be the first
- * file included in your .cc file.
- */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <howto_square_ff.h>
-#include <gr_io_signature.h>
-
-/*
- * Create a new instance of howto_square_ff and return
- * a boost shared_ptr. This is effectively the public constructor.
- */
-howto_square_ff_sptr
-howto_make_square_ff ()
-{
- return gnuradio::get_initial_sptr(new howto_square_ff ());
-}
-
-/*
- * Specify constraints on number of input and output streams.
- * This info is used to construct the input and output signatures
- * (2nd & 3rd args to gr_block's constructor). The input and
- * output signatures are used by the runtime system to
- * check that a valid number and type of inputs and outputs
- * are connected to this block. In this case, we accept
- * only 1 input and 1 output.
- */
-static const int MIN_IN = 1; // mininum number of input streams
-static const int MAX_IN = 1; // maximum number of input streams
-static const int MIN_OUT = 1; // minimum number of output streams
-static const int MAX_OUT = 1; // maximum number of output streams
-
-/*
- * The private constructor
- */
-howto_square_ff::howto_square_ff ()
- : gr_block ("square_ff",
- gr_make_io_signature (MIN_IN, MAX_IN, sizeof (float)),
- gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (float)))
-{
- // nothing else required in this example
-}
-
-/*
- * Our virtual destructor.
- */
-howto_square_ff::~howto_square_ff ()
-{
- // nothing else required in this example
-}
-
-int
-howto_square_ff::general_work (int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- const float *in = (const float *) input_items[0];
- float *out = (float *) output_items[0];
-
- for (int i = 0; i < noutput_items; i++){
- out[i] = in[i] * in[i];
- }
-
- // Tell runtime system how many input items we consumed on
- // each input stream.
-
- consume_each (noutput_items);
-
- // Tell runtime system how many output items we produced.
- return noutput_items;
-}
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 0000000000..6200da9b48
--- /dev/null
+++ b/gr-howto-write-a-block/lib/qa_howto.cc
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * This class gathers together all the test cases for the gr-filter
+ * directory into a single test suite. As you create new test cases,
+ * add them here.
+ */
+
+#include "qa_howto.h"
+#include "qa_square_ff.h"
+#include "qa_square2_ff.h"
+
+CppUnit::TestSuite *
+qa_howto::suite()
+{
+ CppUnit::TestSuite *s = new CppUnit::TestSuite("howto");
+
+ s->addTest(gr::howto::qa_square_ff::suite());
+ s->addTest(gr::howto::qa_square2_ff::suite());
+
+ return s;
+}
diff --git a/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc b/gr-howto-write-a-block/lib/qa_howto.h
index ff1e5d5b0a..8eff956b61 100644
--- a/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc
+++ b/gr-howto-write-a-block/lib/qa_howto.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011 Free Software Foundation, Inc.
+ * Copyright 2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -14,19 +14,25 @@
* 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.
+ * 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 <boost/test/unit_test.hpp>
+#ifndef _QA_HOWTO_H_
+#define _QA_HOWTO_H_
-BOOST_AUTO_TEST_CASE(qa_howto_square2_ff_t1){
- BOOST_CHECK_EQUAL(2 + 2, 4);
- // TODO BOOST_* test macros here
-}
+#include <gruel/attributes.h>
+#include <cppunit/TestSuite.h>
-BOOST_AUTO_TEST_CASE(qa_howto_square2_ff_t2){
- BOOST_CHECK_EQUAL(2 + 2, 4);
- // TODO BOOST_* test macros here
-}
+//! collect all the tests for the gr-filter directory
+
+class __GR_ATTR_EXPORT qa_howto
+{
+ public:
+ //! return suite of tests for all of gr-filter directory
+ static CppUnit::TestSuite *suite();
+};
+
+#endif /* _QA_HOWTO_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
deleted file mode 100644
index 98f6cc587c..0000000000
--- a/gr-howto-write-a-block/lib/qa_howto_square_ff.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2011 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <boost/test/unit_test.hpp>
-
-BOOST_AUTO_TEST_CASE(qa_howto_square_ff_t1){
- BOOST_CHECK_EQUAL(2 + 2, 4);
- // TODO BOOST_* test macros here
-}
-
-BOOST_AUTO_TEST_CASE(qa_howto_square_ff_t2){
- BOOST_CHECK_EQUAL(2 + 2, 4);
- // TODO BOOST_* test macros here
-}
diff --git a/gr-howto-write-a-block/lib/qa_square2_ff.cc b/gr-howto-write-a-block/lib/qa_square2_ff.cc
new file mode 100644
index 0000000000..672e75691b
--- /dev/null
+++ b/gr-howto-write-a-block/lib/qa_square2_ff.cc
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "qa_square2_ff.h"
+#include <cppunit/TestAssert.h>
+
+#include <vector>
+#include <gr_top_block.h>
+#include <gr_vector_source_f.h>
+#include <gr_vector_sink_f.h>
+#include <howto/square2_ff.h>
+
+namespace gr {
+ namespace howto {
+
+ void
+ qa_square2_ff::t1()
+ {
+ std::vector<float> data(5,0);
+ std::vector<float> result(5,0);
+ std::vector<float> output(5,0);
+ for(size_t i = 0; i < data.size(); i++) {
+ data[i] = i;
+ result[i] = i*i;
+ }
+
+ gr_top_block_sptr tb = gr_make_top_block("dial_tone");
+ gr_vector_source_f_sptr src = gr_make_vector_source_f(data);
+ gr_vector_sink_f_sptr snk = gr_make_vector_sink_f();
+
+ square2_ff::sptr op = square2_ff::make();
+
+ tb->connect(src, 0, op, 0);
+ tb->connect(op, 0, snk, 0);
+ tb->run();
+
+ output = snk->data();
+
+ for(size_t i = 0; i < data.size(); i++) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(output[i], result[i], 0.0001);
+ }
+ }
+
+ } /* namespace howto */
+} /* namespace gr */
diff --git a/gr-howto-write-a-block/lib/qa_square2_ff.h b/gr-howto-write-a-block/lib/qa_square2_ff.h
new file mode 100644
index 0000000000..5260cabda9
--- /dev/null
+++ b/gr-howto-write-a-block/lib/qa_square2_ff.h
@@ -0,0 +1,46 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _QA_SQUARE2_FF_H_
+#define _QA_SQUARE2_FF_H_
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+namespace gr {
+ namespace howto {
+
+ class qa_square2_ff : public CppUnit::TestCase
+ {
+ public:
+ CPPUNIT_TEST_SUITE(qa_square2_ff);
+ CPPUNIT_TEST(t1);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void t1();
+ };
+
+ } /* namespace howto */
+} /* namespace gr */
+
+#endif /* _QA_SQUARE2_FF_H_ */
diff --git a/gr-howto-write-a-block/lib/qa_square_ff.cc b/gr-howto-write-a-block/lib/qa_square_ff.cc
new file mode 100644
index 0000000000..dedd934e16
--- /dev/null
+++ b/gr-howto-write-a-block/lib/qa_square_ff.cc
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "qa_square_ff.h"
+#include <cppunit/TestAssert.h>
+
+#include <vector>
+#include <gr_top_block.h>
+#include <gr_vector_source_f.h>
+#include <gr_vector_sink_f.h>
+#include <howto/square_ff.h>
+
+namespace gr {
+ namespace howto {
+
+ void
+ qa_square_ff::t1()
+ {
+ std::vector<float> data(5,0);
+ std::vector<float> result(5,0);
+ std::vector<float> output(5,0);
+ for(size_t i = 0; i < data.size(); i++) {
+ data[i] = i;
+ result[i] = i*i;
+ }
+
+ gr_top_block_sptr tb = gr_make_top_block("dial_tone");
+ gr_vector_source_f_sptr src = gr_make_vector_source_f(data);
+ gr_vector_sink_f_sptr snk = gr_make_vector_sink_f();
+
+ square_ff::sptr op = square_ff::make();
+
+ tb->connect(src, 0, op, 0);
+ tb->connect(op, 0, snk, 0);
+ tb->run();
+
+ output = snk->data();
+
+ for(size_t i = 0; i < data.size(); i++) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(output[i], result[i], 0.0001);
+ }
+ }
+
+ } /* namespace howto */
+} /* namespace gr */
diff --git a/gr-howto-write-a-block/lib/qa_square_ff.h b/gr-howto-write-a-block/lib/qa_square_ff.h
new file mode 100644
index 0000000000..eed699b0be
--- /dev/null
+++ b/gr-howto-write-a-block/lib/qa_square_ff.h
@@ -0,0 +1,46 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _QA_SQUARE_FF_H_
+#define _QA_SQUARE_FF_H_
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+namespace gr {
+ namespace howto {
+
+ class qa_square_ff : public CppUnit::TestCase
+ {
+ public:
+ CPPUNIT_TEST_SUITE(qa_square_ff);
+ CPPUNIT_TEST(t1);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void t1();
+ };
+
+ } /* namespace howto */
+} /* namespace gr */
+
+#endif /* _QA_SQUARE_FF_H_ */
diff --git a/gr-howto-write-a-block/lib/square2_ff_impl.cc b/gr-howto-write-a-block/lib/square2_ff_impl.cc
new file mode 100644
index 0000000000..f508a6e05b
--- /dev/null
+++ b/gr-howto-write-a-block/lib/square2_ff_impl.cc
@@ -0,0 +1,98 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * config.h is generated by configure. It contains the results
+ * of probing for features, options etc. It should be the first
+ * file included in your .cc file.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "square2_ff_impl.h"
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace howto {
+
+ /*
+ * Create a new instance of howto_square2_ff and return a boost
+ * shared_ptr. This is effectively the public constructor.
+ */
+ square2_ff::sptr
+ square2_ff::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new square2_ff_impl());
+ }
+
+ /*
+ * Specify constraints on number of input and output streams.
+ * This info is used to construct the input and output signatures
+ * (2nd & 3rd args to gr_block's constructor). The input and
+ * output signatures are used by the runtime system to check that
+ * a valid number and type of inputs and outputs are connected to
+ * this block. In this case, we accept only 1 input and 1 output.
+ */
+ static const int MIN_IN = 1; // mininum number of input streams
+ static const int MAX_IN = 1; // maximum number of input streams
+ static const int MIN_OUT = 1; // minimum number of output streams
+ static const int MAX_OUT = 1; // maximum number of output streams
+
+ /*
+ * The private constructor
+ */
+ square2_ff_impl::square2_ff_impl()
+ : gr_sync_block("square2_ff",
+ gr_make_io_signature(MIN_IN, MAX_IN, sizeof(float)),
+ gr_make_io_signature(MIN_OUT, MAX_OUT, sizeof(float)))
+ {
+ // nothing else required in this example
+ }
+
+ /*
+ * Our virtual destructor.
+ */
+ square2_ff_impl::~square2_ff_impl()
+ {
+ // nothing else required in this example
+ }
+
+ int
+ square2_ff_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const float *in = (const float*)input_items[0];
+ float *out = (float*)output_items[0];
+
+ for(int i = 0; i < noutput_items; i++) {
+ out[i] = in[i] * in[i];
+ }
+
+ // Tell runtime system how many output items we produced.
+ return noutput_items;
+ }
+
+ } /* namespace howto */
+} /* namespace gr */
diff --git a/gr-howto-write-a-block/lib/square2_ff_impl.h b/gr-howto-write-a-block/lib/square2_ff_impl.h
new file mode 100644
index 0000000000..1f7ca7ab37
--- /dev/null
+++ b/gr-howto-write-a-block/lib/square2_ff_impl.h
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_HOWTO_SQUARE2_FF_IMPL_H
+#define INCLUDED_HOWTO_SQUARE2_FF_IMPL_H
+
+#include <howto/square2_ff.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace howto {
+
+ class square2_ff_impl : public square2_ff
+ {
+ private:
+ // Nothing to declare in this block.
+
+ public:
+ square2_ff_impl(); // implementation constructor
+ ~square2_ff_impl(); // implementation destructor
+
+ // Where all the action really happens
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } // namespace howto
+} // namespace gr
+
+#endif /* INCLUDED_HOWTO_SQUARE2_FF_IMPL_H */
diff --git a/gr-howto-write-a-block/lib/square_ff_impl.cc b/gr-howto-write-a-block/lib/square_ff_impl.cc
new file mode 100644
index 0000000000..d49f72da1e
--- /dev/null
+++ b/gr-howto-write-a-block/lib/square_ff_impl.cc
@@ -0,0 +1,105 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * config.h is generated by configure. It contains the results
+ * of probing for features, options etc. It should be the first
+ * file included in your .cc file.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "square_ff_impl.h"
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace howto {
+
+ /*
+ * Create a new instance of howto_square_ff and return a boost
+ * shared_ptr. This is effectively the public constructor.
+ */
+ square_ff::sptr
+ square_ff::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new square_ff_impl());
+ }
+
+ /*
+ * Specify constraints on number of input and output streams.
+ * This info is used to construct the input and output signatures
+ * (2nd & 3rd args to gr_block's constructor). The input and
+ * output signatures are used by the runtime system to
+ * check that a valid number and type of inputs and outputs
+ * are connected to this block. In this case, we accept
+ * only 1 input and 1 output.
+ */
+ static const int MIN_IN = 1; // mininum number of input streams
+ static const int MAX_IN = 1; // maximum number of input streams
+ static const int MIN_OUT = 1; // minimum number of output streams
+ static const int MAX_OUT = 1; // maximum number of output streams
+
+ /*
+ * The private constructor
+ */
+ square_ff_impl::square_ff_impl()
+ : gr_block("square_ff",
+ gr_make_io_signature(MIN_IN, MAX_IN, sizeof(float)),
+ gr_make_io_signature(MIN_OUT, MAX_OUT, sizeof(float)))
+ {
+ // nothing else required in this example
+ }
+
+ /*
+ * Our virtual destructor.
+ */
+ square_ff_impl::~square_ff_impl()
+ {
+ // nothing else required in this example
+ }
+
+ int
+ square_ff_impl::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const float *in = (const float*)input_items[0];
+ float *out = (float*)output_items[0];
+
+ for(int i = 0; i < noutput_items; i++) {
+ out[i] = in[i] * in[i];
+ }
+
+ // Tell runtime system how many input items we consumed on
+ // each input stream.
+
+ consume_each(noutput_items);
+
+ // Tell runtime system how many output items we produced.
+ return noutput_items;
+ }
+
+ } /* namespace howto */
+} /* namespace gr */
diff --git a/gr-howto-write-a-block/lib/square_ff_impl.h b/gr-howto-write-a-block/lib/square_ff_impl.h
new file mode 100644
index 0000000000..2f0963423a
--- /dev/null
+++ b/gr-howto-write-a-block/lib/square_ff_impl.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_HOWTO_SQUARE_FF_IMPL_H
+#define INCLUDED_HOWTO_SQUARE_FF_IMPL_H
+
+#include <howto/square_ff.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace howto {
+
+ class square_ff_impl : public square_ff
+ {
+ private:
+ // Nothing to declare in this block.
+
+ public:
+ square_ff_impl(); // implementation constructor
+ ~square_ff_impl(); // implementation destructor
+
+ // Where all the action really happens
+
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } // namespace howto
+} // namespace gr
+
+#endif /* INCLUDED_HOWTO_SQUARE_FF_IMPL_H */
diff --git a/gr-howto-write-a-block/lib/test_howto.cc b/gr-howto-write-a-block/lib/test_howto.cc
new file mode 100644
index 0000000000..bf344265d7
--- /dev/null
+++ b/gr-howto-write-a-block/lib/test_howto.cc
@@ -0,0 +1,43 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <cppunit/TextTestRunner.h>
+#include <cppunit/XmlOutputter.h>
+
+#include <gr_unittests.h>
+#include "qa_howto.h"
+#include <iostream>
+
+int
+main (int argc, char **argv)
+{
+ CppUnit::TextTestRunner runner;
+ std::ofstream xmlfile(get_unittest_path("howto.xml").c_str());
+ CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile);
+
+ runner.addTest(qa_howto::suite());
+ runner.setOutputter(xmlout);
+
+ bool was_successful = runner.run("", false);
+
+ return was_successful ? 0 : 1;
+}
diff --git a/gr-howto-write-a-block/python/qa_howto.py b/gr-howto-write-a-block/python/qa_howto.py
index 5e62fc890d..203b06922b 100755..100644
--- a/gr-howto-write-a-block/python/qa_howto.py
+++ b/gr-howto-write-a-block/python/qa_howto.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2007 Free Software Foundation, Inc.
+# Copyright 2004,2007,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -21,40 +21,40 @@
#
from gnuradio import gr, gr_unittest
-import howto_swig
+import howto_swig as howto
from square3_ff import square3_ff
-class qa_howto (gr_unittest.TestCase):
+class qa_howto(gr_unittest.TestCase):
- def setUp (self):
- self.tb = gr.top_block ()
+ def setUp(self):
+ self.tb = gr.top_block()
- def tearDown (self):
+ def tearDown(self):
self.tb = None
- def test_001_square_ff (self):
+ def test_001_square_ff(self):
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_swig.square_ff ()
- dst = gr.vector_sink_f ()
- self.tb.connect (src, sqr)
- self.tb.connect (sqr, dst)
- self.tb.run ()
- result_data = dst.data ()
- self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6)
+ src = gr.vector_source_f(src_data)
+ sqr = howto.square_ff()
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, sqr)
+ self.tb.connect(sqr, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data, 6)
- def test_002_square2_ff (self):
+ def test_002_square2_ff(self):
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_swig.square2_ff ()
- dst = gr.vector_sink_f ()
- self.tb.connect (src, sqr)
- self.tb.connect (sqr, dst)
- self.tb.run ()
- result_data = dst.data ()
- self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6)
+ src = gr.vector_source_f(src_data)
+ sqr = howto.square2_ff()
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, sqr)
+ self.tb.connect(sqr, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data, 6)
def test_003_square3_ff (self):
src_data = (-3, 4, -5.5, 2, 3)
@@ -69,4 +69,4 @@ class qa_howto (gr_unittest.TestCase):
self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6)
if __name__ == '__main__':
- gr_unittest.main ()
+ gr_unittest.run(qa_howto, "qa_howto.xml")
diff --git a/gr-howto-write-a-block/swig/howto_swig.i b/gr-howto-write-a-block/swig/howto_swig.i
index dd662b5e52..162bc6a901 100644
--- a/gr-howto-write-a-block/swig/howto_swig.i
+++ b/gr-howto-write-a-block/swig/howto_swig.i
@@ -7,14 +7,13 @@
//load generated python docstrings
%include "howto_swig_doc.i"
-
%{
-#include "howto_square_ff.h"
-#include "howto_square2_ff.h"
+#include "howto/square_ff.h"
+#include "howto/square2_ff.h"
%}
-GR_SWIG_BLOCK_MAGIC(howto,square_ff);
-%include "howto_square_ff.h"
+%include "howto/square_ff.h"
+%include "howto/square2_ff.h"
-GR_SWIG_BLOCK_MAGIC(howto,square2_ff);
-%include "howto_square2_ff.h"
+GR_SWIG_BLOCK_MAGIC2(howto, square_ff);
+GR_SWIG_BLOCK_MAGIC2(howto, square2_ff);