Merge branch 'wip/pager' of git@gnuradio.org:jcorgan
authorJohnathan Corgan <jcorgan@corganenterprises.com>
Sat, 12 Dec 2009 17:34:35 +0000 (09:34 -0800)
committerJohnathan Corgan <jcorgan@corganenterprises.com>
Sat, 12 Dec 2009 17:34:35 +0000 (09:34 -0800)
Merge-fix: Fix erroneous EXTRA_DIST in lib/
Merge-fix: Don't install usrp_rx_flex.py (unfinished)

180 files changed:
docs/howto-write-a-block/.gitignore
docs/howto-write-a-block/Makefile.am [new file with mode: 0644]
docs/howto-write-a-block/README
docs/howto-write-a-block/howto-write-a-block.xml [new file with mode: 0644]
docs/howto-write-a-block/howto_1.i [new file with mode: 0644]
docs/howto-write-a-block/make_numbered_listing.py [new file with mode: 0755]
docs/howto-write-a-block/qa_howto_1.py [new file with mode: 0755]
docs/howto-write-a-block/src_lib_Makefile_1.am [new file with mode: 0644]
docs/howto-write-a-block/src_lib_Makefile_2.am [new file with mode: 0644]
gnuradio-core/src/lib/general/gr_head.cc
gnuradio-core/src/lib/general/gr_head.h
gnuradio-core/src/lib/general/gr_head.i
gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
gnuradio-core/src/lib/runtime/gr_top_block_impl.h
gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py
gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py
gnuradio-examples/grc/Makefile.am
gnuradio-examples/grc/usrp/usrp_rx_dpsk.grc [new file with mode: 0644]
gnuradio-examples/grc/usrp/usrp_tx_dpsk.grc [new file with mode: 0644]
gr-howto-write-a-block/INSTALL
gr-howto-write-a-block/Makefile.am
gr-howto-write-a-block/Makefile.common
gr-howto-write-a-block/README
gr-howto-write-a-block/README.hacking [new file with mode: 0644]
gr-howto-write-a-block/apps/.gitignore [new file with mode: 0644]
gr-howto-write-a-block/apps/Makefile.am [new file with mode: 0644]
gr-howto-write-a-block/apps/howto_square.grc [new file with mode: 0644]
gr-howto-write-a-block/apps/howto_square.py [new file with mode: 0755]
gr-howto-write-a-block/config.guess [changed mode: 0644->0755]
gr-howto-write-a-block/config.sub [changed mode: 0644->0755]
gr-howto-write-a-block/config/Makefile.am
gr-howto-write-a-block/config/gr_fortran.m4
gr-howto-write-a-block/config/gr_git.m4 [new file with mode: 0644]
gr-howto-write-a-block/config/gr_pwin32.m4
gr-howto-write-a-block/config/gr_python.m4
gr-howto-write-a-block/config/gr_set_md_cpu.m4
gr-howto-write-a-block/config/gr_standalone.m4
gr-howto-write-a-block/config/gr_version.m4 [new file with mode: 0644]
gr-howto-write-a-block/config/lf_warnings.m4
gr-howto-write-a-block/config/usrp_fusb_tech.m4
gr-howto-write-a-block/configure.ac
gr-howto-write-a-block/doc/.gitignore [deleted file]
gr-howto-write-a-block/doc/Makefile.am [deleted file]
gr-howto-write-a-block/doc/howto-write-a-block.xml [deleted file]
gr-howto-write-a-block/doc/howto_1.i [deleted file]
gr-howto-write-a-block/doc/make_numbered_listing.py [deleted file]
gr-howto-write-a-block/doc/qa_howto_1.py [deleted file]
gr-howto-write-a-block/doc/src_lib_Makefile_1.am [deleted file]
gr-howto-write-a-block/doc/src_lib_Makefile_2.am [deleted file]
gr-howto-write-a-block/grc/.gitignore [new file with mode: 0644]
gr-howto-write-a-block/grc/Makefile.am [new file with mode: 0644]
gr-howto-write-a-block/grc/howto_square2_ff.xml [new file with mode: 0644]
gr-howto-write-a-block/grc/howto_square_ff.xml [new file with mode: 0644]
gr-howto-write-a-block/lib/.gitignore [new file with mode: 0644]
gr-howto-write-a-block/lib/Makefile.am [new file with mode: 0644]
gr-howto-write-a-block/lib/howto_square2_ff.cc [new file with mode: 0644]
gr-howto-write-a-block/lib/howto_square2_ff.h [new file with mode: 0644]
gr-howto-write-a-block/lib/howto_square_ff.cc [new file with mode: 0644]
gr-howto-write-a-block/lib/howto_square_ff.h [new file with mode: 0644]
gr-howto-write-a-block/lib/qa_howto.cc [new file with mode: 0644]
gr-howto-write-a-block/lib/qa_howto.h [new file with mode: 0644]
gr-howto-write-a-block/lib/qa_howto_square2_ff.cc [new file with mode: 0644]
gr-howto-write-a-block/lib/qa_howto_square2_ff.h [new file with mode: 0644]
gr-howto-write-a-block/lib/qa_howto_square_ff.cc [new file with mode: 0644]
gr-howto-write-a-block/lib/qa_howto_square_ff.h [new file with mode: 0644]
gr-howto-write-a-block/lib/test_all.cc [new file with mode: 0644]
gr-howto-write-a-block/python/.gitignore [new file with mode: 0644]
gr-howto-write-a-block/python/Makefile.am [new file with mode: 0644]
gr-howto-write-a-block/python/__init__.py [new file with mode: 0644]
gr-howto-write-a-block/python/qa_howto.py [new file with mode: 0755]
gr-howto-write-a-block/python/run_tests.in [new file with mode: 0644]
gr-howto-write-a-block/src/.gitignore [deleted file]
gr-howto-write-a-block/src/Makefile.am [deleted file]
gr-howto-write-a-block/src/lib/.gitignore [deleted file]
gr-howto-write-a-block/src/lib/Makefile.am [deleted file]
gr-howto-write-a-block/src/lib/Makefile.swig.gen [deleted file]
gr-howto-write-a-block/src/lib/howto.i [deleted file]
gr-howto-write-a-block/src/lib/howto_square2_ff.cc [deleted file]
gr-howto-write-a-block/src/lib/howto_square2_ff.h [deleted file]
gr-howto-write-a-block/src/lib/howto_square_ff.cc [deleted file]
gr-howto-write-a-block/src/lib/howto_square_ff.h [deleted file]
gr-howto-write-a-block/src/python/.gitignore [deleted file]
gr-howto-write-a-block/src/python/Makefile.am [deleted file]
gr-howto-write-a-block/src/python/qa_howto.py [deleted file]
gr-howto-write-a-block/src/python/run_tests.in [deleted file]
gr-howto-write-a-block/swig/.gitignore [new file with mode: 0644]
gr-howto-write-a-block/swig/Makefile.am [new file with mode: 0644]
gr-howto-write-a-block/swig/Makefile.swig.gen [new file with mode: 0644]
gr-howto-write-a-block/swig/howto.i [new file with mode: 0644]
gr-howto-write-a-block/swig/howto_square2_ff.i [new file with mode: 0644]
gr-howto-write-a-block/swig/howto_square_ff.i [new file with mode: 0644]
gr-howto-write-a-block/version.sh [new file with mode: 0644]
gr-msdd6000/src/.gitignore
gr-msdd6000/src/Makefile.am
gr-msdd6000/src/Makefile.swig.gen
gr-msdd6000/src/msdd6000_rs.cc [new file with mode: 0644]
gr-msdd6000/src/msdd6000_rs.h [new file with mode: 0644]
gr-msdd6000/src/msdd_rs.i [new file with mode: 0644]
gr-msdd6000/src/msdd_rs_source_simple.cc [new file with mode: 0644]
gr-msdd6000/src/msdd_rs_source_simple.h [new file with mode: 0644]
gr-msdd6000/src/python-examples/msdd_rs_spec_an.py [new file with mode: 0755]
gr-noaa/README
gr-noaa/apps/.gitignore
gr-noaa/apps/Makefile.am
gr-noaa/apps/demod_hrpt_file.grc [deleted file]
gr-noaa/apps/demod_hrpt_file.py [deleted file]
gr-noaa/apps/file_rx_hrpt.grc
gr-noaa/apps/file_rx_hrpt.py
gr-noaa/apps/hrpt_decode.grc [new file with mode: 0644]
gr-noaa/apps/hrpt_decode.py [new file with mode: 0755]
gr-noaa/apps/hrpt_demod.grc [new file with mode: 0644]
gr-noaa/apps/hrpt_demod.py [new file with mode: 0755]
gr-noaa/apps/usrp_rx_hrpt.grc
gr-noaa/apps/usrp_rx_hrpt.py
gr-noaa/apps/usrp_rx_hrpt_nogui.grc
gr-noaa/apps/usrp_rx_hrpt_nogui.py
gr-noaa/grc/noaa_hrpt_decoder.xml
gr-noaa/lib/Makefile.am
gr-noaa/lib/noaa_hrpt.h [new file with mode: 0644]
gr-noaa/lib/noaa_hrpt_decoder.cc
gr-noaa/lib/noaa_hrpt_decoder.h
gr-noaa/lib/noaa_hrpt_deframer.cc
gr-noaa/lib/noaa_hrpt_deframer.h
gr-noaa/oct/frames_to_ppm.m
gr-noaa/swig/noaa_hrpt_decoder.i
gr-pager/apps/Makefile.am
gr-pager/lib/Makefile.am
grc/base/Block.py
grc/base/FlowGraph.py
grc/blocks/Makefile.am
grc/blocks/blks2_dxpsk2_demod.xml [new file with mode: 0644]
grc/blocks/blks2_dxpsk2_mod.xml [new file with mode: 0644]
grc/blocks/blks2_dxpsk_demod.xml
grc/blocks/blks2_dxpsk_mod.xml
grc/blocks/block_tree.xml
grc/blocks/pad_sink.xml
grc/blocks/pad_source.xml
grc/freedesktop/grc_setup_freedesktop.in
grc/grc_gnuradio/usrp/dual_usrp.py
grc/grc_gnuradio/usrp/simple_usrp.py
grc/grc_gnuradio/wxgui/top_block_gui.py
grc/gui/ActionHandler.py
grc/gui/Block.py
grc/gui/Dialogs.py
grc/gui/Element.py
grc/gui/FlowGraph.py
grc/gui/Param.py
grc/gui/Port.py
grc/gui/Utils.py
grc/python/Constants.py
grc/python/FlowGraph.py
grc/python/Param.py
grc/python/convert_hier.py
grc/python/flow_graph.tmpl
usrp/firmware/include/usrp_ids.h
usrp/host/lib/db_xcvr2450.cc
usrp/host/lib/usrp_prims_libusb0.cc
usrp2/firmware/apps/app_common_v2.c
usrp2/firmware/apps/app_common_v2.h
usrp2/firmware/apps/factory_test.c
usrp2/firmware/apps/mimo_tx_slave.c
usrp2/firmware/apps/serdes_txrx.c
usrp2/firmware/apps/txrx.c
usrp2/firmware/config/grc_usrp2_firmware.m4
usrp2/firmware/lib/db_init.c
usrp2/firmware/lib/db_tvrx.c
usrp2/firmware/lib/db_xcvr2450.c
usrp2/firmware/lib/memory_map.h
usrp2/fpga/control_lib/pic.v [new file with mode: 0644]
usrp2/fpga/control_lib/priority_enc.v [new file with mode: 0644]
usrp2/fpga/top/u2_core/u2_core.v
usrp2/fpga/top/u2_rev3/Makefile
usrp2/host/include/usrp2/usrp2.h
usrp2/host/lib/control.h
usrp2/host/lib/usrp2.cc
usrp2/host/lib/usrp2_impl.cc
usrp2/host/lib/usrp2_impl.h
vrt/lib/copiers.cc
vrt/lib/expanded_header.cc
vrt/lib/rx.cc

index 719ea5d4f0cc7e589f0ea728b73fa73216004db9..f65ab6cf722c96bd862ed5ef70e32bcf71c1c6db 100644 (file)
@@ -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/docs/howto-write-a-block/Makefile.am b/docs/howto-write-a-block/Makefile.am
new file mode 100644 (file)
index 0000000..5f58a21
--- /dev/null
@@ -0,0 +1,81 @@
+#
+# Copyright 2004,2005,2007 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.
+# 
+
+TARGETS = howto-write-a-block.html
+
+# To avoid build problems for folks who don't have xmlto installed, we
+# don't build the docs by default.
+
+# html: $(TARGETS)
+all: $(TARGETS)
+
+
+EXTRA_DIST =                           \
+       README                          \
+       howto-write-a-block.xml         \
+       howto_1.i                       \
+       make_numbered_listing.py        \
+       qa_howto_1.py                   \
+       src_lib_Makefile_1.am           \
+       src_lib_Makefile_2.am           
+
+
+BUILT_XML_FILES =                      \
+       gr_block.h.xml                  \
+       howto_1.i.xml                   \
+       howto_square_ff.cc.xml          \
+       howto_square_ff.h.xml           \
+       howto_square2_ff.cc.xml         \
+       howto_square2_ff.h.xml          \
+       qa_howto_1.py.xml               \
+       src_lib_Makefile_1.am.xml       \
+       src_lib_Makefile_2.am.xml       
+
+
+howto-write-a-block.html : howto-write-a-block.xml $(BUILT_XML_FILES)
+
+
+gr_block.h.xml: $(GNURADIO_CORE_INCLUDEDIR)/gr_block.h make_numbered_listing.py
+       $(PYTHON) ./make_numbered_listing.py $(GNURADIO_CORE_INCLUDEDIR)/gr_block.h
+
+howto_square_ff.cc.xml: $(top_srcdir)/src/lib/howto_square_ff.cc make_numbered_listing.py
+       $(PYTHON) ./make_numbered_listing.py $(top_srcdir)/src/lib/howto_square_ff.cc 
+
+howto_square_ff.h.xml: $(top_srcdir)/src/lib/howto_square_ff.h make_numbered_listing.py
+       $(PYTHON) ./make_numbered_listing.py $(top_srcdir)/src/lib/howto_square_ff.h 
+
+howto_square2_ff.cc.xml: $(top_srcdir)/src/lib/howto_square2_ff.cc make_numbered_listing.py
+       $(PYTHON) ./make_numbered_listing.py $(top_srcdir)/src/lib/howto_square2_ff.cc 
+
+howto_square2_ff.h.xml: $(top_srcdir)/src/lib/howto_square2_ff.h make_numbered_listing.py
+       $(PYTHON) ./make_numbered_listing.py $(top_srcdir)/src/lib/howto_square2_ff.h 
+
+
+# ----------------------------------------------------------------
+
+clean:
+       -${RM} -f $(TARGETS) $(BUILT_XML_FILES)
+
+%.html : %.xml
+       xmlto html-nochunks $<
+
+%.xml : % make_numbered_listing.py
+       $(PYTHON) ./make_numbered_listing.py $<
index 73b8e6028b1da857107f58dee331e9ec097a8ca4..ff3b75e5719535221543badd20fdf59ea4cf6894 100644 (file)
@@ -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/docs/howto-write-a-block/howto-write-a-block.xml b/docs/howto-write-a-block/howto-write-a-block.xml
new file mode 100644 (file)
index 0000000..f8027b4
--- /dev/null
@@ -0,0 +1,959 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+          "docbookx.dtd" [
+  <!ENTITY gnuradio "<application>GNU Radio</application>">
+  <!ENTITY SWIG "<application>SWIG</application>">
+  <!ENTITY gr_block "<classname>gr_block</classname>">
+  <!ENTITY square "<classname>howto_square_ff</classname>">
+
+  <!ENTITY were "we&apos;re">
+  <!ENTITY well "we&apos;ll">
+  <!ENTITY thats "that&apos;s">
+  <!ENTITY its "it&apos;s">
+  <!ENTITY lets "let&apos;s">
+  <!ENTITY youre "you&apos;re">
+
+  <!ENTITY gr_block_listing SYSTEM "gr_block.h.xml">
+  <!ENTITY qa_howto_1_listing SYSTEM "qa_howto_1.py.xml">
+  <!ENTITY howto_square_ff_h_listing SYSTEM "howto_square_ff.h.xml">
+  <!ENTITY howto_square_ff_cc_listing SYSTEM "howto_square_ff.cc.xml">
+  <!ENTITY howto_square2_ff_h_listing SYSTEM "howto_square2_ff.h.xml">
+  <!ENTITY howto_square2_ff_cc_listing SYSTEM "howto_square2_ff.cc.xml">
+  <!ENTITY howto_1_i_listing SYSTEM "howto_1.i.xml">
+  <!ENTITY src_lib_Makefile_1_am_listing SYSTEM "src_lib_Makefile_1.am.xml">
+  <!ENTITY src_lib_Makefile_2_am_listing SYSTEM "src_lib_Makefile_2.am.xml">
+
+]>
+
+<article>
+
+<articleinfo>
+<title>How to Write a Signal Processing Block</title>
+<author>
+  <firstname>Eric</firstname>
+  <surname>Blossom</surname>
+  <affiliation>
+    <address>
+      <email>eb@comsec.com</email>
+    </address>
+  </affiliation>
+</author>
+
+<revhistory>
+  <revision>
+  <revnumber>0.1</revnumber>
+  <date>2005-01-20</date>
+  </revision>
+  <revision>
+  <revnumber>0.2</revnumber>
+  <date>2005-02-02</date>
+  <revremark>Updated for SWIG 1.3.24</revremark>
+  </revision>
+  <revision>
+  <revnumber>0.3</revnumber>
+  <date>2006-07-21</date>
+  <revremark>Clarification of 1:1 fixed rate vs item size</revremark>
+  </revision>
+</revhistory>
+
+<copyright>
+  <year>2004</year>
+  <year>2005</year>
+  <holder>Free Software Foundation, Inc.</holder>
+</copyright>
+
+<abstract><para>This article explains how to write signal
+processing blocks for <application>GNU Radio</application>.
+</para></abstract>
+
+</articleinfo>
+
+<sect1 id="prereqs"><title>Prerequisites</title>
+<para>This article assumes that the reader has basic familiarity with
+GNU Radio and has read and understood 
+<ulink url="http://www.gnu.org/software/gnuradio/doc/exploring-gnuradio.html">
+<citetitle>Exploring GNU Radio</citetitle></ulink>.
+</para>
+
+<para>There is a tarball of files that accompany this article.  It
+includes the examples, DocBook source for the article and all the
+Makefiles etc it takes to make it work.  Grab it at <ulink
+url="ftp://ftp.gnu.org/gnu/gnuradio">
+ftp://ftp.gnu.org/gnu/gnuradio</ulink> or one of the mirrors.  The
+file you want is
+<filename>gr-howto-write-a-block-X.Y.tar.gz</filename>.  Pick the one
+with the highest version number. 
+See <ulink url="http://comsec.com/wiki?CvsAccess">
+http://comsec.com/wiki?CvsAccess</ulink> for CVS Access.
+</para>
+
+
+</sect1>
+
+<sect1 id="intro"><title>Introduction</title>
+<para>&gnuradio; provides a framework for building software radios.
+Waveforms -- signal processing applications -- are built using a
+combination of Python code for high level organization, policy, GUI and
+other non performance-critical functions, while performance critical
+signal processing blocks are written in C++.</para>
+
+<para>From the Python point of view, &gnuradio; provides a data flow
+abstraction.  The fundamental concepts are signal processing
+blocks and the connections between them.  This abstraction is
+implemented by the Python <classname>gr.flow_graph</classname> class.
+Each block has a set of input ports and output ports.  Each port has
+an associated data type.  The most common port types are
+<classname>float</classname> and <classname>gr_complex</classname>
+(equivalent to std::complex&lt;float&gt;), though other types are used,
+including those representing structures, arrays or other types of
+packetized data.</para>  
+
+<para>From the high level point-of-view, infinite streams of data flow
+through the ports.  At the C++ level, streams are dealt with in
+convenient sized pieces, represented as contiguous arrays of the
+underlying type.</para>
+
+</sect1>
+
+<sect1 id="overview"><title>The View from 30,000 Feet</title>
+
+<para>This article will walk through the construction of several
+simple signal processing blocks, and explain the techniques and idioms
+used.  Later sections cover debugging signal processing blocks in the
+mixed Python/C++ environment and performance measurement and
+optimization.</para>
+
+<para>The example blocks will be built in the style of all &gnuradio;
+extensions. That is, they are built outside of the gnuradio-core build
+tree, and are constructed as shared libraries that may be dynamically
+loaded into Python using the "import" mechanism.  &SWIG;, the
+Simplified Wrapper and Interface Generator, is used to generate the
+glue that allows our code to be used from Python.</para>
+
+</sect1>
+
+
+<sect1 id="gr_block"><title></title>
+
+<para>The C++ class &gr_block; is the base of all signal processing
+blocks in &gnuradio;.  Writing a new signal processing block involves
+creating 3 files: The .h and .cc files that define the new class and
+the .i file that tells &SWIG; how to generate the glue that binds the
+class into Python.  The new class must derive from &gr_block; or
+one of it&apos;s subclasses.</para>
+
+<para>Our first examples will derive directly from &gr_block;.  Later
+we will look at some other subclasses that simplify the process for
+common cases.</para>
+
+</sect1><!-- end gr_block sect1 -->
+
+
+
+<!-- ================================================================ -->
+
+<sect1 id="autotools"><title>Autotools, Makefiles, and Directory Layout</title>
+
+<para>Before we dive into the code, &lets; talk a bit about the
+overall build environment and the directory structure that &well;
+be using.</para>
+
+<para>To reduce the amount of Makefile hacking that we have to do, and
+to facilitate portability across a variety of systems, we use the GNU
+<application>autoconf</application>,
+<application>automake</application>, and
+<application>libtool</application> tools.  These are collectively
+referred to as the autotools, and once you get over the initial
+shock, they will become your friends. (The good news is that we
+provide boilerplate that can be used pretty much as-is.)</para>
+
+<variablelist>
+
+<varlistentry><term>automake</term>
+
+<listitem><para>automake and configure work together to generate GNU
+compliant Makefiles from a much higher level description contained in
+the corresponding Makefile.am file.  <filename>Makefile.am</filename>
+specifies the libraries and programs to build and the source files
+that compose each.  Automake reads <filename>Makefile.am</filename>
+and produces <filename>Makefile.in</filename>.  Configure reads
+<filename>Makefile.in</filename> and produces
+<filename>Makefile</filename>.  The resulting Makefile contains a
+zillion rules that do the right right thing to build, check and
+install your code.  It is not uncommon for the the resulting
+<filename>Makefile</filename> to be 5 or 6 times larger than
+<filename>Makefile.am</filename>.</para>
+
+</listitem>
+</varlistentry>
+
+<varlistentry><term>autoconf</term>
+<listitem><para>autoconf reads <filename>configure.ac</filename>
+and produces the <filename>configure</filename> shell
+script.  <filename>configure</filename> automatically tests for
+features of the underlying system and sets a bunch of variables and
+defines that can be used in the Makefiles and your C++ code to
+conditionalize the build.  If features are required but not found,
+configure will output an error message and stop.</para>
+</listitem>
+</varlistentry>
+
+<varlistentry><term>libtool</term>
+<listitem><para>libtool works behind the scenes and provides the magic
+to construct shared libraries on a wide variety of systems.</para>
+</listitem>
+</varlistentry>
+
+</variablelist>
+
+<para><xref linkend="dir-layout"/> shows the directory layout and
+common files &well; be using.  After renaming the
+<replaceable>topdir</replaceable> directory, use it in your projects
+too.  We'll talk about particular files as they come up later.</para>
+
+
+<table id="dir-layout"><title>Directory Layout</title>
+<tgroup cols="2">
+
+<thead><row>
+<entry>File/Dir Name</entry>
+<entry>Comment</entry>
+</row>
+</thead>
+
+<tbody>
+
+<row>
+<entry><replaceable>topdir</replaceable>/Makefile.am</entry>
+<entry>Top level Makefile.am</entry>
+</row>
+<row>
+<entry><replaceable>topdir</replaceable>/Makefile.common</entry>
+<entry>Common fragment included in sub-Makefiles</entry>
+</row>
+<row>
+<entry><replaceable>topdir</replaceable>/bootstrap</entry>
+<entry>Runs autoconf, automake, libtool first time through</entry>
+</row>
+<row>
+<entry><replaceable>topdir</replaceable>/config</entry>
+<entry>Directory of m4 macros used by configure.ac</entry>
+</row>
+<row>
+<entry><replaceable>topdir</replaceable>/configure.ac</entry>
+<entry>Input to autoconf</entry>
+</row>
+<row>
+<entry><replaceable>topdir</replaceable>/src</entry>
+</row>
+<row>
+<entry><replaceable>topdir</replaceable>/src/lib</entry>
+<entry>C++ code goes here</entry>
+</row>
+<row>
+<entry><replaceable>topdir</replaceable>/src/lib/Makefile.am</entry>
+</row>
+<row>
+<entry><replaceable>topdir</replaceable>/src/python</entry>
+<entry>Python code goes here</entry>
+</row>
+<row>
+<entry><replaceable>topdir</replaceable>/src/python/Makefile.am</entry>
+</row>
+<row>
+<entry><replaceable>topdir</replaceable>/src/python/run_tests</entry>
+<entry>Script to run tests in the build tree</entry>
+</row>
+
+</tbody>
+</tgroup>
+</table>
+
+</sect1>
+
+<!-- ================================================================ -->
+
+<sect1 id="naming"><title>Naming Conventions</title>
+
+<para>&gnuradio; uses a set of naming conventions to assist in
+comprehending the code base and gluing C++ and Python together.
+Please follow them.</para>
+
+<sect2 id="camel-case"><title><emphasis>Death to CamelCaseNames!</emphasis></title>
+
+<para>We've returned to a kinder, gentler era.  We're now using the
+&quot;STL style&quot; naming convention with a couple of modifications
+since we're not using namespaces.</para>
+
+<para>With the exception of macros and other constant values, all
+identifiers shall be lower case with <literal>words_separated_like_this</literal>.</para>
+
+<para>Macros and constant values (e.g., enumerated values,
+<literal>static const int FOO = 23</literal>) shall be in <literal>UPPER_CASE</literal>.</para>
+
+</sect2>
+
+<sect2 id="global_names"><title>Global Names</title>
+
+<para>All globally visible names (types, functions, variables, consts, etc)
+shall begin with a "package prefix", followed by an underscore.  The bulk of
+the code in GNU Radio belongs to the "gr" package, hence
+names look like <literal>gr_open_file (...)</literal>.</para>
+
+<para>Large coherent bodies of code may use other package prefixes, but
+let's try to keep them to a well thought out list.  See the list
+below.</para>
+
+</sect2>
+
+<sect2 id="package_prefixes"><title>Package Prefixes</title>
+
+<para>These are the current package prefixes:
+
+<variablelist>
+
+<varlistentry><term>gr_</term>
+<listitem><para>Almost everything.</para></listitem>
+</varlistentry>
+
+<varlistentry><term>gri_</term>
+<listitem><para>
+Implementation primitives.  Sometimes we
+have both a gr_<replaceable>foo</replaceable> and a gri_<replaceable>foo</replaceable>.  In that case,
+gr_<replaceable>foo</replaceable> would be derived from gr_block and gri_<replaceable>foo</replaceable>
+would be the low level guts of the function.</para></listitem>
+</varlistentry>
+
+<varlistentry><term>atsc_</term>
+<listitem><para>Code related to the Advanced Television Standards Committee HDTV implementation
+</para></listitem>
+</varlistentry>
+
+<varlistentry><term>usrp_</term>
+<listitem><para>Universal Software Radio Peripheral.</para></listitem>
+</varlistentry>
+
+<varlistentry><term>qa_</term>
+<listitem><para>Quality Assurance (Test code.)</para></listitem>
+</varlistentry>
+
+</variablelist>
+
+</para>
+</sect2>
+
+<sect2 id="class-data-members"><title>Class Data Members (instance variables)</title>
+
+<para>All class data members shall begin with d_<replaceable>foo</replaceable>.</para>
+
+<para>The big win is when you're staring at a block of code it's obvious
+which of the things being assigned to persist outside of the block.
+This also keeps you from having to be creative with parameter names
+for methods and constructors.  You just use the same name as the
+instance variable, without the d_. </para>
+
+<literallayout>
+class gr_wonderfulness {
+  std::string   d_name;
+  double        d_wonderfulness_factor;
+
+public:
+  gr_wonderfulness (std::string name, double wonderfulness_factor)
+    : d_name (name), d_wonderfulness_factor (wonderfulness_factor)
+  {
+    ...
+  }
+  ...
+};
+</literallayout>
+
+</sect2>
+
+<sect2 id="static-data-members"><title>Class Static Data Members (class variables)</title>
+
+<para>
+All class static data members shall begin with s_<replaceable>foo</replaceable>.
+</para>
+
+</sect2>
+
+<sect2 id="file-names"><title>File Names</title>
+
+<para>Each significant class shall be contained in its own file.  The
+declaration of class <classname>gr_foo</classname> shall be in 
+<filename>gr_foo.h</filename> and the definition in
+<filename>gr_foo.cc</filename>.</para>
+</sect2>
+
+
+<sect2><title>Suffixes</title>
+
+<para>By convention, we encode the input and output types of signal
+processing blocks in their name using suffixes.  The suffix is
+typically one or two characters long.  Source and sinks have single
+character suffixes.  Regular blocks that have both inputs and outputs
+have two character suffixes.  The first character indicates the type
+of the input streams, the second indicates the type of the output
+streams.  FIR filter blocks have a three character suffix, indicating
+the type of the inputs, outputs and taps, respectively.</para>
+
+<para>These are the suffix characters and their interpretations:
+<itemizedlist>
+<listitem><para>f - single precision floating point</para></listitem>
+<listitem><para>c - complex&lt;float&gt;</para></listitem>
+<listitem><para>s - short (16-bit integer)</para></listitem>
+<listitem><para>i - integer (32-bit integer)</para></listitem>
+</itemizedlist>
+</para>
+
+<para>In addition, for those cases where the block deals with streams
+of vectors, we use the character 'v' as the first character of the
+suffix.  An example of this usage is
+<classname>gr_fft_vcc</classname>.  The FFT block takes a vector of
+complex numbers on its input and produces a vector of complex
+numbers on its output.</para>
+
+</sect2>
+
+</sect1>
+
+
+
+
+<sect1 id="square"><title>First Block: &square;</title>
+
+<para>For our first example &well; create a block that computes
+the square of its single float input.  This block will accept a single
+float input stream and produce a single float output stream.</para>
+
+<para>Following the naming conventions, &well; use
+<literal>howto</literal> as our package prefix, and the block will
+be called <classname>howto_square_ff</classname>.</para>
+
+<para>We are going to arrange that this block, as well as the others
+that we write in this article, end up in the
+<literal>gnuradio.howto</literal> Python module.  This will allow us
+to access it from Python like this:
+<programlisting>
+from gnuradio import howto
+sqr = howto.square_ff ()
+</programlisting>
+</para>
+
+
+<sect2 id="test_driven"><title>Test Driven Programming</title>
+
+<para>We could just start banging out the C++ code, but being highly
+evolved modern programmers, &were; going to write the test code first.
+After all, we do have a good spec for the behavior: take a single
+stream of floats as the input and produce a single stream of floats as
+the output. The output should be the square of the input.</para>
+
+<para>How hard could this be?  Turns out that this is easy! Check out 
+<xref linkend="qa_howto_1.py"/>.</para>
+
+<example id="qa_howto_1.py">
+<title><filename>qa_howto.py</filename> (first version)</title>
+&qa_howto_1_listing;
+</example>
+
+<para>
+<classname>gr_unittest</classname> is an extension to the standard
+python module <classname>unittest</classname>.
+<classname>gr_unittest</classname> adds support for checking
+approximate equality of tuples of float and complex numbers.  
+Unittest uses Python&apos;s reflection mechanism to find all methods that start with
+<methodname>test_</methodname> and runs them.  Unittest wraps each call
+to <methodname>test_*</methodname> with matching calls to 
+<methodname>setUp</methodname> and <methodname>tearDown</methodname>.
+See the python <ulink url="http://docs.python.org/lib/module-unittest.html">
+unittest</ulink> documentation for details.
+</para>
+
+<para>When we run the test,
+gr_unittest.main is going to invoke
+<methodname>setUp</methodname>,
+<methodname>test_001_square_ff</methodname>, and
+<methodname>tearDown</methodname>.</para>
+<para>
+<methodname>test_001_square_ff</methodname> builds a small graph that
+contains three nodes.  gr.vector_source_f(src_data) will source the
+elements of src_data and then say that &its; finished.  howto.square_ff is the block
+&were; testing.  gr.vector_sink_f gathers the output of
+howto.square_ff.</para>
+
+<para>The <methodname>run</methodname> method runs the graph until all
+the blocks indicate they are finished.  Finally, we check that the
+result of executing square_ff on src_data matches what we expect.
+</para>
+
+</sect2>
+
+<sect2 id="build_vs_install"><title>Build Tree vs. Install Tree</title>
+
+<para>The build tree is everything from <replaceable>topdir</replaceable>
+(the one containing configure.ac) down.  The path to the install tree is
+<filename>
+<replaceable>prefix</replaceable>/lib/python<replaceable>version</replaceable>/site-packages</filename>,
+where <replaceable>prefix</replaceable> is the <literal>--prefix</literal>
+argument to configure (default <filename>/usr/local</filename>) and 
+<replaceable>version</replaceable> is the installed version of
+python. A typical value is 
+<filename>/usr/local/lib/python2.3/site-packages</filename>.</para>
+
+
+<para>We normally set our PYTHONPATH environment variable to point at
+the install tree, and do this in <filename>~/.bash_profile</filename> 
+or <filename>~/.profile</filename>.
+This allows our python apps to access all the standard python
+libraries, plus our locally installed stuff like GNU Radio.</para>
+
+<para>We write our applications such that they access the code and
+libraries in the install tree.  On the other hand, we want our test
+code to run on the build tree, where we can detect problems before
+installation.</para>
+
+</sect2>
+
+<sect2 id="make_check"><title>make check</title>
+
+
+<para>We use <command>make check</command> to run our tests.
+Make check invokes the <command>run_tests</command> shell script which 
+sets up the PYTHONPATH environment variable so that 
+our tests use the build tree versions of our code and libraries.
+It then runs all files
+which have names of the form <filename>qa_*.py</filename> and reports
+the overall success or failure.</para>
+
+<para>There is quite a bit of behind-the-scenes action required to use
+the non-installed versions of our code (look at
+<filename>runtest</filename> for a cheap thrill.)</para>
+
+<para>Finally, running <command>make check</command> in the python
+directory produces this result:
+<literallayout>
+  [eb@bufo python]$ make check
+  make  check-TESTS
+  make[1]: Entering directory `/home/eb/gr-build/gr-howto-write-a-block/src/python'
+  Traceback (most recent call last):
+    File "./qa_howto.py", line 24, in ?
+      import howto
+  ImportError: No module named howto
+  Traceback (most recent call last):
+    File "./qa_howto_1.py", line 24, in ?
+      import howto
+  ImportError: No module named howto
+  FAIL: run_tests
+  ===================
+  1 of 1 tests failed
+  ===================
+  make[1]: *** [check-TESTS] Error 1
+  make[1]: Leaving directory `/home/eb/gr-build/gr-howto-write-a-block/src/python'
+  make: *** [check-am] Error 2
+  [eb@bufo python]$
+</literallayout>
+Excellent!  Our test failed, just as we expected.  The ImportError
+indicates that it can't find the module named
+<classname>howto</classname>.  No surprise, since we haven't written it yet.
+</para>
+
+</sect2>
+
+<sect2><title>The C++ code</title>
+<para>Now that we've got a test case written that successfully fails,
+let's write the C++ code.  As we mentioned earlier, all signal
+processing blocks are derived from <classname>gr_block</classname> or
+one of its subclasses.  Let's take a look at 
+<xref linkend="gr_block.h"/>.</para>
+
+<example id="gr_block.h">
+<title><filename>gr_block.h</filename></title>
+&gr_block_listing;
+</example>
+
+<para>A quick scan of <filename>gr_block.h</filename> reveals that
+since <methodname>general_work</methodname> is pure virtual, we
+definitely need to override that. 
+<methodname>general_work</methodname> is the method that does the
+actual signal processing.  For our squaring example we'll
+need to override <methodname>general_work</methodname> and provide a
+constructor and destructor and a bit of stuff to take advantage of
+the <ulink url="http://www.boost.org">boost</ulink>
+<ulink url="http://www.boost.org/libs/smart_ptr/smart_ptr.htm">
+<classname>shared_ptr</classname>s.</ulink>
+
+</para>
+
+
+<para><xref linkend="howto_square_ff.h"/> 
+and <xref linkend="howto_square_ff.cc"/> are the header and c++
+source.</para>
+
+<example id="howto_square_ff.h">
+<title><filename>howto_square_ff.h</filename></title>
+&howto_square_ff_h_listing;
+</example>
+
+<example id="howto_square_ff.cc">
+<title><filename>howto_square_ff.cc</filename></title>
+&howto_square_ff_cc_listing;
+</example>
+
+<para>Now we need a Makefile.am to get all this to build.  
+<xref linkend="src_lib_Makefile_1"/> 
+is enough to build a shared library from our source file.  We'll be
+adding additional rules to use &SWIG; in just a bit.  If you haven't
+already, this is a good time to browse all the Makefile.am&apos;s in
+the build tree and get an idea for how it all hangs together.</para>
+
+<example id="src_lib_Makefile_1">
+<title><filename>src/lib/Makefile.am</filename> (no &SWIG;)</title>
+&src_lib_Makefile_1_am_listing;
+</example>
+
+</sect2>
+
+
+<!-- ==============================
+
+<sect2 id="io_sig"><title><classname>gr_io_signature</classname></title>
+<para></para>
+</sect2>
+
+<sect2 id="forecast"><title><methodname>forecast</methodname></title>
+<para></para>
+</sect2>
+
+<sect2 id="output_multiple">
+<title><methodname>set_output_multiple</methodname></title>
+<para></para>
+</sect2>
+
+  ============================== -->
+
+
+<sect2 id="swig"><title>The &SWIG; .i file</title> 
+
+<para>Now that we've got something that will compile, we need to write
+the &SWIG; .i file.  This is a pared-down version of the .h file, plus
+a bit of magic that has python work with the boost shared_ptr&apos;s.
+To reduce code bloat, we only declare methods that &well; want to
+access from Python.</para>
+
+<para>We&apos;re going to call the .i file
+<filename>howto.i</filename>, and use it to hold the &SWIG;
+declarations for all classes from <literal>howto</literal> that will
+be accessible from python.  It&apos;s quite small:
+&howto_1_i_listing;
+</para>
+
+</sect2>
+
+<sect2><title>Putting it all together</title>
+<para>
+Now we need to modify <filename>src/lib/Makefile.am</filename>
+to run &SWIG; and to add the glue it generates to the shared library.</para>
+
+<example id="src_lib_Makefile_2">
+<title><filename>src/lib/Makefile.am</filename> (with &SWIG;)</title>
+&src_lib_Makefile_2_am_listing;
+</example>
+
+<para><command>make</command> now builds everything successfully.  We get a
+few warnings, but &thats; OK.</para>
+
+<para>Changing directories back to the python directory we try
+<command>make check</command> again:
+<literallayout>
+  [eb@bufo python]$ make check
+  make  check-TESTS
+  make[1]: Entering directory `/home/eb/gr-build/gr-howto-write-a-block/src/python'
+  .
+  ----------------------------------------------------------------------
+  Ran 1 test in 0.004s
+  
+  OK
+  PASS: run_tests
+  ==================
+  All 1 tests passed
+  ==================
+  make[1]: Leaving directory `/home/eb/gr-build/gr-howto-write-a-block/src/python'
+  [eb@bufo python]$
+</literallayout>
+<emphasis>Victory! Our new block works!</emphasis>
+</para>
+
+</sect2>
+
+</sect1><!-- end First Block: square -->
+
+<sect1 id="additional_methods"><title>Additional gr_block methods</title>
+
+<para>In our <classname>howto_square_ff</classname> example above, we only
+had to override the <methodname>general_work</methodname> method to
+accomplish our goal.  <classname>gr_block</classname> provides a few other
+methods that are sometimes useful.</para>
+
+<sect2 id="forecast"><title>forecast</title>
+
+<para>Looking at <methodname>general_work</methodname> you may
+have wondered how the system knows how much data it needs to
+ensure is valid in each of the input arrays.  The
+<methodname>forecast</methodname> method provides this
+information.</para>
+
+<para>The default implementation of <methodname>forecast</methodname>
+says there is a 1:1 relationship between noutput_items and the
+requirements for each input stream.  The size of the items is defined by
+<classname>gr_io_signature</classname>s in the constructor of
+<classname>gr_block</classname>. The sizes of the input and output items
+can of course differ; this still qualifies as a 1:1 relationship.
+<programlisting>
+  // default implementation:  1:1
+
+  void
+  gr_block::forecast (int noutput_items,
+                      gr_vector_int &amp;ninput_items_required)
+  {
+    unsigned ninputs = ninput_items_required.size ();
+    for (unsigned i = 0; i &lt; ninputs; i++)
+      ninput_items_required[i] = noutput_items;
+  }
+</programlisting>
+</para>
+
+<para>Although the 1:1 implementation worked for howto_square_ff, it
+wouldn&apos;t be appropriate for interpolators, decimators, or blocks
+with a more complicated relationship between noutput_items and the
+input requirements.  That said, by deriving your classes from
+<classname>gr_sync_block</classname>,
+<classname>gr_sync_interpolator</classname> or
+<classname>gr_sync_decimator</classname> instead of
+<classname>gr_block</classname>, you can often avoid
+implementing <methodname>forecast</methodname>.</para>
+
+</sect2>
+
+<sect2 id="set_output_multiple"><title>set_output_multiple</title>
+
+<para>When implementing your <methodname>general_work</methodname>
+routine, &its; occasionally convenient to have the run time system
+ensure that you are only asked to produce a number of output items
+that is a multiple of some particular value.  This might occur if your
+algorithm naturally applies to a fixed sized block of data. 
+Call <methodname>set_output_multiple</methodname> in your constructor
+to specify this requirement. The default output multiple is 1.</para>
+
+</sect2>
+
+</sect1>
+
+
+<sect1 id="common_patterns">
+<title>Subclasses for common patterns</title>
+
+<para><classname>gr_block</classname> allows tremendous flexibility
+with regard to the consumption of input streams and the production of
+output streams.  Adroit use of <methodname>forecast</methodname> and
+<methodname>consume</methodname> allows variable rate blocks to be
+built.  It is possible to construct blocks that consume data at
+different rates on each input, and produce output at a rate that
+is a function of the contents of the input data.</para>
+
+<para>On the other hand, it is very common for signal processing
+blocks to have a fixed relationship between the input rate and the
+output rate.  Many are 1:1, while others have 1:N or N:1
+relationships.</para>
+
+<para>Another common requirement is the need to examine more than one
+input sample to produce a single output sample.  This is orthogonal to
+the relationship between input and output rate.  For example, a
+non-decimating, non-interpolating FIR filter needs to examine N input
+samples for each output sample it produces, where N is the number of
+taps in the filter.  However, it only consumes a single input sample
+to produce a single output.  We call this concept "history", but you
+could also think of it as "look-ahead".</para>
+
+<sect2 id="gr_sync_block"><title><classname>gr_sync_block</classname></title>
+
+<para>
+<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__sync__block.html">
+<classname>gr_sync_block</classname></ulink>
+is derived from
+<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__block.html">
+<classname>gr_block</classname></ulink>
+and implements a 1:1 block with
+optional history.  Given that we know the input to output rate,
+certain simplifications are possible.  From the implementor&apos;s
+point-of-view, the primary change is that we define a
+<methodname>work</methodname> method instead of
+<methodname>general_work</methodname>.  <methodname>work</methodname>
+has a slightly different calling sequence;
+It omits the unnecessary ninput_items parameter, and arranges for
+<methodname>consume_each</methodname> to be called on our
+behalf.</para>
+<programlisting>
+  /*!
+   * \brief Just like gr_block::general_work, only this arranges to
+   *  call consume_each for you.
+   *
+   * The user must override work to define the signal processing code
+   */
+  virtual int work (int noutput_items,
+                    gr_vector_const_void_star &amp;input_items,
+                    gr_vector_void_star &amp;output_items) = 0;
+</programlisting>
+
+<para>This gives us fewer things to worry about, and less code to
+write.  If the block requires history greater than 1, call
+<methodname>set_history</methodname> in the constructor, or any time
+the requirement changes.</para>
+
+<para><classname>gr_sync_block</classname> provides a
+version of <methodname>forecast</methodname> that handles the
+history requirement.</para>
+
+</sect2>
+
+<sect2 id="gr_sync_decimator"><title><classname>gr_sync_decimator</classname></title>
+
+<para>
+<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__sync__decimator.html">
+<classname>gr_sync_decimator</classname></ulink>
+is derived from
+<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__sync__block.html">
+<classname>gr_sync_block</classname></ulink>
+and implements a N:1 block with optional history.  
+</para>
+
+</sect2>
+
+<sect2 id="gr_sync_interpolator"><title><classname>gr_sync_interpolator</classname></title>
+
+<para>
+<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__sync__interpolator.html">
+<classname>gr_sync_interpolator</classname></ulink>
+is derived from
+<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__sync__block.html">
+<classname>gr_sync_block</classname></ulink>
+and implements a 1:N block with optional history.  
+</para>
+
+</sect2>
+
+
+</sect1>
+
+<sect1 id="square2">
+<title>Second Block: <classname>howto_square2_ff</classname></title>
+
+<para>Given that we now know about
+<classname>gr_sync_block</classname>, the way 
+<classname>howto_square_ff</classname> should really be implemented is
+by subclassing <classname>gr_sync_block</classname>.</para>
+
+<para>Here are the revised sources: <xref
+linkend="howto_square2_ff.h"/>, 
+<xref linkend="howto_square2_ff.cc"/>.  
+The accompanying files contain the additional test code.
+</para>
+
+<example id="howto_square2_ff.h">
+<title><filename>howto_square2_ff.h</filename></title>
+&howto_square2_ff_h_listing;
+</example>
+
+<example id="howto_square2_ff.cc">
+<title><filename>howto_square2_ff.cc</filename></title>
+&howto_square2_ff_cc_listing;
+</example>
+
+</sect1>
+
+<sect1 id="where_to"><title>Where to from Here?</title>
+
+<para>At this point, we&apos;ve got a basic overview of how the system
+goes together.  For more insight, I suggest that you look at the code
+of the system.  The doxygen generated <ulink
+url="http://www.gnu.org/software/gnuradio/doc/hierarchy.html"> class
+hierarchy</ulink> is a useful way to find things that might interest
+you.</para>
+
+</sect1>
+
+
+<sect1 id="tips"><title>Miscellaneous Tips</title>
+
+<sect2 id="sources_and_sinks"><title>Sources and Sinks</title>
+
+<para>Sources and sinks are derived from
+<classname>gr_sync_block</classname>.  The only thing different about
+them is that sources have no inputs and sinks have no outputs.  This
+is reflected in the <classname>gr_io_signature</classname>s that are
+passed to the <classname>gr_sync_block</classname> constructor.
+Take a look at <filename>gr_file_source.{h,cc}</filename> and
+<filename>gr_file_sink.{h,cc}</filename> for some very straight-forward examples.
+</para>
+
+</sect2>
+
+<sect2 id="debugging">
+<title>Debugging with <application>gdb</application></title>
+
+<para>If your block isn&apos;t working, and you can&apos;t sort it
+out through python test cases or a few printfs in the code, you may want to
+use <application>gdb</application> to debug it.  The trick of course
+is that all of &gnuradio;, including your new block, is dynamically
+loaded into python for execution.</para>
+
+<para>Try this:  In your python test code, after the relevant imports,
+print out the process id and wait for a keystroke.  In another
+window run gdb and tell it to attach to the python process with the
+given process id.  At this point you can set breakpoints or whatever
+in your code.  Go back to the python window and hit Enter so
+it&apos;ll continue.</para>
+
+<programlisting>
+  #!/usr/bin/env python
+  from gnuradio import gr
+  from gnuradio import my_buggy_module
+
+  # insert this in your test code...
+  import os
+  print 'Blocked waiting for GDB attach (pid = %d)' % (os.getpid(),)
+  raw_input ('Press Enter to continue: ')
+  # remainder of your test code follows...
+</programlisting>
+
+<para>Another SNAFU you might run into is that gdb 6.2 isn&apos;t
+able to set breakpoints in the constructors or destructors generated
+by g++ 3.4.  In this case, insert a call to the nop function
+gri_debugger_hook in the constructor and recompile.  Load the code as
+before and set a break point on gri_debugger_hook.</para>
+
+</sect2>
+
+<sect2 id="oprofile">
+<title>Performance Measurement with <application>oprofile</application></title>
+<para>Oprofile is your friend.  
+See <ulink url="http://oprofile.sourceforge.net">http://oprofile.sourceforge.net</ulink>.
+</para>
+</sect2>
+
+</sect1><!-- end tips -->
+
+<sect1 id="futures"><title>Coming Attractions</title>
+<para></para>
+
+<sect2 id="types"><title>Improved Type System</title>
+<para></para>
+</sect2>
+
+<sect2 id="hierarchy"><title>Hierarchical Blocks</title>
+<para></para>
+</sect2>
+
+</sect1><!-- end Coming Attractions -->
+
+</article>
diff --git a/docs/howto-write-a-block/howto_1.i b/docs/howto-write-a-block/howto_1.i
new file mode 100644 (file)
index 0000000..640d089
--- /dev/null
@@ -0,0 +1,29 @@
+/* -*- c++ -*- */
+
+%include "exception.i"
+%import "gnuradio.i"                           // the common stuff
+
+%{
+#include "gnuradio_swig_bug_workaround.h"      // mandatory bug fix
+#include "howto_square_ff.h"
+#include <stdexcept>
+%}
+
+// ----------------------------------------------------------------
+
+/*
+ * First arg is the package prefix.
+ * Second arg is the name of the class minus the prefix.
+ *
+ * This does some behind-the-scenes magic so we can
+ * access howto_square_ff from python as howto.square_ff
+ */
+GR_SWIG_BLOCK_MAGIC(howto,square_ff);
+
+howto_square_ff_sptr howto_make_square_ff ();
+
+class howto_square_ff : public gr_block
+{
+private:
+  howto_square_ff ();
+};
diff --git a/docs/howto-write-a-block/make_numbered_listing.py b/docs/howto-write-a-block/make_numbered_listing.py
new file mode 100755 (executable)
index 0000000..889c2d7
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+import sys
+import os, os.path
+from optparse import OptionParser
+
+def quote_line (line):
+    line = line.replace ('&', '&amp;')
+    line = line.replace ('<', '&lt;')
+    line = line.replace ('>', '&gt;')
+    line = line.replace ("'", '&apos;')
+    line = line.replace ('"', '&quot;')
+    return line
+
+def generate_listing (input_filename, title=None):
+    inf = open (input_filename, "r")
+    output_filename = os.path.basename (input_filename) + '.xml'
+    outf = open (output_filename, "w")
+    outf.write ('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
+    # outf.write ('<example id="%s">\n' % (input_filename,))
+    # if not title:
+    #     title = input_filename
+    # outf.write ('<title>')
+    # outf.write (title)
+    # outf.write ('</title>\n')
+    outf.write ('<programlisting>\n');
+
+    lineno = 0
+    for line in inf:
+        line = line.expandtabs (8)
+        line = quote_line (line)
+        lineno = lineno + 1
+        outf.write ('%3d  %s' % (lineno, line))
+
+    outf.write ('</programlisting>\n')
+    # outf.write ('</example>\n')
+
+
+def main ():
+    for file in sys.argv[1:]:
+        generate_listing (file)
+
+if __name__ == '__main__':
+    main ()
+    
diff --git a/docs/howto-write-a-block/qa_howto_1.py b/docs/howto-write-a-block/qa_howto_1.py
new file mode 100755 (executable)
index 0000000..3173110
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, gr_unittest
+import howto
+
+class qa_howto (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block ()
+
+    def tearDown (self):
+        self.tb = None
+
+    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.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)
+        
+if __name__ == '__main__':
+    gr_unittest.main ()
diff --git a/docs/howto-write-a-block/src_lib_Makefile_1.am b/docs/howto-write-a-block/src_lib_Makefile_1.am
new file mode 100644 (file)
index 0000000..e97d70d
--- /dev/null
@@ -0,0 +1,25 @@
+include $(top_srcdir)/Makefile.common
+
+# Install this stuff so that it ends up as the gnuradio.howto module
+# This usually ends up at:
+#   ${prefix}/lib/python${python_version}/site-packages/gnuradio
+
+ourpythondir = $(grpythondir)
+ourlibdir    = $(grpyexecdir)
+
+INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES)
+
+ourlib_LTLIBRARIES = _howto.la
+
+# These are the source files that go into the shared library
+_howto_la_SOURCES =                    \
+       howto_square_ff.cc              
+
+# magic flags
+_howto_la_LDFLAGS = -module -avoid-version
+
+# These headers get installed in ${prefix}/include/gnuradio
+grinclude_HEADERS =                    \
+       howto_square_ff.h               
+
+MOSTLYCLEANFILES = $(BUILT_SOURCES) *.pyc
diff --git a/docs/howto-write-a-block/src_lib_Makefile_2.am b/docs/howto-write-a-block/src_lib_Makefile_2.am
new file mode 100644 (file)
index 0000000..dca236e
--- /dev/null
@@ -0,0 +1,86 @@
+#
+# Copyright 2004,2008 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
+
+# Install this stuff so that it ends up as the gnuradio.howto module
+# This usually ends up at:
+#   ${prefix}/lib/python${python_version}/site-packages/gnuradio
+
+ourpythondir = $(grpythondir)
+ourlibdir    = $(grpyexecdir)
+
+INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES)
+
+SWIGCPPPYTHONARGS = -noruntime -c++ -python $(PYTHON_CPPFLAGS) \
+       -I$(swigincludedir) -I$(grincludedir) $(WITH_SWIG_INCLUDES)
+
+ALL_IFILES =                           \
+       $(LOCAL_IFILES)                 \
+       $(NON_LOCAL_IFILES)             
+
+NON_LOCAL_IFILES =                     \
+       $(GNURADIO_CORE_INCLUDEDIR)/swig/gnuradio.i
+
+
+LOCAL_IFILES =                                 \
+       howto.i                         
+
+# These files are built by SWIG.  The first is the C++ glue.
+# The second is the python wrapper that loads the _howto shared library
+# and knows how to call our extensions.
+
+BUILT_SOURCES =                        \
+       howto.cc                        \
+       howto.py                                
+
+# This gets howto.py installed in the right place
+ourpython_PYTHON =                     \
+       howto.py
+
+ourlib_LTLIBRARIES = _howto.la
+
+# These are the source files that go into the shared library
+_howto_la_SOURCES =                    \
+       howto.cc                        \
+       howto_square_ff.cc              
+
+# magic flags
+_howto_la_LDFLAGS = -module -avoid-version
+
+# link the library against some comon swig runtime code and the 
+# c++ standard library
+_howto_la_LIBADD =                     \
+       -lgrswigrunpy                   \
+       -lstdc++                        
+
+howto.cc howto.py: howto.i $(ALL_IFILES)
+       $(SWIG) $(SWIGCPPPYTHONARGS) -module howto -o howto.cc $<
+
+# These headers get installed in ${prefix}/include/gnuradio
+grinclude_HEADERS =                    \
+       howto_square_ff.h               
+
+# These swig headers get installed in ${prefix}/include/gnuradio/swig
+swiginclude_HEADERS =                  \
+       $(LOCAL_IFILES)
+
+MOSTLYCLEANFILES = $(BUILT_SOURCES) *.pyc
index 01035ffcdac02ad0ef15641921b2f7850d564221..b52735c06eb39705ea08e78a68e6005474a5f035 100644 (file)
@@ -27,7 +27,7 @@
 #include <gr_io_signature.h>
 #include <string.h>
 
-gr_head::gr_head (size_t sizeof_stream_item, int nitems)
+gr_head::gr_head (size_t sizeof_stream_item, unsigned long long nitems)
   : gr_sync_block ("head",
                   gr_make_io_signature (1, 1, sizeof_stream_item),
                   gr_make_io_signature (1, 1, sizeof_stream_item)),
@@ -36,7 +36,7 @@ gr_head::gr_head (size_t sizeof_stream_item, int nitems)
 }
 
 gr_head_sptr
-gr_make_head (size_t sizeof_stream_item, int nitems)
+gr_make_head (size_t sizeof_stream_item, unsigned long long nitems)
 {
   return gnuradio::get_initial_sptr(new gr_head (sizeof_stream_item, nitems));
 }
@@ -49,7 +49,7 @@ gr_head::work (int noutput_items,
   if (d_ncopied_items >= d_nitems)
     return -1;                         // Done!
 
-  unsigned n = std::min (d_nitems - d_ncopied_items, noutput_items);
+  unsigned n = std::min (d_nitems - d_ncopied_items, (unsigned long long) noutput_items);
   
   if (n == 0)
     return 0;
index 430d5f8b9644df8ff7b5d06d98bdc3f88a15994c..f7eee10648e3f354455844272f8785ae9af6e571 100644 (file)
@@ -38,11 +38,11 @@ typedef boost::shared_ptr<gr_head> gr_head_sptr;
 
 class gr_head : public gr_sync_block
 {
-  friend gr_head_sptr gr_make_head (size_t sizeof_stream_item, int nitems);
-  gr_head (size_t sizeof_stream_item, int nitems);
+  friend gr_head_sptr gr_make_head (size_t sizeof_stream_item, unsigned long long nitems);
+  gr_head (size_t sizeof_stream_item, unsigned long long nitems);
 
-  int  d_nitems;
-  int  d_ncopied_items;
+  unsigned long long   d_nitems;
+  unsigned long long   d_ncopied_items;
 
  public:
   int work (int noutput_items,
@@ -53,7 +53,7 @@ class gr_head : public gr_sync_block
 };
 
 gr_head_sptr
-gr_make_head (size_t sizeof_stream_item, int nitems);
+gr_make_head (size_t sizeof_stream_item, unsigned long long nitems);
 
 
 #endif /* INCLUDED_GR_HEAD_H */
index 2a88b885f010dd041b69d48f58daf5a7e6bfcd0e..3aece9601c16a039a8cee0acba922550ad350279 100644 (file)
@@ -22,7 +22,7 @@
 
 GR_SWIG_BLOCK_MAGIC(gr,head);
 
-gr_head_sptr gr_make_head(size_t sizeof_stream_item, int nitems);
+gr_head_sptr gr_make_head(size_t sizeof_stream_item, unsigned long long nitems);
 
 class gr_head : public gr_block {
   gr_head();
index 50d480d009e80875b02744740e84917837a33e0e..9cad687fb55f4f685fa4373564c072b5a265218f 100644 (file)
@@ -90,7 +90,7 @@ gr_top_block_impl::~gr_top_block_impl()
 void
 gr_top_block_impl::start()
 {
-  gr_lock_guard        l(d_mutex);
+  gruel::scoped_lock   l(d_mutex);
 
   if (d_state != IDLE)
     throw std::runtime_error("top_block::start: top block already running or wait() not called after previous stop()");
@@ -131,14 +131,14 @@ gr_top_block_impl::wait()
 void
 gr_top_block_impl::lock()
 {
-  gr_lock_guard lock(d_mutex);
+  gruel::scoped_lock lock(d_mutex);
   d_lock_count++;
 }
 
 void
 gr_top_block_impl::unlock()
 {
-  gr_lock_guard lock(d_mutex);
+  gruel::scoped_lock lock(d_mutex);
 
   if (d_lock_count <= 0){
     d_lock_count = 0;          // fix it, then complain
index 35fb44ef92ba7110c4c052e3c96d8a89573fcb8d..ef28dd8292124803f1162b85515b2313d4da0475 100644 (file)
 #define INCLUDED_GR_TOP_BLOCK_IMPL_H
 
 #include <gr_scheduler.h>
-#include <boost/thread.hpp>
-
-typedef boost::mutex                   gr_mutex;       // FIXME move these elsewhere
-typedef boost::lock_guard<boost::mutex>        gr_lock_guard;
+#include <gruel/thread.h>
 
 /*!
  *\brief Abstract implementation details of gr_top_block
@@ -69,7 +66,7 @@ protected:
   gr_flat_flowgraph_sptr         d_ffg;
   gr_scheduler_sptr             d_scheduler;
 
-  gr_mutex                       d_mutex;      // protects d_state and d_lock_count
+  gruel::mutex                   d_mutex;      // protects d_state and d_lock_count
   tb_state                      d_state;
   int                            d_lock_count;
   
index 4541b453b38d6f46efbe229d5152973ac3e44259..cd9a207c876cd51d1caa01b1d54d42247cccd6c0 100644 (file)
@@ -187,7 +187,8 @@ class dbpsk2_demod(gr.hier_block2):
                  timing_max_dev=_def_timing_max_dev,
                  gray_code=_def_gray_code,
                  verbose=_def_verbose,
-                 log=_def_log):
+                 log=_def_log,
+                 sync_out=False):
         """
        Hierarchical block for RRC-filtered differential BPSK demodulation
 
@@ -208,14 +209,18 @@ class dbpsk2_demod(gr.hier_block2):
         @type gray_code: bool
         @param verbose: Print information about modulator?
         @type verbose: bool
-        @param debug: Print modualtion data to files?
-        @type debug: bool
+        @param log: Print modualtion data to files?
+        @type log: bool
+        @param sync_out: Output a sync signal on :1?
+        @type sync_out: bool
        """
-        
-       gr.hier_block2.__init__(self, "dbpsk2_demod",
-                               gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
-                               gr.io_signature(1, 1, gr.sizeof_char))       # Output signature
-                               
+       if sync_out: io_sig_out = gr.io_signaturev(2, 2, (gr.sizeof_char, gr.sizeof_gr_complex))
+       else: io_sig_out = gr.io_signature(1, 1, gr.sizeof_char)
+
+       gr.hier_block2.__init__(self, "dqpsk2_demod",
+                               gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
+                               io_sig_out)       # Output signature
+
         self._samples_per_symbol = samples_per_symbol
         self._excess_bw = excess_bw
         self._costas_alpha = costas_alpha
@@ -278,6 +283,7 @@ class dbpsk2_demod(gr.hier_block2):
                      self.clock_recov,
                      self.time_recov,
                      self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self)
+        if sync_out: self.connect(self.time_recov, (self, 1))
 
     def samples_per_symbol(self):
         return self._samples_per_symbol
index 9704ac98c5776ea250294b38596be293d164a898..fd1e9f0efcfb38aab9529513403cd3e55118c4c7 100644 (file)
@@ -187,7 +187,8 @@ class dqpsk2_demod(gr.hier_block2):
                  timing_max_dev=_def_timing_max_dev,
                  gray_code=_def_gray_code,
                  verbose=_def_verbose,
-                 log=_def_log):
+                 log=_def_log,
+                 sync_out=False):
         """
        Hierarchical block for RRC-filtered DQPSK demodulation
 
@@ -208,13 +209,17 @@ class dqpsk2_demod(gr.hier_block2):
         @type gray_code: bool
         @param verbose: Print information about modulator?
         @type verbose: bool
-        @param debug: Print modualtion data to files?
-        @type debug: bool
+        @param log: Print modualtion data to files?
+        @type log: bool
+        @param sync_out: Output a sync signal on :1?
+        @type sync_out: bool
        """
+       if sync_out: io_sig_out = gr.io_signaturev(2, 2, (gr.sizeof_char, gr.sizeof_gr_complex))
+       else: io_sig_out = gr.io_signature(1, 1, gr.sizeof_char)
 
        gr.hier_block2.__init__(self, "dqpsk2_demod",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
-                               gr.io_signature(1, 1, gr.sizeof_char))       # Output signature
+                               io_sig_out)       # Output signature
 
         self._samples_per_symbol = samples_per_symbol
         self._excess_bw = excess_bw
@@ -278,6 +283,7 @@ class dqpsk2_demod(gr.hier_block2):
                      self.clock_recov,
                      self.time_recov,
                      self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self)
+        if sync_out: self.connect(self.time_recov, (self, 1))
 
     def samples_per_symbol(self):
         return self._samples_per_symbol
index 97417c5a22597697e6c09abe298074afd9f4b648..f8a26bacea60519eb4dc9372b09595f5e45f2882 100644 (file)
@@ -49,6 +49,8 @@ usrpdatadir = $(grc_examples_prefix)/usrp
 dist_usrpdata_DATA = \
        usrp/usrp2_const_wave.grc \
        usrp/usrp2_dpsk_mod.grc \
+       usrp/usrp_rx_dpsk.grc \
+       usrp/usrp_tx_dpsk.grc \
        usrp/usrp2_fft.grc \
        usrp/usrp_two_tone_loopback.grc \
        usrp/usrp_wbfm_receive.grc
diff --git a/gnuradio-examples/grc/usrp/usrp_rx_dpsk.grc b/gnuradio-examples/grc/usrp/usrp_rx_dpsk.grc
new file mode 100644 (file)
index 0000000..9843ee6
--- /dev/null
@@ -0,0 +1,727 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+  <timestamp>Wed Dec  2 11:03:20 2009</timestamp>
+  <block>
+    <key>options</key>
+    <param>
+      <key>id</key>
+      <value>usrp_rx_dpsk</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>USRP RX DPSK</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>(12, 9)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>samps_per_sym</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>4</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(14, 79)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>bb_freq</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>2.45e9</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(18, 151)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>p2p</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>2.0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(13, 314)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_slider</key>
+    <param>
+      <key>id</key>
+      <value>timing_alpha</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>Timing Alpha</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>.1</value>
+    </param>
+    <param>
+      <key>min</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>max</key>
+      <value>.5</value>
+    </param>
+    <param>
+      <key>num_steps</key>
+      <value>100</value>
+    </param>
+    <param>
+      <key>style</key>
+      <value>wx.SL_HORIZONTAL</value>
+    </param>
+    <param>
+      <key>converver</key>
+      <value>float_converter</value>
+    </param>
+    <param>
+      <key>grid_pos</key>
+      <value></value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(759, 365)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_null_sink</key>
+    <param>
+      <key>id</key>
+      <value>gr_null_sink_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(815, 80)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_slider</key>
+    <param>
+      <key>id</key>
+      <value>costas_alpha</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>Costas Alpha</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>0.175</value>
+    </param>
+    <param>
+      <key>min</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>max</key>
+      <value>.5</value>
+    </param>
+    <param>
+      <key>num_steps</key>
+      <value>100</value>
+    </param>
+    <param>
+      <key>style</key>
+      <value>wx.SL_HORIZONTAL</value>
+    </param>
+    <param>
+      <key>converver</key>
+      <value>float_converter</value>
+    </param>
+    <param>
+      <key>grid_pos</key>
+      <value></value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(598, 367)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>wxgui_fftsink2</key>
+    <param>
+      <key>id</key>
+      <value>wxgui_fftsink2_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>Receive Spectrum</value>
+    </param>
+    <param>
+      <key>samp_rate</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>baseband_freq</key>
+      <value>bb_freq</value>
+    </param>
+    <param>
+      <key>y_per_div</key>
+      <value>10</value>
+    </param>
+    <param>
+      <key>y_divs</key>
+      <value>10</value>
+    </param>
+    <param>
+      <key>ref_level</key>
+      <value>-40</value>
+    </param>
+    <param>
+      <key>ref_scale</key>
+      <value>p2p</value>
+    </param>
+    <param>
+      <key>fft_size</key>
+      <value>1024</value>
+    </param>
+    <param>
+      <key>fft_rate</key>
+      <value>15</value>
+    </param>
+    <param>
+      <key>peak_hold</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>average</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>avg_alpha</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>win</key>
+      <value>None</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>(383, 321)</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>1e6/4</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(20, 234)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_slider</key>
+    <param>
+      <key>id</key>
+      <value>gain</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>Gain</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>20</value>
+    </param>
+    <param>
+      <key>min</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>max</key>
+      <value>70</value>
+    </param>
+    <param>
+      <key>num_steps</key>
+      <value>100</value>
+    </param>
+    <param>
+      <key>style</key>
+      <value>wx.SL_HORIZONTAL</value>
+    </param>
+    <param>
+      <key>converver</key>
+      <value>float_converter</value>
+    </param>
+    <param>
+      <key>grid_pos</key>
+      <value></value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(152, 378)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>usrp2_source_xxxx</key>
+    <param>
+      <key>id</key>
+      <value>usrp2_source_xxxx_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>interface</key>
+      <value></value>
+    </param>
+    <param>
+      <key>mac_addr</key>
+      <value></value>
+    </param>
+    <param>
+      <key>decimation</key>
+      <value>int(100e6/samp_rate)</value>
+    </param>
+    <param>
+      <key>frequency</key>
+      <value>bb_freq</value>
+    </param>
+    <param>
+      <key>lo_offset</key>
+      <value>float('inf')</value>
+    </param>
+    <param>
+      <key>gain</key>
+      <value>gain</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(158, 51)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>usrp_simple_source_x</key>
+    <param>
+      <key>id</key>
+      <value>usrp_simple_source_x_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>format</key>
+      <value></value>
+    </param>
+    <param>
+      <key>which</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>decimation</key>
+      <value>int(64e6/samp_rate)</value>
+    </param>
+    <param>
+      <key>frequency</key>
+      <value>bb_freq</value>
+    </param>
+    <param>
+      <key>lo_offset</key>
+      <value>float('inf')</value>
+    </param>
+    <param>
+      <key>gain</key>
+      <value>gain</value>
+    </param>
+    <param>
+      <key>side</key>
+      <value>B</value>
+    </param>
+    <param>
+      <key>rx_ant</key>
+      <value>TX/RX</value>
+    </param>
+    <param>
+      <key>hb_filters</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(154, 218)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>blks2_dxpsk2_demod</key>
+    <param>
+      <key>id</key>
+      <value>blks2_dxpsk2_demod_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>dqpsk</value>
+    </param>
+    <param>
+      <key>samples_per_symbol</key>
+      <value>samps_per_sym</value>
+    </param>
+    <param>
+      <key>excess_bw</key>
+      <value>0.35</value>
+    </param>
+    <param>
+      <key>costas_alpha</key>
+      <value>costas_alpha</value>
+    </param>
+    <param>
+      <key>timing_alpha</key>
+      <value>timing_alpha</value>
+    </param>
+    <param>
+      <key>timing_max_dev</key>
+      <value>1.5</value>
+    </param>
+    <param>
+      <key>omega_relative_limit</key>
+      <value>0.005</value>
+    </param>
+    <param>
+      <key>gray_code</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>verbose</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>log</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>sync_out</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(487, 64)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>wxgui_scopesink2</key>
+    <param>
+      <key>id</key>
+      <value>wxgui_scopesink2_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>Recovered DQPSK Constellation</value>
+    </param>
+    <param>
+      <key>samp_rate</key>
+      <value>samp_rate/4/20</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</value>
+    </param>
+    <param>
+      <key>ac_couple</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>xy_mode</key>
+      <value>True</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>(760, 239)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>180</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_keep_one_in_n</key>
+    <param>
+      <key>id</key>
+      <value>gr_keep_one_in_n_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>n</key>
+      <value>20</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(873, 151)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <connection>
+    <source_block_id>usrp2_source_xxxx_0</source_block_id>
+    <sink_block_id>wxgui_fftsink2_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>usrp2_source_xxxx_0</source_block_id>
+    <sink_block_id>blks2_dxpsk2_demod_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blks2_dxpsk2_demod_0</source_block_id>
+    <sink_block_id>gr_null_sink_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blks2_dxpsk2_demod_0</source_block_id>
+    <sink_block_id>gr_keep_one_in_n_0</sink_block_id>
+    <source_key>1</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_keep_one_in_n_0</source_block_id>
+    <sink_block_id>wxgui_scopesink2_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+</flow_graph>
diff --git a/gnuradio-examples/grc/usrp/usrp_tx_dpsk.grc b/gnuradio-examples/grc/usrp/usrp_tx_dpsk.grc
new file mode 100644 (file)
index 0000000..90ec5e9
--- /dev/null
@@ -0,0 +1,583 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+  <timestamp>Thu Dec  3 11:42:41 2009</timestamp>
+  <block>
+    <key>options</key>
+    <param>
+      <key>id</key>
+      <value>usrp_tx_dpsk</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>USRP TX DPSK</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>samps_per_sym</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>4</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(15, 76)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>random_source_x</key>
+    <param>
+      <key>id</key>
+      <value>random_source_x_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>min</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>max</key>
+      <value>2**8</value>
+    </param>
+    <param>
+      <key>num_samps</key>
+      <value>1000</value>
+    </param>
+    <param>
+      <key>repeat</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(23, 319)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>blks2_dxpsk2_mod</key>
+    <param>
+      <key>id</key>
+      <value>blks2_dxpsk2_mod_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>dqpsk</value>
+    </param>
+    <param>
+      <key>samples_per_symbol</key>
+      <value>samps_per_sym</value>
+    </param>
+    <param>
+      <key>excess_bw</key>
+      <value>0.35</value>
+    </param>
+    <param>
+      <key>gray_code</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>verbose</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>log</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(234, 151)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>usrp_simple_sink_x</key>
+    <param>
+      <key>id</key>
+      <value>usrp_simple_sink_x_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>which</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>interpolation</key>
+      <value>int(128e6/samp_rate)</value>
+    </param>
+    <param>
+      <key>frequency</key>
+      <value>bb_freq</value>
+    </param>
+    <param>
+      <key>lo_offset</key>
+      <value>float('inf')</value>
+    </param>
+    <param>
+      <key>gain</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>side</key>
+      <value>A</value>
+    </param>
+    <param>
+      <key>transmit</key>
+      <value>auto_tr</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(516, 203)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>usrp2_sink_xxxx</key>
+    <param>
+      <key>id</key>
+      <value>usrp2_sink_xxxx_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>interface</key>
+      <value></value>
+    </param>
+    <param>
+      <key>mac_addr</key>
+      <value></value>
+    </param>
+    <param>
+      <key>interpolation</key>
+      <value>int(100e6/samp_rate)</value>
+    </param>
+    <param>
+      <key>frequency</key>
+      <value>bb_freq</value>
+    </param>
+    <param>
+      <key>lo_offset</key>
+      <value>float('inf')</value>
+    </param>
+    <param>
+      <key>gain</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(498, 51)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_slider</key>
+    <param>
+      <key>id</key>
+      <value>tx_ampl</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>TX Amplitude</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>.2</value>
+    </param>
+    <param>
+      <key>min</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>max</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>num_steps</key>
+      <value>100</value>
+    </param>
+    <param>
+      <key>style</key>
+      <value>wx.SL_HORIZONTAL</value>
+    </param>
+    <param>
+      <key>converver</key>
+      <value>float_converter</value>
+    </param>
+    <param>
+      <key>grid_pos</key>
+      <value></value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(277, 491)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>bb_freq</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>2.45e9+freq_off</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(14, 141)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_slider</key>
+    <param>
+      <key>id</key>
+      <value>freq_off</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>Frequency Offset</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>min</key>
+      <value>-samp_rate/2</value>
+    </param>
+    <param>
+      <key>max</key>
+      <value>samp_rate/2</value>
+    </param>
+    <param>
+      <key>num_steps</key>
+      <value>100</value>
+    </param>
+    <param>
+      <key>style</key>
+      <value>wx.SL_HORIZONTAL</value>
+    </param>
+    <param>
+      <key>converver</key>
+      <value>float_converter</value>
+    </param>
+    <param>
+      <key>grid_pos</key>
+      <value></value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(63, 483)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>p2p</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>2**15</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(179, 37)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_multiply_const_vxx</key>
+    <param>
+      <key>id</key>
+      <value>gr_multiply_const_vxx_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>const</key>
+      <value>tx_ampl*p2p/2.</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(306, 355)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>wxgui_fftsink2</key>
+    <param>
+      <key>id</key>
+      <value>wxgui_fftsink2_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>Transmit Spectrum</value>
+    </param>
+    <param>
+      <key>samp_rate</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>baseband_freq</key>
+      <value>bb_freq</value>
+    </param>
+    <param>
+      <key>y_per_div</key>
+      <value>10</value>
+    </param>
+    <param>
+      <key>y_divs</key>
+      <value>10</value>
+    </param>
+    <param>
+      <key>ref_level</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>ref_scale</key>
+      <value>p2p</value>
+    </param>
+    <param>
+      <key>fft_size</key>
+      <value>1024</value>
+    </param>
+    <param>
+      <key>fft_rate</key>
+      <value>20</value>
+    </param>
+    <param>
+      <key>peak_hold</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>average</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>avg_alpha</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>win</key>
+      <value>None</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>(576, 410)</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>1e6/4</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(12, 207)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <connection>
+    <source_block_id>random_source_x_0</source_block_id>
+    <sink_block_id>blks2_dxpsk2_mod_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blks2_dxpsk2_mod_0</source_block_id>
+    <sink_block_id>gr_multiply_const_vxx_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_multiply_const_vxx_0</source_block_id>
+    <sink_block_id>usrp_simple_sink_x_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_multiply_const_vxx_0</source_block_id>
+    <sink_block_id>wxgui_fftsink2_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+</flow_graph>
index d3c5b40a94091285c27361905f591af64c1f7b21..8b82ade08e87bbfb02fbf4c3b45b181ab6dda8cb 100644 (file)
@@ -2,15 +2,15 @@ Installation Instructions
 *************************
 
 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2007 Free Software Foundation, Inc.
+2006, 2007, 2008 Free Software Foundation, Inc.
 
-This file is free documentation; the Free Software Foundation gives
+   This file is free documentation; the Free Software Foundation gives
 unlimited permission to copy, distribute and modify it.
 
 Basic Installation
 ==================
 
-Briefly, the shell commands `./configure; make; make install' should
+   Briefly, the shell commands `./configure; make; make install' should
 configure, build, and install this package.  The following
 more-detailed instructions are generic; see the `README' file for
 instructions specific to this package.
@@ -73,9 +73,9 @@ The simplest way to compile this package is:
 Compilers and Options
 =====================
 
-Some systems require unusual options for compilation or linking that the
-`configure' script does not know about.  Run `./configure --help' for
-details on some of the pertinent environment variables.
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  Run `./configure --help'
+for details on some of the pertinent environment variables.
 
    You can give `configure' initial values for configuration parameters
 by setting variables in the command line or in the environment.  Here
@@ -88,7 +88,7 @@ is an example:
 Compiling For Multiple Architectures
 ====================================
 
-You can compile the package for more than one kind of computer at the
+   You can compile the package for more than one kind of computer at the
 same time, by placing the object files for each architecture in their
 own directory.  To do this, you can use GNU `make'.  `cd' to the
 directory where you want the object files and executables to go and run
@@ -100,10 +100,24 @@ architecture at a time in the source code directory.  After you have
 installed the package for one architecture, use `make distclean' before
 reconfiguring for another architecture.
 
+   On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor.  Like
+this:
+
+     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CPP="gcc -E" CXXCPP="g++ -E"
+
+   This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
 Installation Names
 ==================
 
-By default, `make install' installs the package's commands under
+   By default, `make install' installs the package's commands under
 `/usr/local/bin', include files under `/usr/local/include', etc.  You
 can specify an installation prefix other than `/usr/local' by giving
 `configure' the option `--prefix=PREFIX'.
@@ -126,7 +140,7 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
 Optional Features
 =================
 
-Some packages pay attention to `--enable-FEATURE' options to
+   Some packages pay attention to `--enable-FEATURE' options to
 `configure', where FEATURE indicates an optional part of the package.
 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
 is something like `gnu-as' or `x' (for the X Window System).  The
@@ -138,14 +152,36 @@ find the X include and library files automatically, but if it doesn't,
 you can use the `configure' options `--x-includes=DIR' and
 `--x-libraries=DIR' to specify their locations.
 
+Particular systems
+==================
+
+   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+     ./configure CC="cc -Ae"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
+a workaround.  If GNU CC is not installed, it is therefore recommended
+to try
+
+     ./configure CC="cc"
+
+and if that doesn't work, try
+
+     ./configure CC="cc -nodtk"
+
 Specifying the System Type
 ==========================
 
-There may be some features `configure' cannot figure out automatically,
-but needs to determine by the type of machine the package will run on.
-Usually, assuming the package is built to be run on the _same_
-architectures, `configure' can figure that out, but if it prints a
-message saying it cannot guess the machine type, give it the
+   There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on.  Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+message saying it cannot guess the machine type, give it the
 `--build=TYPE' option.  TYPE can either be a short name for the system
 type, such as `sun4', or a canonical name which has the form:
 
@@ -171,9 +207,9 @@ eventually be run) with `--host=TYPE'.
 Sharing Defaults
 ================
 
-If you want to set default values for `configure' scripts to share, you
-can create a site shell script called `config.site' that gives default
-values for variables like `CC', `cache_file', and `prefix'.
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
 `configure' looks for `PREFIX/share/config.site' if it exists, then
 `PREFIX/etc/config.site' if it exists.  Or, you can set the
 `CONFIG_SITE' environment variable to the location of the site script.
@@ -182,7 +218,7 @@ A warning: not all `configure' scripts look for a site script.
 Defining Variables
 ==================
 
-Variables not defined in a site shell script can be set in the
+   Variables not defined in a site shell script can be set in the
 environment passed to `configure'.  However, some packages may run
 configure again during the build, and the customized values of these
 variables may be lost.  In order to avoid this problem, you should set
@@ -201,11 +237,19 @@ an Autoconf bug.  Until the bug is fixed you can use this workaround:
 `configure' Invocation
 ======================
 
-`configure' recognizes the following options to control how it operates.
+   `configure' recognizes the following options to control how it
+operates.
 
 `--help'
 `-h'
-     Print a summary of the options to `configure', and exit.
+     Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+     Print a summary of the options unique to this package's
+     `configure', and exit.  The `short' variant lists options used
+     only in the top level, while the `recursive' variant lists options
+     also present in any nested packages.
 
 `--version'
 `-V'
@@ -232,6 +276,16 @@ an Autoconf bug.  Until the bug is fixed you can use this workaround:
      Look for the package's source code in directory DIR.  Usually
      `configure' can determine that directory automatically.
 
+`--prefix=DIR'
+     Use DIR as the installation prefix.  *Note Installation Names::
+     for more details, including other options available for fine-tuning
+     the installation locations.
+
+`--no-create'
+`-n'
+     Run the configure checks, but stop before creating any output
+     files.
+
 `configure' also accepts some other, not widely useful, options.  Run
 `configure --help' for more details.
 
index 56307aada053766671445349e8256bbd2c8620d6..98368c211905930a16d9e3523dbf814a8b405249 100644 (file)
@@ -23,11 +23,19 @@ ACLOCAL_AMFLAGS = -I config
 
 include $(top_srcdir)/Makefile.common
 
-EXTRA_DIST = bootstrap configure config.h.in \
-       Makefile.swig Makefile.swig.gen.t
+EXTRA_DIST = \
+       bootstrap \
+       configure \
+       config.h.in \
+       Makefile.swig \
+       Makefile.swig.gen.t \
+       version.sh \
+       README \
+       README.hacking
 
-SUBDIRS = config src
-DIST_SUBDIRS = config src doc
+SUBDIRS = config lib swig python grc apps
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA =
+
+DISTCLEANFILES = gr-howto-write-a-block*.tar.gz
index 4b808112511afb5f5c6a50e63496e1c27c303780..c81bc780dcf4efc2ed61a369ef0a562baa745439 100644 (file)
@@ -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.
index 29c1e99b14801e3eee36a5d8ab820a366d23731d..368e71994dac212a5cab752de0ae7b12fb45d153 100644 (file)
@@ -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 (file)
index 0000000..c670fd1
--- /dev/null
@@ -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 (file)
index 0000000..b336cc7
--- /dev/null
@@ -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 (file)
index 0000000..85ed222
--- /dev/null
@@ -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 (file)
index 0000000..a856369
--- /dev/null
@@ -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 (executable)
index 0000000..8d3d870
--- /dev/null
@@ -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)
+
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 5858d2219b3b8567b02ff29e20c3896563c91a99..23f4a4b16e68fa10ea6cb394bd92d91f9285b242 100644 (file)
@@ -49,6 +49,7 @@ m4macros = \
        gr_check_usrp.m4 \
        gr_doxygen.m4 \
        gr_fortran.m4 \
+       gr_git.m4 \
        gr_gprof.m4 \
        gr_lib64.m4 \
        gr_libgnuradio_core_extra_ldflags.m4 \
@@ -63,6 +64,7 @@ m4macros = \
        gr_subversion.m4 \
        gr_swig.m4 \
        gr_sysv_shm.m4 \
+       gr_version.m4 \
        lf_cc.m4 \
        lf_cxx.m4 \
        lf_warnings.m4 \
index b5b0470f45c2ce78cb525490bf56d32b0548f140..033ef0307820e4987a2be810a9acc54e4f5a45bc 100644 (file)
@@ -29,4 +29,5 @@ AC_DEFUN([GR_FORTRAN],[
         AC_PROG_F77
         AC_F77_LIBRARY_LDFLAGS
     fi
+    AC_PROG_CC dnl bug fix to restore $ac_ext
 ])
diff --git a/gr-howto-write-a-block/config/gr_git.m4 b/gr-howto-write-a-block/config/gr_git.m4
new file mode 100644 (file)
index 0000000..5fe4248
--- /dev/null
@@ -0,0 +1,35 @@
+dnl Copyright 2009 Free Software Foundation, Inc.
+dnl 
+dnl This file is part of GNU Radio
+dnl 
+dnl GNU Radio is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3, or (at your option)
+dnl any later version.
+dnl 
+dnl GNU Radio is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with GNU Radio; see the file COPYING.  If not, write to
+dnl the Free Software Foundation, Inc., 51 Franklin Street,
+dnl Boston, MA 02110-1301, USA.
+
+
+AC_DEFUN([GR_GIT],[
+  dnl Identify git binary
+  AC_PATH_PROG([GIT],[git])
+  
+  dnl If it exists, get either 'git describe' or fallback to current commit
+  if test x$GIT != x ; then
+    if (cd $srcdir && $GIT describe >/dev/null 2>&1); then
+      GIT_VERSION=`cd $srcdir && $GIT describe --abbrev=8 | cut -f 2- -d '-'`
+    else
+      if (cd $srcdir && $GIT describe --always --abbrev=8 >/dev/null 2>&1); then
+        GIT_VERSION=`cd $srcdir && $GIT describe --always --abbrev=8`
+      fi
+    fi
+  fi
+])
index 7b99cba6b7301de4f0c2720ab8d096cfd6e85b91..495e9dd4d39dba2246bbe9a48ef9fbd6715c2ec6 100644 (file)
@@ -99,6 +99,9 @@ struct timespec {
        long    tv_nsec;
 };
 #endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 static inline int nanosleep(const struct timespec *req, struct timespec *rem) { return usleep(req->tv_sec*1000000+req->tv_nsec/1000); }
 #endif
 
index 6c862bba397b2516ef92f92c5f8a403ab8a7d2c7..43ccfc01575f5e0c53cab03a12f603e92c10c64b 100644 (file)
@@ -123,6 +123,50 @@ print path
              ;;
            esac
 
+           case $host_os in
+                *mingw* )
+             # Python 2.5 requires ".pyd" instead of ".dll" for extensions
+             PYTHON_LDFLAGS="-shrext .pyd ${PYTHON_LDFLAGS}"
+           esac
+
            AC_SUBST(PYTHON_LDFLAGS)
        fi
 ])
+
+# PYTHON_CHECK_MODULE
+#
+# Determines if a particular Python module can be imported
+#
+# $1 - module name
+# $2 - module description
+# $3 - action if found
+# $4 - action if not found
+# $5 - test command
+
+AC_DEFUN([PYTHON_CHECK_MODULE],[
+    AC_MSG_CHECKING([for $2])
+    dnl ########################################
+    dnl # import and test checking
+    dnl ########################################
+    if test "$5"; then
+        python_cmd='
+try:
+    import $1
+    assert $5
+except: exit(1)'
+    dnl ########################################
+    dnl # import checking only
+    dnl ########################################
+    else
+        python_cmd='
+try: import $1
+except: exit(1)'
+    fi
+    if ! $PYTHON -c "$python_cmd" 2> /dev/null; then
+        AC_MSG_RESULT([no])
+        $4
+    else
+        AC_MSG_RESULT([yes])
+        $3
+    fi
+])
index b9c570eded395c28cbe3a36638cb6088df37776d..7ebf88a66428d73309c626e6467686d43bed9457 100644 (file)
@@ -1,5 +1,5 @@
 dnl
-dnl Copyright 2003,2008 Free Software Foundation, Inc.
+dnl Copyright 2003,2008,2009 Free Software Foundation, Inc.
 dnl 
 dnl This file is part of GNU Radio
 dnl 
@@ -19,20 +19,89 @@ dnl the Free Software Foundation, Inc., 51 Franklin Street,
 dnl Boston, MA 02110-1301, USA.
 dnl 
 
+AC_DEFUN([_TRY_ADD_ALTIVEC],
+[
+  LF_CHECK_CC_FLAG([-mabi=altivec -maltivec])
+  LF_CHECK_CXX_FLAG([-mabi=altivec -maltivec])
+])
+
+AC_DEFUN([_FIND_ARM_ISA],
+[
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+  [[#ifndef __ARM_ARCH_5__
+    #error "Not armv5"
+    #endif
+  ]])],
+    [is_armv5=yes],
+    [is_armv5=no])
+
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+  [[#ifndef __ARM_ARCH_7A__
+    #error "Not armv7-a"
+    #endif
+  ]])],
+    [is_armv7_a=yes],
+    [is_armv7_a=no])
+
+])
+
 AC_DEFUN([GR_SET_MD_CPU],[
   AC_REQUIRE([AC_CANONICAL_HOST])
   AC_ARG_WITH(md-cpu,
-       [  --with-md-cpu=ARCH      set machine dependent speedups (auto)],
+       AC_HELP_STRING([--with-md-cpu=ARCH],[set machine dependent speedups (auto)]),
                [cf_with_md_cpu="$withval"],
-               [cf_with_md_cpu="$host_cpu"])
-
-  AC_MSG_CHECKING([for machine dependent speedups])
+               [
+  dnl see if the user has specified --host or --build, via 'cross_compiling'
+  if test "$cross_compiling" != no; then
+    dnl when cross-compiling, because the user specified it either via
+    dnl --target or --build, just keep the user's specs & hope for the best.
+    cf_with_md_cpu="$host_cpu"
+  else
+    dnl when the user didn't specify --target or --build, on Darwin 10
+    dnl (OSX 10.6.0 and .1) and GNU libtoool 2.2.6, 'configure' doesn't
+    dnl figure out the CPU type correctly, so do it by hand here using
+    dnl the sizeof (void*): if 4 then use i386, and otherwise use x86_64.
+    case "$host_os" in
+     *darwin*10*)
+      AC_CHECK_SIZEOF(void*)
+      if test "$ac_cv_sizeof_voidp" = 4; then
+       cf_with_md_cpu="i386"
+      else
+       cf_with_md_cpu="x86_64"
+      fi
+      ;;
+     *)
+      cf_with_md_cpu="$host_cpu"
+      ;;
+    esac
+  fi
+  ])
   case "$cf_with_md_cpu" in
    x86 | i[[3-7]]86)   MD_CPU=x86      MD_SUBCPU=x86 ;;
    x86_64)             MD_CPU=x86      MD_SUBCPU=x86_64 ;;
    powerpc*)            MD_CPU=powerpc ;;
+   arm)
+       _FIND_ARM_ISA
+       if test $is_armv5 = yes; then MD_CPU=armv5;
+       elif test $is_armv7_a = yes; then MD_CPU=armv7_a;
+       else MD_CPU=generic; fi
+       ;;
    *)                  MD_CPU=generic ;;
   esac
+
+  AC_ARG_ENABLE(altivec,
+    AC_HELP_STRING([--enable-altivec],[enable altivec on PowerPC (yes)]),
+    [ if test $MD_CPU = powerpc; then
+        case "$enableval" in
+          (no)  MD_CPU=generic ;;
+          (yes) _TRY_ADD_ALTIVEC ;;
+          (*) AC_MSG_ERROR([Invalid argument ($enableval) to --enable-altivec]) ;;
+        esac
+      fi],
+    [ if test $MD_CPU = powerpc; then _TRY_ADD_ALTIVEC fi])
+
+
+  AC_MSG_CHECKING([for machine dependent speedups])
   AC_MSG_RESULT($MD_CPU)
   AC_SUBST(MD_CPU)
   AC_SUBST(MD_SUBCPU) 
@@ -40,5 +109,7 @@ AC_DEFUN([GR_SET_MD_CPU],[
   AM_CONDITIONAL(MD_CPU_x86,     test "$MD_CPU" = "x86")
   AM_CONDITIONAL(MD_SUBCPU_x86_64,  test "$MD_SUBCPU" = "x86_64")
   AM_CONDITIONAL(MD_CPU_powerpc, test "$MD_CPU" = "powerpc")
+  AM_CONDITIONAL(MD_CPU_armv5, test "$MD_CPU" = "armv5")
+  AM_CONDITIONAL(MD_CPU_armv7_a, test "$MD_CPU" = "armv7_a")
   AM_CONDITIONAL(MD_CPU_generic, test "$MD_CPU" = "generic")
 ])
index 2f8851676d1def6f0c138eb7c6aa808b5df17379..3f8ddf1d62f74c213d43582f20622602a8b794eb 100644 (file)
@@ -31,12 +31,6 @@ m4_define([GR_STANDALONE],
   AC_CONFIG_SRCDIR([config/gr_standalone.m4])
   AM_CONFIG_HEADER(config.h)
 
-  AC_CANONICAL_BUILD
-  AC_CANONICAL_HOST
-  AC_CANONICAL_TARGET
-
-  AM_INIT_AUTOMAKE
-
   dnl Remember if the user explicity set CXXFLAGS
   if test -n "${CXXFLAGS}"; then
     user_set_cxxflags=yes
@@ -130,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/config/gr_version.m4 b/gr-howto-write-a-block/config/gr_version.m4
new file mode 100644 (file)
index 0000000..3360b7d
--- /dev/null
@@ -0,0 +1,74 @@
+dnl Copyright 2009 Free Software Foundation, Inc.
+dnl 
+dnl This file is part of GNU Radio
+dnl 
+dnl GNU Radio is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3, or (at your option)
+dnl any later version.
+dnl 
+dnl GNU Radio is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with GNU Radio; see the file COPYING.  If not, write to
+dnl the Free Software Foundation, Inc., 51 Franklin Street,
+dnl Boston, MA 02110-1301, USA.
+
+AC_DEFUN([GR_VERSION],[
+  dnl Computed version based on version.sh
+  dnl Does not force recompile on rev change
+  dnl
+  dnl Source the variables describing the release version
+  dnl 
+  dnl MAJOR_VERSION          Major release generation (2.x, 3.x, etc.)
+  dnl API_COMPAT             API compatibility version (3.2.x, 3.3.x, etc.)
+  dnl MINOR_VERSION          Minor release version
+  dnl MAINT_VERSION          Pure bugfix additions to make maintenance release
+  dnl
+  dnl The last two fields can have 'git' instead of a number to indicate
+  dnl that this branch is between versions.
+  . $srcdir/version.sh
+  RELEASE=$MAJOR_VERSION.$API_COMPAT
+  
+  dnl Get git version if available
+  GR_GIT
+
+  dnl Test if we should use git version
+  if test "$MINOR_VERSION" == "git"; then
+    dnl 3.3git-xxx-gxxxxxxxx
+    RELEASE=$RELEASE$MINOR_VERSION
+    DOCVER=$RELEASE
+    if test "$GIT_VERSION" != "" ; then
+      RELEASE=$RELEASE-$GIT_VERSION
+    fi
+  else
+    if test "$MAINT_VERSION" == "git" ; then
+      dnl 3.3.1git-xxx-gxxxxxxxx
+      RELEASE=$RELEASE.$MINOR_VERSION$MAINT_VERSION
+      DOCVER=$RELEASE
+      if test "$GIT_VERSION" != "" ; then
+        RELEASE=$RELEASE-$GIT_VERSION
+      fi
+    else
+      dnl This is a numbered reelase.
+      dnl Test if minor version is 0, which we don't encode, unless it is also
+      dnl a maintenance release
+      if test "$MINOR_VERSION" != "0" -o "$MAINT_VERSION" != "0"; then
+        dnl 3.3.1
+        RELEASE=$RELEASE.$MINOR_VERSION                          
+        if test "$MAINT_VERSION" != "0"; then
+          dnl 3.3.0.1, 3.3.1.1
+          RELEASE=$RELEASE.$MAINT_VERSION
+        fi
+       DOCVER=$RELEASE
+      fi
+    fi
+  fi
+
+  AC_MSG_NOTICE([GNU Radio Release $RELEASE])
+  AC_SUBST(RELEASE)
+  AC_SUBST(DOCVER)
+])
index 4e2ca9111736a862f029f9e21d3117f16325f945..d40c77f14d56206e56334727bc35d438a03cbece 100644 (file)
@@ -1,4 +1,5 @@
 dnl Copyright (C) 1988 Eleftherios Gkioulekas <lf@amath.washington.edu>
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
 dnl  
 dnl This program is free software; you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
@@ -21,7 +22,7 @@ dnl distribution terms that you use for the rest of that program.
 
 # --------------------------------------------------------------------------
 # Check whether the C++ compiler accepts a certain flag
-# If it does it adds the flag to CXXFLAGS
+# If it does it adds the flag to lf_CXXFLAGS
 # If it does not then it returns an error to lf_ok
 # Usage:
 #   LF_CHECK_CXX_FLAG(-flag1 -flag2 -flag3 ...)
@@ -34,18 +35,19 @@ AC_DEFUN([LF_CHECK_CXX_FLAG],[
     AC_MSG_CHECKING([whether $CXX accepts $i])
     if test -z "`${CXX} $i -c conftest.cc 2>&1`"
     then
-      CXXFLAGS="${CXXFLAGS} $i"
+      lf_CXXFLAGS="${lf_CXXFLAGS} $i"
       AC_MSG_RESULT(yes)
     else
       AC_MSG_RESULT(no)
     fi
   done
   rm -f conftest.cc conftest.o
+  AC_SUBST(lf_CXXFLAGS)
 ])
 
 # --------------------------------------------------------------------------
 # Check whether the C compiler accepts a certain flag
-# If it does it adds the flag to CFLAGS
+# If it does it adds the flag to lf_CFLAGS
 # If it does not then it returns an error to lf_ok
 # Usage:
 #  LF_CHECK_CC_FLAG(-flag1 -flag2 -flag3 ...)
@@ -58,18 +60,19 @@ AC_DEFUN([LF_CHECK_CC_FLAG],[
     AC_MSG_CHECKING([whether $CC accepts $i])
     if test -z "`${CC} $i -c conftest.c 2>&1`"
     then
-      CFLAGS="${CFLAGS} $i"
+      lf_CFLAGS="${lf_CFLAGS} $i"
       AC_MSG_RESULT(yes)
     else
       AC_MSG_RESULT(no)
     fi
   done
   rm -f conftest.c conftest.o
+  AC_SUBST(lf_CFLAGS)
 ])
 
 # --------------------------------------------------------------------------
 # Check whether the Fortran compiler accepts a certain flag
-# If it does it adds the flag to FFLAGS
+# If it does it adds the flag to lf_FFLAGS
 # If it does not then it returns an error to lf_ok
 # Usage:
 #  LF_CHECK_F77_FLAG(-flag1 -flag2 -flag3 ...)
@@ -87,42 +90,32 @@ EOF
     AC_MSG_CHECKING([whether $F77 accepts $i])
     if test -z "`${F77} $i -c conftest.f 2>&1`"
     then
-      FFLAGS="${FFLAGS} $i"
+      lf_FFLAGS="${lf_FFLAGS} $i"
       AC_MSG_RESULT(yes)  
     else
       AC_MSG_RESULT(no)
     fi
   done
   rm -f conftest.f conftest.o
+  AC_SUBST(lf_FFLAGS)
 ])
 
 # ----------------------------------------------------------------------
-# Provide the configure script with an --with-warnings option that
-# turns on warnings. Call this command AFTER you have configured ALL your
-# compilers. 
+# Enable compiler warnings. 
+# Call this command AFTER you have configured ALL your compilers. 
 # ----------------------------------------------------------------------
 
 AC_DEFUN([LF_SET_WARNINGS],[
-  dnl Check for --with-warnings
-  AC_MSG_CHECKING([whether user wants warnings])
-  AC_ARG_WITH(warnings,
-              [  --with-warnings         Turn on warnings],
-              [ lf_warnings=yes ], [ lf_warnings=no ])
-  lf_warnings=yes # hard code for now -eb
-  AC_MSG_RESULT($lf_warnings)
-  
   dnl Warnings for the two main compilers
-  cc_warning_flags="-Wall"
+  dnl add -Wextra when you're got time to fix a bunch of them ;-)
+  cc_warning_flags="-Wall -Werror-implicit-function-declaration"
   cxx_warning_flags="-Wall -Woverloaded-virtual"
-  if test $lf_warnings = yes
+  if test -n "${CC}"
   then
-    if test -n "${CC}"
-    then
-      LF_CHECK_CC_FLAG($cc_warning_flags)
-    fi
-    if test -n "${CXX}" 
-    then
-      LF_CHECK_CXX_FLAG($cxx_warning_flags)
-    fi
+    LF_CHECK_CC_FLAG($cc_warning_flags)
+  fi
+  if test -n "${CXX}" 
+  then
+    LF_CHECK_CXX_FLAG($cxx_warning_flags)
   fi
 ])
index db857249b0d0f126b74f367afb795551bd0631e5..b99cf243207c43ba9210732e7346172d0c994a93 100644 (file)
@@ -1,5 +1,5 @@
 dnl
-dnl Copyright 2003,2008 Free Software Foundation, Inc.
+dnl Copyright 2003,2008,2009 Free Software Foundation, Inc.
 dnl 
 dnl This file is part of GNU Radio
 dnl 
@@ -25,6 +25,8 @@ dnl
 #   ""  : do these tests
 
 AC_DEFUN([USRP_SET_FUSB_TECHNIQUE],[
+  req_libusb1=no
+  USE_LIBUSB1=0
   AC_ARG_WITH([fusb-tech],
               AC_HELP_STRING([--with-fusb-tech=OS],
                             [Set fast USB technique (default=auto)]),
@@ -32,6 +34,11 @@ AC_DEFUN([USRP_SET_FUSB_TECHNIQUE],[
              [cf_with_fusb_tech="$host_os"])
   if test [x]$1 != xno; then
       case "$cf_with_fusb_tech" in
+        libusb1*)
+          FUSB_TECH=libusb1
+          req_libusb1=yes
+         USE_LIBUSB1=1
+          ;;
         linux*)
           AC_CHECK_HEADER([linux/usbdevice_fs.h],
                          [x_have_usbdevice_fs_h=yes],
@@ -70,5 +77,11 @@ AC_DEFUN([USRP_SET_FUSB_TECHNIQUE],[
   AM_CONDITIONAL(FUSB_TECH_win32,    test x$FUSB_TECH = xwin32)
   AM_CONDITIONAL(FUSB_TECH_generic,  test x$FUSB_TECH = xgeneric)
   AM_CONDITIONAL(FUSB_TECH_linux,    test x$FUSB_TECH = xlinux)
+  AM_CONDITIONAL(FUSB_TECH_libusb1,  test x$FUSB_TECH = xlibusb1)
   AM_CONDITIONAL(FUSB_TECH_ra_wb,    test x$FUSB_TECH = xra_wb)
+
+  AC_SUBST(USE_LIBUSB1)
+  AC_CONFIG_FILES([\
+       usrp/host/include/usrp/libusb_types.h \
+  ])
 ])
index bfb431526ba722199c094ef41f2e62f6111d27ec..52c4639bb544c83b1281faa730845de8f96b431d 100644 (file)
@@ -19,10 +19,20 @@ dnl  the Free Software Foundation, Inc., 51 Franklin Street,
 dnl  Boston, MA 02110-1301, USA.
 dnl 
 
-AC_INIT(gr-howto-write-a-block,3.3svn)
+
+AC_INIT
 AC_PREREQ(2.57)
 AC_CONFIG_AUX_DIR([.]) 
 
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
+
+GR_VERSION
+dnl ustar required to have pathnames > 99 chars
+_AM_SET_OPTION([tar-ustar])
+AM_INIT_AUTOMAKE(gr-howto-write-a-block,$RELEASE)
+
 dnl This is kind of non-standard, but it sure shortens up this file :-)
 m4_include([config/gr_standalone.m4])
 GR_STANDALONE
@@ -61,15 +71,18 @@ dnl AX_BOOST_WSERIALIZATION
 
 AC_CONFIG_FILES([\
          Makefile \
+         apps/Makefile \
          config/Makefile \
-         doc/Makefile \
-         src/Makefile \
-         src/lib/Makefile \
-         src/python/Makefile \
-         src/python/run_tests \
+         grc/Makefile \
+         lib/Makefile \
+         python/Makefile \
+         python/run_tests \
+         swig/Makefile \
        ])
 
 dnl run_tests is created from run_tests.in.  Make it executable.
-AC_CONFIG_COMMANDS([run_tests], [chmod +x src/python/run_tests])
+AC_CONFIG_COMMANDS([run_tests], [chmod +x python/run_tests])
 
 AC_OUTPUT
+
+echo Configured gr-howto-write-a-block release $RELEASE for build.
diff --git a/gr-howto-write-a-block/doc/.gitignore b/gr-howto-write-a-block/doc/.gitignore
deleted file mode 100644 (file)
index f65ab6c..0000000
+++ /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/doc/Makefile.am b/gr-howto-write-a-block/doc/Makefile.am
deleted file mode 100644 (file)
index 0152eca..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#
-# Copyright 2004,2005,2007 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.
-# 
-
-TARGETS = howto-write-a-block.html
-
-
-# To avoid build problems for folks who don't have xmlto installed, we
-# don't build the docs by default.
-
-# html: $(TARGETS)
-all: $(TARGETS)
-
-
-EXTRA_DIST =                           \
-       howto-write-a-block.xml         \
-       howto_1.i                       \
-       make_numbered_listing.py        \
-       qa_howto_1.py                   \
-       src_lib_Makefile_1.am           \
-       src_lib_Makefile_2.am           
-
-
-BUILT_XML_FILES =                      \
-       gr_block.h.xml                  \
-       howto_1.i.xml                   \
-       howto_square_ff.cc.xml          \
-       howto_square_ff.h.xml           \
-       howto_square2_ff.cc.xml         \
-       howto_square2_ff.h.xml          \
-       qa_howto_1.py.xml               \
-       src_lib_Makefile_1.am.xml       \
-       src_lib_Makefile_2.am.xml       
-
-
-howto-write-a-block.html : howto-write-a-block.xml $(BUILT_XML_FILES)
-
-
-gr_block.h.xml: $(GNURADIO_CORE_INCLUDEDIR)/gr_block.h make_numbered_listing.py
-       $(PYTHON) ./make_numbered_listing.py $(GNURADIO_CORE_INCLUDEDIR)/gr_block.h
-
-howto_square_ff.cc.xml: $(top_srcdir)/src/lib/howto_square_ff.cc make_numbered_listing.py
-       $(PYTHON) ./make_numbered_listing.py $(top_srcdir)/src/lib/howto_square_ff.cc 
-
-howto_square_ff.h.xml: $(top_srcdir)/src/lib/howto_square_ff.h make_numbered_listing.py
-       $(PYTHON) ./make_numbered_listing.py $(top_srcdir)/src/lib/howto_square_ff.h 
-
-howto_square2_ff.cc.xml: $(top_srcdir)/src/lib/howto_square2_ff.cc make_numbered_listing.py
-       $(PYTHON) ./make_numbered_listing.py $(top_srcdir)/src/lib/howto_square2_ff.cc 
-
-howto_square2_ff.h.xml: $(top_srcdir)/src/lib/howto_square2_ff.h make_numbered_listing.py
-       $(PYTHON) ./make_numbered_listing.py $(top_srcdir)/src/lib/howto_square2_ff.h 
-
-
-# ----------------------------------------------------------------
-
-clean:
-       -${RM} -f $(TARGETS) $(BUILT_XML_FILES)
-
-%.html : %.xml
-       xmlto html-nochunks $<
-
-%.xml : % make_numbered_listing.py
-       $(PYTHON) ./make_numbered_listing.py $<
diff --git a/gr-howto-write-a-block/doc/howto-write-a-block.xml b/gr-howto-write-a-block/doc/howto-write-a-block.xml
deleted file mode 100644 (file)
index f8027b4..0000000
+++ /dev/null
@@ -1,959 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
-          "docbookx.dtd" [
-  <!ENTITY gnuradio "<application>GNU Radio</application>">
-  <!ENTITY SWIG "<application>SWIG</application>">
-  <!ENTITY gr_block "<classname>gr_block</classname>">
-  <!ENTITY square "<classname>howto_square_ff</classname>">
-
-  <!ENTITY were "we&apos;re">
-  <!ENTITY well "we&apos;ll">
-  <!ENTITY thats "that&apos;s">
-  <!ENTITY its "it&apos;s">
-  <!ENTITY lets "let&apos;s">
-  <!ENTITY youre "you&apos;re">
-
-  <!ENTITY gr_block_listing SYSTEM "gr_block.h.xml">
-  <!ENTITY qa_howto_1_listing SYSTEM "qa_howto_1.py.xml">
-  <!ENTITY howto_square_ff_h_listing SYSTEM "howto_square_ff.h.xml">
-  <!ENTITY howto_square_ff_cc_listing SYSTEM "howto_square_ff.cc.xml">
-  <!ENTITY howto_square2_ff_h_listing SYSTEM "howto_square2_ff.h.xml">
-  <!ENTITY howto_square2_ff_cc_listing SYSTEM "howto_square2_ff.cc.xml">
-  <!ENTITY howto_1_i_listing SYSTEM "howto_1.i.xml">
-  <!ENTITY src_lib_Makefile_1_am_listing SYSTEM "src_lib_Makefile_1.am.xml">
-  <!ENTITY src_lib_Makefile_2_am_listing SYSTEM "src_lib_Makefile_2.am.xml">
-
-]>
-
-<article>
-
-<articleinfo>
-<title>How to Write a Signal Processing Block</title>
-<author>
-  <firstname>Eric</firstname>
-  <surname>Blossom</surname>
-  <affiliation>
-    <address>
-      <email>eb@comsec.com</email>
-    </address>
-  </affiliation>
-</author>
-
-<revhistory>
-  <revision>
-  <revnumber>0.1</revnumber>
-  <date>2005-01-20</date>
-  </revision>
-  <revision>
-  <revnumber>0.2</revnumber>
-  <date>2005-02-02</date>
-  <revremark>Updated for SWIG 1.3.24</revremark>
-  </revision>
-  <revision>
-  <revnumber>0.3</revnumber>
-  <date>2006-07-21</date>
-  <revremark>Clarification of 1:1 fixed rate vs item size</revremark>
-  </revision>
-</revhistory>
-
-<copyright>
-  <year>2004</year>
-  <year>2005</year>
-  <holder>Free Software Foundation, Inc.</holder>
-</copyright>
-
-<abstract><para>This article explains how to write signal
-processing blocks for <application>GNU Radio</application>.
-</para></abstract>
-
-</articleinfo>
-
-<sect1 id="prereqs"><title>Prerequisites</title>
-<para>This article assumes that the reader has basic familiarity with
-GNU Radio and has read and understood 
-<ulink url="http://www.gnu.org/software/gnuradio/doc/exploring-gnuradio.html">
-<citetitle>Exploring GNU Radio</citetitle></ulink>.
-</para>
-
-<para>There is a tarball of files that accompany this article.  It
-includes the examples, DocBook source for the article and all the
-Makefiles etc it takes to make it work.  Grab it at <ulink
-url="ftp://ftp.gnu.org/gnu/gnuradio">
-ftp://ftp.gnu.org/gnu/gnuradio</ulink> or one of the mirrors.  The
-file you want is
-<filename>gr-howto-write-a-block-X.Y.tar.gz</filename>.  Pick the one
-with the highest version number. 
-See <ulink url="http://comsec.com/wiki?CvsAccess">
-http://comsec.com/wiki?CvsAccess</ulink> for CVS Access.
-</para>
-
-
-</sect1>
-
-<sect1 id="intro"><title>Introduction</title>
-<para>&gnuradio; provides a framework for building software radios.
-Waveforms -- signal processing applications -- are built using a
-combination of Python code for high level organization, policy, GUI and
-other non performance-critical functions, while performance critical
-signal processing blocks are written in C++.</para>
-
-<para>From the Python point of view, &gnuradio; provides a data flow
-abstraction.  The fundamental concepts are signal processing
-blocks and the connections between them.  This abstraction is
-implemented by the Python <classname>gr.flow_graph</classname> class.
-Each block has a set of input ports and output ports.  Each port has
-an associated data type.  The most common port types are
-<classname>float</classname> and <classname>gr_complex</classname>
-(equivalent to std::complex&lt;float&gt;), though other types are used,
-including those representing structures, arrays or other types of
-packetized data.</para>  
-
-<para>From the high level point-of-view, infinite streams of data flow
-through the ports.  At the C++ level, streams are dealt with in
-convenient sized pieces, represented as contiguous arrays of the
-underlying type.</para>
-
-</sect1>
-
-<sect1 id="overview"><title>The View from 30,000 Feet</title>
-
-<para>This article will walk through the construction of several
-simple signal processing blocks, and explain the techniques and idioms
-used.  Later sections cover debugging signal processing blocks in the
-mixed Python/C++ environment and performance measurement and
-optimization.</para>
-
-<para>The example blocks will be built in the style of all &gnuradio;
-extensions. That is, they are built outside of the gnuradio-core build
-tree, and are constructed as shared libraries that may be dynamically
-loaded into Python using the "import" mechanism.  &SWIG;, the
-Simplified Wrapper and Interface Generator, is used to generate the
-glue that allows our code to be used from Python.</para>
-
-</sect1>
-
-
-<sect1 id="gr_block"><title></title>
-
-<para>The C++ class &gr_block; is the base of all signal processing
-blocks in &gnuradio;.  Writing a new signal processing block involves
-creating 3 files: The .h and .cc files that define the new class and
-the .i file that tells &SWIG; how to generate the glue that binds the
-class into Python.  The new class must derive from &gr_block; or
-one of it&apos;s subclasses.</para>
-
-<para>Our first examples will derive directly from &gr_block;.  Later
-we will look at some other subclasses that simplify the process for
-common cases.</para>
-
-</sect1><!-- end gr_block sect1 -->
-
-
-
-<!-- ================================================================ -->
-
-<sect1 id="autotools"><title>Autotools, Makefiles, and Directory Layout</title>
-
-<para>Before we dive into the code, &lets; talk a bit about the
-overall build environment and the directory structure that &well;
-be using.</para>
-
-<para>To reduce the amount of Makefile hacking that we have to do, and
-to facilitate portability across a variety of systems, we use the GNU
-<application>autoconf</application>,
-<application>automake</application>, and
-<application>libtool</application> tools.  These are collectively
-referred to as the autotools, and once you get over the initial
-shock, they will become your friends. (The good news is that we
-provide boilerplate that can be used pretty much as-is.)</para>
-
-<variablelist>
-
-<varlistentry><term>automake</term>
-
-<listitem><para>automake and configure work together to generate GNU
-compliant Makefiles from a much higher level description contained in
-the corresponding Makefile.am file.  <filename>Makefile.am</filename>
-specifies the libraries and programs to build and the source files
-that compose each.  Automake reads <filename>Makefile.am</filename>
-and produces <filename>Makefile.in</filename>.  Configure reads
-<filename>Makefile.in</filename> and produces
-<filename>Makefile</filename>.  The resulting Makefile contains a
-zillion rules that do the right right thing to build, check and
-install your code.  It is not uncommon for the the resulting
-<filename>Makefile</filename> to be 5 or 6 times larger than
-<filename>Makefile.am</filename>.</para>
-
-</listitem>
-</varlistentry>
-
-<varlistentry><term>autoconf</term>
-<listitem><para>autoconf reads <filename>configure.ac</filename>
-and produces the <filename>configure</filename> shell
-script.  <filename>configure</filename> automatically tests for
-features of the underlying system and sets a bunch of variables and
-defines that can be used in the Makefiles and your C++ code to
-conditionalize the build.  If features are required but not found,
-configure will output an error message and stop.</para>
-</listitem>
-</varlistentry>
-
-<varlistentry><term>libtool</term>
-<listitem><para>libtool works behind the scenes and provides the magic
-to construct shared libraries on a wide variety of systems.</para>
-</listitem>
-</varlistentry>
-
-</variablelist>
-
-<para><xref linkend="dir-layout"/> shows the directory layout and
-common files &well; be using.  After renaming the
-<replaceable>topdir</replaceable> directory, use it in your projects
-too.  We'll talk about particular files as they come up later.</para>
-
-
-<table id="dir-layout"><title>Directory Layout</title>
-<tgroup cols="2">
-
-<thead><row>
-<entry>File/Dir Name</entry>
-<entry>Comment</entry>
-</row>
-</thead>
-
-<tbody>
-
-<row>
-<entry><replaceable>topdir</replaceable>/Makefile.am</entry>
-<entry>Top level Makefile.am</entry>
-</row>
-<row>
-<entry><replaceable>topdir</replaceable>/Makefile.common</entry>
-<entry>Common fragment included in sub-Makefiles</entry>
-</row>
-<row>
-<entry><replaceable>topdir</replaceable>/bootstrap</entry>
-<entry>Runs autoconf, automake, libtool first time through</entry>
-</row>
-<row>
-<entry><replaceable>topdir</replaceable>/config</entry>
-<entry>Directory of m4 macros used by configure.ac</entry>
-</row>
-<row>
-<entry><replaceable>topdir</replaceable>/configure.ac</entry>
-<entry>Input to autoconf</entry>
-</row>
-<row>
-<entry><replaceable>topdir</replaceable>/src</entry>
-</row>
-<row>
-<entry><replaceable>topdir</replaceable>/src/lib</entry>
-<entry>C++ code goes here</entry>
-</row>
-<row>
-<entry><replaceable>topdir</replaceable>/src/lib/Makefile.am</entry>
-</row>
-<row>
-<entry><replaceable>topdir</replaceable>/src/python</entry>
-<entry>Python code goes here</entry>
-</row>
-<row>
-<entry><replaceable>topdir</replaceable>/src/python/Makefile.am</entry>
-</row>
-<row>
-<entry><replaceable>topdir</replaceable>/src/python/run_tests</entry>
-<entry>Script to run tests in the build tree</entry>
-</row>
-
-</tbody>
-</tgroup>
-</table>
-
-</sect1>
-
-<!-- ================================================================ -->
-
-<sect1 id="naming"><title>Naming Conventions</title>
-
-<para>&gnuradio; uses a set of naming conventions to assist in
-comprehending the code base and gluing C++ and Python together.
-Please follow them.</para>
-
-<sect2 id="camel-case"><title><emphasis>Death to CamelCaseNames!</emphasis></title>
-
-<para>We've returned to a kinder, gentler era.  We're now using the
-&quot;STL style&quot; naming convention with a couple of modifications
-since we're not using namespaces.</para>
-
-<para>With the exception of macros and other constant values, all
-identifiers shall be lower case with <literal>words_separated_like_this</literal>.</para>
-
-<para>Macros and constant values (e.g., enumerated values,
-<literal>static const int FOO = 23</literal>) shall be in <literal>UPPER_CASE</literal>.</para>
-
-</sect2>
-
-<sect2 id="global_names"><title>Global Names</title>
-
-<para>All globally visible names (types, functions, variables, consts, etc)
-shall begin with a "package prefix", followed by an underscore.  The bulk of
-the code in GNU Radio belongs to the "gr" package, hence
-names look like <literal>gr_open_file (...)</literal>.</para>
-
-<para>Large coherent bodies of code may use other package prefixes, but
-let's try to keep them to a well thought out list.  See the list
-below.</para>
-
-</sect2>
-
-<sect2 id="package_prefixes"><title>Package Prefixes</title>
-
-<para>These are the current package prefixes:
-
-<variablelist>
-
-<varlistentry><term>gr_</term>
-<listitem><para>Almost everything.</para></listitem>
-</varlistentry>
-
-<varlistentry><term>gri_</term>
-<listitem><para>
-Implementation primitives.  Sometimes we
-have both a gr_<replaceable>foo</replaceable> and a gri_<replaceable>foo</replaceable>.  In that case,
-gr_<replaceable>foo</replaceable> would be derived from gr_block and gri_<replaceable>foo</replaceable>
-would be the low level guts of the function.</para></listitem>
-</varlistentry>
-
-<varlistentry><term>atsc_</term>
-<listitem><para>Code related to the Advanced Television Standards Committee HDTV implementation
-</para></listitem>
-</varlistentry>
-
-<varlistentry><term>usrp_</term>
-<listitem><para>Universal Software Radio Peripheral.</para></listitem>
-</varlistentry>
-
-<varlistentry><term>qa_</term>
-<listitem><para>Quality Assurance (Test code.)</para></listitem>
-</varlistentry>
-
-</variablelist>
-
-</para>
-</sect2>
-
-<sect2 id="class-data-members"><title>Class Data Members (instance variables)</title>
-
-<para>All class data members shall begin with d_<replaceable>foo</replaceable>.</para>
-
-<para>The big win is when you're staring at a block of code it's obvious
-which of the things being assigned to persist outside of the block.
-This also keeps you from having to be creative with parameter names
-for methods and constructors.  You just use the same name as the
-instance variable, without the d_. </para>
-
-<literallayout>
-class gr_wonderfulness {
-  std::string   d_name;
-  double        d_wonderfulness_factor;
-
-public:
-  gr_wonderfulness (std::string name, double wonderfulness_factor)
-    : d_name (name), d_wonderfulness_factor (wonderfulness_factor)
-  {
-    ...
-  }
-  ...
-};
-</literallayout>
-
-</sect2>
-
-<sect2 id="static-data-members"><title>Class Static Data Members (class variables)</title>
-
-<para>
-All class static data members shall begin with s_<replaceable>foo</replaceable>.
-</para>
-
-</sect2>
-
-<sect2 id="file-names"><title>File Names</title>
-
-<para>Each significant class shall be contained in its own file.  The
-declaration of class <classname>gr_foo</classname> shall be in 
-<filename>gr_foo.h</filename> and the definition in
-<filename>gr_foo.cc</filename>.</para>
-</sect2>
-
-
-<sect2><title>Suffixes</title>
-
-<para>By convention, we encode the input and output types of signal
-processing blocks in their name using suffixes.  The suffix is
-typically one or two characters long.  Source and sinks have single
-character suffixes.  Regular blocks that have both inputs and outputs
-have two character suffixes.  The first character indicates the type
-of the input streams, the second indicates the type of the output
-streams.  FIR filter blocks have a three character suffix, indicating
-the type of the inputs, outputs and taps, respectively.</para>
-
-<para>These are the suffix characters and their interpretations:
-<itemizedlist>
-<listitem><para>f - single precision floating point</para></listitem>
-<listitem><para>c - complex&lt;float&gt;</para></listitem>
-<listitem><para>s - short (16-bit integer)</para></listitem>
-<listitem><para>i - integer (32-bit integer)</para></listitem>
-</itemizedlist>
-</para>
-
-<para>In addition, for those cases where the block deals with streams
-of vectors, we use the character 'v' as the first character of the
-suffix.  An example of this usage is
-<classname>gr_fft_vcc</classname>.  The FFT block takes a vector of
-complex numbers on its input and produces a vector of complex
-numbers on its output.</para>
-
-</sect2>
-
-</sect1>
-
-
-
-
-<sect1 id="square"><title>First Block: &square;</title>
-
-<para>For our first example &well; create a block that computes
-the square of its single float input.  This block will accept a single
-float input stream and produce a single float output stream.</para>
-
-<para>Following the naming conventions, &well; use
-<literal>howto</literal> as our package prefix, and the block will
-be called <classname>howto_square_ff</classname>.</para>
-
-<para>We are going to arrange that this block, as well as the others
-that we write in this article, end up in the
-<literal>gnuradio.howto</literal> Python module.  This will allow us
-to access it from Python like this:
-<programlisting>
-from gnuradio import howto
-sqr = howto.square_ff ()
-</programlisting>
-</para>
-
-
-<sect2 id="test_driven"><title>Test Driven Programming</title>
-
-<para>We could just start banging out the C++ code, but being highly
-evolved modern programmers, &were; going to write the test code first.
-After all, we do have a good spec for the behavior: take a single
-stream of floats as the input and produce a single stream of floats as
-the output. The output should be the square of the input.</para>
-
-<para>How hard could this be?  Turns out that this is easy! Check out 
-<xref linkend="qa_howto_1.py"/>.</para>
-
-<example id="qa_howto_1.py">
-<title><filename>qa_howto.py</filename> (first version)</title>
-&qa_howto_1_listing;
-</example>
-
-<para>
-<classname>gr_unittest</classname> is an extension to the standard
-python module <classname>unittest</classname>.
-<classname>gr_unittest</classname> adds support for checking
-approximate equality of tuples of float and complex numbers.  
-Unittest uses Python&apos;s reflection mechanism to find all methods that start with
-<methodname>test_</methodname> and runs them.  Unittest wraps each call
-to <methodname>test_*</methodname> with matching calls to 
-<methodname>setUp</methodname> and <methodname>tearDown</methodname>.
-See the python <ulink url="http://docs.python.org/lib/module-unittest.html">
-unittest</ulink> documentation for details.
-</para>
-
-<para>When we run the test,
-gr_unittest.main is going to invoke
-<methodname>setUp</methodname>,
-<methodname>test_001_square_ff</methodname>, and
-<methodname>tearDown</methodname>.</para>
-<para>
-<methodname>test_001_square_ff</methodname> builds a small graph that
-contains three nodes.  gr.vector_source_f(src_data) will source the
-elements of src_data and then say that &its; finished.  howto.square_ff is the block
-&were; testing.  gr.vector_sink_f gathers the output of
-howto.square_ff.</para>
-
-<para>The <methodname>run</methodname> method runs the graph until all
-the blocks indicate they are finished.  Finally, we check that the
-result of executing square_ff on src_data matches what we expect.
-</para>
-
-</sect2>
-
-<sect2 id="build_vs_install"><title>Build Tree vs. Install Tree</title>
-
-<para>The build tree is everything from <replaceable>topdir</replaceable>
-(the one containing configure.ac) down.  The path to the install tree is
-<filename>
-<replaceable>prefix</replaceable>/lib/python<replaceable>version</replaceable>/site-packages</filename>,
-where <replaceable>prefix</replaceable> is the <literal>--prefix</literal>
-argument to configure (default <filename>/usr/local</filename>) and 
-<replaceable>version</replaceable> is the installed version of
-python. A typical value is 
-<filename>/usr/local/lib/python2.3/site-packages</filename>.</para>
-
-
-<para>We normally set our PYTHONPATH environment variable to point at
-the install tree, and do this in <filename>~/.bash_profile</filename> 
-or <filename>~/.profile</filename>.
-This allows our python apps to access all the standard python
-libraries, plus our locally installed stuff like GNU Radio.</para>
-
-<para>We write our applications such that they access the code and
-libraries in the install tree.  On the other hand, we want our test
-code to run on the build tree, where we can detect problems before
-installation.</para>
-
-</sect2>
-
-<sect2 id="make_check"><title>make check</title>
-
-
-<para>We use <command>make check</command> to run our tests.
-Make check invokes the <command>run_tests</command> shell script which 
-sets up the PYTHONPATH environment variable so that 
-our tests use the build tree versions of our code and libraries.
-It then runs all files
-which have names of the form <filename>qa_*.py</filename> and reports
-the overall success or failure.</para>
-
-<para>There is quite a bit of behind-the-scenes action required to use
-the non-installed versions of our code (look at
-<filename>runtest</filename> for a cheap thrill.)</para>
-
-<para>Finally, running <command>make check</command> in the python
-directory produces this result:
-<literallayout>
-  [eb@bufo python]$ make check
-  make  check-TESTS
-  make[1]: Entering directory `/home/eb/gr-build/gr-howto-write-a-block/src/python'
-  Traceback (most recent call last):
-    File "./qa_howto.py", line 24, in ?
-      import howto
-  ImportError: No module named howto
-  Traceback (most recent call last):
-    File "./qa_howto_1.py", line 24, in ?
-      import howto
-  ImportError: No module named howto
-  FAIL: run_tests
-  ===================
-  1 of 1 tests failed
-  ===================
-  make[1]: *** [check-TESTS] Error 1
-  make[1]: Leaving directory `/home/eb/gr-build/gr-howto-write-a-block/src/python'
-  make: *** [check-am] Error 2
-  [eb@bufo python]$
-</literallayout>
-Excellent!  Our test failed, just as we expected.  The ImportError
-indicates that it can't find the module named
-<classname>howto</classname>.  No surprise, since we haven't written it yet.
-</para>
-
-</sect2>
-
-<sect2><title>The C++ code</title>
-<para>Now that we've got a test case written that successfully fails,
-let's write the C++ code.  As we mentioned earlier, all signal
-processing blocks are derived from <classname>gr_block</classname> or
-one of its subclasses.  Let's take a look at 
-<xref linkend="gr_block.h"/>.</para>
-
-<example id="gr_block.h">
-<title><filename>gr_block.h</filename></title>
-&gr_block_listing;
-</example>
-
-<para>A quick scan of <filename>gr_block.h</filename> reveals that
-since <methodname>general_work</methodname> is pure virtual, we
-definitely need to override that. 
-<methodname>general_work</methodname> is the method that does the
-actual signal processing.  For our squaring example we'll
-need to override <methodname>general_work</methodname> and provide a
-constructor and destructor and a bit of stuff to take advantage of
-the <ulink url="http://www.boost.org">boost</ulink>
-<ulink url="http://www.boost.org/libs/smart_ptr/smart_ptr.htm">
-<classname>shared_ptr</classname>s.</ulink>
-
-</para>
-
-
-<para><xref linkend="howto_square_ff.h"/> 
-and <xref linkend="howto_square_ff.cc"/> are the header and c++
-source.</para>
-
-<example id="howto_square_ff.h">
-<title><filename>howto_square_ff.h</filename></title>
-&howto_square_ff_h_listing;
-</example>
-
-<example id="howto_square_ff.cc">
-<title><filename>howto_square_ff.cc</filename></title>
-&howto_square_ff_cc_listing;
-</example>
-
-<para>Now we need a Makefile.am to get all this to build.  
-<xref linkend="src_lib_Makefile_1"/> 
-is enough to build a shared library from our source file.  We'll be
-adding additional rules to use &SWIG; in just a bit.  If you haven't
-already, this is a good time to browse all the Makefile.am&apos;s in
-the build tree and get an idea for how it all hangs together.</para>
-
-<example id="src_lib_Makefile_1">
-<title><filename>src/lib/Makefile.am</filename> (no &SWIG;)</title>
-&src_lib_Makefile_1_am_listing;
-</example>
-
-</sect2>
-
-
-<!-- ==============================
-
-<sect2 id="io_sig"><title><classname>gr_io_signature</classname></title>
-<para></para>
-</sect2>
-
-<sect2 id="forecast"><title><methodname>forecast</methodname></title>
-<para></para>
-</sect2>
-
-<sect2 id="output_multiple">
-<title><methodname>set_output_multiple</methodname></title>
-<para></para>
-</sect2>
-
-  ============================== -->
-
-
-<sect2 id="swig"><title>The &SWIG; .i file</title> 
-
-<para>Now that we've got something that will compile, we need to write
-the &SWIG; .i file.  This is a pared-down version of the .h file, plus
-a bit of magic that has python work with the boost shared_ptr&apos;s.
-To reduce code bloat, we only declare methods that &well; want to
-access from Python.</para>
-
-<para>We&apos;re going to call the .i file
-<filename>howto.i</filename>, and use it to hold the &SWIG;
-declarations for all classes from <literal>howto</literal> that will
-be accessible from python.  It&apos;s quite small:
-&howto_1_i_listing;
-</para>
-
-</sect2>
-
-<sect2><title>Putting it all together</title>
-<para>
-Now we need to modify <filename>src/lib/Makefile.am</filename>
-to run &SWIG; and to add the glue it generates to the shared library.</para>
-
-<example id="src_lib_Makefile_2">
-<title><filename>src/lib/Makefile.am</filename> (with &SWIG;)</title>
-&src_lib_Makefile_2_am_listing;
-</example>
-
-<para><command>make</command> now builds everything successfully.  We get a
-few warnings, but &thats; OK.</para>
-
-<para>Changing directories back to the python directory we try
-<command>make check</command> again:
-<literallayout>
-  [eb@bufo python]$ make check
-  make  check-TESTS
-  make[1]: Entering directory `/home/eb/gr-build/gr-howto-write-a-block/src/python'
-  .
-  ----------------------------------------------------------------------
-  Ran 1 test in 0.004s
-  
-  OK
-  PASS: run_tests
-  ==================
-  All 1 tests passed
-  ==================
-  make[1]: Leaving directory `/home/eb/gr-build/gr-howto-write-a-block/src/python'
-  [eb@bufo python]$
-</literallayout>
-<emphasis>Victory! Our new block works!</emphasis>
-</para>
-
-</sect2>
-
-</sect1><!-- end First Block: square -->
-
-<sect1 id="additional_methods"><title>Additional gr_block methods</title>
-
-<para>In our <classname>howto_square_ff</classname> example above, we only
-had to override the <methodname>general_work</methodname> method to
-accomplish our goal.  <classname>gr_block</classname> provides a few other
-methods that are sometimes useful.</para>
-
-<sect2 id="forecast"><title>forecast</title>
-
-<para>Looking at <methodname>general_work</methodname> you may
-have wondered how the system knows how much data it needs to
-ensure is valid in each of the input arrays.  The
-<methodname>forecast</methodname> method provides this
-information.</para>
-
-<para>The default implementation of <methodname>forecast</methodname>
-says there is a 1:1 relationship between noutput_items and the
-requirements for each input stream.  The size of the items is defined by
-<classname>gr_io_signature</classname>s in the constructor of
-<classname>gr_block</classname>. The sizes of the input and output items
-can of course differ; this still qualifies as a 1:1 relationship.
-<programlisting>
-  // default implementation:  1:1
-
-  void
-  gr_block::forecast (int noutput_items,
-                      gr_vector_int &amp;ninput_items_required)
-  {
-    unsigned ninputs = ninput_items_required.size ();
-    for (unsigned i = 0; i &lt; ninputs; i++)
-      ninput_items_required[i] = noutput_items;
-  }
-</programlisting>
-</para>
-
-<para>Although the 1:1 implementation worked for howto_square_ff, it
-wouldn&apos;t be appropriate for interpolators, decimators, or blocks
-with a more complicated relationship between noutput_items and the
-input requirements.  That said, by deriving your classes from
-<classname>gr_sync_block</classname>,
-<classname>gr_sync_interpolator</classname> or
-<classname>gr_sync_decimator</classname> instead of
-<classname>gr_block</classname>, you can often avoid
-implementing <methodname>forecast</methodname>.</para>
-
-</sect2>
-
-<sect2 id="set_output_multiple"><title>set_output_multiple</title>
-
-<para>When implementing your <methodname>general_work</methodname>
-routine, &its; occasionally convenient to have the run time system
-ensure that you are only asked to produce a number of output items
-that is a multiple of some particular value.  This might occur if your
-algorithm naturally applies to a fixed sized block of data. 
-Call <methodname>set_output_multiple</methodname> in your constructor
-to specify this requirement. The default output multiple is 1.</para>
-
-</sect2>
-
-</sect1>
-
-
-<sect1 id="common_patterns">
-<title>Subclasses for common patterns</title>
-
-<para><classname>gr_block</classname> allows tremendous flexibility
-with regard to the consumption of input streams and the production of
-output streams.  Adroit use of <methodname>forecast</methodname> and
-<methodname>consume</methodname> allows variable rate blocks to be
-built.  It is possible to construct blocks that consume data at
-different rates on each input, and produce output at a rate that
-is a function of the contents of the input data.</para>
-
-<para>On the other hand, it is very common for signal processing
-blocks to have a fixed relationship between the input rate and the
-output rate.  Many are 1:1, while others have 1:N or N:1
-relationships.</para>
-
-<para>Another common requirement is the need to examine more than one
-input sample to produce a single output sample.  This is orthogonal to
-the relationship between input and output rate.  For example, a
-non-decimating, non-interpolating FIR filter needs to examine N input
-samples for each output sample it produces, where N is the number of
-taps in the filter.  However, it only consumes a single input sample
-to produce a single output.  We call this concept "history", but you
-could also think of it as "look-ahead".</para>
-
-<sect2 id="gr_sync_block"><title><classname>gr_sync_block</classname></title>
-
-<para>
-<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__sync__block.html">
-<classname>gr_sync_block</classname></ulink>
-is derived from
-<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__block.html">
-<classname>gr_block</classname></ulink>
-and implements a 1:1 block with
-optional history.  Given that we know the input to output rate,
-certain simplifications are possible.  From the implementor&apos;s
-point-of-view, the primary change is that we define a
-<methodname>work</methodname> method instead of
-<methodname>general_work</methodname>.  <methodname>work</methodname>
-has a slightly different calling sequence;
-It omits the unnecessary ninput_items parameter, and arranges for
-<methodname>consume_each</methodname> to be called on our
-behalf.</para>
-<programlisting>
-  /*!
-   * \brief Just like gr_block::general_work, only this arranges to
-   *  call consume_each for you.
-   *
-   * The user must override work to define the signal processing code
-   */
-  virtual int work (int noutput_items,
-                    gr_vector_const_void_star &amp;input_items,
-                    gr_vector_void_star &amp;output_items) = 0;
-</programlisting>
-
-<para>This gives us fewer things to worry about, and less code to
-write.  If the block requires history greater than 1, call
-<methodname>set_history</methodname> in the constructor, or any time
-the requirement changes.</para>
-
-<para><classname>gr_sync_block</classname> provides a
-version of <methodname>forecast</methodname> that handles the
-history requirement.</para>
-
-</sect2>
-
-<sect2 id="gr_sync_decimator"><title><classname>gr_sync_decimator</classname></title>
-
-<para>
-<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__sync__decimator.html">
-<classname>gr_sync_decimator</classname></ulink>
-is derived from
-<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__sync__block.html">
-<classname>gr_sync_block</classname></ulink>
-and implements a N:1 block with optional history.  
-</para>
-
-</sect2>
-
-<sect2 id="gr_sync_interpolator"><title><classname>gr_sync_interpolator</classname></title>
-
-<para>
-<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__sync__interpolator.html">
-<classname>gr_sync_interpolator</classname></ulink>
-is derived from
-<ulink url="http://www.gnu.org/software/gnuradio/doc/classgr__sync__block.html">
-<classname>gr_sync_block</classname></ulink>
-and implements a 1:N block with optional history.  
-</para>
-
-</sect2>
-
-
-</sect1>
-
-<sect1 id="square2">
-<title>Second Block: <classname>howto_square2_ff</classname></title>
-
-<para>Given that we now know about
-<classname>gr_sync_block</classname>, the way 
-<classname>howto_square_ff</classname> should really be implemented is
-by subclassing <classname>gr_sync_block</classname>.</para>
-
-<para>Here are the revised sources: <xref
-linkend="howto_square2_ff.h"/>, 
-<xref linkend="howto_square2_ff.cc"/>.  
-The accompanying files contain the additional test code.
-</para>
-
-<example id="howto_square2_ff.h">
-<title><filename>howto_square2_ff.h</filename></title>
-&howto_square2_ff_h_listing;
-</example>
-
-<example id="howto_square2_ff.cc">
-<title><filename>howto_square2_ff.cc</filename></title>
-&howto_square2_ff_cc_listing;
-</example>
-
-</sect1>
-
-<sect1 id="where_to"><title>Where to from Here?</title>
-
-<para>At this point, we&apos;ve got a basic overview of how the system
-goes together.  For more insight, I suggest that you look at the code
-of the system.  The doxygen generated <ulink
-url="http://www.gnu.org/software/gnuradio/doc/hierarchy.html"> class
-hierarchy</ulink> is a useful way to find things that might interest
-you.</para>
-
-</sect1>
-
-
-<sect1 id="tips"><title>Miscellaneous Tips</title>
-
-<sect2 id="sources_and_sinks"><title>Sources and Sinks</title>
-
-<para>Sources and sinks are derived from
-<classname>gr_sync_block</classname>.  The only thing different about
-them is that sources have no inputs and sinks have no outputs.  This
-is reflected in the <classname>gr_io_signature</classname>s that are
-passed to the <classname>gr_sync_block</classname> constructor.
-Take a look at <filename>gr_file_source.{h,cc}</filename> and
-<filename>gr_file_sink.{h,cc}</filename> for some very straight-forward examples.
-</para>
-
-</sect2>
-
-<sect2 id="debugging">
-<title>Debugging with <application>gdb</application></title>
-
-<para>If your block isn&apos;t working, and you can&apos;t sort it
-out through python test cases or a few printfs in the code, you may want to
-use <application>gdb</application> to debug it.  The trick of course
-is that all of &gnuradio;, including your new block, is dynamically
-loaded into python for execution.</para>
-
-<para>Try this:  In your python test code, after the relevant imports,
-print out the process id and wait for a keystroke.  In another
-window run gdb and tell it to attach to the python process with the
-given process id.  At this point you can set breakpoints or whatever
-in your code.  Go back to the python window and hit Enter so
-it&apos;ll continue.</para>
-
-<programlisting>
-  #!/usr/bin/env python
-  from gnuradio import gr
-  from gnuradio import my_buggy_module
-
-  # insert this in your test code...
-  import os
-  print 'Blocked waiting for GDB attach (pid = %d)' % (os.getpid(),)
-  raw_input ('Press Enter to continue: ')
-  # remainder of your test code follows...
-</programlisting>
-
-<para>Another SNAFU you might run into is that gdb 6.2 isn&apos;t
-able to set breakpoints in the constructors or destructors generated
-by g++ 3.4.  In this case, insert a call to the nop function
-gri_debugger_hook in the constructor and recompile.  Load the code as
-before and set a break point on gri_debugger_hook.</para>
-
-</sect2>
-
-<sect2 id="oprofile">
-<title>Performance Measurement with <application>oprofile</application></title>
-<para>Oprofile is your friend.  
-See <ulink url="http://oprofile.sourceforge.net">http://oprofile.sourceforge.net</ulink>.
-</para>
-</sect2>
-
-</sect1><!-- end tips -->
-
-<sect1 id="futures"><title>Coming Attractions</title>
-<para></para>
-
-<sect2 id="types"><title>Improved Type System</title>
-<para></para>
-</sect2>
-
-<sect2 id="hierarchy"><title>Hierarchical Blocks</title>
-<para></para>
-</sect2>
-
-</sect1><!-- end Coming Attractions -->
-
-</article>
diff --git a/gr-howto-write-a-block/doc/howto_1.i b/gr-howto-write-a-block/doc/howto_1.i
deleted file mode 100644 (file)
index 640d089..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- c++ -*- */
-
-%include "exception.i"
-%import "gnuradio.i"                           // the common stuff
-
-%{
-#include "gnuradio_swig_bug_workaround.h"      // mandatory bug fix
-#include "howto_square_ff.h"
-#include <stdexcept>
-%}
-
-// ----------------------------------------------------------------
-
-/*
- * First arg is the package prefix.
- * Second arg is the name of the class minus the prefix.
- *
- * This does some behind-the-scenes magic so we can
- * access howto_square_ff from python as howto.square_ff
- */
-GR_SWIG_BLOCK_MAGIC(howto,square_ff);
-
-howto_square_ff_sptr howto_make_square_ff ();
-
-class howto_square_ff : public gr_block
-{
-private:
-  howto_square_ff ();
-};
diff --git a/gr-howto-write-a-block/doc/make_numbered_listing.py b/gr-howto-write-a-block/doc/make_numbered_listing.py
deleted file mode 100755 (executable)
index 889c2d7..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import os, os.path
-from optparse import OptionParser
-
-def quote_line (line):
-    line = line.replace ('&', '&amp;')
-    line = line.replace ('<', '&lt;')
-    line = line.replace ('>', '&gt;')
-    line = line.replace ("'", '&apos;')
-    line = line.replace ('"', '&quot;')
-    return line
-
-def generate_listing (input_filename, title=None):
-    inf = open (input_filename, "r")
-    output_filename = os.path.basename (input_filename) + '.xml'
-    outf = open (output_filename, "w")
-    outf.write ('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
-    # outf.write ('<example id="%s">\n' % (input_filename,))
-    # if not title:
-    #     title = input_filename
-    # outf.write ('<title>')
-    # outf.write (title)
-    # outf.write ('</title>\n')
-    outf.write ('<programlisting>\n');
-
-    lineno = 0
-    for line in inf:
-        line = line.expandtabs (8)
-        line = quote_line (line)
-        lineno = lineno + 1
-        outf.write ('%3d  %s' % (lineno, line))
-
-    outf.write ('</programlisting>\n')
-    # outf.write ('</example>\n')
-
-
-def main ():
-    for file in sys.argv[1:]:
-        generate_listing (file)
-
-if __name__ == '__main__':
-    main ()
-    
diff --git a/gr-howto-write-a-block/doc/qa_howto_1.py b/gr-howto-write-a-block/doc/qa_howto_1.py
deleted file mode 100755 (executable)
index 3173110..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-
-from gnuradio import gr, gr_unittest
-import howto
-
-class qa_howto (gr_unittest.TestCase):
-
-    def setUp (self):
-        self.tb = gr.top_block ()
-
-    def tearDown (self):
-        self.tb = None
-
-    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.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)
-        
-if __name__ == '__main__':
-    gr_unittest.main ()
diff --git a/gr-howto-write-a-block/doc/src_lib_Makefile_1.am b/gr-howto-write-a-block/doc/src_lib_Makefile_1.am
deleted file mode 100644 (file)
index e97d70d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-include $(top_srcdir)/Makefile.common
-
-# Install this stuff so that it ends up as the gnuradio.howto module
-# This usually ends up at:
-#   ${prefix}/lib/python${python_version}/site-packages/gnuradio
-
-ourpythondir = $(grpythondir)
-ourlibdir    = $(grpyexecdir)
-
-INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES)
-
-ourlib_LTLIBRARIES = _howto.la
-
-# These are the source files that go into the shared library
-_howto_la_SOURCES =                    \
-       howto_square_ff.cc              
-
-# magic flags
-_howto_la_LDFLAGS = -module -avoid-version
-
-# These headers get installed in ${prefix}/include/gnuradio
-grinclude_HEADERS =                    \
-       howto_square_ff.h               
-
-MOSTLYCLEANFILES = $(BUILT_SOURCES) *.pyc
diff --git a/gr-howto-write-a-block/doc/src_lib_Makefile_2.am b/gr-howto-write-a-block/doc/src_lib_Makefile_2.am
deleted file mode 100644 (file)
index dca236e..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#
-# Copyright 2004,2008 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
-
-# Install this stuff so that it ends up as the gnuradio.howto module
-# This usually ends up at:
-#   ${prefix}/lib/python${python_version}/site-packages/gnuradio
-
-ourpythondir = $(grpythondir)
-ourlibdir    = $(grpyexecdir)
-
-INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES)
-
-SWIGCPPPYTHONARGS = -noruntime -c++ -python $(PYTHON_CPPFLAGS) \
-       -I$(swigincludedir) -I$(grincludedir) $(WITH_SWIG_INCLUDES)
-
-ALL_IFILES =                           \
-       $(LOCAL_IFILES)                 \
-       $(NON_LOCAL_IFILES)             
-
-NON_LOCAL_IFILES =                     \
-       $(GNURADIO_CORE_INCLUDEDIR)/swig/gnuradio.i
-
-
-LOCAL_IFILES =                                 \
-       howto.i                         
-
-# These files are built by SWIG.  The first is the C++ glue.
-# The second is the python wrapper that loads the _howto shared library
-# and knows how to call our extensions.
-
-BUILT_SOURCES =                        \
-       howto.cc                        \
-       howto.py                                
-
-# This gets howto.py installed in the right place
-ourpython_PYTHON =                     \
-       howto.py
-
-ourlib_LTLIBRARIES = _howto.la
-
-# These are the source files that go into the shared library
-_howto_la_SOURCES =                    \
-       howto.cc                        \
-       howto_square_ff.cc              
-
-# magic flags
-_howto_la_LDFLAGS = -module -avoid-version
-
-# link the library against some comon swig runtime code and the 
-# c++ standard library
-_howto_la_LIBADD =                     \
-       -lgrswigrunpy                   \
-       -lstdc++                        
-
-howto.cc howto.py: howto.i $(ALL_IFILES)
-       $(SWIG) $(SWIGCPPPYTHONARGS) -module howto -o howto.cc $<
-
-# These headers get installed in ${prefix}/include/gnuradio
-grinclude_HEADERS =                    \
-       howto_square_ff.h               
-
-# These swig headers get installed in ${prefix}/include/gnuradio/swig
-swiginclude_HEADERS =                  \
-       $(LOCAL_IFILES)
-
-MOSTLYCLEANFILES = $(BUILT_SOURCES) *.pyc
diff --git a/gr-howto-write-a-block/grc/.gitignore b/gr-howto-write-a-block/grc/.gitignore
new file mode 100644 (file)
index 0000000..b336cc7
--- /dev/null
@@ -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 (file)
index 0000000..32dcf1b
--- /dev/null
@@ -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 (file)
index 0000000..2b46106
--- /dev/null
@@ -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 (file)
index 0000000..ed318bf
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..b1e56d3
--- /dev/null
@@ -0,0 +1,12 @@
+/Makefile
+/Makefile.in
+/.la
+/.lo
+/.deps
+/.libs
+/*.la
+/*.lo
+/*.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
new file mode 100644 (file)
index 0000000..336cb8a
--- /dev/null
@@ -0,0 +1,80 @@
+#
+# Copyright 2004,2005,2006,2008,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
+
+# 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 =            \
+       howto_square_ff.h       \
+       howto_square2_ff.h
+
+lib_LTLIBRARIES = libgnuradio-howto.la
+
+libgnuradio_howto_la_SOURCES =         \
+       howto_square_ff.cc      \
+       howto_square2_ff.cc
+
+libgnuradio_howto_la_LIBADD =  \
+       $(GNURADIO_CORE_LA)
+
+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/howto_square2_ff.cc b/gr-howto-write-a-block/lib/howto_square2_ff.cc
new file mode 100644 (file)
index 0000000..e86db93
--- /dev/null
@@ -0,0 +1,92 @@
+/* -*- 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.
+ */
+
+/*
+ * 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 howto_square2_ff_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_square2_ff.h b/gr-howto-write-a-block/lib/howto_square2_ff.h
new file mode 100644 (file)
index 0000000..536b04f
--- /dev/null
@@ -0,0 +1,77 @@
+/* -*- 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 <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_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_square2_ff : public gr_sync_block
+{
+private:
+  // The friend declaration allows howto_make_square2_ff to
+  // access the private constructor.
+
+  friend 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/lib/howto_square_ff.cc b/gr-howto-write-a-block/lib/howto_square_ff.cc
new file mode 100644 (file)
index 0000000..5ab45d1
--- /dev/null
@@ -0,0 +1,98 @@
+/* -*- 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.
+ */
+
+/*
+ * 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 howto_square_ff_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/howto_square_ff.h b/gr-howto-write-a-block/lib/howto_square_ff.h
new file mode 100644 (file)
index 0000000..092b936
--- /dev/null
@@ -0,0 +1,78 @@
+/* -*- 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 <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_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_square_ff : public gr_block
+{
+private:
+  // The friend declaration allows howto_make_square_ff to
+  // access the private constructor.
+
+  friend howto_square_ff_sptr howto_make_square_ff ();
+
+  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/qa_howto.cc b/gr-howto-write-a-block/lib/qa_howto.cc
new file mode 100644 (file)
index 0000000..f1411a3
--- /dev/null
@@ -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 (file)
index 0000000..fa5a42f
--- /dev/null
@@ -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 (file)
index 0000000..a374651
--- /dev/null
@@ -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 (file)
index 0000000..c74d086
--- /dev/null
@@ -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 (file)
index 0000000..2f0b597
--- /dev/null
@@ -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 (file)
index 0000000..1b7c5e9
--- /dev/null
@@ -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 (file)
index 0000000..192c537
--- /dev/null
@@ -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/python/.gitignore b/gr-howto-write-a-block/python/.gitignore
new file mode 100644 (file)
index 0000000..bf03975
--- /dev/null
@@ -0,0 +1,9 @@
+/Makefile
+/Makefile.in
+/.deps
+/.libs
+/*.la
+/*.lo
+/*.pyc
+/*.pyo
+/run_tests
diff --git a/gr-howto-write-a-block/python/Makefile.am b/gr-howto-write-a-block/python/Makefile.am
new file mode 100644 (file)
index 0000000..4ef5fc9
--- /dev/null
@@ -0,0 +1,33 @@
+#
+# 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.
+# 
+
+include $(top_srcdir)/Makefile.common
+
+ourpythondir = $(grpythondir)/howto
+
+EXTRA_DIST = run_tests.in
+TESTS = run_tests
+
+ourpython_PYTHON = \
+       __init__.py
+
+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 (file)
index 0000000..d4a41c2
--- /dev/null
@@ -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
new file mode 100755 (executable)
index 0000000..630f57b
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2007 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+from gnuradio import gr, gr_unittest
+import howto_swig
+
+class qa_howto (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block ()
+
+    def tearDown (self):
+        self.tb = None
+
+    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)
+
+    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)
+        
+if __name__ == '__main__':
+    gr_unittest.main ()
diff --git a/gr-howto-write-a-block/python/run_tests.in b/gr-howto-write-a-block/python/run_tests.in
new file mode 100644 (file)
index 0000000..5b50509
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# All this strange PYTHONPATH manipulation is required to run our
+# tests using our just built shared library and swig-generated python
+# code prior to installation.
+
+# build tree == src tree unless you're doing a VPATH build.  
+# If you don't know what a VPATH build is, you're not doing one.  Relax...
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+
+# Where to look in the build tree for our shared library
+libbld=@abs_top_builddir@/lib
+# Where to look in the build tree for swig generated python code
+libswig=@abs_top_builddir@/swig
+# Where to look in the src tree for hand written python code
+py=@abs_top_srcdir@/python
+
+# Where to look for installed GNU Radio python modules
+# FIXME this is wrong on a distcheck.  We really need to ask gnuradio-core
+# where it put its python files.
+installed_pythondir=@pythondir@
+installed_pyexecdir=@pyexecdir@
+
+PYTHONPATH="$libbld:$libbld/.libs:$libswig:$libswig/.libs:$py:$installed_pythondir:$installed_pyexecdir:$PYTHONPATH"
+echo $PYTHONPATH
+
+export PYTHONPATH
+
+#
+# This is the simple part...
+# Run everything that matches qa_*.py and return the final result.
+#
+
+ok=yes
+for file in @srcdir@/qa_*.py
+do
+  if ! $file
+  then
+    ok=no
+  fi  
+done
+
+if [ $ok = yes ]
+then
+  exit 0
+else
+  exit 1
+fi
diff --git a/gr-howto-write-a-block/src/.gitignore b/gr-howto-write-a-block/src/.gitignore
deleted file mode 100644 (file)
index bb3f277..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/Makefile
-/Makefile.in
-/.la
-/.lo
-/.deps
-/.libs
-/*.la
-/*.lo
-/howto.cc
-/howto.py
diff --git a/gr-howto-write-a-block/src/Makefile.am b/gr-howto-write-a-block/src/Makefile.am
deleted file mode 100644 (file)
index 4c8650d..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright 2004,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.
-# 
-
-SUBDIRS = lib
-
-if PYTHON
-SUBDIRS += python
-endif
diff --git a/gr-howto-write-a-block/src/lib/.gitignore b/gr-howto-write-a-block/src/lib/.gitignore
deleted file mode 100644 (file)
index d957a68..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/Makefile
-/Makefile.in
-/.la
-/.lo
-/.deps
-/.libs
-/*.la
-/*.lo
-/*.pyc
-/howto.cc
-/howto.py
diff --git a/gr-howto-write-a-block/src/lib/Makefile.am b/gr-howto-write-a-block/src/lib/Makefile.am
deleted file mode 100644 (file)
index fa6b439..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Copyright 2004,2005,2006,2008,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
-
-###################################
-# howto C++ library
-
-# C/C++ headers get installed in ${prefix}/include/gnuradio
-grinclude_HEADERS =            \
-       howto_square_ff.h       \
-       howto_square2_ff.h
-
-lib_LTLIBRARIES = libgnuradio-howto.la
-
-libgnuradio_howto_la_SOURCES =         \
-       howto_square_ff.cc      \
-       howto_square2_ff.cc
-
-libgnuradio_howto_la_LIBADD =  \
-       $(GNURADIO_CORE_LA)
-
-libgnuradio_howto_la_LDFLAGS = \
-       $(NO_UNDEFINED)
-
-if PYTHON
-###################################
-# SWIG Python interface and library
-
-TOP_SWIG_IFILES =              \
-       howto.i
-
-# Install so that they end up available as:
-#   import gnuradio.howto
-# This ends up at:
-#   ${prefix}/lib/python${python_version}/site-packages/gnuradio
-howto_pythondir_category =     \
-       gnuradio
-
-howto_la_swig_libadd =         \
-       libgnuradio-howto.la
-
-include $(top_srcdir)/Makefile.swig
-
-# add some of the variables generated inside the Makefile.swig.gen
-BUILT_SOURCES = $(swig_built_sources)
-
-# Do not distribute the output of SWIG
-no_dist_files = $(swig_built_sources)
-endif
diff --git a/gr-howto-write-a-block/src/lib/Makefile.swig.gen b/gr-howto-write-a-block/src/lib/Makefile.swig.gen
deleted file mode 100644 (file)
index f76cc63..0000000
+++ /dev/null
@@ -1,259 +0,0 @@
-# -*- Makefile -*-
-#
-# 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.
-# 
-
-# Makefile.swig.gen for howto.i
-
-## Default install locations for these files:
-##
-## Default location for the Python directory is:
-##  ${prefix}/lib/python${python_version}/site-packages/[category]/howto
-## Default location for the Python exec directory is:
-##  ${exec_prefix}/lib/python${python_version}/site-packages/[category]/howto
-##
-## The following can be overloaded to change the install location, but
-## this has to be done in the including Makefile.am -before-
-## Makefile.swig is included.
-
-howto_pythondir_category ?= gnuradio/howto
-howto_pylibdir_category ?= $(howto_pythondir_category)
-howto_pythondir = $(pythondir)/$(howto_pythondir_category)
-howto_pylibdir = $(pyexecdir)/$(howto_pylibdir_category)
-
-## SWIG headers are always installed into the same directory.
-
-howto_swigincludedir = $(swigincludedir)
-
-## This is a template file for a "generated" Makefile addition (in
-## this case, "Makefile.swig.gen").  By including the top-level
-## Makefile.swig, this file will be used to generate the SWIG
-## dependencies.  Assign the variable TOP_SWIG_FILES to be the list of
-## SWIG .i files to generated wrappings for; there can be more than 1
-## so long as the names are unique (no sorting is done on the
-## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i
-## file will generate .cc, .py, and possibly .h files -- meaning that
-## all of these files will have the same base name (that provided for
-## the SWIG .i file).
-##
-## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the
-## right thing.  For more info, see <
-## http://sources.redhat.com/automake/automake.html#Multiple-Outputs >
-
-## Stamps used to ensure parallel make does the right thing.  These
-## are removed by "make clean", but otherwise unused except during the
-## parallel built.  These will not be included in a tarball, because
-## the SWIG-generated files will be removed from the distribution.
-
-STAMPS += $(DEPDIR)/howto-generate-*
-
-## Other cleaned files: dependency files generated by SWIG or this Makefile
-
-MOSTLYCLEANFILES += $(DEPDIR)/*.S*
-
-## Add the .py and .cc files to the list of SWIG built sources.  The
-## .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
-
-## 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_swiginclude_headers)
-
-howto_pylib_LTLIBRARIES =              \
-       _howto.la
-
-_howto_la_SOURCES =                    \
-       howto.cc                        \
-       $(howto_la_swig_sources)
-
-_howto_la_LIBADD =                     \
-       $(STD_SWIG_LA_LIB_ADD)          \
-       $(howto_la_swig_libadd)
-
-_howto_la_LDFLAGS =                    \
-       $(STD_SWIG_LA_LD_FLAGS)         \
-       $(howto_la_swig_ldflags)
-
-_howto_la_CXXFLAGS =                   \
-       $(STD_SWIG_CXX_FLAGS)           \
-       $(howto_la_swig_cxxflags)
-
-howto_python_PYTHON =                  \
-       howto.py                        \
-       $(howto_python)
-
-## Entry rule for running SWIG
-
-howto.h howto.py howto.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:
-##
-## * The .i file is newer than any or all of the generated files;
-##
-## * Any or all of the .cc, .h, or .py files does not exist and is
-##   needed (in the case this file is not needed, the rule for it is
-##   ignored); or
-##
-## * Some SWIG-based dependecy of the .cc file isn't met and hence the
-##   .cc file needs be be regenerated.  Explanation: Because MAKE
-##   knows how to handle dependencies for .cc files (regardless of
-##   their name or extension), then the .cc file is used as a target
-##   instead of the .i file -- but with the dependencies of the .i
-##   file.  It is this last reason why the line:
-##
-##             if test -f $@; then :; else
-##
-##   cannot be used in this case: If a .i file dependecy is not met,
-##   then the .cc file needs to be rebuilt.  But if the stamp is newer
-##   than the .cc file, and the .cc file exists, then in the original
-##   version (with the 'test' above) the internal MAKE call will not
-##   be issued and hence the .cc file will not be rebuilt.
-##
-## Once execution gets to here, it should always proceed no matter the
-## state of a stamp (as discussed in link above).  The
-## $(DEPDIR)/howto-generate stuff is used to allow for parallel
-## builds to "do the right thing".  The stamp has no relationship with
-## either the target files or dependency file; it is used solely for
-## the protection of multiple builds during a given call to MAKE.
-##
-## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM
-## (15).  At a caught signal, the quoted command will be issued before
-## exiting.  In this case, remove any stamp, whether temporary of not.
-## The trap is valid until the process exits; the process includes all
-## commands appended via "\"s.
-##
-       trap 'rm -rf $(DEPDIR)/howto-generate-*' 1 2 13 15; \
-##
-## Create a temporary directory, which acts as a lock.  The first
-## process to create the directory will succeed and issue the MAKE
-## command to do the actual work, while all subsequent processes will
-## fail -- leading them to wait for the first process to finish.
-##
-       if mkdir $(DEPDIR)/howto-generate-lock 2>/dev/null; then \
-##
-## This code is being executed by the first process to succeed in
-## creating the directory lock.
-##
-## Remove the stamp associated with this filename.
-##
-               rm -f $(DEPDIR)/howto-generate-stamp; \
-##
-## Tell MAKE to run the rule for creating this stamp.
-##
-               $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/howto-generate-stamp WHAT=$<; \
-##
-## Now that the .cc, .h, and .py files have been (re)created from the
-## .i file, future checking of this rule during the same MAKE
-## execution will come back that the rule doesn't need to be executed
-## because none of the conditions mentioned at the start of this rule
-## will be positive.  Remove the the directory lock, which frees up
-## any waiting process(es) to continue.
-##
-               rmdir $(DEPDIR)/howto-generate-lock; \
-       else \
-##
-## This code is being executed by any follower processes while the
-## directory lock is in place.
-##
-## Wait until the first process is done, testing once per second.
-##
-               while test -d $(DEPDIR)/howto-generate-lock; do \
-                       sleep 1; \
-               done; \
-##
-## Succeed if and only if the first process succeeded; exit this
-## process returning the status of the generated stamp.
-##
-               test -f $(DEPDIR)/howto-generate-stamp; \
-               exit $$?; \
-       fi;
-
-$(DEPDIR)/howto-generate-stamp:
-## This rule will be called only by the first process issuing the
-## above rule to succeed in creating the lock directory, after
-## removing the actual stamp file in order to guarantee that MAKE will
-## execute this rule.
-##
-## Call SWIG to generate the various output files; special
-## post-processing on 'mingw32' host OS for the dependency file.
-##
-       if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(howto_swig_args) \
-               -MD -MF $(DEPDIR)/howto.Std \
-               -module howto -o howto.cc $(WHAT); then \
-           if test $(host_os) = mingw32; then \
-               $(RM) $(DEPDIR)/howto.Sd; \
-               $(SED) 's,\\\\,/,g' < $(DEPDIR)/howto.Std \
-                       > $(DEPDIR)/howto.Sd; \
-               $(RM) $(DEPDIR)/howto.Std; \
-               $(MV) $(DEPDIR)/howto.Sd $(DEPDIR)/howto.Std; \
-           fi; \
-       else \
-           $(RM) $(DEPDIR)/howto.S*; exit 1; \
-       fi;
-##
-## Mess with the SWIG output .Std dependency file, to create a
-## dependecy file valid for the input .i file: Basically, simulate the
-## dependency file created for libraries by GNU's libtool for C++,
-## where all of the dependencies for the target are first listed, then
-## each individual dependency is listed as a target with no further
-## dependencies.
-##
-## (1) remove the current dependency file
-##
-       $(RM) $(DEPDIR)/howto.d
-##
-## (2) Copy the whole SWIG file:
-##
-       cp $(DEPDIR)/howto.Std $(DEPDIR)/howto.d
-##
-## (3) all a carriage return to the end of the dependency file.
-##
-       echo "" >> $(DEPDIR)/howto.d
-##
-## (4) from the SWIG file, remove the first line (the target); remove
-##     trailing " \" and " " from each line.  Append ":" to each line,
-##     followed by 2 carriage returns, then append this to the end of
-##     the dependency file.
-##
-       $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/howto.Std | \
-               awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/howto.d
-##
-## (5) remove the SWIG-generated file
-##
-       $(RM) $(DEPDIR)/howto.Std
-##
-## Create the stamp for this filename generation, to signal success in
-## executing this rule; allows other threads waiting on this process
-## to continue.
-##
-       touch $(DEPDIR)/howto-generate-stamp
-
-# KLUDGE: Force runtime include of a SWIG dependency file.  This is
-# not guaranteed to be portable, but will probably work.  If it works,
-# we have accurate dependencies for our swig stuff, which is good.
-
-@am__include@ @am__quote@./$(DEPDIR)/howto.d@am__quote@
-
diff --git a/gr-howto-write-a-block/src/lib/howto.i b/gr-howto-write-a-block/src/lib/howto.i
deleted file mode 100644 (file)
index c3dae9d..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- c++ -*- */
-
-%include "gnuradio.i"                  // the common stuff
-
-%{
-#include "howto_square_ff.h"
-#include "howto_square2_ff.h"
-%}
-
-// ----------------------------------------------------------------
-
-/*
- * First arg is the package prefix.
- * Second arg is the name of the class minus the prefix.
- *
- * This does some behind-the-scenes magic so we can
- * access howto_square_ff from python as howto.square_ff
- */
-GR_SWIG_BLOCK_MAGIC(howto,square_ff);
-
-howto_square_ff_sptr howto_make_square_ff ();
-
-class howto_square_ff : public gr_block
-{
-private:
-  howto_square_ff ();
-};
-
-// ----------------------------------------------------------------
-
-GR_SWIG_BLOCK_MAGIC(howto,square2_ff);
-
-howto_square2_ff_sptr howto_make_square2_ff ();
-
-class howto_square2_ff : public gr_sync_block
-{
-private:
-  howto_square2_ff ();
-};
diff --git a/gr-howto-write-a-block/src/lib/howto_square2_ff.cc b/gr-howto-write-a-block/src/lib/howto_square2_ff.cc
deleted file mode 100644 (file)
index e86db93..0000000
+++ /dev/null
@@ -1,92 +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.
- */
-
-/*
- * 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 howto_square2_ff_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/src/lib/howto_square2_ff.h b/gr-howto-write-a-block/src/lib/howto_square2_ff.h
deleted file mode 100644 (file)
index 536b04f..0000000
+++ /dev/null
@@ -1,77 +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 <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_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_square2_ff : public gr_sync_block
-{
-private:
-  // The friend declaration allows howto_make_square2_ff to
-  // access the private constructor.
-
-  friend 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/src/lib/howto_square_ff.cc b/gr-howto-write-a-block/src/lib/howto_square_ff.cc
deleted file mode 100644 (file)
index 5ab45d1..0000000
+++ /dev/null
@@ -1,98 +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.
- */
-
-/*
- * 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 howto_square_ff_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/src/lib/howto_square_ff.h b/gr-howto-write-a-block/src/lib/howto_square_ff.h
deleted file mode 100644 (file)
index 092b936..0000000
+++ /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_SQUARE_FF_H
-#define INCLUDED_HOWTO_SQUARE_FF_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_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_square_ff : public gr_block
-{
-private:
-  // The friend declaration allows howto_make_square_ff to
-  // access the private constructor.
-
-  friend howto_square_ff_sptr howto_make_square_ff ();
-
-  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/src/python/.gitignore b/gr-howto-write-a-block/src/python/.gitignore
deleted file mode 100644 (file)
index bf03975..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-/Makefile
-/Makefile.in
-/.deps
-/.libs
-/*.la
-/*.lo
-/*.pyc
-/*.pyo
-/run_tests
diff --git a/gr-howto-write-a-block/src/python/Makefile.am b/gr-howto-write-a-block/src/python/Makefile.am
deleted file mode 100644 (file)
index 79f4401..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# 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.
-# 
-
-include $(top_srcdir)/Makefile.common
-
-EXTRA_DIST = run_tests.in
-
-
-TESTS =                                \
-       run_tests
-
-
-noinst_PYTHON =                        \
-       qa_howto.py                     
diff --git a/gr-howto-write-a-block/src/python/qa_howto.py b/gr-howto-write-a-block/src/python/qa_howto.py
deleted file mode 100755 (executable)
index 0abe0e2..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2004,2007 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-# 
-
-from gnuradio import gr, gr_unittest
-import howto
-
-class qa_howto (gr_unittest.TestCase):
-
-    def setUp (self):
-        self.tb = gr.top_block ()
-
-    def tearDown (self):
-        self.tb = None
-
-    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.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):
-        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 ()
-        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)
-        
-if __name__ == '__main__':
-    gr_unittest.main ()
diff --git a/gr-howto-write-a-block/src/python/run_tests.in b/gr-howto-write-a-block/src/python/run_tests.in
deleted file mode 100644 (file)
index 6e4b83e..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/sh
-
-# All this strange PYTHONPATH manipulation is required to run our
-# tests using our just built shared library and swig-generated python
-# code prior to installation.
-
-# build tree == src tree unless you're doing a VPATH build.  
-# If you don't know what a VPATH build is, you're not doing one.  Relax...
-
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-
-# Where to look in the build tree for our shared library
-libbld=@abs_top_builddir@/src/lib
-# Where to look in the src tree for swig generated python code
-libsrc=@abs_top_srcdir@/src/lib
-# Where to look in the src tree for hand written python code
-py=@abs_top_srcdir@/src/python
-
-# Where to look for installed GNU Radio python modules
-# FIXME this is wrong on a distcheck.  We really need to ask gnuradio-core
-# where it put its python files.
-installed_pythondir=@pythondir@
-installed_pyexecdir=@pyexecdir@
-
-PYTHONPATH="$libbld:$libbld/.libs:$libsrc:$py:$installed_pythondir:$installed_pyexecdir:$PYTHONPATH"
-#PYTHONPATH="$libbld:$libbld/.libs:$libsrc:$py:$installed_pythondir:$installed_pyexecdir"
-
-export PYTHONPATH
-
-#
-# This is the simple part...
-# Run everything that matches qa_*.py and return the final result.
-#
-
-ok=yes
-for file in @srcdir@/qa_*.py
-do
-  if ! $file
-  then
-    ok=no
-  fi  
-done
-
-if [ $ok = yes ]
-then
-  exit 0
-else
-  exit 1
-fi
diff --git a/gr-howto-write-a-block/swig/.gitignore b/gr-howto-write-a-block/swig/.gitignore
new file mode 100644 (file)
index 0000000..7f4c478
--- /dev/null
@@ -0,0 +1,6 @@
+/.deps
+/.libs
+/Makefile.in
+/Makefile
+/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
new file mode 100644 (file)
index 0000000..fc40109
--- /dev/null
@@ -0,0 +1,55 @@
+#
+# Copyright 2004,2005,2006,2008,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
+
+AM_CPPFLAGS += -I$(top_srcdir)/lib
+
+if PYTHON
+###################################
+# SWIG Python interface and library
+
+TOP_SWIG_IFILES =              \
+       howto.i
+
+# Install so that they end up available as:
+#   import gnuradio.howto
+# This ends up at:
+#   ${prefix}/lib/python${python_version}/site-packages/gnuradio
+howto_pythondir_category = gnuradio/howto
+
+howto_la_swig_libadd =         \
+       $(top_builddir)/lib/libgnuradio-howto.la
+
+include $(top_srcdir)/Makefile.swig
+
+# add some of the variables generated inside the Makefile.swig.gen
+BUILT_SOURCES = $(swig_built_sources)
+
+# Do not distribute the output of SWIG
+no_dist_files = $(swig_built_sources)
+
+# additional SWIG files to be installed
+howto_swiginclude_headers =    \
+       howto_square_ff.i \
+       howto_square2_ff.i
+
+endif
diff --git a/gr-howto-write-a-block/swig/Makefile.swig.gen b/gr-howto-write-a-block/swig/Makefile.swig.gen
new file mode 100644 (file)
index 0000000..c62e5aa
--- /dev/null
@@ -0,0 +1,259 @@
+# -*- Makefile -*-
+#
+# 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.
+# 
+
+# Makefile.swig.gen for howto.i
+
+## Default install locations for these files:
+##
+## Default location for the Python directory is:
+##  ${prefix}/lib/python${python_version}/site-packages/[category]/howto
+## Default location for the Python exec directory is:
+##  ${exec_prefix}/lib/python${python_version}/site-packages/[category]/howto
+##
+## The following can be overloaded to change the install location, but
+## this has to be done in the including Makefile.am -before-
+## Makefile.swig is included.
+
+howto_pythondir_category ?= gnuradio/howto
+howto_pylibdir_category ?= $(howto_pythondir_category)
+howto_pythondir = $(pythondir)/$(howto_pythondir_category)
+howto_pylibdir = $(pyexecdir)/$(howto_pylibdir_category)
+
+## SWIG headers are always installed into the same directory.
+
+howto_swigincludedir = $(swigincludedir)
+
+## This is a template file for a "generated" Makefile addition (in
+## this case, "Makefile.swig.gen").  By including the top-level
+## Makefile.swig, this file will be used to generate the SWIG
+## dependencies.  Assign the variable TOP_SWIG_FILES to be the list of
+## SWIG .i files to generated wrappings for; there can be more than 1
+## so long as the names are unique (no sorting is done on the
+## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i
+## file will generate .cc, .py, and possibly .h files -- meaning that
+## all of these files will have the same base name (that provided for
+## the SWIG .i file).
+##
+## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the
+## right thing.  For more info, see <
+## http://sources.redhat.com/automake/automake.html#Multiple-Outputs >
+
+## Stamps used to ensure parallel make does the right thing.  These
+## are removed by "make clean", but otherwise unused except during the
+## parallel built.  These will not be included in a tarball, because
+## the SWIG-generated files will be removed from the distribution.
+
+STAMPS += $(DEPDIR)/howto-generate-*
+
+## Other cleaned files: dependency files generated by SWIG or this Makefile
+
+MOSTLYCLEANFILES += $(DEPDIR)/*.S*
+
+## Add the .py and .cc files to the list of SWIG built sources.  The
+## .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_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_swiginclude_headers)
+
+howto_pylib_LTLIBRARIES =              \
+       _howto_swig.la
+
+_howto_swig_la_SOURCES =               \
+       howto_swig.cc                   \
+       $(howto_la_swig_sources)
+
+_howto_swig_la_LIBADD =                        \
+       $(STD_SWIG_LA_LIB_ADD)          \
+       $(howto_la_swig_libadd)
+
+_howto_swig_la_LDFLAGS =               \
+       $(STD_SWIG_LA_LD_FLAGS)         \
+       $(howto_la_swig_ldflags)
+
+_howto_swig_la_CXXFLAGS =              \
+       $(STD_SWIG_CXX_FLAGS)           \
+       $(howto_la_swig_cxxflags)
+
+howto_python_PYTHON =                  \
+       howto_swig.py                   \
+       $(howto_python)
+
+## Entry rule for running SWIG
+
+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:
+##
+## * The .i file is newer than any or all of the generated files;
+##
+## * Any or all of the .cc, .h, or .py files does not exist and is
+##   needed (in the case this file is not needed, the rule for it is
+##   ignored); or
+##
+## * Some SWIG-based dependecy of the .cc file isn't met and hence the
+##   .cc file needs be be regenerated.  Explanation: Because MAKE
+##   knows how to handle dependencies for .cc files (regardless of
+##   their name or extension), then the .cc file is used as a target
+##   instead of the .i file -- but with the dependencies of the .i
+##   file.  It is this last reason why the line:
+##
+##             if test -f $@; then :; else
+##
+##   cannot be used in this case: If a .i file dependecy is not met,
+##   then the .cc file needs to be rebuilt.  But if the stamp is newer
+##   than the .cc file, and the .cc file exists, then in the original
+##   version (with the 'test' above) the internal MAKE call will not
+##   be issued and hence the .cc file will not be rebuilt.
+##
+## Once execution gets to here, it should always proceed no matter the
+## state of a stamp (as discussed in link above).  The
+## $(DEPDIR)/howto-generate stuff is used to allow for parallel
+## builds to "do the right thing".  The stamp has no relationship with
+## either the target files or dependency file; it is used solely for
+## the protection of multiple builds during a given call to MAKE.
+##
+## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM
+## (15).  At a caught signal, the quoted command will be issued before
+## exiting.  In this case, remove any stamp, whether temporary of not.
+## The trap is valid until the process exits; the process includes all
+## commands appended via "\"s.
+##
+       trap 'rm -rf $(DEPDIR)/howto-generate-*' 1 2 13 15; \
+##
+## Create a temporary directory, which acts as a lock.  The first
+## process to create the directory will succeed and issue the MAKE
+## command to do the actual work, while all subsequent processes will
+## fail -- leading them to wait for the first process to finish.
+##
+       if mkdir $(DEPDIR)/howto-generate-lock 2>/dev/null; then \
+##
+## This code is being executed by the first process to succeed in
+## creating the directory lock.
+##
+## Remove the stamp associated with this filename.
+##
+               rm -f $(DEPDIR)/howto-generate-stamp; \
+##
+## Tell MAKE to run the rule for creating this stamp.
+##
+               $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/howto-generate-stamp WHAT=$<; \
+##
+## Now that the .cc, .h, and .py files have been (re)created from the
+## .i file, future checking of this rule during the same MAKE
+## execution will come back that the rule doesn't need to be executed
+## because none of the conditions mentioned at the start of this rule
+## will be positive.  Remove the the directory lock, which frees up
+## any waiting process(es) to continue.
+##
+               rmdir $(DEPDIR)/howto-generate-lock; \
+       else \
+##
+## This code is being executed by any follower processes while the
+## directory lock is in place.
+##
+## Wait until the first process is done, testing once per second.
+##
+               while test -d $(DEPDIR)/howto-generate-lock; do \
+                       sleep 1; \
+               done; \
+##
+## Succeed if and only if the first process succeeded; exit this
+## process returning the status of the generated stamp.
+##
+               test -f $(DEPDIR)/howto-generate-stamp; \
+               exit $$?; \
+       fi;
+
+$(DEPDIR)/howto-generate-stamp:
+## This rule will be called only by the first process issuing the
+## above rule to succeed in creating the lock directory, after
+## removing the actual stamp file in order to guarantee that MAKE will
+## execute this rule.
+##
+## Call SWIG to generate the various output files; special
+## post-processing on 'mingw32' host OS for the dependency file.
+##
+       if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(howto_swig_args) \
+               -MD -MF $(DEPDIR)/howto.Std \
+               -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 \
+                       > $(DEPDIR)/howto.Sd; \
+               $(RM) $(DEPDIR)/howto.Std; \
+               $(MV) $(DEPDIR)/howto.Sd $(DEPDIR)/howto.Std; \
+           fi; \
+       else \
+           $(RM) $(DEPDIR)/howto.S*; exit 1; \
+       fi;
+##
+## Mess with the SWIG output .Std dependency file, to create a
+## dependecy file valid for the input .i file: Basically, simulate the
+## dependency file created for libraries by GNU's libtool for C++,
+## where all of the dependencies for the target are first listed, then
+## each individual dependency is listed as a target with no further
+## dependencies.
+##
+## (1) remove the current dependency file
+##
+       $(RM) $(DEPDIR)/howto.d
+##
+## (2) Copy the whole SWIG file:
+##
+       cp $(DEPDIR)/howto.Std $(DEPDIR)/howto.d
+##
+## (3) all a carriage return to the end of the dependency file.
+##
+       echo "" >> $(DEPDIR)/howto.d
+##
+## (4) from the SWIG file, remove the first line (the target); remove
+##     trailing " \" and " " from each line.  Append ":" to each line,
+##     followed by 2 carriage returns, then append this to the end of
+##     the dependency file.
+##
+       $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/howto.Std | \
+               awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/howto.d
+##
+## (5) remove the SWIG-generated file
+##
+       $(RM) $(DEPDIR)/howto.Std
+##
+## Create the stamp for this filename generation, to signal success in
+## executing this rule; allows other threads waiting on this process
+## to continue.
+##
+       touch $(DEPDIR)/howto-generate-stamp
+
+# KLUDGE: Force runtime include of a SWIG dependency file.  This is
+# not guaranteed to be portable, but will probably work.  If it works,
+# we have accurate dependencies for our swig stuff, which is good.
+
+@am__include@ @am__quote@./$(DEPDIR)/howto.d@am__quote@
+
diff --git a/gr-howto-write-a-block/swig/howto.i b/gr-howto-write-a-block/swig/howto.i
new file mode 100644 (file)
index 0000000..8dc5020
--- /dev/null
@@ -0,0 +1,11 @@
+/* -*- c++ -*- */
+
+%include "gnuradio.i"                  // the common stuff
+
+%{
+#include "howto_square_ff.h"
+#include "howto_square2_ff.h"
+%}
+
+%include "howto_square_ff.i"
+%include "howto_square2_ff.i"
diff --git a/gr-howto-write-a-block/swig/howto_square2_ff.i b/gr-howto-write-a-block/swig/howto_square2_ff.i
new file mode 100644 (file)
index 0000000..683a93d
--- /dev/null
@@ -0,0 +1,9 @@
+GR_SWIG_BLOCK_MAGIC(howto,square2_ff);
+
+howto_square2_ff_sptr howto_make_square2_ff ();
+
+class howto_square2_ff : public gr_sync_block
+{
+private:
+  howto_square2_ff ();
+};
diff --git a/gr-howto-write-a-block/swig/howto_square_ff.i b/gr-howto-write-a-block/swig/howto_square_ff.i
new file mode 100644 (file)
index 0000000..f8ae769
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * First arg is the package prefix.
+ * Second arg is the name of the class minus the prefix.
+ *
+ * This does some behind-the-scenes magic so we can
+ * access howto_square_ff from python as howto.square_ff
+ */
+GR_SWIG_BLOCK_MAGIC(howto,square_ff);
+
+howto_square_ff_sptr howto_make_square_ff ();
+
+class howto_square_ff : public gr_block
+{
+private:
+  howto_square_ff ();
+};
diff --git a/gr-howto-write-a-block/version.sh b/gr-howto-write-a-block/version.sh
new file mode 100644 (file)
index 0000000..b2cad87
--- /dev/null
@@ -0,0 +1,4 @@
+MAJOR_VERSION=3
+API_COMPAT=3
+MINOR_VERSION=git
+MAINT_VERSION=
index 33061d3ab41ce59cf706e6bacf419b7692b3e686..ca4a54fb08f6e050cbd20e1c0f5180c65056dbdb 100644 (file)
@@ -4,3 +4,5 @@
 /.deps
 /msdd.cc
 /msdd.py
+/msdd_rs.cc
+/msdd_rs.py
index 0865d40de7c96d5f51cc87b3331463e862bb9ddd..9ae4efb0a6672bce6589f4f7326e58f77dc68a58 100644 (file)
@@ -28,26 +28,40 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \
 grinclude_HEADERS =                    \
        msdd_source_simple.h            \
        msdd_buffer_copy_behaviors.h    \
-       msdd6000.h
+       msdd6000.h                      \
+       msdd_rs_source_simple.h         \
+       msdd6000_rs.h
 
-lib_LTLIBRARIES = libgnuradio-msdd6000.la
+lib_LTLIBRARIES = libgnuradio-msdd6000.la \
+       libgnuradio-msdd6000_rs.la
 
 libgnuradio_msdd6000_la_SOURCES =      \
        msdd_source_simple.cc           \
        msdd6000.cc
 
+
+libgnuradio_msdd6000_rs_la_SOURCES =   \
+       msdd_rs_source_simple.cc                \
+       msdd6000_rs.cc
+
 libgnuradio_msdd6000_la_LIBADD =       \
        $(GNURADIO_CORE_LA)
 
 libgnuradio_msdd6000_la_LDFLAGS =      \
        $(NO_UNDEFINED)
 
+libgnuradio_msdd6000_rs_la_LIBADD =    \
+       $(GNURADIO_CORE_LA)
+
+libgnuradio_msdd6000_rs_la_LDFLAGS =   \
+       $(NO_UNDEFINED)
+
 if PYTHON
 #################################
 # SWIG interface and library
 
 TOP_SWIG_IFILES =                      \
-       msdd.i
+       msdd.i msdd_rs.i
 
 # Install so that they end up available as:
 #   import gnuradio.msdd
@@ -56,10 +70,16 @@ TOP_SWIG_IFILES =                   \
 msdd_pythondir_category =              \
        gnuradio
 
+msdd_rs_pythondir_category =   \ 
+       gnuradio
+
 # additional libraries for linking with the SWIG-generated library
 msdd_la_swig_libadd =                  \
        libgnuradio-msdd6000.la
 
+msdd_rs_la_swig_libadd =                       \
+       libgnuradio-msdd6000_rs.la
+
 include $(top_srcdir)/Makefile.swig
 
 # add some of the variables generated inside the Makefile.swig.gen
index 5c2920230f6f9ec2c22447d0c247f183eac160e0..ced3979f7fcb68f12f032478d015873b66adb91a 100644 (file)
 ## this has to be done in the including Makefile.am -before-
 ## Makefile.swig is included.
 
+
 msdd_pythondir_category ?= gnuradio/msdd
 msdd_pylibdir_category ?= $(msdd_pythondir_category)
 msdd_pythondir = $(pythondir)/$(msdd_pythondir_category)
 msdd_pylibdir = $(pyexecdir)/$(msdd_pylibdir_category)
 
+msdd_rs_pythondir_category ?= gnuradio/msdd_rs
+msdd_rs_pylibdir_category ?= $(msdd_rs_pythondir_category)
+msdd_rs_pythondir = $(pythondir)/$(msdd_rs_pythondir_category)
+msdd_rs_pylibdir = $(pyexecdir)/$(msdd_rs_pylibdir_category)
+
 ## SWIG headers are always installed into the same directory.
 
 msdd_swigincludedir = $(swigincludedir)
+msdd_rs_swigincludedir = $(swigincludedir)
 
 ## This is a template file for a "generated" Makefile addition (in
 ## this case, "Makefile.swig.gen").  By including the top-level
@@ -63,6 +70,7 @@ msdd_swigincludedir = $(swigincludedir)
 ## the SWIG-generated files will be removed from the distribution.
 
 STAMPS += $(DEPDIR)/msdd-generate-*
+STAMPS += $(DEPDIR)/msdd_rs-generate-*
 
 ## Other cleaned files: dependency files generated by SWIG or this Makefile
 
@@ -72,27 +80,40 @@ 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 += msdd.py msdd.cc
+swig_built_sources += msdd.py msdd_rs.py msdd.cc msdd_rs.cc
 
 ## Various SWIG variables.  These can be overloaded in the including
 ## Makefile.am by setting the variable value there, then including
 ## Makefile.swig .
 
 msdd_swiginclude_HEADERS =             \
-       msdd.i                  \
+       msdd.i                          \
+       msdd_rs.i                       \
        $(msdd_swiginclude_headers)
 
 msdd_pylib_LTLIBRARIES =               \
        _msdd.la
 
+msdd_rs_pylib_LTLIBRARIES =            \
+        _msdd_rs.la
+
 _msdd_la_SOURCES =                     \
-       msdd.cc                 \
+       msdd.cc                         \
        $(msdd_la_swig_sources)
 
+_msdd_rs_la_SOURCES =                          \
+    msdd_rs.cc                                 \
+    $(msdd_la_swig_sources)
+
+
 _msdd_la_LIBADD =                      \
        $(STD_SWIG_LA_LIB_ADD)          \
        $(msdd_la_swig_libadd)
 
+_msdd_rs_la_LIBADD =                           \
+    $(STD_SWIG_LA_LIB_ADD)             \
+    $(msdd_rs_la_swig_libadd)
+
 _msdd_la_LDFLAGS =                     \
        $(STD_SWIG_LA_LD_FLAGS)         \
        $(msdd_la_swig_ldflags)
@@ -101,10 +122,22 @@ _msdd_la_CXXFLAGS =                       \
        $(STD_SWIG_CXX_FLAGS)           \
        $(msdd_la_swig_cxxflags)
 
+_msdd_rs_la_LDFLAGS =                          \
+    $(STD_SWIG_LA_LD_FLAGS)            \
+    $(msdd_rs_la_swig_ldflags)
+
+_msdd_rs_la_CXXFLAGS =                         \
+    $(STD_SWIG_CXX_FLAGS)              \
+    $(msdd_rs_la_swig_cxxflags)
+
 msdd_python_PYTHON =                   \
-       msdd.py                 \
+       msdd.py                         \
        $(msdd_python)
 
+msdd_rs_python_PYTHON =                        \
+    msdd_rs.py                                 \
+    $(msdd_rs_python)
+
 ## Entry rule for running SWIG
 
 msdd.h msdd.py msdd.cc: msdd.i
@@ -251,9 +284,161 @@ $(DEPDIR)/msdd-generate-stamp:
 ##
        touch $(DEPDIR)/msdd-generate-stamp
 
+
+
+
+
+
+msdd_rs.h msdd_rs.py msdd_rs.cc: msdd_rs.i
+## This rule will get called only when MAKE decides that one of the
+## targets needs to be created or re-created, because:
+##
+## * The .i file is newer than any or all of the generated files;
+##
+## * Any or all of the .cc, .h, or .py files does not exist and is
+##   needed (in the case this file is not needed, the rule for it is
+##   ignored); or
+##
+## * Some SWIG-based dependecy of the .cc file isn't met and hence the
+##   .cc file needs be be regenerated.  Explanation: Because MAKE
+##   knows how to handle dependencies for .cc files (regardless of
+##   their name or extension), then the .cc file is used as a target
+##   instead of the .i file -- but with the dependencies of the .i
+##   file.  It is this last reason why the line:
+##
+##             if test -f $@; then :; else
+##
+##   cannot be used in this case: If a .i file dependecy is not met,
+##   then the .cc file needs to be rebuilt.  But if the stamp is newer
+##   than the .cc file, and the .cc file exists, then in the original
+##   version (with the 'test' above) the internal MAKE call will not
+##   be issued and hence the .cc file will not be rebuilt.
+##
+## Once execution gets to here, it should always proceed no matter the
+## state of a stamp (as discussed in link above).  The
+## $(DEPDIR)/msdd-generate stuff is used to allow for parallel
+## builds to "do the right thing".  The stamp has no relationship with
+## either the target files or dependency file; it is used solely for
+## the protection of multiple builds during a given call to MAKE.
+##
+## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM
+## (15).  At a caught signal, the quoted command will be issued before
+## exiting.  In this case, remove any stamp, whether temporary of not.
+## The trap is valid until the process exits; the process includes all
+## commands appended via "\"s.
+##
+       trap 'rm -rf $(DEPDIR)/msdd_rs-generate-*' 1 2 13 15; \
+##
+## Create a temporary directory, which acts as a lock.  The first
+## process to create the directory will succeed and issue the MAKE
+## command to do the actual work, while all subsequent processes will
+## fail -- leading them to wait for the first process to finish.
+##
+       if mkdir $(DEPDIR)/msdd_rs-generate-lock 2>/dev/null; then \
+##
+## This code is being executed by the first process to succeed in
+## creating the directory lock.
+##
+## Remove the stamp associated with this filename.
+##
+               rm -f $(DEPDIR)/msdd_rs-generate-stamp; \
+##
+## Tell MAKE to run the rule for creating this stamp.
+##
+               $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/msdd_rs-generate-stamp WHAT=$<; \
+##
+## Now that the .cc, .h, and .py files have been (re)created from the
+## .i file, future checking of this rule during the same MAKE
+## execution will come back that the rule doesn't need to be executed
+## because none of the conditions mentioned at the start of this rule
+## will be positive.  Remove the the directory lock, which frees up
+## any waiting process(es) to continue.
+##
+               rmdir $(DEPDIR)/msdd_rs-generate-lock; \
+       else \
+##
+## This code is being executed by any follower processes while the
+## directory lock is in place.
+##
+## Wait until the first process is done, testing once per second.
+##
+               while test -d $(DEPDIR)/msdd_rs-generate-lock; do \
+                       sleep 1; \
+               done; \
+##
+## Succeed if and only if the first process succeeded; exit this
+## process returning the status of the generated stamp.
+##
+               test -f $(DEPDIR)/msdd_rs-generate-stamp; \
+               exit $$?; \
+       fi;
+
+$(DEPDIR)/msdd_rs-generate-stamp:
+## This rule will be called only by the first process issuing the
+## above rule to succeed in creating the lock directory, after
+## removing the actual stamp file in order to guarantee that MAKE will
+## execute this rule.
+##
+## Call SWIG to generate the various output files; special
+## post-processing on 'mingw32' host OS for the dependency file.
+##
+       if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(msdd_rs_swig_args) \
+               -MD -MF $(DEPDIR)/msdd_rs.Std \
+               -module msdd_rs -o msdd_rs.cc $(WHAT); then \
+           if test $(host_os) = mingw32; then \
+               $(RM) $(DEPDIR)/msdd_rs.Sd; \
+               $(SED) 's,\\\\,/,g' < $(DEPDIR)/msdd_rs.Std \
+                       > $(DEPDIR)/msdd_rs.Sd; \
+               $(RM) $(DEPDIR)/msdd_rs.Std; \
+               $(MV) $(DEPDIR)/msdd_rs.Sd $(DEPDIR)/msdd_rs.Std; \
+           fi; \
+       else \
+           $(RM) $(DEPDIR)/msdd_rs.S*; exit 1; \
+       fi;
+##
+## Mess with the SWIG output .Std dependency file, to create a
+## dependecy file valid for the input .i file: Basically, simulate the
+## dependency file created for libraries by GNU's libtool for C++,
+## where all of the dependencies for the target are first listed, then
+## each individual dependency is listed as a target with no further
+## dependencies.
+##
+## (1) remove the current dependency file
+##
+       $(RM) $(DEPDIR)/msdd_rs.d
+##
+## (2) Copy the whole SWIG file:
+##
+       cp $(DEPDIR)/msdd_rs.Std $(DEPDIR)/msdd_rs.d
+##
+## (3) all a carriage return to the end of the dependency file.
+##
+       echo "" >> $(DEPDIR)/msdd_rs.d
+##
+## (4) from the SWIG file, remove the first line (the target); remove
+##     trailing " \" and " " from each line.  Append ":" to each line,
+##     followed by 2 carriage returns, then append this to the end of
+##     the dependency file.
+##
+       $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/msdd_rs.Std | \
+               awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/msdd_rs.d
+##
+## (5) remove the SWIG-generated file
+##
+       $(RM) $(DEPDIR)/msdd_rs.Std
+##
+## Create the stamp for this filename generation, to signal success in
+## executing this rule; allows other threads waiting on this process
+## to continue.
+##
+       touch $(DEPDIR)/msdd_rs-generate-stamp
+
 # KLUDGE: Force runtime include of a SWIG dependency file.  This is
 # not guaranteed to be portable, but will probably work.  If it works,
 # we have accurate dependencies for our swig stuff, which is good.
 
+
 @am__include@ @am__quote@./$(DEPDIR)/msdd.d@am__quote@
+@am__include@ @am__quote@./$(DEPDIR)/msdd_rs.d@am__quote@
+
 
diff --git a/gr-msdd6000/src/msdd6000_rs.cc b/gr-msdd6000/src/msdd6000_rs.cc
new file mode 100644 (file)
index 0000000..d78f2b4
--- /dev/null
@@ -0,0 +1,286 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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.
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <msdd6000_rs.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#define DEBUG(A)       printf("=debug=> %s\n", A)
+
+static void 
+optimize_socket(int socket);
+
+/*
+ * Holds types that need autoconf help.  They're here and not in the .h file because
+ * here we've got access to config.h
+ */
+class MSDD6000_RS::detail {
+public:
+  struct sockaddr_in d_sockaddr;
+};
+
+
+MSDD6000_RS::MSDD6000_RS(char* addr)
+  : d_detail(new MSDD6000_RS::detail())
+{
+       d_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
+       
+       optimize_socket(d_sock);
+       
+       
+       // set up remote sockaddr
+//     int s = inet_aton(addr, &d_adx); 
+       d_detail->d_sockaddr.sin_family = AF_INET;
+       d_detail->d_sockaddr.sin_port = htons(10000);
+       int s = inet_aton(addr, &d_detail->d_sockaddr.sin_addr);
+       
+       // set up local sockaddr
+       struct in_addr d_myadx;
+       struct sockaddr_in d_mysockaddr;
+       short int port = 10010;
+       d_myadx.s_addr = INADDR_ANY;
+       d_mysockaddr.sin_family = AF_INET;
+       d_mysockaddr.sin_port = htons(port);
+       memcpy(&d_mysockaddr.sin_addr.s_addr, &d_myadx.s_addr, sizeof(in_addr));
+       //d_sockaddr.sin_addr = INADDR_ANY;
+       s = bind(d_sock, (const sockaddr*) &d_mysockaddr, sizeof(d_mysockaddr));
+       
+       // set default values
+       //d_decim = 2;
+       d_ddc_gain      = 2;
+       d_rf_attn       = 0;
+       d_fc_mhz        = 3500;
+       d_offset_hz = 0;
+        d_ddc_gain  = 0;
+        d_ddc_sample_rate_khz = 25600;
+        d_ddc_bw_khz          = 25600;
+        d_start               = 0;
+       d_state = STATE_STOPPED;
+}
+
+MSDD6000_RS::~MSDD6000_RS()
+{
+       //printf("MSDD6000_RS::Destructing\n");
+       close(d_sock);
+}
+
+
+static void
+optimize_socket(int socket){
+#define BANDWIDTH      1000000000/8
+#define DELAY          0.5
+       int ret;
+
+       int sock_buf_size = static_cast<int>(2*BANDWIDTH*DELAY);
+       char textbuf[512];
+       snprintf(textbuf, sizeof(textbuf), "%d", sock_buf_size);
+       printf("sock_buf_size = %d\n", sock_buf_size);
+       
+       ret = setsockopt(socket, SOL_SOCKET, SO_SNDBUF,
+                        &sock_buf_size, sizeof(sock_buf_size));
+
+       ret = setsockopt(socket, SOL_SOCKET, SO_RCVBUF,
+                        &sock_buf_size, sizeof(sock_buf_size));
+       
+       int uid = getuid();
+       if(uid!=0){
+               printf(" ****** COULD NOT OPTIMIZE SYSTEM NETWORK PARAMETERS BECAUSE YOU ARE NOT RUNNING AS ROOT *******\n ****** YOUR MSDD6000_RS RECIEVER PERFORMANCE IS GOING TO BE TERRIBLE *******\n");
+               return;
+       }
+
+
+       // SET UP SOME SYSTEM WIDE TCP SOCKET PARAMETERS
+       // FIXME seems like kind of a big hammer.  Are you sure you need this?
+       FILE* fd = fopen("/proc/sys/net/core/netdev_max_backlog", "w");
+       if (fd){
+         fwrite("10000", 1, strlen("10000"), fd);
+         fclose(fd);
+       }
+
+       fd = fopen("/proc/sys/net/core/rmem_max", "w");
+       if (fd){
+         fwrite(textbuf, 1, strlen(textbuf), fd);
+         fclose(fd);
+       }
+
+       fd = fopen("/proc/sys/net/core/wmem_max", "w");
+       if (fd){
+         fwrite(textbuf, 1, strlen(textbuf), fd);
+         fclose(fd);
+       }
+
+       // just incase these were rejected before because of max sizes...
+
+       ret = setsockopt( socket, SOL_SOCKET, SO_SNDBUF,
+                   (char *)&sock_buf_size, sizeof(sock_buf_size) );
+
+       ret = setsockopt( socket, SOL_SOCKET, SO_RCVBUF,
+                   (char *)&sock_buf_size, sizeof(sock_buf_size) );
+       
+}
+
+
+//void MSDD6000_RS::set_decim(int decim_pow2){
+//     DEBUG("SETTING NEW DECIM");
+//     d_decim = decim_pow2;
+//
+//     if(d_state==STATE_STARTED)
+//             send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz);
+//}
+
+void MSDD6000_RS::set_rf_attn(int attn){
+       DEBUG("SETTING NEW RF ATTN");
+       d_rf_attn = attn;
+       if(d_state==STATE_STARTED)
+               send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start);
+}
+
+void MSDD6000_RS::set_ddc_gain(int gain){
+       DEBUG("SETTING NEW DDC GAIN");
+       d_ddc_gain = gain;
+       if(d_state==STATE_STARTED)
+               send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start);
+}
+
+void MSDD6000_RS::set_fc(int center_mhz, int offset_hz){
+       DEBUG("SETTING NEW FC");
+       d_fc_mhz = center_mhz;
+       d_offset_hz = offset_hz;
+       
+       send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start);
+//     if(d_state==STATE_STARTED)
+//             send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz);
+//             send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start);
+//             
+}
+
+void MSDD6000_RS::set_ddc_samp_rate(float sample_rate_khz){
+       DEBUG("SETTING NEW SAMPLE RATE");
+       d_ddc_sample_rate_khz = sample_rate_khz;
+       send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start);               
+}
+
+void MSDD6000_RS::set_ddc_bw(float bw_khz){
+       DEBUG("SETTING NEW DDC BW");
+       d_ddc_bw_khz = bw_khz;
+       send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start);               
+}
+
+void MSDD6000_RS::start(){
+    send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start);       
+    return;
+}
+
+void MSDD6000_RS::stop(){
+       // new request with 0 decim tells it to halt
+       stop_data();
+}
+
+
+int MSDD6000_RS::start_data(){
+       d_start = 1;
+       send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start);       
+       d_state = STATE_STARTED;
+    return 0;
+       }
+
+
+int MSDD6000_RS::stop_data(){
+       // new request with 0 decim tells it to halt
+       d_start = 0;
+       send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start);       
+       d_state = STATE_STOPPED;
+    return 0;
+       }
+       
+/* Query functions */
+float MSDD6000_RS::pull_ddc_samp_rate(){
+  return d_ddc_sample_rate_khz;
+}
+float MSDD6000_RS::pull_ddc_bw(){
+       return d_ddc_bw_khz;
+}
+
+float MSDD6000_RS::pull_rx_freq(){
+       return d_fc_mhz;
+}
+int   MSDD6000_RS::pull_ddc_gain(){
+       return d_ddc_gain;
+}
+
+int   MSDD6000_RS::pull_rf_atten(){
+       return d_rf_attn;
+}
+
+
+void MSDD6000_RS::send_request(float freq_mhz, float rf_attn, float ddc_gain, float ddc_offset_hz, float ddc_samp_rate_khz, float ddc_input_bw_khz, float ddc_start){
+       static char buff[512];
+       // Send MSDD6000_RS control frame.
+       sprintf(buff, "%f %f %f %f %f %f %f\n",freq_mhz, rf_attn, ddc_gain, ddc_offset_hz, ddc_samp_rate_khz, ddc_input_bw_khz, ddc_start); //ddc_dec, ddc_offset_hz);
+       printf("sending: %s\n", buff);
+        int flags = 0;
+       sendto( d_sock, buff, strlen(buff)+1, flags,
+               (const sockaddr*)&(d_detail->d_sockaddr), sizeof(d_detail->d_sockaddr));
+       }
+
+
+int  MSDD6000_RS::read(char* buf, int size){
+       int flags = 0;
+       return recv(d_sock, buf, size, flags);
+       }
+       
+int MSDD6000_RS::parse_control(char* buf, int size){
+    //packet_len = sprintf(&txbuff[6], "%f %f %f %f %f %f %f",downsamp,ddc_dec_rate,ddc_step_int,ddc_step_frac,ddc_samp_rate_khz,ddc_input_bw_khz,ddc_start);    
+
+    float downsamp;
+    float ddc_dec_rate;
+    float ddc_step_int;
+    float ddc_step_frac;
+    float ddc_samp_rate_khz;
+    float ddc_input_bw_khz;
+    float ddc_start;
+
+    sscanf(&buf[6],"%f %f %f %f %f %f %f",&downsamp,&ddc_dec_rate,&ddc_step_int,&ddc_step_frac,&ddc_samp_rate_khz,&ddc_input_bw_khz,&ddc_start);
+  
+    // pull off sample rate  
+    d_ddc_sample_rate_khz = ddc_samp_rate_khz;
+    printf("Sample Rate %f\n",d_ddc_sample_rate_khz);
+    // pull off bw
+    d_ddc_bw_khz  =  ddc_input_bw_khz;
+    printf("BW %f\n", d_ddc_bw_khz);
+    return 0;
+}
+
+
diff --git a/gr-msdd6000/src/msdd6000_rs.h b/gr-msdd6000/src/msdd6000_rs.h
new file mode 100644 (file)
index 0000000..4be4624
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef MSDD_RS__RS_6000_H
+#define MSDD_RS__RS_6000_H
+
+#include <boost/scoped_ptr.hpp>
+
+class MSDD6000_RS {
+  class detail;
+
+  //! holds objects with system dependent types
+  boost::scoped_ptr<detail>    d_detail;  
+
+public:
+
+  enum state {
+    STATE_STOPPED, STATE_STARTED
+  };
+
+  MSDD6000_RS(char* ip_addr);
+  ~MSDD6000_RS();
+
+  /* set functions -- sets digitizer parameters */
+ // void set_output(int mode, void* arg);
+
+  void set_rf_attn(int attn);
+  void set_ddc_gain(int gain);
+  void set_fc(int center_mhz, int offset_hz);
+  void set_ddc_samp_rate(float sample_rate_khz);
+  void set_ddc_bw(float bw_khz);
+
+  void start();
+  void stop();
+
+  /* function starts the flow of data from the digitizer */
+  int start_data();
+  /* function stops the flow of data from the digitizer */
+  int stop_data();
+  
+  /* query functions -- queries digitizer 'actual' parameters */
+  float pull_ddc_samp_rate();
+  float pull_ddc_bw();
+  float pull_rx_freq();
+  int   pull_ddc_gain();
+  int   pull_rf_atten();
+       
+  void send_request(float,float,float,float,float,float,float);        
+  int read(char*, int);
+
+  int parse_control(char*, int);
+
+private:
+  // parameters for a receiver object.
+  int   d_fc_mhz;
+  int   d_offset_hz;
+  int   d_rf_attn;
+  int   d_ddc_gain;
+  float d_ddc_sample_rate_khz;
+  float d_ddc_bw_khz;
+  int   d_start;
+  int   d_sock;
+  state d_state;
+
+};
+
+
+#endif
diff --git a/gr-msdd6000/src/msdd_rs.i b/gr-msdd6000/src/msdd_rs.i
new file mode 100644 (file)
index 0000000..16a1bec
--- /dev/null
@@ -0,0 +1,93 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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 "gnuradio.i"  // the common stuff
+
+%{
+#include "msdd_rs_source_simple.h"
+%}
+
+
+GR_SWIG_BLOCK_MAGIC(msdd_rs,source_simple)
+
+msdd_rs_source_simple_sptr
+msdd_rs_make_source_simple (
+       const char *src,
+       unsigned short port_src
+       );
+
+class msdd_rs_source_simple : public gr_sync_block {
+  protected:
+    msdd_rs_source_simple(
+       const char *src,
+       unsigned short port_src
+       );
+  public:
+    ~msdd_rs_source_c(); 
+  int work (int noutput_items,
+      gr_vector_const_void_star &input_items,
+      gr_vector_void_star &output_items);
+
+  bool start();
+  bool stop();
+
+  /* function starts the flow of data */
+  int start_data();
+
+  /* function stops the flow of data */
+  int stop_data();
+
+  long pull_adc_freq();
+  /* Request the current ddc sample rate */
+  float pull_ddc_samp_rate();
+  /* Request the current ddc bandwidth */
+  float pull_ddc_bw();
+  /* Request the current rx freq */
+  float pull_rx_freq();
+  /* Request current ddc gain */
+  int pull_ddc_gain();
+  /* Request current RF attenuation */
+  int pull_rf_atten();
+
+
+  /*  int decim_rate(); */
+  gr_vector_int gain_range();
+  gr_vector_float freq_range();
+
+  /* Set Functions */
+  /*  bool set_decim_rate(unsigned int); */
+  bool set_rx_freq(double); /* set_rx_freq(int,double); */
+  /*  bool set_pga(int,double); */
+
+  bool set_ddc_gain(double);
+  /* Set desired sample rate of MSDD6000 -- Note bounds checking is 
+  done by the module and it will return the value actually used in the hardware. */
+  bool set_ddc_samp_rate(double);
+  /* Set desired input BW of MSDD6000 -- Note bounds checking is 
+  // done by the module and it will return the value actually used in the hardware. */
+  bool set_ddc_bw(double);
+
+  bool set_rf_atten(double);
+
+
+  };
diff --git a/gr-msdd6000/src/msdd_rs_source_simple.cc b/gr-msdd6000/src/msdd_rs_source_simple.cc
new file mode 100644 (file)
index 0000000..2ffc642
--- /dev/null
@@ -0,0 +1,237 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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.
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <msdd_rs_source_simple.h>
+#include <gr_io_signature.h>
+#include <string.h>
+#include <cstdio>
+
+
+msdd_rs_source_simple_sptr
+msdd_rs_make_source_simple ( const char *src, unsigned short port_src) 
+{
+  return msdd_rs_source_simple_sptr (new msdd_rs_source_simple ( src, port_src)); 
+}
+
+
+msdd_rs_source_simple::msdd_rs_source_simple (
+                   const char *src, 
+                   unsigned short port_src) 
+               : gr_sync_block("MSDD_RS_SOURCE_SIMPLE",
+                               gr_make_io_signature (0,0,0),
+                               gr_make_io_signature (1, 1, sizeof (short))),
+                  rcv(new MSDD6000_RS((char*) src)), d_lastseq(0)
+{
+}
+
+msdd_rs_source_simple::~msdd_rs_source_simple ()
+{
+}
+
+
+int
+msdd_rs_source_simple::work (int noutput_items,
+                         gr_vector_const_void_star &input_items,
+                         gr_vector_void_star &output_items)
+{
+       
+#define BUF_LEN        (366*sizeof(short)*2 + 6)
+
+       float* out1 =(float*) output_items[0];
+
+       char buffer[BUF_LEN];
+       /* Read a buffer out -- looking at UDP payload at this point.*/
+       rcv->read( &buffer[0], BUF_LEN );
+       
+       int seq = *((int*) &buffer[2]);
+       char type = buffer[0];
+       //printf("Sequence %d\n",seq);
+       
+       // FIXME get rid of these magic 366's!
+       if(d_lastseq == -366)
+       {
+        if (type != 0){
+            /* Received control packet -- parse and update locally stored parameters */
+            printf("Parsing control Packet\n");
+            rcv->parse_control(&buffer[0], seq);       
+        }
+        else{   
+            // not started case
+            if(seq == 0){
+                d_lastseq = 0;
+            } 
+            else 
+            {
+                // THROW AWAY SAMPLES WE ARE NOT STARTED YET!
+                return 0;
+            }
+        }
+       } 
+       // Started case
+       else 
+       {
+        if (type != 0){
+                        /* Received control packet -- parse and update locally stored parameters */
+            printf("Parsing control Packet\n");
+            rcv->parse_control(&buffer[0], seq);       
+        }
+            
+        else {
+            int samples_missed = seq - d_lastseq - 366;
+            if(samples_missed > 0)
+            {
+                printf("dropped %d samples.\n", samples_missed);
+            }
+            d_lastseq = seq;
+        }
+       }
+       
+       if(noutput_items< 366*2){
+               printf("NOT ENOUGH SPACE IN OUTPUT BUFFER!!! >:-(\n");
+               }
+       
+       memcpy(&out1[0], &buffer[6], BUF_LEN - 6);
+       
+//     for(int i = 0; i < 366*2; i++){
+//             out1[i] = (float)  (*((short*) &buffer[6+2*i]) );
+//     }
+       
+       return 366*2;
+}
+
+//bool msdd_rs_source_simple::set_decim_rate(unsigned int rate)
+//{
+//     // FIXME seems buggy.  How about a floor or ceil?
+//        rcv->set_decim((int) log2(rate));
+//     return true;
+//}
+
+bool msdd_rs_source_simple::set_rx_freq(double freq)
+{
+       long new_fc = (long)freq;
+       rcv->set_fc( new_fc/1000000, new_fc%1000000);
+       return true;
+}
+
+
+bool msdd_rs_source_simple::set_ddc_gain(double gain)
+{
+       if(gain < 0 || gain > 7){ // only 3 bits available.
+               printf("GAIN IS OUTSIDE ACCEPTABLE RANGE!\n");
+               return false;
+       }
+       //decimation gain
+       rcv->set_ddc_gain((int)gain);
+       return true;
+}
+
+// Set desired sample rate of MSDD6000 -- Note bounds checking is 
+// done by the module and it will return the value actually used in the hardware.
+bool msdd_rs_source_simple::set_ddc_samp_rate(double rate)
+{
+       rcv->set_ddc_samp_rate((float) rate);
+       return true;            
+}
+
+// Set desired input BW of MSDD6000 -- Note bounds checking is 
+// done by the module and it will return the value actually used in the hardware.
+bool msdd_rs_source_simple::set_ddc_bw(double bw)
+{
+       rcv->set_ddc_bw((float) bw);
+       return true;            
+}
+
+bool msdd_rs_source_simple::set_rf_atten(double rf_atten)
+{
+        rcv->set_rf_attn((int) rf_atten);
+        return true;
+}
+
+bool msdd_rs_source_simple::start()
+{
+       rcv->start();
+    rcv->stop_data();
+       return true;
+}
+
+bool msdd_rs_source_simple::stop()
+{
+       rcv->stop();
+       return true;
+}
+
+int msdd_rs_source_simple::start_data()
+{
+       return rcv->start_data();
+}
+
+int msdd_rs_source_simple::stop_data()
+{
+       return rcv->stop_data();
+}
+
+/* Query functions */
+long msdd_rs_source_simple::pull_adc_freq(){
+       return 102400000;
+}
+
+/* Request the current ddc sample rate */
+float msdd_rs_source_simple::pull_ddc_samp_rate(){
+       return(rcv->pull_ddc_samp_rate());
+}
+
+/* Request the current ddc bandwidth */
+float msdd_rs_source_simple::pull_ddc_bw(){
+       return(rcv->pull_ddc_bw());
+       
+}
+
+/* Request the current rx freq */
+float msdd_rs_source_simple::pull_rx_freq(){
+       return(rcv->pull_rx_freq());
+}
+
+/* Request current ddc gain */
+int msdd_rs_source_simple::pull_ddc_gain(){
+       return(rcv->pull_ddc_gain());
+}
+
+/* Request current RF attenuation */
+int msdd_rs_source_simple::pull_rf_atten(){
+       return(rcv->pull_rf_atten());
+}
+
+std::vector<int> msdd_rs_source_simple::gain_range(){
+       static std::vector<int> r;
+       r.push_back(0);
+       r.push_back(12);
+       return r;
+}
+
+std::vector<float> msdd_rs_source_simple::freq_range(){
+       std::vector<float> r;
+       r.push_back(30.0*1000*1000);
+       r.push_back(6.0*1000*1000*1000);
+       return r;
+}
diff --git a/gr-msdd6000/src/msdd_rs_source_simple.h b/gr-msdd6000/src/msdd_rs_source_simple.h
new file mode 100644 (file)
index 0000000..f320cbb
--- /dev/null
@@ -0,0 +1,87 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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_MSDD_RS_SOURCE_SIMPLE_H
+#define INCLUDED_MSDD_RS_SOURCE_SIMPLE_H
+
+#include <gr_sync_block.h>
+#include <msdd6000_rs.h>
+#include <boost/scoped_ptr.hpp>
+
+class msdd_rs_source_simple;
+typedef boost::shared_ptr<msdd_rs_source_simple> msdd_rs_source_simple_sptr;
+
+
+// public shared_ptr constructor
+
+msdd_rs_source_simple_sptr msdd_rs_make_source_simple ( const char *src, unsigned short port_src);
+
+
+class msdd_rs_source_simple : public gr_sync_block {
+ private:
+  friend msdd_rs_source_simple_sptr
+  msdd_rs_make_source_simple ( const char *src, unsigned short port_src);
+
+  boost::scoped_ptr<MSDD6000_RS> rcv;
+  int d_lastseq;
+
+ protected:
+  msdd_rs_source_simple (const char *src, unsigned short port_src);
+
+ public:
+  ~msdd_rs_source_simple ();
+  bool stop();
+  bool start();
+
+  /* function starts the flow of data from the digitizer */
+  int start_data();
+  /* function stops the flow of data from the digitizer */
+  int stop_data();
+
+  // Do not need this //
+//  bool set_decim_rate(unsigned int);
+  /* Adding functions for setting the sample rate and
+  * receiver bandwidth
+  */
+  
+  /* hardware commands -- change current state of digitizer */
+  bool set_ddc_samp_rate(double);
+  bool set_ddc_bw(double);
+  
+  bool set_rx_freq(double);
+  bool set_ddc_gain(double);
+  bool set_rf_atten(double);
+
+  int work(int, gr_vector_const_void_star&, gr_vector_void_star&);
+  
+  /* Query methods -- query current state of digitizer */
+  long  pull_adc_freq();
+  float pull_ddc_samp_rate();
+  float pull_ddc_bw();
+  float pull_rx_freq();
+  int   pull_ddc_gain();
+  int   pull_rf_atten();
+  
+  /* Pulling back gain and frequency ranges */
+  std::vector<int> gain_range();
+  std::vector<float> freq_range();
+};
+
+#endif /* INCLUDED_MSDD_RS__RS__SOURCE_C_H */
diff --git a/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py b/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py
new file mode 100755 (executable)
index 0000000..4855375
--- /dev/null
@@ -0,0 +1,350 @@
+#!/usr/bin/env python
+#
+# 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.
+# 
+
+from gnuradio import gr
+from gnuradio import msdd_rs
+from gnuradio import eng_notation
+from gnuradio.eng_option import eng_option
+from gnuradio.qtgui import qtgui
+from optparse import OptionParser
+import sys,time
+
+try:
+    from gnuradio.qtgui import qtgui
+    from PyQt4 import QtGui, QtCore
+    import sip
+except ImportError:
+    print "Please install gr-qtgui."
+    sys.exit(1)
+
+try:
+    from msdd_display_qtgui import Ui_MainWindow
+except ImportError:
+    print "Error: could not find msdd_display_qtgui.py:"
+    print "\t\"pyuic4 msdd_display_qtgui.ui -o msdd_display_qtgui.py\""
+    sys.exit(1)
+
+
+# ////////////////////////////////////////////////////////////////////
+#        Define the QT Interface and Control Dialog
+# ////////////////////////////////////////////////////////////////////
+
+
+class main_window(QtGui.QMainWindow):
+    def __init__(self, snk, fg, parent=None):
+
+        QtGui.QWidget.__init__(self, parent)
+        self.gui = Ui_MainWindow()
+        self.gui.setupUi(self)
+
+        self.fg = fg
+
+        # Add the qtsnk widgets to the layout box
+        self.gui.sinkLayout.addWidget(snk)
+
+        self.gui.dcGainEdit.setText(QtCore.QString("%1").arg(0.001))
+
+        # Connect up some signals
+        self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"),
+                     self.pauseFg)
+        self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"),
+                     self.frequencyEditText)
+        self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"),
+                     self.gainEditText)
+        self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"),
+                     self.bandwidthEditText)
+        self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"),
+                     self.amplifierEditText)
+
+        self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"),
+                     self.saveData)
+        self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save)
+
+        self.connect(self.gui.dcGainEdit, QtCore.SIGNAL("editingFinished()"),
+                     self.dcGainEditText)
+        self.connect(self.gui.dcCancelCheckBox, QtCore.SIGNAL("clicked(bool)"),
+                     self.dcCancelClicked)
+
+    def pauseFg(self):
+        if(self.gui.pauseButton.text() == "Pause"):
+            self.fg.stop()
+            self.fg.wait()
+            self.fg.stop_data()
+            self.gui.pauseButton.setText("Unpause")
+        else:
+            self.fg.start()
+            self.fg.start_data()
+            self.gui.pauseButton.setText("Pause")
+      
+
+    # Functions to set the values in the GUI
+    def set_frequency(self, freq):
+        self.freq = freq
+        sfreq = eng_notation.num_to_str(self.freq)
+        self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq))
+        
+    def set_gain(self, gain):
+        self.gain = gain
+        self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain))
+
+    def set_bandwidth(self, bw):
+        self.bw = bw
+        sbw = eng_notation.num_to_str(self.bw)
+        self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw))
+
+    def set_amplifier(self, amp):
+        self.amp = amp
+        self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp))
+
+
+    # Functions called when signals are triggered in the GUI
+    def frequencyEditText(self):
+        try:
+            freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) 
+            self.fg.set_frequency(freq)
+            self.freq = freq
+        except RuntimeError:
+            pass
+
+    def gainEditText(self):
+        try:
+            gain = float(self.gui.gainEdit.text())
+            self.fg.set_gain(gain)
+            self.gain = gain
+        except ValueError:
+            pass
+                
+    def bandwidthEditText(self):
+        try:
+            bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii())
+            self.fg.set_bandwidth(bw)
+            self.bw = bw
+        except ValueError:
+            pass
+        
+    def amplifierEditText(self):
+        try:
+            amp = float(self.gui.amplifierEdit.text())
+            self.fg.set_amplifier_gain(amp)
+            self.amp = amp
+        except ValueError:
+            pass
+
+    def saveData(self):
+        fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", ".");
+        if(len(fileName)):
+            self.fg.save_to_file(str(fileName))
+
+    def dcGainEditText(self):
+        gain = float(self.gui.dcGainEdit.text())
+        self.fg.set_dc_gain(gain)
+        
+    def dcCancelClicked(self, state):
+        self.dcGainEditText()
+        self.fg.cancel_dc(state)
+        
+
+        
+class my_top_block(gr.top_block):
+    def __init__(self):
+        gr.top_block.__init__(self)
+
+        parser = OptionParser(option_class=eng_option)
+        parser.add_option("-e", "--interface", type="string", default="eth0",
+                          help="select Ethernet interface, default is eth0")
+        parser.add_option("-m", "--mac-addr", type="string", default="",
+                          help="select USRP by MAC address, default is auto-select")
+        parser.add_option("-W", "--bw", type="float", default=1e6,
+                          help="set bandwidth of receiver [default=%default]")
+        parser.add_option("-f", "--freq", type="eng_float", default="2.4G",
+                          help="set frequency to FREQ", metavar="FREQ")
+        parser.add_option("-g", "--gain", type="eng_float", default=None,
+                          help="set gain in dB (default is midpoint)")
+        parser.add_option("--fft-size", type="int", default=2048,
+                          help="Set number of FFT bins [default=%default]")
+        (options, args) = parser.parse_args()
+
+        if len(args) != 0:
+            parser.print_help()
+            sys.exit(1)
+       self.options = options
+        self.show_debug_info = True
+        
+        self.qapp = QtGui.QApplication(sys.argv)
+
+#        self.u = usrp2.source_32fc(options.interface, options.mac_addr)
+       self.u = msdd_rs.source_simple("192.168.1.20", 10000);
+       self.conv = gr.interleaved_short_to_complex();
+        self._adc_rate = self.u.pull_adc_freq()
+        self.set_bandwidth(options.bw)
+
+        if options.gain is None:
+            # if no gain was specified, use the mid-point in dB
+#            g = self.u.gain_range()   
+           g = [0, 10]
+            #options.gain = float(g[0]+g[1])/2
+            options.gain = float(0)
+        self.set_gain(options.gain)
+
+        if options.freq is None:
+               options.freq = 2.4e9;
+#            # if no frequency was specified, use the mid-point of the subdev
+#            f = self.u.freq_range()
+#            options.freq = float(f[0]+f[1])/2
+
+       self.set_frequency(options.freq)
+
+        self._fftsize = options.fft_size
+
+
+       self._freq = options.freq;
+       self._bandwidth = 400;
+        
+       self.set_bandwidth(self._bandwidth);
+
+        self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS,
+                                self._freq, self._bandwidth,
+                                "USRP2 Display",
+                                True, True, False, True, False)
+
+        # Set up internal amplifier
+        self.amp = gr.multiply_const_cc(0.0)
+        self.set_amplifier_gain(0.01)
+
+        # Create a single-pole IIR filter to remove DC
+        #   but don't connect it yet
+        self.dc_gain = 0.001
+        self.dc = gr.single_pole_iir_filter_cc(self.dc_gain)
+        self.dc_sub = gr.sub_cc()
+
+       self.agc = gr.agc2_cc(1e-3, 1e-5, 0.01, 0.01, 10);
+
+        self.connect(self.u, self.conv, self.snk)
+        #self.connect(self.u, self.conv, self.amp, self.snk)
+
+        if self.show_debug_info:
+            print "Decimation rate: ", self._decim
+            print "Bandwidth: ", self._bandwidth
+#            print "D'board: ", self.u.daughterboard_id()
+
+        # Get the reference pointer to the SpectrumDisplayForm QWidget
+        # Wrap the pointer as a PyQt SIP object
+        #     This can now be manipulated as a PyQt4.QtGui.QWidget
+        self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)
+
+        self.main_win = main_window(self.pysink, self)
+
+        self.main_win.set_frequency(self._freq)
+        self.main_win.set_gain(self._gain)
+        self.main_win.set_bandwidth(self._bandwidth)
+        self.main_win.set_amplifier(self._amp_value)
+
+        self.main_win.show()
+
+
+    def save_to_file(self, name):
+        self.lock()
+
+        # Add file sink to save data
+        self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name)
+        self.connect(self.conv, self.file_sink)
+
+        self.unlock()
+
+    def set_gain(self, gain):
+        self._gain = gain
+        self.u.set_ddc_gain(self._gain)
+
+    def set_frequency(self, freq):
+        self._freq = freq
+        r = self.u.set_rx_freq(freq)
+
+        try:
+            self.snk.set_frequency_range(self._freq, self._bandwidth)
+        except:
+            pass
+
+    def set_bandwidth(self, bw):
+        self._bandwidth = bw
+        self._decim = int(self._adc_rate / self._bandwidth)
+#        self.u.set_decim_rate(self._decim)
+       r1 = self.u.set_ddc_samp_rate( bw );
+       r2 = self.u.set_ddc_bw( bw );
+       self.u.start_data();
+
+       print r1
+       print r2;
+       
+       time.sleep(0.05);
+       bw = self.u.pull_ddc_bw();
+       sr = self.u.pull_ddc_samp_rate();
+       fc = self.u.pull_rx_freq();
+       
+       #self.snk.d_bandwidth = sr;
+
+       print bw;
+       print sr;
+       print fc;
+
+#      sys.exit(-1);
+
+        try:
+            self.snk.set_frequency_range(self._freq, self._bandwidth)
+        except:
+            pass
+
+    def set_amplifier_gain(self, amp):
+        self._amp_value = amp
+        self.amp.set_k(self._amp_value)
+
+    def set_dc_gain(self, gain):
+        self.dc.set_taps(gain)
+        
+    def cancel_dc(self, state):
+        self.lock()
+
+        if(state):
+            self.disconnect(self.u, self.amp)
+            self.connect(self.u, (self.dc_sub,0))
+            self.connect(self.u, self.dc, (self.dc_sub,1))
+            self.connect(self.dc_sub, self.amp)
+        else:
+            self.disconnect(self.dc_sub, self.amp)
+            self.disconnect(self.dc, (self.dc_sub,1))
+            self.disconnect(self.u, self.dc)
+            self.disconnect(self.u, (self.dc_sub,0))
+            self.connect(self.u, self.amp)
+
+        self.unlock()
+
+def main ():
+    tb = my_top_block()
+    tb.start()
+    tb.u.start_data();
+    tb.snk.exec_();
+
+if __name__ == '__main__':
+    try:
+        main ()
+    except KeyboardInterrupt:
+        pass
+    
index 29d11f59349ac5d6f19e1e77d96a5c45a7f10b4f..f00d2d28deec0c0bf9b227aeee90a6d509417a8c 100644 (file)
@@ -40,7 +40,7 @@ be set in the configuration file prior to running.  It has no command-line
 parameters, and works identically to the GUI scripts.
 
 
-demod_hrpt_file.py
+hrpt_demod_file.py
 ------------------
 
 This non-GUI script will operate on a file generated with
index 6bd1ab99593a948cca795ade1958a165d832b87a..cd8d543cc19784476f362673b6c272353b825bbb 100644 (file)
@@ -1,2 +1,3 @@
 *.dat
-*.txt
\ No newline at end of file
+*.txt
+*.hrpt
index 961b09afabe5fa9e243867393fd7ec0c2d2e189d..e246ba76a5c6c326f8a96464d251395b250dd6d4 100644 (file)
@@ -24,15 +24,17 @@ include $(top_srcdir)/Makefile.common
 if PYTHON
 
 dist_bin_SCRIPTS = \
-       demod_hrpt_file.py \
+       hrpt_decode.py \
+       hrpt_demod.py \
        file_rx_hrpt.py \
        usrp_rx_hrpt.py \
        usrp_rx_hrpt_nogui.py \
        usrp_rx_lrit.py
 
 EXTRA_DIST = \
+       hrpt_decode.grc \
+       hrpt_demod.grc \
        file_rx_hrpt.grc \
-       demod_hrpt_file.grc \
        usrp_rx_hrpt.grc \
        usrp_rx_hrpt_nogui.grc \
        usrp_rx_lrit.grc
diff --git a/gr-noaa/apps/demod_hrpt_file.grc b/gr-noaa/apps/demod_hrpt_file.grc
deleted file mode 100644 (file)
index 3c5e3ef..0000000
+++ /dev/null
@@ -1,774 +0,0 @@
-<?xml version='1.0' encoding='ASCII'?>
-<flow_graph>
-  <timestamp>Mon Nov  2 07:06:57 2009</timestamp>
-  <block>
-    <key>options</key>
-    <param>
-      <key>id</key>
-      <value>demod_hrpt_file</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>4096,4096</value>
-    </param>
-    <param>
-      <key>generate_options</key>
-      <value>no_gui</value>
-    </param>
-    <param>
-      <key>category</key>
-      <value>Custom</value>
-    </param>
-    <param>
-      <key>run_options</key>
-      <value>run</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>max_carrier_offset</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>2*math.pi*100e3/sample_rate</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(575, 19)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>sym_rate</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>600*1109</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(301, 19)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>sps</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>sample_rate/sym_rate</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(397, 19)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>hs</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>int(sps/2.0)</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(499, 19)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>sample_rate</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>64e6/decim</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(198, 17)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>max_clock_offset</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(710, 17)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>import</key>
-    <param>
-      <key>id</key>
-      <value>import_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>import</key>
-      <value>import math, os</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(11, 103)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>parameter</key>
-    <param>
-      <key>id</key>
-      <value>decim</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>label</key>
-      <value>decim</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>16</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>intx</value>
-    </param>
-    <param>
-      <key>short_id</key>
-      <value>d</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(202, 102)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>parameter</key>
-    <param>
-      <key>id</key>
-      <value>pll_alpha</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>label</key>
-      <value>pll_alpha</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.05</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>eng_float</value>
-    </param>
-    <param>
-      <key>short_id</key>
-      <value>p</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(294, 101)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>parameter</key>
-    <param>
-      <key>id</key>
-      <value>clock_alpha</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>label</key>
-      <value>clock_alpha</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.05</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>eng_float</value>
-    </param>
-    <param>
-      <key>short_id</key>
-      <value>a</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(395, 101)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>parameter</key>
-    <param>
-      <key>id</key>
-      <value>sync_alpha</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>label</key>
-      <value>sync_alpha</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.05</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>eng_float</value>
-    </param>
-    <param>
-      <key>short_id</key>
-      <value>s</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(508, 102)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>parameter</key>
-    <param>
-      <key>id</key>
-      <value>input_filename</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>label</key>
-      <value>input_filename</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>usrp.dat</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>string</value>
-    </param>
-    <param>
-      <key>short_id</key>
-      <value>F</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(618, 102)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>parameter</key>
-    <param>
-      <key>id</key>
-      <value>output_filename</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>label</key>
-      <value>output_filename</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>frames.dat</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>string</value>
-    </param>
-    <param>
-      <key>short_id</key>
-      <value>o</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(726, 102)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>180</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_file_source</key>
-    <param>
-      <key>id</key>
-      <value>file_source</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>file</key>
-      <value>input_filename</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>short</value>
-    </param>
-    <param>
-      <key>repeat</key>
-      <value>False</value>
-    </param>
-    <param>
-      <key>vlen</key>
-      <value>1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(62, 306)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_interleaved_short_to_complex</key>
-    <param>
-      <key>id</key>
-      <value>cs2cf</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(297, 318)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_agc_xx</key>
-    <param>
-      <key>id</key>
-      <value>agc</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>complex</value>
-    </param>
-    <param>
-      <key>rate</key>
-      <value>1e-5</value>
-    </param>
-    <param>
-      <key>reference</key>
-      <value>1.0</value>
-    </param>
-    <param>
-      <key>gain</key>
-      <value>1.0/32768.0</value>
-    </param>
-    <param>
-      <key>max_gain</key>
-      <value>1.0</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(538, 290)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>noaa_hrpt_pll_cf</key>
-    <param>
-      <key>id</key>
-      <value>pll</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>alpha</key>
-      <value>pll_alpha</value>
-    </param>
-    <param>
-      <key>beta</key>
-      <value>pll_alpha**2/4.0</value>
-    </param>
-    <param>
-      <key>max_offset</key>
-      <value>max_carrier_offset</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(720, 297)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_moving_average_xx</key>
-    <param>
-      <key>id</key>
-      <value>gr_moving_average_xx_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>float</value>
-    </param>
-    <param>
-      <key>length</key>
-      <value>hs</value>
-    </param>
-    <param>
-      <key>scale</key>
-      <value>1.0/hs</value>
-    </param>
-    <param>
-      <key>max_iter</key>
-      <value>4000</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(949, 297)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_clock_recovery_mm_xx</key>
-    <param>
-      <key>id</key>
-      <value>gr_clock_recovery_mm_xx_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>float</value>
-    </param>
-    <param>
-      <key>omega</key>
-      <value>sps/2.0</value>
-    </param>
-    <param>
-      <key>gain_omega</key>
-      <value>clock_alpha**2/4.0</value>
-    </param>
-    <param>
-      <key>mu</key>
-      <value>0.5</value>
-    </param>
-    <param>
-      <key>gain_mu</key>
-      <value>clock_alpha</value>
-    </param>
-    <param>
-      <key>omega_relative_limit</key>
-      <value>max_clock_offset</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(1158, 281)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_file_sink</key>
-    <param>
-      <key>id</key>
-      <value>gr_file_sink_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>file</key>
-      <value>output_filename</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>short</value>
-    </param>
-    <param>
-      <key>vlen</key>
-      <value>1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(732, 615)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>noaa_hrpt_decoder</key>
-    <param>
-      <key>id</key>
-      <value>noaa_hrpt_decoder_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(730, 537)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_binary_slicer_fb</key>
-    <param>
-      <key>id</key>
-      <value>gr_binary_slicer_fb_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(112, 537)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>noaa_hrpt_deframer</key>
-    <param>
-      <key>id</key>
-      <value>noaa_hrpt_deframer_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(536, 537)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <connection>
-    <source_block_id>file_source</source_block_id>
-    <sink_block_id>cs2cf</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>gr_clock_recovery_mm_xx_0</source_block_id>
-    <sink_block_id>gr_binary_slicer_fb_0</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>gr_moving_average_xx_0</source_block_id>
-    <sink_block_id>gr_clock_recovery_mm_xx_0</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>pll</source_block_id>
-    <sink_block_id>gr_moving_average_xx_0</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>cs2cf</source_block_id>
-    <sink_block_id>agc</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>agc</source_block_id>
-    <sink_block_id>pll</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>noaa_hrpt_deframer_0</source_block_id>
-    <sink_block_id>gr_file_sink_0</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>noaa_hrpt_deframer_0</source_block_id>
-    <sink_block_id>noaa_hrpt_decoder_0</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>gr_binary_slicer_fb_0</source_block_id>
-    <sink_block_id>noaa_hrpt_deframer_0</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-</flow_graph>
diff --git a/gr-noaa/apps/demod_hrpt_file.py b/gr-noaa/apps/demod_hrpt_file.py
deleted file mode 100755 (executable)
index d866501..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/usr/bin/env python
-##################################################
-# Gnuradio Python Flow Graph
-# Title: Demod Hrpt File
-# Generated: Mon Nov  2 07:06:57 2009
-##################################################
-
-from gnuradio import eng_notation
-from gnuradio import gr
-from gnuradio import noaa
-from gnuradio.eng_option import eng_option
-from gnuradio.gr import firdes
-from optparse import OptionParser
-import math, os
-
-class demod_hrpt_file(gr.top_block):
-
-       def __init__(self, decim=16, pll_alpha=0.05, clock_alpha=0.05, sync_alpha=0.05, input_filename="usrp.dat", output_filename="frames.dat"):
-               gr.top_block.__init__(self, "Demod Hrpt File")
-
-               ##################################################
-               # Parameters
-               ##################################################
-               self.decim = decim
-               self.pll_alpha = pll_alpha
-               self.clock_alpha = clock_alpha
-               self.sync_alpha = sync_alpha
-               self.input_filename = input_filename
-               self.output_filename = output_filename
-
-               ##################################################
-               # Variables
-               ##################################################
-               self.sym_rate = sym_rate = 600*1109
-               self.sample_rate = sample_rate = 64e6/decim
-               self.sps = sps = sample_rate/sym_rate
-               self.max_clock_offset = max_clock_offset = 0.1
-               self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate
-               self.hs = hs = int(sps/2.0)
-
-               ##################################################
-               # Blocks
-               ##################################################
-               self.agc = gr.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0)
-               self.cs2cf = gr.interleaved_short_to_complex()
-               self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False)
-               self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
-               self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
-               self.gr_file_sink_0 = gr.file_sink(gr.sizeof_short*1, output_filename)
-               self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
-               self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder()
-               self.noaa_hrpt_deframer_0 = noaa.hrpt_deframer()
-               self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
-
-               ##################################################
-               # Connections
-               ##################################################
-               self.connect((self.file_source, 0), (self.cs2cf, 0))
-               self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0))
-               self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0))
-               self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
-               self.connect((self.cs2cf, 0), (self.agc, 0))
-               self.connect((self.agc, 0), (self.pll, 0))
-               self.connect((self.noaa_hrpt_deframer_0, 0), (self.gr_file_sink_0, 0))
-               self.connect((self.noaa_hrpt_deframer_0, 0), (self.noaa_hrpt_decoder_0, 0))
-               self.connect((self.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_deframer_0, 0))
-
-       def set_decim(self, decim):
-               self.decim = decim
-               self.set_sample_rate(64e6/self.decim)
-
-       def set_pll_alpha(self, pll_alpha):
-               self.pll_alpha = pll_alpha
-               self.pll.set_alpha(self.pll_alpha)
-               self.pll.set_beta(self.pll_alpha**2/4.0)
-
-       def set_clock_alpha(self, clock_alpha):
-               self.clock_alpha = clock_alpha
-               self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0)
-               self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha)
-
-       def set_sync_alpha(self, sync_alpha):
-               self.sync_alpha = sync_alpha
-
-       def set_input_filename(self, input_filename):
-               self.input_filename = input_filename
-
-       def set_output_filename(self, output_filename):
-               self.output_filename = output_filename
-
-       def set_sym_rate(self, sym_rate):
-               self.sym_rate = sym_rate
-               self.set_sps(self.sample_rate/self.sym_rate)
-
-       def set_sample_rate(self, sample_rate):
-               self.sample_rate = sample_rate
-               self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate)
-               self.set_sps(self.sample_rate/self.sym_rate)
-
-       def set_sps(self, sps):
-               self.sps = sps
-               self.set_hs(int(self.sps/2.0))
-               self.gr_clock_recovery_mm_xx_0.set_omega(self.sps/2.0)
-
-       def set_max_clock_offset(self, max_clock_offset):
-               self.max_clock_offset = max_clock_offset
-
-       def set_max_carrier_offset(self, max_carrier_offset):
-               self.max_carrier_offset = max_carrier_offset
-               self.pll.set_max_offset(self.max_carrier_offset)
-
-       def set_hs(self, hs):
-               self.hs = hs
-               self.gr_moving_average_xx_0.set_length_and_scale(self.hs, 1.0/self.hs)
-
-if __name__ == '__main__':
-       parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
-       parser.add_option("-d", "--decim", dest="decim", type="intx", default=16,
-               help="Set decim [default=%default]")
-       parser.add_option("-p", "--pll-alpha", dest="pll_alpha", type="eng_float", default=eng_notation.num_to_str(0.05),
-               help="Set pll_alpha [default=%default]")
-       parser.add_option("-a", "--clock-alpha", dest="clock_alpha", type="eng_float", default=eng_notation.num_to_str(0.05),
-               help="Set clock_alpha [default=%default]")
-       parser.add_option("-s", "--sync-alpha", dest="sync_alpha", type="eng_float", default=eng_notation.num_to_str(0.05),
-               help="Set sync_alpha [default=%default]")
-       parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default="usrp.dat",
-               help="Set usrp.dat [default=%default]")
-       parser.add_option("-o", "--output-filename", dest="output_filename", type="string", default="frames.dat",
-               help="Set frames.dat [default=%default]")
-       (options, args) = parser.parse_args()
-       tb = demod_hrpt_file(decim=options.decim, pll_alpha=options.pll_alpha, clock_alpha=options.clock_alpha, sync_alpha=options.sync_alpha, input_filename=options.input_filename, output_filename=options.output_filename)
-       tb.run()
-
index f34143756996a89cbf56ec0963f18b5537187653..e3cccd39330fa2154bc911740822944d35bf6147 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version='1.0' encoding='ASCII'?>
 <flow_graph>
-  <timestamp>Mon Nov  2 08:30:47 2009</timestamp>
+  <timestamp>Mon Nov  9 07:47:17 2009</timestamp>
   <block>
     <key>options</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>max_carrier_offset</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>2*math.pi*100e3/sample_rate</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(575, 19)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>variable</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>hs</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>int(sps/2.0)</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(499, 19)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>variable</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>max_clock_offset</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(705, 19)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable_config</key>
-    <param>
-      <key>id</key>
-      <value>side</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>'A'</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>string</value>
-    </param>
-    <param>
-      <key>config_file</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>section</key>
-      <value>'usrp_rx_hrpt'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'side'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>side</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(194, 253)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_file_sink</key>
-    <param>
-      <key>id</key>
-      <value>frame_sink</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>file</key>
-      <value>output_filename</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>short</value>
-    </param>
-    <param>
-      <key>vlen</key>
-      <value>1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(973, 1024)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>virtual_source</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>noaa_hrpt_decoder</key>
-    <param>
-      <key>id</key>
-      <value>decoder</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(974, 925)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>variable</key>
     <param>
     </param>
   </block>
   <block>
-    <key>gr_throttle</key>
+    <key>gr_file_source</key>
     <param>
       <key>id</key>
-      <value>throttle</value>
+      <value>gr_file_source_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
+    <param>
+      <key>file</key>
+      <value>input_filename</value>
+    </param>
     <param>
       <key>type</key>
       <value>short</value>
     </param>
     <param>
-      <key>samples_per_second</key>
-      <value>sample_rate</value>
+      <key>repeat</key>
+      <value>False</value>
     </param>
     <param>
       <key>vlen</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(75, 679)</value>
+      <value>(76, 613)</value>
     </param>
     <param>
       <key>_rotation</key>
-      <value>180</value>
+      <value>0</value>
     </param>
   </block>
   <block>
-    <key>gr_file_source</key>
+    <key>notebook</key>
     <param>
       <key>id</key>
-      <value>gr_file_source_0</value>
+      <value>displays</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>file</key>
-      <value>input_filename</value>
+      <key>style</key>
+      <value>wx.NB_TOP</value>
+    </param>
+    <param>
+      <key>labels</key>
+      <value>['Spectrum','Demod']</value>
+    </param>
+    <param>
+      <key>grid_pos</key>
+      <value>1,0,1,2</value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(12, 249)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>wxgui_fftsink2</key>
+    <param>
+      <key>id</key>
+      <value>rx_fft</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
       <key>type</key>
-      <value>short</value>
+      <value>complex</value>
     </param>
     <param>
-      <key>repeat</key>
+      <key>title</key>
+      <value>RX Spectrum</value>
+    </param>
+    <param>
+      <key>samp_rate</key>
+      <value>sample_rate</value>
+    </param>
+    <param>
+      <key>baseband_freq</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>y_per_div</key>
+      <value>5</value>
+    </param>
+    <param>
+      <key>y_divs</key>
+      <value>8</value>
+    </param>
+    <param>
+      <key>ref_level</key>
+      <value>-5</value>
+    </param>
+    <param>
+      <key>ref_scale</key>
+      <value>2.0</value>
+    </param>
+    <param>
+      <key>fft_size</key>
+      <value>1024</value>
+    </param>
+    <param>
+      <key>fft_rate</key>
+      <value>15</value>
+    </param>
+    <param>
+      <key>peak_hold</key>
       <value>False</value>
     </param>
+    <param>
+      <key>average</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>avg_alpha</key>
+      <value>0.1</value>
+    </param>
+    <param>
+      <key>win</key>
+      <value>None</value>
+    </param>
+    <param>
+      <key>win_size</key>
+      <value>640, 360</value>
+    </param>
+    <param>
+      <key>grid_pos</key>
+      <value>0, 0, 1, 1</value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value>displays, 0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(471, 450)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_binary_slicer_fb</key>
+    <param>
+      <key>id</key>
+      <value>gr_binary_slicer_fb_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(393, 975)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_throttle</key>
+    <param>
+      <key>id</key>
+      <value>throttle</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>short</value>
+    </param>
+    <param>
+      <key>samples_per_second</key>
+      <value>2*sample_rate</value>
+    </param>
     <param>
       <key>vlen</key>
       <value>1</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(76, 613)</value>
+      <value>(75, 679)</value>
     </param>
     <param>
       <key>_rotation</key>
-      <value>0</value>
+      <value>180</value>
     </param>
   </block>
   <block>
     </param>
     <param>
       <key>value</key>
-      <value>'usrp.dat'</value>
+      <value>usrp.dat</value>
     </param>
     <param>
       <key>type</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(198, 107)</value>
+      <value>(196, 98)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
     <param>
       <key>value</key>
-      <value>16</value>
+      <value>32</value>
     </param>
     <param>
       <key>type</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(308, 107)</value>
+      <value>(307, 98)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(397, 108)</value>
+      <value>(397, 98)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(539, 105)</value>
+      <value>(540, 98)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>variable_config</key>
+    <key>variable</key>
     <param>
       <key>id</key>
-      <value>saved_pll_alpha</value>
+      <value>hs</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>0.05</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>real</value>
-    </param>
-    <param>
-      <key>config_file</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>section</key>
-      <value>'usrp_rx_hrpt'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'pll_alpha'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>pll_alpha</value>
+      <value>int(sps/2.0)</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(363, 254)</value>
+      <value>(499, 19)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>variable_config</key>
+    <key>variable</key>
     <param>
       <key>id</key>
-      <value>saved_clock_alpha</value>
+      <value>max_carrier_offset</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>0.05</value>
+      <value>2*math.pi*100e3/sample_rate</value>
     </param>
     <param>
-      <key>type</key>
-      <value>real</value>
+      <key>_coordinate</key>
+      <value>(575, 19)</value>
     </param>
     <param>
-      <key>config_file</key>
-      <value>config_filename</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>variable</key>
     <param>
-      <key>section</key>
-      <value>'usrp_rx_hrpt'</value>
+      <key>id</key>
+      <value>max_clock_offset</value>
     </param>
     <param>
-      <key>option</key>
-      <value>'clock_alpha'</value>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
-      <key>writeback</key>
-      <value>clock_alpha</value>
+      <key>value</key>
+      <value>100e-6</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(527, 256)</value>
+      <value>(705, 19)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
     <param>
       <key>value</key>
-      <value>'frames.dat'</value>
+      <value>'frames.hrpt'</value>
     </param>
     <param>
       <key>type</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(689, 257)</value>
+      <value>(521, 254)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>notebook</key>
+    <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>displays</value>
+      <value>saved_pll_alpha</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>style</key>
-      <value>wx.NB_TOP</value>
+      <key>value</key>
+      <value>0.01</value>
     </param>
     <param>
-      <key>labels</key>
-      <value>['Spectrum','Demod']</value>
+      <key>type</key>
+      <value>real</value>
     </param>
     <param>
-      <key>grid_pos</key>
-      <value>1,0,1,2</value>
+      <key>config_file</key>
+      <value>config_filename</value>
     </param>
     <param>
-      <key>notebook</key>
-      <value></value>
+      <key>section</key>
+      <value>'usrp_rx_hrpt'</value>
+    </param>
+    <param>
+      <key>option</key>
+      <value>'pll_alpha'</value>
+    </param>
+    <param>
+      <key>writeback</key>
+      <value>pll_alpha</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(12, 249)</value>
+      <value>(195, 253)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>wxgui_fftsink2</key>
+    <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>rx_fft</value>
+      <value>saved_clock_alpha</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>type</key>
-      <value>complex</value>
-    </param>
-    <param>
-      <key>title</key>
-      <value>RX Spectrum</value>
+      <key>value</key>
+      <value>0.01</value>
     </param>
     <param>
-      <key>samp_rate</key>
-      <value>sample_rate</value>
+      <key>type</key>
+      <value>real</value>
     </param>
     <param>
-      <key>baseband_freq</key>
-      <value>0</value>
+      <key>config_file</key>
+      <value>config_filename</value>
     </param>
     <param>
-      <key>y_per_div</key>
-      <value>5</value>
+      <key>section</key>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
-      <key>y_divs</key>
-      <value>8</value>
+      <key>option</key>
+      <value>'clock_alpha'</value>
     </param>
     <param>
-      <key>ref_level</key>
-      <value>-5</value>
+      <key>writeback</key>
+      <value>clock_alpha</value>
     </param>
     <param>
-      <key>ref_scale</key>
-      <value>2.0</value>
+      <key>_coordinate</key>
+      <value>(360, 255)</value>
     </param>
     <param>
-      <key>fft_size</key>
-      <value>1024</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_deframer</key>
     <param>
-      <key>fft_rate</key>
-      <value>15</value>
+      <key>id</key>
+      <value>deframer</value>
     </param>
     <param>
-      <key>peak_hold</key>
-      <value>False</value>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
-      <key>average</key>
-      <value>True</value>
+      <key>_coordinate</key>
+      <value>(579, 975)</value>
     </param>
     <param>
-      <key>avg_alpha</key>
-      <value>0.1</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_decoder</key>
     <param>
-      <key>win</key>
-      <value>None</value>
+      <key>id</key>
+      <value>decoder</value>
     </param>
     <param>
-      <key>win_size</key>
-      <value>640, 360</value>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
-      <key>grid_pos</key>
-      <value>0, 0, 1, 1</value>
+      <key>verbose</key>
+      <value>True</value>
     </param>
     <param>
-      <key>notebook</key>
-      <value>displays, 0</value>
+      <key>output</key>
+      <value>False</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(471, 450)</value>
+      <value>(849, 925)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>gr_binary_slicer_fb</key>
+    <key>gr_file_sink</key>
     <param>
       <key>id</key>
-      <value>gr_binary_slicer_fb_0</value>
+      <value>frame_sink</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>_coordinate</key>
-      <value>(393, 975)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
+      <key>file</key>
+      <value>output_filename</value>
     </param>
-  </block>
-  <block>
-    <key>noaa_hrpt_deframer</key>
     <param>
-      <key>id</key>
-      <value>deframer</value>
+      <key>type</key>
+      <value>short</value>
     </param>
     <param>
-      <key>_enabled</key>
-      <value>True</value>
+      <key>vlen</key>
+      <value>1</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(762, 975)</value>
+      <value>(848, 1007)</value>
     </param>
     <param>
       <key>_rotation</key>
index 1513141ec43cacd73aaa1ef4ae75056dafb96902..13b887635814f6ea3e841355b19916f5d213dbbd 100755 (executable)
@@ -2,7 +2,7 @@
 ##################################################
 # Gnuradio Python Flow Graph
 # Title: USRP HRPT Receiver
-# Generated: Mon Nov  2 08:30:47 2009
+# Generated: Mon Nov  9 07:47:17 2009
 ##################################################
 
 from gnuradio import eng_notation
@@ -22,7 +22,7 @@ import wx
 
 class file_rx_hrpt(grc_wxgui.top_block_gui):
 
-       def __init__(self, input_filename='usrp.dat', decim=16):
+       def __init__(self, input_filename="usrp.dat", decim=32):
                grc_wxgui.top_block_gui.__init__(self, title="USRP HRPT Receiver")
 
                ##################################################
@@ -41,25 +41,20 @@ class file_rx_hrpt(grc_wxgui.top_block_gui):
                self._saved_pll_alpha_config = ConfigParser.ConfigParser()
                self._saved_pll_alpha_config.read(config_filename)
                try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha')
-               except: saved_pll_alpha = 0.05
+               except: saved_pll_alpha = 0.01
                self.saved_pll_alpha = saved_pll_alpha
                self._saved_clock_alpha_config = ConfigParser.ConfigParser()
                self._saved_clock_alpha_config.read(config_filename)
                try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat('usrp_rx_hrpt', 'clock_alpha')
-               except: saved_clock_alpha = 0.05
+               except: saved_clock_alpha = 0.01
                self.saved_clock_alpha = saved_clock_alpha
-               self._side_config = ConfigParser.ConfigParser()
-               self._side_config.read(config_filename)
-               try: side = self._side_config.get('usrp_rx_hrpt', 'side')
-               except: side = 'A'
-               self.side = side
                self.pll_alpha = pll_alpha = saved_pll_alpha
                self._output_filename_config = ConfigParser.ConfigParser()
                self._output_filename_config.read(config_filename)
                try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename')
-               except: output_filename = 'frames.dat'
+               except: output_filename = 'frames.hrpt'
                self.output_filename = output_filename
-               self.max_clock_offset = max_clock_offset = 0.1
+               self.max_clock_offset = max_clock_offset = 100e-6
                self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate
                self.hs = hs = int(sps/2.0)
                self.clock_alpha = clock_alpha = saved_clock_alpha
@@ -126,7 +121,7 @@ class file_rx_hrpt(grc_wxgui.top_block_gui):
                # Blocks
                ##################################################
                self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0)
-               self.decoder = noaa.hrpt_decoder()
+               self.decoder = noaa.hrpt_decoder(True,False)
                self.deframer = noaa.hrpt_deframer()
                self.demod_scope = scopesink2.scope_sink_f(
                        self.displays.GetPage(1).GetWin(),
@@ -164,7 +159,7 @@ class file_rx_hrpt(grc_wxgui.top_block_gui):
                        size=(640, 360),
                )
                self.displays.GetPage(0).GridAdd(self.rx_fft.win, 0, 0, 1, 1)
-               self.throttle = gr.throttle(gr.sizeof_short*1, sample_rate)
+               self.throttle = gr.throttle(gr.sizeof_short*1, 2*sample_rate)
 
                ##################################################
                # Connections
@@ -196,18 +191,18 @@ class file_rx_hrpt(grc_wxgui.top_block_gui):
 
        def set_sample_rate(self, sample_rate):
                self.sample_rate = sample_rate
-               self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate)
                self.set_sps(self.sample_rate/self.sym_rate)
                self.rx_fft.set_sample_rate(self.sample_rate)
+               self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate)
 
        def set_config_filename(self, config_filename):
                self.config_filename = config_filename
-               self._side_config = ConfigParser.ConfigParser()
-               self._side_config.read(self.config_filename)
-               if not self._side_config.has_section('usrp_rx_hrpt'):
-                       self._side_config.add_section('usrp_rx_hrpt')
-               self._side_config.set('usrp_rx_hrpt', 'side', str(self.side))
-               self._side_config.write(open(self.config_filename, 'w'))
+               self._output_filename_config = ConfigParser.ConfigParser()
+               self._output_filename_config.read(self.config_filename)
+               if not self._output_filename_config.has_section('usrp_rx_hrpt'):
+                       self._output_filename_config.add_section('usrp_rx_hrpt')
+               self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename))
+               self._output_filename_config.write(open(self.config_filename, 'w'))
                self._saved_pll_alpha_config = ConfigParser.ConfigParser()
                self._saved_pll_alpha_config.read(self.config_filename)
                if not self._saved_pll_alpha_config.has_section('usrp_rx_hrpt'):
@@ -220,17 +215,11 @@ class file_rx_hrpt(grc_wxgui.top_block_gui):
                        self._saved_clock_alpha_config.add_section('usrp_rx_hrpt')
                self._saved_clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha))
                self._saved_clock_alpha_config.write(open(self.config_filename, 'w'))
-               self._output_filename_config = ConfigParser.ConfigParser()
-               self._output_filename_config.read(self.config_filename)
-               if not self._output_filename_config.has_section('usrp_rx_hrpt'):
-                       self._output_filename_config.add_section('usrp_rx_hrpt')
-               self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename))
-               self._output_filename_config.write(open(self.config_filename, 'w'))
 
        def set_sps(self, sps):
                self.sps = sps
-               self.set_hs(int(self.sps/2.0))
                self.gr_clock_recovery_mm_xx_0.set_omega(self.sps/2.0)
+               self.set_hs(int(self.sps/2.0))
 
        def set_saved_pll_alpha(self, saved_pll_alpha):
                self.saved_pll_alpha = saved_pll_alpha
@@ -240,15 +229,6 @@ class file_rx_hrpt(grc_wxgui.top_block_gui):
                self.saved_clock_alpha = saved_clock_alpha
                self.set_clock_alpha(self.saved_clock_alpha)
 
-       def set_side(self, side):
-               self.side = side
-               self._side_config = ConfigParser.ConfigParser()
-               self._side_config.read(self.config_filename)
-               if not self._side_config.has_section('usrp_rx_hrpt'):
-                       self._side_config.add_section('usrp_rx_hrpt')
-               self._side_config.set('usrp_rx_hrpt', 'side', str(self.side))
-               self._side_config.write(open(self.config_filename, 'w'))
-
        def set_pll_alpha(self, pll_alpha):
                self.pll_alpha = pll_alpha
                self.pll.set_alpha(self.pll_alpha)
@@ -297,9 +277,9 @@ class file_rx_hrpt(grc_wxgui.top_block_gui):
 
 if __name__ == '__main__':
        parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
-       parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default='usrp.dat',
+       parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default="usrp.dat",
                help="Set usrp.dat [default=%default]")
-       parser.add_option("-d", "--decim", dest="decim", type="intx", default=16,
+       parser.add_option("-d", "--decim", dest="decim", type="intx", default=32,
                help="Set decim [default=%default]")
        (options, args) = parser.parse_args()
        tb = file_rx_hrpt(input_filename=options.input_filename, decim=options.decim)
diff --git a/gr-noaa/apps/hrpt_decode.grc b/gr-noaa/apps/hrpt_decode.grc
new file mode 100644 (file)
index 0000000..39fe195
--- /dev/null
@@ -0,0 +1,428 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+  <timestamp>Sun Nov  8 10:48:59 2009</timestamp>
+  <block>
+    <key>options</key>
+    <param>
+      <key>id</key>
+      <value>hrpt_decode</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>4096,4096</value>
+    </param>
+    <param>
+      <key>generate_options</key>
+      <value>no_gui</value>
+    </param>
+    <param>
+      <key>category</key>
+      <value>Custom</value>
+    </param>
+    <param>
+      <key>run_options</key>
+      <value>run</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>max_carrier_offset</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>2*math.pi*100e3/sample_rate</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(575, 19)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>hs</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>int(sps/2.0)</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(499, 19)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>sample_rate</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>64e6/decim</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(198, 17)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>import</key>
+    <param>
+      <key>id</key>
+      <value>import_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>import</key>
+      <value>import math, os</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(11, 103)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>max_clock_offset</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>100e-6</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(710, 17)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>sym_rate</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>600*1109</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(307, 18)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>sps</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>sample_rate/sym_rate</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(400, 17)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>parameter</key>
+    <param>
+      <key>id</key>
+      <value>decim</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>decim</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>32</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>intx</value>
+    </param>
+    <param>
+      <key>short_id</key>
+      <value>d</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(202, 102)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>parameter</key>
+    <param>
+      <key>id</key>
+      <value>pll_alpha</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>pll_alpha</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>0.01</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>eng_float</value>
+    </param>
+    <param>
+      <key>short_id</key>
+      <value>p</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(294, 101)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>parameter</key>
+    <param>
+      <key>id</key>
+      <value>clock_alpha</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>clock_alpha</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>0.01</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>eng_float</value>
+    </param>
+    <param>
+      <key>short_id</key>
+      <value>s</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(395, 101)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_file_source</key>
+    <param>
+      <key>id</key>
+      <value>file_source</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>file</key>
+      <value>input_filename</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>short</value>
+    </param>
+    <param>
+      <key>repeat</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(231, 419)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_decoder</key>
+    <param>
+      <key>id</key>
+      <value>decoder</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>verbose</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>output</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(462, 419)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>parameter</key>
+    <param>
+      <key>id</key>
+      <value>input_filename</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>input_filename</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>frames.hrpt</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>string</value>
+    </param>
+    <param>
+      <key>short_id</key>
+      <value>F</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(522, 100)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <connection>
+    <source_block_id>file_source</source_block_id>
+    <sink_block_id>decoder</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+</flow_graph>
diff --git a/gr-noaa/apps/hrpt_decode.py b/gr-noaa/apps/hrpt_decode.py
new file mode 100755 (executable)
index 0000000..158780b
--- /dev/null
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+##################################################
+# Gnuradio Python Flow Graph
+# Title: Hrpt Decode
+# Generated: Sun Nov  8 10:49:01 2009
+##################################################
+
+from gnuradio import eng_notation
+from gnuradio import gr
+from gnuradio import noaa
+from gnuradio.eng_option import eng_option
+from gnuradio.gr import firdes
+from optparse import OptionParser
+import math, os
+
+class hrpt_decode(gr.top_block):
+
+       def __init__(self, decim=32, pll_alpha=0.01, clock_alpha=0.01, input_filename="frames.hrpt"):
+               gr.top_block.__init__(self, "Hrpt Decode")
+
+               ##################################################
+               # Parameters
+               ##################################################
+               self.decim = decim
+               self.pll_alpha = pll_alpha
+               self.clock_alpha = clock_alpha
+               self.input_filename = input_filename
+
+               ##################################################
+               # Variables
+               ##################################################
+               self.sym_rate = sym_rate = 600*1109
+               self.sample_rate = sample_rate = 64e6/decim
+               self.sps = sps = sample_rate/sym_rate
+               self.max_clock_offset = max_clock_offset = 100e-6
+               self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate
+               self.hs = hs = int(sps/2.0)
+
+               ##################################################
+               # Blocks
+               ##################################################
+               self.decoder = noaa.hrpt_decoder(True,True)
+               self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False)
+
+               ##################################################
+               # Connections
+               ##################################################
+               self.connect((self.file_source, 0), (self.decoder, 0))
+
+       def set_decim(self, decim):
+               self.decim = decim
+               self.set_sample_rate(64e6/self.decim)
+
+       def set_pll_alpha(self, pll_alpha):
+               self.pll_alpha = pll_alpha
+
+       def set_clock_alpha(self, clock_alpha):
+               self.clock_alpha = clock_alpha
+
+       def set_input_filename(self, input_filename):
+               self.input_filename = input_filename
+
+       def set_sym_rate(self, sym_rate):
+               self.sym_rate = sym_rate
+               self.set_sps(self.sample_rate/self.sym_rate)
+
+       def set_sample_rate(self, sample_rate):
+               self.sample_rate = sample_rate
+               self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate)
+               self.set_sps(self.sample_rate/self.sym_rate)
+
+       def set_sps(self, sps):
+               self.sps = sps
+               self.set_hs(int(self.sps/2.0))
+
+       def set_max_clock_offset(self, max_clock_offset):
+               self.max_clock_offset = max_clock_offset
+
+       def set_max_carrier_offset(self, max_carrier_offset):
+               self.max_carrier_offset = max_carrier_offset
+
+       def set_hs(self, hs):
+               self.hs = hs
+
+if __name__ == '__main__':
+       parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
+       parser.add_option("-d", "--decim", dest="decim", type="intx", default=32,
+               help="Set decim [default=%default]")
+       parser.add_option("-p", "--pll-alpha", dest="pll_alpha", type="eng_float", default=eng_notation.num_to_str(0.01),
+               help="Set pll_alpha [default=%default]")
+       parser.add_option("-s", "--clock-alpha", dest="clock_alpha", type="eng_float", default=eng_notation.num_to_str(0.01),
+               help="Set clock_alpha [default=%default]")
+       parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default="frames.hrpt",
+               help="Set frames.hrpt [default=%default]")
+       (options, args) = parser.parse_args()
+       tb = hrpt_decode(decim=options.decim, pll_alpha=options.pll_alpha, clock_alpha=options.clock_alpha, input_filename=options.input_filename)
+       tb.run()
+
diff --git a/gr-noaa/apps/hrpt_demod.grc b/gr-noaa/apps/hrpt_demod.grc
new file mode 100644 (file)
index 0000000..8af3d82
--- /dev/null
@@ -0,0 +1,747 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+  <timestamp>Sun Nov  8 10:41:07 2009</timestamp>
+  <block>
+    <key>options</key>
+    <param>
+      <key>id</key>
+      <value>hrpt_demod</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>4096,4096</value>
+    </param>
+    <param>
+      <key>generate_options</key>
+      <value>no_gui</value>
+    </param>
+    <param>
+      <key>category</key>
+      <value>Custom</value>
+    </param>
+    <param>
+      <key>run_options</key>
+      <value>run</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>max_carrier_offset</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>2*math.pi*100e3/sample_rate</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(575, 19)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>hs</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>int(sps/2.0)</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(499, 19)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>sample_rate</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>64e6/decim</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(198, 17)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>import</key>
+    <param>
+      <key>id</key>
+      <value>import_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>import</key>
+      <value>import math, os</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(11, 103)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>parameter</key>
+    <param>
+      <key>id</key>
+      <value>input_filename</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>input_filename</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>usrp.dat</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>string</value>
+    </param>
+    <param>
+      <key>short_id</key>
+      <value>F</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(618, 102)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>parameter</key>
+    <param>
+      <key>id</key>
+      <value>output_filename</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>output_filename</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>frames.dat</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>string</value>
+    </param>
+    <param>
+      <key>short_id</key>
+      <value>o</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(726, 102)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>180</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_file_source</key>
+    <param>
+      <key>id</key>
+      <value>file_source</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>file</key>
+      <value>input_filename</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>short</value>
+    </param>
+    <param>
+      <key>repeat</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(63, 277)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_interleaved_short_to_complex</key>
+    <param>
+      <key>id</key>
+      <value>cs2cf</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(275, 289)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_agc_xx</key>
+    <param>
+      <key>id</key>
+      <value>agc</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>rate</key>
+      <value>1e-5</value>
+    </param>
+    <param>
+      <key>reference</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>gain</key>
+      <value>1.0/32768.0</value>
+    </param>
+    <param>
+      <key>max_gain</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(117, 394)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_pll_cf</key>
+    <param>
+      <key>id</key>
+      <value>pll</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>alpha</key>
+      <value>pll_alpha</value>
+    </param>
+    <param>
+      <key>beta</key>
+      <value>pll_alpha**2/4.0</value>
+    </param>
+    <param>
+      <key>max_offset</key>
+      <value>max_carrier_offset</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(292, 402)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_moving_average_xx</key>
+    <param>
+      <key>id</key>
+      <value>gr_moving_average_xx_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>float</value>
+    </param>
+    <param>
+      <key>length</key>
+      <value>hs</value>
+    </param>
+    <param>
+      <key>scale</key>
+      <value>1.0/hs</value>
+    </param>
+    <param>
+      <key>max_iter</key>
+      <value>4000</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(504, 402)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_clock_recovery_mm_xx</key>
+    <param>
+      <key>id</key>
+      <value>gr_clock_recovery_mm_xx_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>float</value>
+    </param>
+    <param>
+      <key>omega</key>
+      <value>sps/2.0</value>
+    </param>
+    <param>
+      <key>gain_omega</key>
+      <value>clock_alpha**2/4.0</value>
+    </param>
+    <param>
+      <key>mu</key>
+      <value>0.5</value>
+    </param>
+    <param>
+      <key>gain_mu</key>
+      <value>clock_alpha</value>
+    </param>
+    <param>
+      <key>omega_relative_limit</key>
+      <value>max_clock_offset</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(703, 386)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_deframer</key>
+    <param>
+      <key>id</key>
+      <value>noaa_hrpt_deframer_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1142, 422)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_binary_slicer_fb</key>
+    <param>
+      <key>id</key>
+      <value>gr_binary_slicer_fb_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(960, 422)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>max_clock_offset</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>100e-6</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(710, 17)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>sym_rate</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>600*1109</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(307, 18)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>sps</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>sample_rate/sym_rate</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(400, 17)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>parameter</key>
+    <param>
+      <key>id</key>
+      <value>decim</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>decim</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>32</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>intx</value>
+    </param>
+    <param>
+      <key>short_id</key>
+      <value>d</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(202, 102)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>parameter</key>
+    <param>
+      <key>id</key>
+      <value>pll_alpha</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>pll_alpha</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>0.01</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>eng_float</value>
+    </param>
+    <param>
+      <key>short_id</key>
+      <value>p</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(294, 101)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>parameter</key>
+    <param>
+      <key>id</key>
+      <value>clock_alpha</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>clock_alpha</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>0.01</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>eng_float</value>
+    </param>
+    <param>
+      <key>short_id</key>
+      <value>s</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(395, 101)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_decoder</key>
+    <param>
+      <key>id</key>
+      <value>decoder</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>verbose</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>output</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1150, 341)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>180</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_file_sink</key>
+    <param>
+      <key>id</key>
+      <value>gr_file_sink_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>file</key>
+      <value>output_filename</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>short</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1144, 489)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>180</value>
+    </param>
+  </block>
+  <connection>
+    <source_block_id>file_source</source_block_id>
+    <sink_block_id>cs2cf</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_clock_recovery_mm_xx_0</source_block_id>
+    <sink_block_id>gr_binary_slicer_fb_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_moving_average_xx_0</source_block_id>
+    <sink_block_id>gr_clock_recovery_mm_xx_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>pll</source_block_id>
+    <sink_block_id>gr_moving_average_xx_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>cs2cf</source_block_id>
+    <sink_block_id>agc</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>agc</source_block_id>
+    <sink_block_id>pll</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>noaa_hrpt_deframer_0</source_block_id>
+    <sink_block_id>gr_file_sink_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>noaa_hrpt_deframer_0</source_block_id>
+    <sink_block_id>decoder</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_binary_slicer_fb_0</source_block_id>
+    <sink_block_id>noaa_hrpt_deframer_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+</flow_graph>
diff --git a/gr-noaa/apps/hrpt_demod.py b/gr-noaa/apps/hrpt_demod.py
new file mode 100755 (executable)
index 0000000..38d0316
--- /dev/null
@@ -0,0 +1,127 @@
+#!/usr/bin/env python
+##################################################
+# Gnuradio Python Flow Graph
+# Title: Hrpt Demod
+# Generated: Sun Nov  8 10:41:08 2009
+##################################################
+
+from gnuradio import eng_notation
+from gnuradio import gr
+from gnuradio import noaa
+from gnuradio.eng_option import eng_option
+from gnuradio.gr import firdes
+from optparse import OptionParser
+import math, os
+
+class hrpt_demod(gr.top_block):
+
+       def __init__(self, input_filename="usrp.dat", output_filename="frames.dat", decim=32, pll_alpha=0.01, clock_alpha=0.01):
+               gr.top_block.__init__(self, "Hrpt Demod")
+
+               ##################################################
+               # Parameters
+               ##################################################
+               self.input_filename = input_filename
+               self.output_filename = output_filename
+               self.decim = decim
+               self.pll_alpha = pll_alpha
+               self.clock_alpha = clock_alpha
+
+               ##################################################
+               # Variables
+               ##################################################
+               self.sym_rate = sym_rate = 600*1109
+               self.sample_rate = sample_rate = 64e6/decim
+               self.sps = sps = sample_rate/sym_rate
+               self.max_clock_offset = max_clock_offset = 100e-6
+               self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate
+               self.hs = hs = int(sps/2.0)
+
+               ##################################################
+               # Blocks
+               ##################################################
+               self.agc = gr.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0)
+               self.cs2cf = gr.interleaved_short_to_complex()
+               self.decoder = noaa.hrpt_decoder(True,False)
+               self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False)
+               self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
+               self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
+               self.gr_file_sink_0 = gr.file_sink(gr.sizeof_short*1, output_filename)
+               self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
+               self.noaa_hrpt_deframer_0 = noaa.hrpt_deframer()
+               self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
+
+               ##################################################
+               # Connections
+               ##################################################
+               self.connect((self.file_source, 0), (self.cs2cf, 0))
+               self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0))
+               self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0))
+               self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
+               self.connect((self.cs2cf, 0), (self.agc, 0))
+               self.connect((self.agc, 0), (self.pll, 0))
+               self.connect((self.noaa_hrpt_deframer_0, 0), (self.gr_file_sink_0, 0))
+               self.connect((self.noaa_hrpt_deframer_0, 0), (self.decoder, 0))
+               self.connect((self.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_deframer_0, 0))
+
+       def set_input_filename(self, input_filename):
+               self.input_filename = input_filename
+
+       def set_output_filename(self, output_filename):
+               self.output_filename = output_filename
+
+       def set_decim(self, decim):
+               self.decim = decim
+               self.set_sample_rate(64e6/self.decim)
+
+       def set_pll_alpha(self, pll_alpha):
+               self.pll_alpha = pll_alpha
+               self.pll.set_alpha(self.pll_alpha)
+               self.pll.set_beta(self.pll_alpha**2/4.0)
+
+       def set_clock_alpha(self, clock_alpha):
+               self.clock_alpha = clock_alpha
+               self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0)
+               self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha)
+
+       def set_sym_rate(self, sym_rate):
+               self.sym_rate = sym_rate
+               self.set_sps(self.sample_rate/self.sym_rate)
+
+       def set_sample_rate(self, sample_rate):
+               self.sample_rate = sample_rate
+               self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate)
+               self.set_sps(self.sample_rate/self.sym_rate)
+
+       def set_sps(self, sps):
+               self.sps = sps
+               self.set_hs(int(self.sps/2.0))
+               self.gr_clock_recovery_mm_xx_0.set_omega(self.sps/2.0)
+
+       def set_max_clock_offset(self, max_clock_offset):
+               self.max_clock_offset = max_clock_offset
+
+       def set_max_carrier_offset(self, max_carrier_offset):
+               self.max_carrier_offset = max_carrier_offset
+               self.pll.set_max_offset(self.max_carrier_offset)
+
+       def set_hs(self, hs):
+               self.hs = hs
+               self.gr_moving_average_xx_0.set_length_and_scale(self.hs, 1.0/self.hs)
+
+if __name__ == '__main__':
+       parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
+       parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default="usrp.dat",
+               help="Set usrp.dat [default=%default]")
+       parser.add_option("-o", "--output-filename", dest="output_filename", type="string", default="frames.dat",
+               help="Set frames.dat [default=%default]")
+       parser.add_option("-d", "--decim", dest="decim", type="intx", default=32,
+               help="Set decim [default=%default]")
+       parser.add_option("-p", "--pll-alpha", dest="pll_alpha", type="eng_float", default=eng_notation.num_to_str(0.01),
+               help="Set pll_alpha [default=%default]")
+       parser.add_option("-s", "--clock-alpha", dest="clock_alpha", type="eng_float", default=eng_notation.num_to_str(0.01),
+               help="Set clock_alpha [default=%default]")
+       (options, args) = parser.parse_args()
+       tb = hrpt_demod(input_filename=options.input_filename, output_filename=options.output_filename, decim=options.decim, pll_alpha=options.pll_alpha, clock_alpha=options.clock_alpha)
+       tb.run()
+
index ac7a87a1608e3d275be08efed4f1f0dc456282d4..990855f6967999d66447ff7f0901e1b99961cf4b 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version='1.0' encoding='ASCII'?>
 <flow_graph>
-  <timestamp>Mon Nov  2 08:31:09 2009</timestamp>
+  <timestamp>Mon Nov  9 07:56:11 2009</timestamp>
   <block>
     <key>options</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>variable_config</key>
-    <param>
-      <key>id</key>
-      <value>output_filename</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>'frames.dat'</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>string</value>
-    </param>
-    <param>
-      <key>config_file</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>section</key>
-      <value>'usrp_rx_hrpt'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'filename'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>output_filename</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(1139, 259)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>max_clock_offset</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(705, 19)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>variable_slider</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>variable_config</key>
-    <param>
-      <key>id</key>
-      <value>saved_pll_alpha</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.05</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>real</value>
-    </param>
-    <param>
-      <key>config_file</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>section</key>
-      <value>'usrp_rx_hrpt'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'pll_alpha'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>pll_alpha</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(823, 258)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable_config</key>
-    <param>
-      <key>id</key>
-      <value>saved_clock_alpha</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.05</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>real</value>
-    </param>
-    <param>
-      <key>config_file</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>section</key>
-      <value>'usrp_rx_hrpt'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'clock_alpha'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>clock_alpha</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(981, 258)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable_config</key>
-    <param>
-      <key>id</key>
-      <value>decim</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>16</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>real</value>
-    </param>
-    <param>
-      <key>config_file</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>section</key>
-      <value>'usrp_rx_hrpt'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'decim'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>decim</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(351, 255)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>variable_config</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>noaa_hrpt_decoder</key>
-    <param>
-      <key>id</key>
-      <value>decoder</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(974, 925)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>gr_agc_xx</key>
     <param>
       <value>0</value>
     </param>
   </block>
+  <block>
+    <key>variable_config</key>
+    <param>
+      <key>id</key>
+      <value>decim</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>32</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>real</value>
+    </param>
+    <param>
+      <key>config_file</key>
+      <value>config_filename</value>
+    </param>
+    <param>
+      <key>section</key>
+      <value>'usrp_rx_hrpt'</value>
+    </param>
+    <param>
+      <key>option</key>
+      <value>'decim'</value>
+    </param>
+    <param>
+      <key>writeback</key>
+      <value>decim</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(351, 255)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_config</key>
+    <param>
+      <key>id</key>
+      <value>saved_pll_alpha</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>0.01</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>real</value>
+    </param>
+    <param>
+      <key>config_file</key>
+      <value>config_filename</value>
+    </param>
+    <param>
+      <key>section</key>
+      <value>'usrp_rx_hrpt'</value>
+    </param>
+    <param>
+      <key>option</key>
+      <value>'pll_alpha'</value>
+    </param>
+    <param>
+      <key>writeback</key>
+      <value>pll_alpha</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(823, 258)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_config</key>
+    <param>
+      <key>id</key>
+      <value>saved_clock_alpha</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>0.01</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>real</value>
+    </param>
+    <param>
+      <key>config_file</key>
+      <value>config_filename</value>
+    </param>
+    <param>
+      <key>section</key>
+      <value>'usrp_rx_hrpt'</value>
+    </param>
+    <param>
+      <key>option</key>
+      <value>'clock_alpha'</value>
+    </param>
+    <param>
+      <key>writeback</key>
+      <value>clock_alpha</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(981, 258)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_config</key>
+    <param>
+      <key>id</key>
+      <value>output_filename</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>'frames.hrpt'</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>string</value>
+    </param>
+    <param>
+      <key>config_file</key>
+      <value>config_filename</value>
+    </param>
+    <param>
+      <key>section</key>
+      <value>'usrp_rx_hrpt'</value>
+    </param>
+    <param>
+      <key>option</key>
+      <value>'filename'</value>
+    </param>
+    <param>
+      <key>writeback</key>
+      <value>output_filename</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1139, 259)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_decoder</key>
+    <param>
+      <key>id</key>
+      <value>decoder</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>verbose</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>output</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(974, 925)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>max_clock_offset</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>100e-6</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(705, 19)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
   <connection>
     <source_block_id>virtual_source_0</source_block_id>
     <sink_block_id>gr_binary_slicer_fb_0</sink_block_id>
index a5f9a8e946148febdbca5407b72e0b754cd39e14..48c5f9d29f49f169b0b1bc3a1afa020694298cd8 100755 (executable)
@@ -2,7 +2,7 @@
 ##################################################
 # Gnuradio Python Flow Graph
 # Title: USRP HRPT Receiver
-# Generated: Mon Nov  2 08:31:10 2009
+# Generated: Mon Nov  9 07:56:11 2009
 ##################################################
 
 from gnuradio import eng_notation
@@ -33,7 +33,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self._decim_config = ConfigParser.ConfigParser()
                self._decim_config.read(config_filename)
                try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim')
-               except: decim = 16
+               except: decim = 32
                self.decim = decim
                self.sym_rate = sym_rate = 600*1109
                self.sample_rate = sample_rate = 64e6/decim
@@ -46,7 +46,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self._saved_pll_alpha_config = ConfigParser.ConfigParser()
                self._saved_pll_alpha_config.read(config_filename)
                try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha')
-               except: saved_pll_alpha = 0.05
+               except: saved_pll_alpha = 0.01
                self.saved_pll_alpha = saved_pll_alpha
                self._saved_gain_config = ConfigParser.ConfigParser()
                self._saved_gain_config.read(config_filename)
@@ -61,16 +61,16 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self._saved_clock_alpha_config = ConfigParser.ConfigParser()
                self._saved_clock_alpha_config.read(config_filename)
                try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat('usrp_rx_hrpt', 'clock_alpha')
-               except: saved_clock_alpha = 0.05
+               except: saved_clock_alpha = 0.01
                self.saved_clock_alpha = saved_clock_alpha
                self.side_text = side_text = side
                self.pll_alpha = pll_alpha = saved_pll_alpha
                self._output_filename_config = ConfigParser.ConfigParser()
                self._output_filename_config.read(config_filename)
                try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename')
-               except: output_filename = 'frames.dat'
+               except: output_filename = 'frames.hrpt'
                self.output_filename = output_filename
-               self.max_clock_offset = max_clock_offset = 0.1
+               self.max_clock_offset = max_clock_offset = 100e-6
                self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate
                self.hs = hs = int(sps/2.0)
                self.gain = gain = saved_gain
@@ -187,7 +187,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                # Blocks
                ##################################################
                self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0)
-               self.decoder = noaa.hrpt_decoder()
+               self.decoder = noaa.hrpt_decoder(True,True)
                self.deframer = noaa.hrpt_deframer()
                self.demod_scope = scopesink2.scope_sink_f(
                        self.displays.GetPage(1).GetWin(),
@@ -256,12 +256,18 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                        self._saved_gain_config.add_section('usrp_rx_hrpt')
                self._saved_gain_config.set('usrp_rx_hrpt', 'gain', str(self.gain))
                self._saved_gain_config.write(open(self.config_filename, 'w'))
-               self._output_filename_config = ConfigParser.ConfigParser()
-               self._output_filename_config.read(self.config_filename)
-               if not self._output_filename_config.has_section('usrp_rx_hrpt'):
-                       self._output_filename_config.add_section('usrp_rx_hrpt')
-               self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename))
-               self._output_filename_config.write(open(self.config_filename, 'w'))
+               self._side_config = ConfigParser.ConfigParser()
+               self._side_config.read(self.config_filename)
+               if not self._side_config.has_section('usrp_rx_hrpt'):
+                       self._side_config.add_section('usrp_rx_hrpt')
+               self._side_config.set('usrp_rx_hrpt', 'side', str(self.side))
+               self._side_config.write(open(self.config_filename, 'w'))
+               self._decim_config = ConfigParser.ConfigParser()
+               self._decim_config.read(self.config_filename)
+               if not self._decim_config.has_section('usrp_rx_hrpt'):
+                       self._decim_config.add_section('usrp_rx_hrpt')
+               self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim))
+               self._decim_config.write(open(self.config_filename, 'w'))
                self._saved_pll_alpha_config = ConfigParser.ConfigParser()
                self._saved_pll_alpha_config.read(self.config_filename)
                if not self._saved_pll_alpha_config.has_section('usrp_rx_hrpt'):
@@ -274,30 +280,24 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                        self._saved_clock_alpha_config.add_section('usrp_rx_hrpt')
                self._saved_clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha))
                self._saved_clock_alpha_config.write(open(self.config_filename, 'w'))
-               self._decim_config = ConfigParser.ConfigParser()
-               self._decim_config.read(self.config_filename)
-               if not self._decim_config.has_section('usrp_rx_hrpt'):
-                       self._decim_config.add_section('usrp_rx_hrpt')
-               self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim))
-               self._decim_config.write(open(self.config_filename, 'w'))
-               self._side_config = ConfigParser.ConfigParser()
-               self._side_config.read(self.config_filename)
-               if not self._side_config.has_section('usrp_rx_hrpt'):
-                       self._side_config.add_section('usrp_rx_hrpt')
-               self._side_config.set('usrp_rx_hrpt', 'side', str(self.side))
-               self._side_config.write(open(self.config_filename, 'w'))
+               self._output_filename_config = ConfigParser.ConfigParser()
+               self._output_filename_config.read(self.config_filename)
+               if not self._output_filename_config.has_section('usrp_rx_hrpt'):
+                       self._output_filename_config.add_section('usrp_rx_hrpt')
+               self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename))
+               self._output_filename_config.write(open(self.config_filename, 'w'))
 
        def set_decim(self, decim):
                self.decim = decim
                self.set_sample_rate(64e6/self.decim)
                self.set_decim_text(self.decim)
+               self.usrp_source.set_decim_rate(self.decim)
                self._decim_config = ConfigParser.ConfigParser()
                self._decim_config.read(self.config_filename)
                if not self._decim_config.has_section('usrp_rx_hrpt'):
                        self._decim_config.add_section('usrp_rx_hrpt')
                self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim))
                self._decim_config.write(open(self.config_filename, 'w'))
-               self.usrp_source.set_decim_rate(self.decim)
 
        def set_sym_rate(self, sym_rate):
                self.sym_rate = sym_rate
@@ -349,14 +349,14 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self.pll_alpha = pll_alpha
                self._pll_alpha_slider.set_value(self.pll_alpha)
                self._pll_alpha_text_box.set_value(self.pll_alpha)
+               self.pll.set_alpha(self.pll_alpha)
+               self.pll.set_beta(self.pll_alpha**2/4.0)
                self._saved_pll_alpha_config = ConfigParser.ConfigParser()
                self._saved_pll_alpha_config.read(self.config_filename)
                if not self._saved_pll_alpha_config.has_section('usrp_rx_hrpt'):
                        self._saved_pll_alpha_config.add_section('usrp_rx_hrpt')
                self._saved_pll_alpha_config.set('usrp_rx_hrpt', 'pll_alpha', str(self.pll_alpha))
                self._saved_pll_alpha_config.write(open(self.config_filename, 'w'))
-               self.pll.set_alpha(self.pll_alpha)
-               self.pll.set_beta(self.pll_alpha**2/4.0)
 
        def set_output_filename(self, output_filename):
                self.output_filename = output_filename
@@ -410,14 +410,14 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self.clock_alpha = clock_alpha
                self._clock_alpha_slider.set_value(self.clock_alpha)
                self._clock_alpha_text_box.set_value(self.clock_alpha)
+               self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0)
+               self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha)
                self._saved_clock_alpha_config = ConfigParser.ConfigParser()
                self._saved_clock_alpha_config.read(self.config_filename)
                if not self._saved_clock_alpha_config.has_section('usrp_rx_hrpt'):
                        self._saved_clock_alpha_config.add_section('usrp_rx_hrpt')
                self._saved_clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha))
                self._saved_clock_alpha_config.write(open(self.config_filename, 'w'))
-               self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0)
-               self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha)
 
 if __name__ == '__main__':
        parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
index 02d509f08d99bd7b644cbd8a664a3913b2b9264a..22bd3bdc3cacda8ead81442e282179d5255ebc39 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version='1.0' encoding='ASCII'?>
 <flow_graph>
-  <timestamp>Mon Nov  2 08:31:35 2009</timestamp>
+  <timestamp>Mon Nov  9 08:03:25 2009</timestamp>
   <block>
     <key>options</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>max_clock_offset</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(705, 19)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>variable</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>variable_config</key>
-    <param>
-      <key>id</key>
-      <value>clock_alpha</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.05</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>real</value>
-    </param>
-    <param>
-      <key>config_file</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>section</key>
-      <value>'usrp_rx_hrpt'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'clock_alpha'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>clock_alpha</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(986, 101)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>variable_config</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>variable_config</key>
-    <param>
-      <key>id</key>
-      <value>decim</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>16</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>real</value>
-    </param>
-    <param>
-      <key>config_file</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>section</key>
-      <value>'usrp_rx_hrpt'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'decim'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>decim</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(355, 97)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable_config</key>
-    <param>
-      <key>id</key>
-      <value>output_filename</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>'frames.dat'</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>string</value>
-    </param>
-    <param>
-      <key>config_file</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>section</key>
-      <value>'usrp_rx_hrpt'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'filename'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>output_filename</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(1143, 101)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable_config</key>
-    <param>
-      <key>id</key>
-      <value>pll_alpha</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.05</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>real</value>
-    </param>
-    <param>
-      <key>config_file</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>section</key>
-      <value>'usrp_rx_hrpt'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'pll_alpha'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>pll_alpha</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(827, 100)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>variable_config</key>
     <param>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_decoder</key>
+    <key>gr_binary_slicer_fb</key>
     <param>
       <key>id</key>
-      <value>decoder</value>
+      <value>gr_binary_slicer_fb_0</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(1027, 623)</value>
+      <value>(446, 673)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>gr_binary_slicer_fb</key>
+    <key>noaa_hrpt_deframer</key>
     <param>
       <key>id</key>
-      <value>gr_binary_slicer_fb_0</value>
+      <value>deframer</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(446, 673)</value>
+      <value>(815, 673)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_deframer</key>
+    <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>deframer</value>
+      <value>decim</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
+    <param>
+      <key>value</key>
+      <value>32</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>real</value>
+    </param>
+    <param>
+      <key>config_file</key>
+      <value>config_filename</value>
+    </param>
+    <param>
+      <key>section</key>
+      <value>'usrp_rx_hrpt'</value>
+    </param>
+    <param>
+      <key>option</key>
+      <value>'decim'</value>
+    </param>
+    <param>
+      <key>writeback</key>
+      <value>decim</value>
+    </param>
     <param>
       <key>_coordinate</key>
-      <value>(815, 673)</value>
+      <value>(355, 97)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_config</key>
+    <param>
+      <key>id</key>
+      <value>pll_alpha</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>0.01</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>real</value>
+    </param>
+    <param>
+      <key>config_file</key>
+      <value>config_filename</value>
+    </param>
+    <param>
+      <key>section</key>
+      <value>'usrp_rx_hrpt'</value>
+    </param>
+    <param>
+      <key>option</key>
+      <value>'pll_alpha'</value>
+    </param>
+    <param>
+      <key>writeback</key>
+      <value>pll_alpha</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(827, 100)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_config</key>
+    <param>
+      <key>id</key>
+      <value>clock_alpha</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>0.01</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>real</value>
+    </param>
+    <param>
+      <key>config_file</key>
+      <value>config_filename</value>
+    </param>
+    <param>
+      <key>section</key>
+      <value>'usrp_rx_hrpt'</value>
+    </param>
+    <param>
+      <key>option</key>
+      <value>'clock_alpha'</value>
+    </param>
+    <param>
+      <key>writeback</key>
+      <value>clock_alpha</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(986, 101)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_config</key>
+    <param>
+      <key>id</key>
+      <value>output_filename</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>'frames.hrpt'</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>string</value>
+    </param>
+    <param>
+      <key>config_file</key>
+      <value>config_filename</value>
+    </param>
+    <param>
+      <key>section</key>
+      <value>'usrp_rx_hrpt'</value>
+    </param>
+    <param>
+      <key>option</key>
+      <value>'filename'</value>
+    </param>
+    <param>
+      <key>writeback</key>
+      <value>output_filename</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1143, 101)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>max_clock_offset</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>100e-6</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(705, 19)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_decoder</key>
+    <param>
+      <key>id</key>
+      <value>decoder</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>verbose</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>output</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1027, 623)</value>
     </param>
     <param>
       <key>_rotation</key>
index 4dc32dbda9df8686c3f346ba5a9f124bb73d3643..1b510bdb2ef2851c005e41a8a5f9f6284b3ed949 100755 (executable)
@@ -2,7 +2,7 @@
 ##################################################
 # Gnuradio Python Flow Graph
 # Title: Usrp Rx Hrpt Nogui
-# Generated: Mon Nov  2 08:31:35 2009
+# Generated: Mon Nov  9 08:03:25 2009
 ##################################################
 
 from gnuradio import eng_notation
@@ -27,7 +27,7 @@ class usrp_rx_hrpt_nogui(gr.top_block):
                self._decim_config = ConfigParser.ConfigParser()
                self._decim_config.read(config_filename)
                try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim')
-               except: decim = 16
+               except: decim = 32
                self.decim = decim
                self.sym_rate = sym_rate = 600*1109
                self.sample_rate = sample_rate = 64e6/decim
@@ -40,14 +40,14 @@ class usrp_rx_hrpt_nogui(gr.top_block):
                self._pll_alpha_config = ConfigParser.ConfigParser()
                self._pll_alpha_config.read(config_filename)
                try: pll_alpha = self._pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha')
-               except: pll_alpha = 0.05
+               except: pll_alpha = 0.01
                self.pll_alpha = pll_alpha
                self._output_filename_config = ConfigParser.ConfigParser()
                self._output_filename_config.read(config_filename)
                try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename')
-               except: output_filename = 'frames.dat'
+               except: output_filename = 'frames.hrpt'
                self.output_filename = output_filename
-               self.max_clock_offset = max_clock_offset = 0.1
+               self.max_clock_offset = max_clock_offset = 100e-6
                self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate
                self.hs = hs = int(sps/2.0)
                self._gain_config = ConfigParser.ConfigParser()
@@ -63,14 +63,14 @@ class usrp_rx_hrpt_nogui(gr.top_block):
                self._clock_alpha_config = ConfigParser.ConfigParser()
                self._clock_alpha_config.read(config_filename)
                try: clock_alpha = self._clock_alpha_config.getfloat('usrp_rx_hrpt', 'clock_alpha')
-               except: clock_alpha = 0.05
+               except: clock_alpha = 0.01
                self.clock_alpha = clock_alpha
 
                ##################################################
                # Blocks
                ##################################################
                self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0)
-               self.decoder = noaa.hrpt_decoder()
+               self.decoder = noaa.hrpt_decoder(True,True)
                self.deframer = noaa.hrpt_deframer()
                self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename)
                self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
@@ -96,12 +96,6 @@ class usrp_rx_hrpt_nogui(gr.top_block):
 
        def set_config_filename(self, config_filename):
                self.config_filename = config_filename
-               self._clock_alpha_config = ConfigParser.ConfigParser()
-               self._clock_alpha_config.read(self.config_filename)
-               if not self._clock_alpha_config.has_section('usrp_rx_hrpt'):
-                       self._clock_alpha_config.add_section('usrp_rx_hrpt')
-               self._clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha))
-               self._clock_alpha_config.write(open(self.config_filename, 'w'))
                self._gain_config = ConfigParser.ConfigParser()
                self._gain_config.read(self.config_filename)
                if not self._gain_config.has_section('usrp_rx_hrpt'):
@@ -114,41 +108,47 @@ class usrp_rx_hrpt_nogui(gr.top_block):
                        self._freq_config.add_section('usrp_rx_hrpt')
                self._freq_config.set('usrp_rx_hrpt', 'freq', str(self.freq))
                self._freq_config.write(open(self.config_filename, 'w'))
+               self._side_config = ConfigParser.ConfigParser()
+               self._side_config.read(self.config_filename)
+               if not self._side_config.has_section('usrp_rx_hrpt'):
+                       self._side_config.add_section('usrp_rx_hrpt')
+               self._side_config.set('usrp_rx_hrpt', 'side', str(self.side))
+               self._side_config.write(open(self.config_filename, 'w'))
                self._decim_config = ConfigParser.ConfigParser()
                self._decim_config.read(self.config_filename)
                if not self._decim_config.has_section('usrp_rx_hrpt'):
                        self._decim_config.add_section('usrp_rx_hrpt')
                self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim))
                self._decim_config.write(open(self.config_filename, 'w'))
-               self._output_filename_config = ConfigParser.ConfigParser()
-               self._output_filename_config.read(self.config_filename)
-               if not self._output_filename_config.has_section('usrp_rx_hrpt'):
-                       self._output_filename_config.add_section('usrp_rx_hrpt')
-               self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename))
-               self._output_filename_config.write(open(self.config_filename, 'w'))
                self._pll_alpha_config = ConfigParser.ConfigParser()
                self._pll_alpha_config.read(self.config_filename)
                if not self._pll_alpha_config.has_section('usrp_rx_hrpt'):
                        self._pll_alpha_config.add_section('usrp_rx_hrpt')
                self._pll_alpha_config.set('usrp_rx_hrpt', 'pll_alpha', str(self.pll_alpha))
                self._pll_alpha_config.write(open(self.config_filename, 'w'))
-               self._side_config = ConfigParser.ConfigParser()
-               self._side_config.read(self.config_filename)
-               if not self._side_config.has_section('usrp_rx_hrpt'):
-                       self._side_config.add_section('usrp_rx_hrpt')
-               self._side_config.set('usrp_rx_hrpt', 'side', str(self.side))
-               self._side_config.write(open(self.config_filename, 'w'))
+               self._clock_alpha_config = ConfigParser.ConfigParser()
+               self._clock_alpha_config.read(self.config_filename)
+               if not self._clock_alpha_config.has_section('usrp_rx_hrpt'):
+                       self._clock_alpha_config.add_section('usrp_rx_hrpt')
+               self._clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha))
+               self._clock_alpha_config.write(open(self.config_filename, 'w'))
+               self._output_filename_config = ConfigParser.ConfigParser()
+               self._output_filename_config.read(self.config_filename)
+               if not self._output_filename_config.has_section('usrp_rx_hrpt'):
+                       self._output_filename_config.add_section('usrp_rx_hrpt')
+               self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename))
+               self._output_filename_config.write(open(self.config_filename, 'w'))
 
        def set_decim(self, decim):
                self.decim = decim
                self.set_sample_rate(64e6/self.decim)
+               self.usrp_source.set_decim_rate(self.decim)
                self._decim_config = ConfigParser.ConfigParser()
                self._decim_config.read(self.config_filename)
                if not self._decim_config.has_section('usrp_rx_hrpt'):
                        self._decim_config.add_section('usrp_rx_hrpt')
                self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim))
                self._decim_config.write(open(self.config_filename, 'w'))
-               self.usrp_source.set_decim_rate(self.decim)
 
        def set_sym_rate(self, sym_rate):
                self.sym_rate = sym_rate
@@ -175,14 +175,14 @@ class usrp_rx_hrpt_nogui(gr.top_block):
 
        def set_pll_alpha(self, pll_alpha):
                self.pll_alpha = pll_alpha
+               self.pll.set_alpha(self.pll_alpha)
+               self.pll.set_beta(self.pll_alpha**2/4.0)
                self._pll_alpha_config = ConfigParser.ConfigParser()
                self._pll_alpha_config.read(self.config_filename)
                if not self._pll_alpha_config.has_section('usrp_rx_hrpt'):
                        self._pll_alpha_config.add_section('usrp_rx_hrpt')
                self._pll_alpha_config.set('usrp_rx_hrpt', 'pll_alpha', str(self.pll_alpha))
                self._pll_alpha_config.write(open(self.config_filename, 'w'))
-               self.pll.set_alpha(self.pll_alpha)
-               self.pll.set_beta(self.pll_alpha**2/4.0)
 
        def set_output_filename(self, output_filename):
                self.output_filename = output_filename
@@ -226,14 +226,14 @@ class usrp_rx_hrpt_nogui(gr.top_block):
 
        def set_clock_alpha(self, clock_alpha):
                self.clock_alpha = clock_alpha
+               self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0)
+               self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha)
                self._clock_alpha_config = ConfigParser.ConfigParser()
                self._clock_alpha_config.read(self.config_filename)
                if not self._clock_alpha_config.has_section('usrp_rx_hrpt'):
                        self._clock_alpha_config.add_section('usrp_rx_hrpt')
                self._clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha))
                self._clock_alpha_config.write(open(self.config_filename, 'w'))
-               self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0)
-               self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha)
 
 if __name__ == '__main__':
        parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
index 183d72aba34b2d7e0ef18780a5fb0dc4c2c3768b..2d6e98c5311dc420e3715da5fcfe14370428c2e1 100644 (file)
@@ -4,7 +4,20 @@
   <key>noaa_hrpt_decoder</key>
   <category>NOAA</category>
   <import>from gnuradio import noaa</import>
-  <make>noaa.hrpt_decoder()</make>
+  <make>noaa.hrpt_decoder($verbose,$output)</make>
+
+  <param>
+    <name>Verbose</name>
+    <key>verbose</key>
+    <type>bool</type>
+  </param>
+
+  <param>
+    <name>Output Files</name>
+    <key>output</key>
+    <type>bool</type>
+  </param>
+
   <sink>
     <name>in</name>
     <type>short</type>
index 4ef4eb87bdaf884ddeb3862a05f17d3fec38be34..f01bbfab89c46bf21e086ffe294994fce274ae72 100644 (file)
@@ -33,6 +33,9 @@ libgnuradio_noaa_la_SOURCES = \
        noaa_hrpt_deframer.cc \
        noaa_hrpt_pll_cf.cc
 
+noinst_HEADERS = \
+       noaa_hrpt.h
+
 libgnuradio_noaa_la_LIBADD = \
        $(GNURADIO_CORE_LA)
 
diff --git a/gr-noaa/lib/noaa_hrpt.h b/gr-noaa/lib/noaa_hrpt.h
new file mode 100644 (file)
index 0000000..3812e93
--- /dev/null
@@ -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 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_NOAA_HRPT_H
+#define INCLUDED_NOAA_HRPT_H
+
+#define HRPT_SYNC1 0x0284
+#define HRPT_SYNC2 0x016F
+#define HRPT_SYNC3 0x035C
+#define HRPT_SYNC4 0x019D
+#define HRPT_SYNC5 0x020F
+#define HRPT_SYNC6 0x0095
+
+#define HRPT_MINOR_FRAME_SYNC  0x0A116FD719D83C95LL
+
+#define HRPT_SYNC_WORDS        6
+#define HRPT_MINOR_FRAME_WORDS 11090
+#define HRPT_BITS_PER_WORD     10
+
+#endif /* INCLUDED_NOAA_HRPT_H */
index 8cfaa913c46c588e69bce82c8d58ec632c8a1a4f..24331008910748ea0016c60aa210e2ba7e1714a3 100644 (file)
 #endif
 
 #include <noaa_hrpt_decoder.h>
+#include <noaa_hrpt.h>
 #include <gr_io_signature.h>
+#include <cstdio>
 
-#define SYNC1 0x0284
-#define SYNC2 0x016F
-#define SYNC3 0x035C
-#define SYNC4 0x019D
-#define SYNC5 0x020F
-#define SYNC6 0x0095
+static const char *hrpt_ids[] = {
+  "000000",
+  "NOAA11",
+  "000002",
+  "NOAA16",
+  "000004",
+  "000005",
+  "000006",
+  "NOAA15",
+  "000008",
+  "NOAA12",
+  "000010",
+  "NOAA17",
+  "000012",
+  "NOAA18",
+  "000014",
+  "NOAA19"
+};
 
 noaa_hrpt_decoder_sptr
-noaa_make_hrpt_decoder()
+noaa_make_hrpt_decoder(bool verbose, bool output_files)
 {
-  return gnuradio::get_initial_sptr(new noaa_hrpt_decoder());
+  return gnuradio::get_initial_sptr(new noaa_hrpt_decoder(verbose, output_files));
 }
 
-noaa_hrpt_decoder::noaa_hrpt_decoder()
+noaa_hrpt_decoder::noaa_hrpt_decoder(bool verbose, bool output_files)
   : gr_sync_block("noaa_hrpt_decoder",
                  gr_make_io_signature(1, 1, sizeof(short)),
-                 gr_make_io_signature(0, 0, 0))
+                 gr_make_io_signature(0, 0, 0)),
+    d_verbose(verbose),
+    d_output_files(output_files),
+    d_word_num(0),
+    d_frames_seen(0),
+    d_current_mfnum(0),
+    d_expected_mfnum(0),
+    d_seq_errs(0),
+    d_address(0),
+    d_day_of_year(0),
+    d_milliseconds(0),
+    d_last_time(0)
 {
-  d_word_count = 0;
+  // Start of capture processing here
 }
 
 int
@@ -57,21 +82,119 @@ noaa_hrpt_decoder::work(int noutput_items,
 
   int i = 0;
   while (i < noutput_items) {
-    unsigned short word = in[i++];
-    d_word_count++;
-    //fprintf(stderr, "%5u:  ", d_word_count);
-    for (int pos = 0; pos < 10; pos++) {
-      char ch = (word & (1 << 9)) ? '1' : '0';
-      word = word << 1;
-      //fprintf(stderr, "%c ", ch);
+    d_current_word = in[i++] & 0x3FF;
+    d_word_num++;
+
+    // Per HRPT word processing here
+
+    switch (d_word_num) {
+    case 7:
+      process_mfnum();
+      process_address();
+      break;
+
+    case 9:
+      process_day_of_year();
+      break;
+
+    case 10:
+      process_milli1();
+      break;
+
+    case 11:
+      process_milli2();
+      break;
+
+    case 12:
+      process_milli3();
+      break;
+
+    default:
+      break;
     }
-    //fprintf(stderr, "\n");
 
-    if (d_word_count == 11090) {
-      d_word_count = 0;
-      //fprintf(stderr, "\n");
+    if (d_word_num == HRPT_MINOR_FRAME_WORDS) {
+
+      // End of minor frame processing here
+      d_frames_seen++;
+      d_word_num = 0;
+      fprintf(stderr, "\n");
     }
   }
 
   return i;
 }
+
+void
+noaa_hrpt_decoder::process_mfnum()
+{
+  d_current_mfnum = (d_current_word & 0x180) >> 7;
+
+  if (d_verbose)
+    fprintf(stderr, "MF:");
+
+  if (d_current_mfnum != d_expected_mfnum && d_frames_seen > 0) {
+    d_seq_errs++;
+
+    if (d_verbose)
+      fprintf(stderr, "*");
+  }
+  else
+    if (d_verbose)
+      fprintf(stderr, " ");
+  
+  if (d_verbose)
+    fprintf(stderr, "%i  ", d_current_mfnum);
+  d_expected_mfnum = (d_current_mfnum == 3) ? 1 : d_current_mfnum+1;
+}
+
+void
+noaa_hrpt_decoder::process_address()
+{
+  d_address = ((d_current_word & 0x078) >> 3) & 0x000F;
+
+  if (d_verbose)
+    fprintf(stderr, "SA: %s  ", hrpt_ids[d_address]);
+}
+
+void
+noaa_hrpt_decoder::process_day_of_year()
+{
+  d_day_of_year = d_current_word >> 1;
+
+  if (d_verbose)
+    fprintf(stderr, "DOY: %3i  ", d_day_of_year);
+}
+
+void
+noaa_hrpt_decoder::process_milli1()
+{
+  d_milliseconds = (d_current_word & 0x7F) << 20;
+}
+
+void
+noaa_hrpt_decoder::process_milli2()
+{
+  d_milliseconds |= (d_current_word << 10);
+}
+
+void
+noaa_hrpt_decoder::process_milli3()
+{
+  d_milliseconds |= d_current_word;
+  int delta = d_milliseconds - d_last_time;
+  d_last_time = d_milliseconds;
+
+  if (d_verbose)
+    fprintf(stderr, "MS: %8i  DT: %8i", d_milliseconds, delta);
+}
+
+noaa_hrpt_decoder::~noaa_hrpt_decoder()
+{
+  // End of capture processing here
+
+  if (d_verbose) {
+    fprintf(stderr, "Frames seen:     %10i\n", d_frames_seen);
+    fprintf(stderr, "Sequence errors: %10i\n", d_seq_errs);
+  }
+}
index 305243b09a273f4b360e9247ba2bc22af6099231..9d67d7108e64af9a54567c2152b2fc4bd6519c99 100644 (file)
@@ -29,16 +29,45 @@ class noaa_hrpt_decoder;
 typedef boost::shared_ptr<noaa_hrpt_decoder> noaa_hrpt_decoder_sptr;
 
 noaa_hrpt_decoder_sptr
-noaa_make_hrpt_decoder();
+noaa_make_hrpt_decoder(bool verbose, bool output_files);
 
 class noaa_hrpt_decoder : public gr_sync_block
 {
-  friend noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder();
-  noaa_hrpt_decoder();
+  friend noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder(bool verbose, bool output_files);
+  noaa_hrpt_decoder(bool verbose, bool output_files);
+
+  // Configuration
+  bool d_verbose;
+  bool d_output_files;
+
+  // Frame-level state
+  unsigned short d_current_word;
+  unsigned int   d_word_num;
+  int            d_frames_seen;
+
+  // Minor frame number
+  int d_current_mfnum;
+  int d_expected_mfnum;
+  int d_seq_errs;
+
+  // Spacecraft address
+  int d_address;
+
+  // Minor frame timestamp
+  int d_day_of_year;
+  int d_milliseconds;
+  int d_last_time;
+
+  void process_mfnum();
+  void process_address();
+  void process_day_of_year();
+  void process_milli1();
+  void process_milli2();
+  void process_milli3();
 
-  unsigned int d_word_count;
 public:
+  ~noaa_hrpt_decoder();
+
   int work(int noutput_items,
           gr_vector_const_void_star &input_items,
           gr_vector_void_star &output_items);
index e79894869bb7568043a2f1c40ee2e224eaf20393..1a2af6c37922c3b52c6510530d68d6e474ccec69 100644 (file)
 
 #include <noaa_hrpt_deframer.h>
 #include <gr_io_signature.h>
+#include <noaa_hrpt.h>
 #include <cstring>
 #include <cstdio>
 
 #define ST_IDLE   0
 #define ST_SYNCED 1
 
-#define SYNC1 0x0284
-#define SYNC2 0x016F
-#define SYNC3 0x035C
-#define SYNC4 0x019D
-#define SYNC5 0x020F
-#define SYNC6 0x0095
-
-#define HRPT_MINOR_FRAME_SYNC  0x0A116FD719D83C95LL
-
-static int frames_seen = 0;
-
 noaa_hrpt_deframer_sptr
 noaa_make_hrpt_deframer()
 {
@@ -98,13 +88,12 @@ noaa_hrpt_deframer::general_work(int noutput_items,
        d_shifter = (d_shifter << 1) | bit; // MSB transmitted first
        
        if ((d_shifter & 0x0FFFFFFFFFFFFFFFLL) == HRPT_MINOR_FRAME_SYNC) {
-         fprintf(stderr, "SYNC #%i", frames_seen++);
-         out[j++] = SYNC1;
-         out[j++] = SYNC2;
-         out[j++] = SYNC3;
-         out[j++] = SYNC4;
-         out[j++] = SYNC5;
-         out[j++] = SYNC6;
+         out[j++] = HRPT_SYNC1;
+         out[j++] = HRPT_SYNC2;
+         out[j++] = HRPT_SYNC3;
+         out[j++] = HRPT_SYNC4;
+         out[j++] = HRPT_SYNC5;
+         out[j++] = HRPT_SYNC6;
          enter_synced();
        }
        break;
@@ -116,7 +105,6 @@ noaa_hrpt_deframer::general_work(int noutput_items,
          d_word = 0;
          d_bit_count = HRPT_BITS_PER_WORD;
          if (--d_word_count == 0) {
-           fprintf(stderr, "...done\n");
            enter_idle();
          }
        }
index 43abba0e9152bb383c728d07e1766a14d8870b88..b11d0fa2b6bed7de78f3e59687bc999403b49b55 100644 (file)
 #ifndef INCLUDED_NOAA_HRPT_DEFRAMER_H
 #define INCLUDED_NOAA_HRPT_DEFRAMER_H
 
-#define HRPT_SYNC_WORDS        6
-#define HRPT_MINOR_FRAME_WORDS 11090
-#define HRPT_BITS_PER_WORD     10
-
 #include <gr_block.h>
 
 class noaa_hrpt_deframer;
index aeb22faace48e13b0f4a381ade96606d89824de2..73842f0a9f6b19a46071396aa400ac31ca2fc691 100644 (file)
@@ -23,7 +23,7 @@
 % Extract AVHRR images from HRPT frames.dat
 clear
 
-fid = fopen('frames.dat');
+fid = fopen('frames.hrpt');
 dat = fread(fid, 'uint16');
 
 frame_len = 11090;
index ddf181c280e62bad89a1503594b93b5e00b503ea..220a5714d75a690bbc06ccfc8428a96d562679a1 100644 (file)
@@ -23,7 +23,7 @@
 GR_SWIG_BLOCK_MAGIC(noaa,hrpt_decoder)
 
 noaa_hrpt_decoder_sptr
-noaa_make_hrpt_decoder();
+noaa_make_hrpt_decoder(bool verbose, bool output_files);
 
 class noaa_hrpt_decoder : public gr_sync_block
 {
index 0e9f1215bfed07ab464208a5dedf78b288800108..7b495fd2b46202be188c4ae3350f0e47c8fe1189 100644 (file)
@@ -26,10 +26,11 @@ if PYTHON
 dist_bin_SCRIPTS = \
        usrp_flex.py \
        usrp_flex_all.py \
-       usrp_flex_band.py \
+       usrp_flex_band.py
+
+noinst_PYTHON = \
        usrp_rx_flex.py
 endif
 
 EXTRA_DIST = \
        usrp_rx_flex.grc
-
index 42053eb17ca1e4bd79adc69d800cc79c07060e60..1d8a43b3c831fd4073469cd7ac309fe1da09ee04 100644 (file)
@@ -21,8 +21,6 @@
 
 include $(top_srcdir)/Makefile.common
 
-EXTRA_DIST = run_tests.in
-
 AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES)
 
 # These headers get installed in ${prefix}/include/gnuradio
index b2015cc403ec4f5cffab3284e82311f8e350fb74..42eb6b3fbcfb23368bbf9417977eda07df2667f0 100644 (file)
@@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 from . import odict
 from Element import Element
-from Param import Param
-from Port import Port
 
 from Cheetah.Template import Template
 from UserDict import UserDict
index 7c51ef42a475a7fb0ba6fceff4465c2131c079a3..b4ac8fc3a2bf6a489d027cd07d77c8dae7b48eec 100644 (file)
@@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 from . import odict
 from Element import Element
-from Block import Block
-from Connection import Connection
 from .. gui import Messages
 
 class FlowGraph(Element):
index e436cc7645e970708505ba4c8d8db2173a2f4580..9c91af54376c9ce6f85ba343682a089a4316178a 100644 (file)
@@ -34,6 +34,8 @@ dist_ourdata_DATA = \
        blks2_cvsd_decode.xml \
        blks2_dxpsk_demod.xml \
        blks2_dxpsk_mod.xml \
+       blks2_dxpsk2_demod.xml \
+       blks2_dxpsk2_mod.xml \
        blks2_error_rate.xml \
        blks2_fm_deemph.xml \
        blks2_fm_demod_cf.xml \
diff --git a/grc/blocks/blks2_dxpsk2_demod.xml b/grc/blocks/blks2_dxpsk2_demod.xml
new file mode 100644 (file)
index 0000000..ce8305c
--- /dev/null
@@ -0,0 +1,145 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##DPSK2 Demod - 2, 4
+###################################################
+ -->
+<block>
+       <name>DPSK2 Demod</name>
+       <key>blks2_dxpsk2_demod</key>
+       <import>from gnuradio import blks2</import>
+       <make>blks2.$(type)2_demod(
+       samples_per_symbol=$samples_per_symbol,
+       excess_bw=$excess_bw,
+       costas_alpha=$costas_alpha,
+       timing_alpha=$timing_alpha,
+       timing_max_dev=$timing_max_dev,
+       gray_code=$gray_code,
+       verbose=$verbose,
+       log=$log,
+       sync_out=$sync_out,
+)</make>
+       <callback>clock_recov.set_alpha($costas_alpha)</callback>
+       <callback>clock_recov.set_beta(0.25*$costas_alpha**2)</callback>
+       <callback>time_recov.set_alpha($timing_alpha)</callback>
+       <param>
+               <name>Type</name>
+               <key>type</key>
+               <type>enum</type>
+               <option>
+                       <name>DBPSK</name>
+                       <key>dbpsk</key>
+               </option>
+               <option>
+                       <name>DQPSK</name>
+                       <key>dqpsk</key>
+               </option>
+       </param>
+       <param>
+               <name>Samples/Symbol</name>
+               <key>samples_per_symbol</key>
+               <value>2</value>
+               <type>int</type>
+       </param>
+       <param>
+               <name>Excess BW</name>
+               <key>excess_bw</key>
+               <value>0.35</value>
+               <type>real</type>
+       </param>
+       <param>
+               <name>Costas Alpha</name>
+               <key>costas_alpha</key>
+               <value>0.175</value>
+               <type>real</type>
+       </param>
+       <param>
+               <name>Timing Alpha</name>
+               <key>timing_alpha</key>
+               <value>0.100</value>
+               <type>real</type>
+       </param>
+       <param>
+               <name>Timing Max Dev</name>
+               <key>timing_max_dev</key>
+               <value>1.5</value>
+               <type>real</type>
+       </param>
+       <param>
+               <name>Omega Relative Limit</name>
+               <key>omega_relative_limit</key>
+               <value>0.005</value>
+               <type>real</type>
+       </param>
+       <param>
+               <name>Gray Code</name>
+               <key>gray_code</key>
+               <value>True</value>
+               <type>bool</type>
+               <option>
+                       <name>Yes</name>
+                       <key>True</key>
+               </option>
+               <option>
+                       <name>No</name>
+                       <key>False</key>
+               </option>
+       </param>
+       <param>
+               <name>Verbose</name>
+               <key>verbose</key>
+               <value>False</value>
+               <type>bool</type>
+               <hide>#if str($verbose) == 'False' then 'part' else 'none'#</hide>
+               <option>
+                       <name>On</name>
+                       <key>True</key>
+               </option>
+               <option>
+                       <name>Off</name>
+                       <key>False</key>
+               </option>
+       </param>
+       <param>
+               <name>Logging</name>
+               <key>log</key>
+               <value>False</value>
+               <type>bool</type>
+               <hide>#if str($log) == 'False' then 'part' else 'none'#</hide>
+               <option>
+                       <name>On</name>
+                       <key>True</key>
+               </option>
+               <option>
+                       <name>Off</name>
+                       <key>False</key>
+               </option>
+       </param>
+       <param>
+               <name>Sync Out</name>
+               <key>sync_out</key>
+               <value>False</value>
+               <type>bool</type>
+               <option>
+                       <name>On</name>
+                       <key>True</key>
+               </option>
+               <option>
+                       <name>Off</name>
+                       <key>False</key>
+               </option>
+       </param>
+       <sink>
+               <name>in</name>
+               <type>complex</type>
+       </sink>
+       <source>
+               <name>out</name>
+               <type>byte</type>
+       </source>
+       <source>
+               <name>sync</name>
+               <type>complex</type>
+               <optional>1</optional>
+       </source>
+</block>
diff --git a/grc/blocks/blks2_dxpsk2_mod.xml b/grc/blocks/blks2_dxpsk2_mod.xml
new file mode 100644 (file)
index 0000000..bf292be
--- /dev/null
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##DPSK2 Mod - 2, 4
+###################################################
+ -->
+<block>
+       <name>DPSK2 Mod</name>
+       <key>blks2_dxpsk2_mod</key>
+       <import>from gnuradio import blks2</import>
+       <make>blks2.$(type)2_mod(
+       samples_per_symbol=$samples_per_symbol,
+       excess_bw=$excess_bw,
+       gray_code=$gray_code,
+       verbose=$verbose,
+       log=$log,
+)</make>
+       <param>
+               <name>Type</name>
+               <key>type</key>
+               <type>enum</type>
+               <option>
+                       <name>DBPSK</name>
+                       <key>dbpsk</key>
+               </option>
+               <option>
+                       <name>DQPSK</name>
+                       <key>dqpsk</key>
+               </option>
+       </param>
+       <param>
+               <name>Samples/Symbol</name>
+               <key>samples_per_symbol</key>
+               <value>2</value>
+               <type>int</type>
+       </param>
+       <param>
+               <name>Excess BW</name>
+               <key>excess_bw</key>
+               <value>0.35</value>
+               <type>real</type>
+       </param>
+       <param>
+               <name>Gray Code</name>
+               <key>gray_code</key>
+               <value>True</value>
+               <type>bool</type>
+               <option>
+                       <name>Yes</name>
+                       <key>True</key>
+               </option>
+               <option>
+                       <name>No</name>
+                       <key>False</key>
+               </option>
+       </param>
+       <param>
+               <name>Verbose</name>
+               <key>verbose</key>
+               <value>False</value>
+               <type>bool</type>
+               <hide>#if str($verbose) == 'False' then 'part' else 'none'#</hide>
+               <option>
+                       <name>On</name>
+                       <key>True</key>
+               </option>
+               <option>
+                       <name>Off</name>
+                       <key>False</key>
+               </option>
+       </param>
+       <param>
+               <name>Logging</name>
+               <key>log</key>
+               <value>False</value>
+               <type>bool</type>
+               <hide>#if str($log) == 'False' then 'part' else 'none'#</hide>
+               <option>
+                       <name>On</name>
+                       <key>True</key>
+               </option>
+               <option>
+                       <name>Off</name>
+                       <key>False</key>
+               </option>
+       </param>
+       <sink>
+               <name>in</name>
+               <type>byte</type>
+       </sink>
+       <source>
+               <name>out</name>
+               <type>complex</type>
+       </source>
+</block>
index 4c13b3415e73ec5f2beeb82bc3c7c7f3229c1dd6..1c96b6cec62ab7d0e554ff90b3ce9857ea395e5c 100644 (file)
@@ -76,7 +76,7 @@
                <name>Gray Code</name>
                <key>gray_code</key>
                <value>True</value>
-               <type>enum</type>
+               <type>bool</type>
                <option>
                        <name>Yes</name>
                        <key>True</key>
index 28fd742fa6b9400c238b5d1b58f99b24bce2de27..77505d8ad588f54b3e7def2f00dd43de9f3ae233 100644 (file)
@@ -48,7 +48,7 @@
                <name>Gray Code</name>
                <key>gray_code</key>
                <value>True</value>
-               <type>enum</type>
+               <type>bool</type>
                <option>
                        <name>Yes</name>
                        <key>True</key>
index fc074cb69101e0577bf4e84b060a2ef008baf7dc..57703f6d69f4f01e78aa18f6d0169d885ea3863d 100644 (file)
                <block>blks2_dxpsk_mod</block>
                <block>blks2_dxpsk_demod</block>
 
+               <block>blks2_dxpsk2_mod</block>
+               <block>blks2_dxpsk2_demod</block>
+
                <block>blks2_gmsk_mod</block>
                <block>blks2_gmsk_demod</block>
 
index 734526793fae96b1c1ef890faf61feeab0c3167b..2e949526039150e0e166c9deb1bcfc415815bfcc 100644 (file)
@@ -9,10 +9,10 @@
        <key>pad_sink</key>
        <make></make>
        <param>
-               <name>Num Inputs</name>
-               <key>nports</key>
-               <value>1</value>
-               <type>int</type>
+               <name>Label</name>
+               <key>label</key>
+               <value>out</value>
+               <type>string</type>
        </param>
        <param>
                <name>Input Type</name>
                <type>int</type>
        </param>
        <check>$vlen &gt; 0</check>
-       <check>0 &lt; $nports</check>
        <sink>
                <name>in</name>
                <type>$type</type>
                <vlen>$vlen</vlen>
-               <nports>$nports</nports>
        </sink>
        <doc>
-The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block. \
-Limit one sink pad block per flow graph.
+The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block.
+
+Pad sink will be ordered alphabetically by their ids. The first pad sink will have an index of 0.
        </doc>
 </block>
index f44d9623879d77b1c35026b82eeddf745bdc3b3c..7b2210cbbc75f74df47c526f7d4040ab414edb19 100644 (file)
@@ -9,10 +9,10 @@
        <key>pad_source</key>
        <make></make>
        <param>
-               <name>Num Outputs</name>
-               <key>nports</key>
-               <value>1</value>
-               <type>int</type>
+               <name>Label</name>
+               <key>label</key>
+               <value>in</value>
+               <type>string</type>
        </param>
        <param>
                <name>Output Type</name>
                <type>int</type>
        </param>
        <check>$vlen &gt; 0</check>
-       <check>0 &lt; $nports</check>
        <source>
                <name>out</name>
                <type>$type</type>
                <vlen>$vlen</vlen>
-               <nports>$nports</nports>
        </source>
        <doc>
-The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block. \
-Limit one source pad block per flow graph. \
-The "pad sink id" will be ignored in this mode.
+The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block.
+
+Pad sources will be ordered alphabetically by their ids. The first pad source will have an index of 0.
        </doc>
 </block>
index 33fc4e1ac6b53439ac4f359b7815ebc23c9b77c3..db65064524577a859218760b26e3d5b9efbda6a6 100644 (file)
@@ -20,11 +20,12 @@ case "$1" in
        echo "Begin freedesktop install..."
        for size in ${ICON_SIZES}; do \
                echo "Install icon: ${size}x${size}"
-               xdg-icon-resource install --context mimetypes --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \
-               xdg-icon-resource install --context mimetypes --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \
-               xdg-icon-resource install --context apps --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \
-               xdg-icon-resource install --context apps --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \
+               xdg-icon-resource install --noupdate --context mimetypes --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \
+               xdg-icon-resource install --noupdate --context mimetypes --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \
+               xdg-icon-resource install --noupdate --context apps --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \
+               xdg-icon-resource install --noupdate --context apps --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \
        done
+       xdg-icon-resource forceupdate
        echo "Install mime type"
        xdg-mime install ${SRCDIR}/gnuradio-grc.xml
        echo "Install menu items"
index 3692e17602148c9d674e648eb7a1a157f86e93a2..b26dbddd41f899c7be1fcc678755bcf3642a6aa2 100644 (file)
@@ -19,7 +19,7 @@
 #
 
 import common
-from gnuradio import gr, usrp
+from gnuradio import gr
 
 ####################################################################
 # Dual USRP Source
index fc4c75bf0618598dab80b60fc0df990a7e623c92..fb7a39570f0dead666abe6a4290e688f2580117b 100644 (file)
@@ -19,7 +19,7 @@
 #
 
 import common
-from gnuradio import gr, usrp
+from gnuradio import gr
 
 ####################################################################
 # Simple USRP Source
index 998575897399c6d7db643dfb0a37d735c1644b45..333ccf1c1203a2caca749a324efc677188917f8b 100644 (file)
@@ -19,7 +19,6 @@
 #
 
 import wx
-import sys, os
 from gnuradio import gr
 import panel
 
index ee3e19a6c6628db3d4e79ab1a4facd3e85bc8a8d..108e23a2355da942434e81f6a5d856401f830728 100644 (file)
@@ -29,7 +29,6 @@ import Preferences
 from threading import Thread
 import Messages
 from .. base import ParseXML
-import random
 from MainWindow import MainWindow
 from PropsDialog import PropsDialog
 import Dialogs
index 8c65bf06f104a2dd347856460d347775c813ff9f..27143e070420ccdd6cec709f0b2d098e509a5e30 100644 (file)
@@ -29,6 +29,7 @@ from Constants import \
 import pygtk
 pygtk.require('2.0')
 import gtk
+import pango
 
 BLOCK_MARKUP_TMPL="""\
 #set $foreground = $block.is_valid() and 'black' or 'red'
@@ -130,8 +131,11 @@ class Block(Element):
                layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self))
                self.label_width, self.label_height = layout.get_pixel_size()
                #display the params
-               for param in filter(lambda p: p.get_hide() not in ('all', 'part'), self.get_params()):
-                       layout = param.get_layout()
+               markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')]
+               if markups:
+                       layout = gtk.DrawingArea().create_pango_layout('')
+                       layout.set_spacing(LABEL_SEPARATION*pango.SCALE)
+                       layout.set_markup('\n'.join(markups))
                        layouts.append(layout)
                        w,h = layout.get_pixel_size()
                        self.label_width = max(w, self.label_width)
@@ -151,12 +155,11 @@ class Block(Element):
                        else: w_off = 0
                        pixmap.draw_layout(gc, w_off, h_off, layout)
                        h_off = h + h_off + LABEL_SEPARATION
-               #create vertical and horizontal images
-               self.horizontal_label = image = pixmap.get_image(0, 0, width, height)
+               #create vertical and horizontal pixmaps
+               self.horizontal_label = pixmap
                if self.is_vertical():
-                       self.vertical_label = vimage = gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), height, width)
-                       for i in range(width):
-                               for j in range(height): vimage.put_pixel(j, width-i-1, image.get_pixel(i, j))
+                       self.vertical_label = self.get_parent().new_pixmap(height, width)
+                       Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
                #calculate width and height needed
                self.W = self.label_width + 2*BLOCK_LABEL_PADDING
                self.H = max(*(
@@ -179,9 +182,9 @@ class Block(Element):
                )
                #draw label image
                if self.is_horizontal():
-                       window.draw_image(gc, self.horizontal_label, 0, 0, x+BLOCK_LABEL_PADDING, y+(self.H-self.label_height)/2, -1, -1)
+                       window.draw_drawable(gc, self.horizontal_label, 0, 0, x+BLOCK_LABEL_PADDING, y+(self.H-self.label_height)/2, -1, -1)
                elif self.is_vertical():
-                       window.draw_image(gc, self.vertical_label, 0, 0, x+(self.H-self.label_height)/2, y+BLOCK_LABEL_PADDING, -1, -1)
+                       window.draw_drawable(gc, self.vertical_label, 0, 0, x+(self.H-self.label_height)/2, y+BLOCK_LABEL_PADDING, -1, -1)
                #draw ports
                for port in self.get_ports(): port.draw(gc, window)
 
index af40f47c088a38d57baebc2dc20477a25fcb9b35..473c796aff23bf6efe931612cc859f52f30f891d 100644 (file)
@@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 import pygtk
 pygtk.require('2.0')
 import gtk
-import Preferences
 import Utils
 
 class TextDisplay(gtk.TextView):
index f0518ee12ba56883debd666ede1a8e31c12bc8fe..e020c5caa9ba5854bf91f2dc0b8ff0deb00acfa6 100644 (file)
@@ -17,9 +17,6 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 """
 
-import pygtk
-pygtk.require('2.0')
-import gtk
 from Constants import LINE_SELECT_SENSITIVITY
 from Constants import POSSIBLE_ROTATIONS
 
index 8feb171f1fd15e1a25c1f24013f56d8a6dd1f768..5adecccc13a063e756825b37ed24e5652da318f0 100644 (file)
@@ -22,7 +22,6 @@ import Actions
 import Colors
 import Utils
 from Element import Element
-from .. base import FlowGraph as _FlowGraph
 import pygtk
 pygtk.require('2.0')
 import gtk
index 4464a57ab77505f006b06a3731d1120248d891bb..b3018dab216a59b43b8539b72abb1a35172585bf 100644 (file)
@@ -38,6 +38,7 @@ class InputParam(gtk.HBox):
                #connect events
                self.connect('show', self._update_gui)
        def set_color(self, color): pass
+       def set_tooltip_text(self, text): pass
 
        def _update_gui(self, *args):
                """
@@ -51,8 +52,7 @@ class InputParam(gtk.HBox):
                #set the color
                self.set_color(self.param.get_color())
                #set the tooltip
-               if self.tp: self.tp.set_tip(
-                       self.entry,
+               self.set_tooltip_text(
                        Utils.parse_template(TIP_MARKUP_TMPL, param=self.param).strip(),
                )
                #show/hide
@@ -77,16 +77,13 @@ class EntryParam(InputParam):
 
        def __init__(self, *args, **kwargs):
                InputParam.__init__(self, *args, **kwargs)
-               self.entry = input = gtk.Entry()
-               input.set_text(self.param.get_value())
-               input.connect('changed', self._handle_changed)
-               self.pack_start(input, True)
-               self.get_text = input.get_text
-               #tool tip
-               self.tp = gtk.Tooltips()
-               self.tp.set_tip(self.entry, '')
-               self.tp.enable()
-       def set_color(self, color): self.entry.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
+               self._input = gtk.Entry()
+               self._input.set_text(self.param.get_value())
+               self._input.connect('changed', self._handle_changed)
+               self.pack_start(self._input, True)
+       def get_text(self): return self._input.get_text()
+       def set_color(self, color): self._input.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
+       def set_tooltip_text(self, text): self._input.set_tooltip_text(text)
 
 class EnumParam(InputParam):
        """Provide an entry box for Enum types with a drop down menu."""
@@ -99,6 +96,7 @@ class EnumParam(InputParam):
                self._input.connect('changed', self._handle_changed)
                self.pack_start(self._input, False)
        def get_text(self): return self.param.get_option_keys()[self._input.get_active()]
+       def set_tooltip_text(self, text): self._input.set_tooltip_text(text)
 
 class EnumEntryParam(InputParam):
        """Provide an entry box and drop down menu for Raw Enum types."""
@@ -117,6 +115,10 @@ class EnumEntryParam(InputParam):
        def get_text(self):
                if self._input.get_active() == -1: return self._input.get_child().get_text()
                return self.param.get_option_keys()[self._input.get_active()]
+       def set_tooltip_text(self, text):
+               if self._input.get_active() == -1: #custom entry
+                       self._input.get_child().set_tooltip_text(text)
+               else: self._input.set_tooltip_text(text)
        def set_color(self, color):
                if self._input.get_active() == -1: #custom entry, use color
                        self._input.get_child().modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
@@ -163,11 +165,9 @@ class Param(Element):
                if self.get_options(): return EnumEntryParam(self, *args, **kwargs)
                return EntryParam(self, *args, **kwargs)
 
-       def get_layout(self):
+       def get_markup(self):
                """
-               Create a layout based on the current markup.
-               @return the pango layout
+               Get the markup for this param.
+               @return a pango markup string
                """
-               layout = gtk.DrawingArea().create_pango_layout('')
-               layout.set_markup(Utils.parse_template(PARAM_MARKUP_TMPL, param=self))
-               return layout
+               return Utils.parse_template(PARAM_MARKUP_TMPL, param=self)
index 6763f6cbd553f61ab7673095f247687000e06dc4..2896d04c18e0efae889198a503ed1bf99aaeaf52 100644 (file)
@@ -97,12 +97,11 @@ class Port(Element):
                gc.set_foreground(self._bg_color)
                pixmap.draw_rectangle(gc, True, 0, 0, self.w, self.h)
                pixmap.draw_layout(gc, 0, 0, layout)
-               #create the images
-               self.horizontal_label = image = pixmap.get_image(0, 0, self.w, self.h)
+               #create vertical and horizontal pixmaps
+               self.horizontal_label = pixmap
                if self.is_vertical():
-                       self.vertical_label = vimage = gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), self.h, self.w)
-                       for i in range(self.w):
-                               for j in range(self.h): vimage.put_pixel(j, self.w-i-1, image.get_pixel(i, j))
+                       self.vertical_label = self.get_parent().get_parent().new_pixmap(self.h, self.w)
+                       Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
 
        def draw(self, gc, window):
                """
@@ -117,9 +116,9 @@ class Port(Element):
                X,Y = self.get_coordinate()
                (x,y),(w,h) = self._areas_list[0] #use the first area's sizes to place the labels
                if self.is_horizontal():
-                       window.draw_image(gc, self.horizontal_label, 0, 0, x+X+(self.W-self.w)/2, y+Y+(self.H-self.h)/2, -1, -1)
+                       window.draw_drawable(gc, self.horizontal_label, 0, 0, x+X+(self.W-self.w)/2, y+Y+(self.H-self.h)/2, -1, -1)
                elif self.is_vertical():
-                       window.draw_image(gc, self.vertical_label, 0, 0, x+X+(self.H-self.h)/2, y+Y+(self.W-self.w)/2, -1, -1)
+                       window.draw_drawable(gc, self.vertical_label, 0, 0, x+X+(self.H-self.h)/2, y+Y+(self.W-self.w)/2, -1, -1)
 
        def get_connector_coordinate(self):
                """
index 83036a4b858c0c4eb5460738be7eb2f3e4002e6d..b5489d56e7ac5cc2c866ee385f9625605a40e750 100644 (file)
@@ -19,8 +19,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 from Constants import POSSIBLE_ROTATIONS
 from Cheetah.Template import Template
+import pygtk
+pygtk.require('2.0')
+import gtk
 import gobject
 
+def rotate_pixmap(gc, src_pixmap, dst_pixmap, angle=gtk.gdk.PIXBUF_ROTATE_COUNTERCLOCKWISE):
+       """
+       Load the destination pixmap with a rotated version of the source pixmap.
+       The source pixmap will be loaded into a pixbuf, rotated, and drawn to the destination pixmap.
+       The pixbuf is a client-side drawable, where a pixmap is a server-side drawable.
+       @param gc the graphics context
+       @param src_pixmap the source pixmap
+       @param dst_pixmap the destination pixmap
+       @param angle the angle to rotate by
+       """
+       width, height = src_pixmap.get_size()
+       pixbuf = gtk.gdk.Pixbuf(
+               colorspace=gtk.gdk.COLORSPACE_RGB,
+               has_alpha=False, bits_per_sample=8,
+               width=width, height=height,
+       )
+       pixbuf.get_from_drawable(src_pixmap, src_pixmap.get_colormap(), 0, 0, 0, 0, -1, -1)
+       pixbuf = pixbuf.rotate_simple(angle)
+       dst_pixmap.draw_pixbuf(gc, pixbuf, 0, 0, 0, 0)
+
 def get_rotated_coordinate(coor, rotation):
        """
        Rotate the coordinate by the given rotation.
index 439a524209da7277526f81b1b0f6f92194345c0c..e661c392782a2501fe740a2485278041c41aa77c 100644 (file)
@@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 """
 
 import os
-import sys
 import stat
 from gnuradio import gr
 
index 4dd18a81f4cd230dbec042dfb77a2068129ed859..b2d406bbd65514ffdc155e58fb799cd74a3292fa 100644 (file)
@@ -20,8 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 import expr_utils
 from .. base.FlowGraph import FlowGraph as _FlowGraph
 from .. gui.FlowGraph import FlowGraph as _GUIFlowGraph
-from Block import Block
-from Connection import Connection
 import re
 
 _variable_matcher = re.compile('^(variable\w*)$')
@@ -50,44 +48,36 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
                #return from cache
                return self._eval_cache[my_hash]
 
-       def _get_io_signature(self, pad_key):
+       def _get_io_signaturev(self, pad_key):
                """
-               Get an io signature for this flow graph.
+               Get a list of io signatures for this flow graph.
                The pad key determines the directionality of the io signature.
                @param pad_key a string of pad_source or pad_sink
-               @return a dict with: type, nports, vlen, size
+               @return a list of dicts with: type, label, vlen, size
                """
                pads = filter(lambda b: b.get_key() == pad_key, self.get_enabled_blocks())
-               if not pads: return {
-                       'nports': '0',
-                       'type': '',
-                       'vlen': '0',
-                       'size': '0',
-               }
-               pad = pads[0] #take only the first, user should not have more than 1
+               sorted_pads = sorted(pads, lambda x, y: cmp(x.get_id(), y.get_id()))
                #load io signature
-               return {
-                       'nports': str(pad.get_param('nports').get_evaluated()),
+               return [{
+                       'label': str(pad.get_param('label').get_evaluated()),
                        'type': str(pad.get_param('type').get_evaluated()),
                        'vlen': str(pad.get_param('vlen').get_evaluated()),
                        'size': pad.get_param('type').get_opt('size'),
-               }
+               } for pad in sorted_pads]
 
-       def get_input_signature(self):
+       def get_input_signaturev(self):
                """
                Get the io signature for the input side of this flow graph.
-               The io signature with be "0", "0" if no pad source is present.
-               @return a string tuple of type, num_ports, port_size
+               @return a list of io signature structures
                """
-               return self._get_io_signature('pad_source')
+               return self._get_io_signaturev('pad_source')
 
-       def get_output_signature(self):
+       def get_output_signaturev(self):
                """
                Get the io signature for the output side of this flow graph.
-               The io signature with be "0", "0" if no pad sink is present.
-               @return a string tuple of type, num_ports, port_size
+               @return a list of io signature structures
                """
-               return self._get_io_signature('pad_sink')
+               return self._get_io_signaturev('pad_sink')
 
        def get_imports(self):
                """
index 81fb6ba7acb7b48407fc2197099223a7a6780fe5..febb112ad3a1f4404b71574c1b1e5394e440240f 100644 (file)
@@ -17,7 +17,6 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 """
 
-import expr_utils
 from .. base.Param import Param as _Param
 from .. gui.Param import Param as _GUIParam
 from .. gui.Param import EntryParam
index bdafbcbc13dde8d9dc2fa7c028996f9cc7426c7b..befddccea0ce2e947befdf59c200cae18c603e7f 100644 (file)
@@ -23,8 +23,8 @@ from .. base import odict
 
 def convert_hier(flow_graph, python_file):
        #extract info from the flow graph
-       input_sig = flow_graph.get_input_signature()
-       output_sig = flow_graph.get_output_signature()
+       input_sigs = flow_graph.get_input_signaturev()
+       output_sigs = flow_graph.get_output_signaturev()
        parameters = flow_graph.get_parameters()
        block_key = flow_graph.get_option('id')
        block_name = flow_graph.get_option('title')
@@ -56,20 +56,18 @@ def convert_hier(flow_graph, python_file):
                params_n.append(param_n)
        block_n['param'] = params_n
        #sink data
-       if int(input_sig['nports']):
+       for input_sig in input_sigs:
                sink_n = odict()
-               sink_n['name'] = 'in'
+               sink_n['name'] = input_sig['label']
                sink_n['type'] = input_sig['type']
                sink_n['vlen'] = input_sig['vlen']
-               sink_n['nports'] = input_sig['nports']
                block_n['sink'] = sink_n
        #source data
-       if int(output_sig['nports']):
+       for output_sig in output_sigs:
                source_n = odict()
-               source_n['name'] = 'out'
+               source_n['name'] = output_sig['label']
                source_n['type'] = output_sig['type']
                source_n['vlen'] = output_sig['vlen']
-               source_n['nports'] = output_sig['nports']
                block_n['source'] = source_n
        #doc data
        block_n['doc'] = "%s\n%s\n%s"%(block_author, block_desc, python_file)
index ab764006c06e304f9a663a655b7a2edd66ed75bb..a1a9308aa30335fb2228a252536c2215421dd83c 100644 (file)
@@ -65,15 +65,25 @@ class $(class_name)(gr.top_block):
        def __init__($param_str):
                gr.top_block.__init__(self, "$title")
 #elif $generate_options == 'hb'
-       #set $in_sig = $flow_graph.get_input_signature()
-       #set $out_sig = $flow_graph.get_output_signature()
+       #set $in_sigs = $flow_graph.get_input_signaturev()
+       #set $out_sigs = $flow_graph.get_output_signaturev()
 class $(class_name)(gr.hier_block2):
+#def make_io_sig($io_sigs)
+       #set $size_strs = ['%s*%s'%(io_sig['size'], io_sig['vlen']) for io_sig in $io_sigs]
+       #if len($io_sigs) == 0
+gr.io_signature(0, 0, 0)#slurp
+       #elif len($io_sigs) == 1
+gr.io_signature(1, 1, $size_strs[0])#slurp
+       #else
+gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])#slurp
+       #end if
+#end def
 
        def __init__($param_str):
                gr.hier_block2.__init__(
                        self, "$title",
-                       gr.io_signature($in_sig.nports, $in_sig.nports, $in_sig.size*$in_sig.vlen),
-                       gr.io_signature($out_sig.nports, $out_sig.nports, $out_sig.size*$out_sig.vlen),
+                       $make_io_sig($in_sigs),
+                       $make_io_sig($out_sigs),
                )
 #end if
 ########################################################
index 4f9ac4f9d9593cc5af115f8f8c9b45dc8987fae7..dd5daed0122e84edaee5fb6a59d726d8968939a3 100644 (file)
@@ -54,6 +54,7 @@
 #define USB_PID_FSF_BDALE_7            0x0011    // Bdale Garbee <bdale@gag.com>
 #define USB_PID_FSF_BDALE_8            0x0012    // Bdale Garbee <bdale@gag.com>
 #define USB_PID_FSF_BDALE_9            0x0013    // Bdale Garbee <bdale@gag.com>
+#define USB_PID_FSF_HPSDR_HERMES       0x0014    // HPSDR Hermes
 
 #define USB_PID_FSF_LBNL_UXO            0x0018    // http://recycle.lbl.gov/~ldoolitt/uxo/
 
index 72367286caf721ecb16a958f7a542f610e2ae63f..ce9d1f4e8a9c8b173dc3058a5cce97ed7fe21f4b 100644 (file)
@@ -322,8 +322,8 @@ xcvr2450::set_reg_lpf()
 {
   d_reg_lpf = (
             (d_rssi_hbw<<15)  |
-            (d_txlpf_bw<<10)  |
-            (d_rxlpf_bw<<9)   |
+            (d_txlpf_bw<<9)  |
+            (d_rxlpf_bw<<7)   |
             (d_rxlpf_fine<<4) | 7);
   send_reg(d_reg_lpf);
 }
index 4d1fd78c97c7f2ee27c40a094c5dfb8ee85cea72..4fbfabea941e3d6bcee733dbd3fb6f3c048cfb3a 100644 (file)
@@ -83,7 +83,7 @@ _usb_control_transfer (struct usb_dev_handle *udh, int request_type,
   ret = usb_control_msg (udh, request_type,request, value, index,
                          (char*) data, length, (int) timeout);
   if (ret < 0) 
-    fprintf (stderr, "usrp: usb_claim_interface failed: %s\n", usb_strerror());
+    fprintf (stderr, "usrp: usb_control_msg failed: %s\n", usb_strerror());
 
   return ret;
 }
index 67cccd53b43131bc0ef6acad563963634231cef9..2d131bda73847de3ae92e8c76ccfbd64856fafe4 100644 (file)
@@ -152,7 +152,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p,
   memset(&tune_result, 0, sizeof(tune_result));
 
   bool ok = true;
-  
+
   if (p->valid & CFGV_GAIN){
     ok &= db_set_gain(tx_dboard, p->gain);
   }
@@ -161,7 +161,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p,
     bool was_streaming = is_streaming();
     if (was_streaming)
       stop_rx_cmd();
-    
+
     u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo);
     bool tune_ok = db_tune(tx_dboard, f, &tune_result);
     ok &= tune_ok;
@@ -185,7 +185,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p,
       hb1 = 1;
       interp = interp >> 1;
     }
-    
+
     if (interp < MIN_CIC_INTERP || interp > MAX_CIC_INTERP)
       ok = false;
     else {
@@ -215,7 +215,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p,
 }
 
 static size_t
-config_rx_v2_cmd(const op_config_rx_v2_t *p, 
+config_rx_v2_cmd(const op_config_rx_v2_t *p,
                 void *reply_payload, size_t reply_payload_space)
 {
   op_config_rx_reply_v2_t *r = (op_config_rx_reply_v2_t *) reply_payload;
@@ -226,7 +226,7 @@ config_rx_v2_cmd(const op_config_rx_v2_t *p,
   memset(&tune_result, 0, sizeof(tune_result));
 
   bool ok = true;
-  
+
   if (p->valid & CFGV_GAIN){
     ok &= db_set_gain(rx_dboard, p->gain);
   }
@@ -235,7 +235,7 @@ config_rx_v2_cmd(const op_config_rx_v2_t *p,
     bool was_streaming = is_streaming();
     if (was_streaming)
       stop_rx_cmd();
-    
+
     u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo);
     bool tune_ok = db_tune(rx_dboard, f, &tune_result);
     ok &= tune_ok;
@@ -249,17 +249,17 @@ config_rx_v2_cmd(const op_config_rx_v2_t *p,
     int decim = p->decim;
     int hb1 = 0;
     int hb2 = 0;
-    
+
     if(!(decim & 1)) {
       hb2 = 1;
       decim = decim >> 1;
     }
-    
+
     if(!(decim & 1)) {
       hb1 = 1;
       decim = decim >> 1;
     }
-    
+
     if (decim < MIN_CIC_DECIM || decim > MAX_CIC_DECIM)
       ok = false;
     else {
@@ -294,7 +294,7 @@ read_time_cmd(const op_generic_t *p,
              void *reply_payload, size_t reply_payload_space)
 {
   op_read_time_reply_t *r = (op_read_time_reply_t *) reply_payload;
-  if (reply_payload_space < sizeof(*r))                
+  if (reply_payload_space < sizeof(*r))
     return 0;                                  // no room
 
   r->opcode = OP_READ_TIME_REPLY;
@@ -323,7 +323,7 @@ dboard_info_cmd(const op_generic_t *p,
                void *reply_payload, size_t reply_payload_space)
 {
   op_dboard_info_reply_t *r = (op_dboard_info_reply_t *) reply_payload;
-  if (reply_payload_space < sizeof(*r))                
+  if (reply_payload_space < sizeof(*r))
     return 0;                                  // no room
 
   r->opcode = OP_DBOARD_INFO_REPLY;
@@ -411,14 +411,14 @@ generic_reply(const op_generic_t *p,
              bool ok)
 {
   op_generic_t *r = (op_generic_t *) reply_payload;
-  if (reply_payload_space < sizeof(*r))                
+  if (reply_payload_space < sizeof(*r))
     return 0;                                  // no room
-  
+
   r->opcode = p->opcode | OP_REPLY_BIT;
   r->len = sizeof(*r);
   r->rid = p->rid;
   r->ok = ok;
-  
+
   return r->len;
 }
 
@@ -426,14 +426,14 @@ static size_t
 add_eop(void *reply_payload, size_t reply_payload_space)
 {
   op_generic_t *r = (op_generic_t *) reply_payload;
-  if (reply_payload_space < sizeof(*r))                
+  if (reply_payload_space < sizeof(*r))
     return 0;                                  // no room
-  
+
   r->opcode = OP_EOP;
   r->len = sizeof(*r);
   r->rid = 0;
   r->ok =  0;
-  
+
   return r->len;
 }
 
@@ -443,15 +443,15 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len)
   unsigned char reply[sizeof(u2_eth_packet_t) + 4 * sizeof(u2_subpkt_t)] _AL4;
   unsigned char *reply_payload = &reply[sizeof(u2_eth_packet_t)];
   int reply_payload_space = sizeof(reply) - sizeof(u2_eth_packet_t);
-  
+
   // initialize reply
   memset(reply, 0, sizeof(reply));
   set_reply_hdr((u2_eth_packet_t *) reply, pkt);
-  
+
   // point to beginning of payload (subpackets)
   unsigned char *payload = ((unsigned char *) pkt) + sizeof(u2_eth_packet_t);
   int payload_len = len - sizeof(u2_eth_packet_t);
-  
+
   size_t subpktlen = 0;
   bool ok = false;
 
@@ -468,7 +468,7 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len)
     case OP_ID:
       subpktlen = op_id_cmd(gp, reply_payload, reply_payload_space);
       break;
-    
+
     case OP_CONFIG_TX_V2:
       subpktlen = config_tx_v2_cmd((op_config_tx_v2_t *) payload, reply_payload, reply_payload_space);
       break;
@@ -478,15 +478,18 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len)
       break;
 
     case OP_START_RX_STREAMING:
-      start_rx_streaming_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *) payload);
+      if (pkt->fixed.timestamp == -1) // Start now (default)
+        start_rx_streaming_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *) payload);
+      else
+        start_rx_streaming_at_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *)payload, pkt->fixed.timestamp);
       ok = true;
       goto generic_reply;
-    
+
     case OP_STOP_RX:
       stop_rx_cmd();
       ok = true;
       goto generic_reply;
-    
+
     case OP_BURN_MAC_ADDR:
       ok = ethernet_set_mac_addr(&((op_burn_mac_addr_t *)payload)->addr);
       goto generic_reply;
@@ -532,8 +535,8 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len)
 
     case OP_GPIO_SET_DDR:
       ok = true;
-      hal_gpio_set_ddr(((op_gpio_t *)payload)->bank, 
-                      ((op_gpio_t *)payload)->value, 
+      hal_gpio_set_ddr(((op_gpio_t *)payload)->bank,
+                      ((op_gpio_t *)payload)->value,
                       ((op_gpio_t *)payload)->mask);
       goto generic_reply;
 
@@ -549,8 +552,8 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len)
 
     case OP_GPIO_WRITE:
       ok = true;
-      hal_gpio_write(((op_gpio_t *)payload)->bank, 
-                    ((op_gpio_t *)payload)->value, 
+      hal_gpio_write(((op_gpio_t *)payload)->bank,
+                    ((op_gpio_t *)payload)->value,
                     ((op_gpio_t *)payload)->mask);
       goto generic_reply;
 
index 5058661ad05c437b02386f531fe7324433b6084f..ff1baec064affb894ad1dc9be1f272c52159efc3 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -55,8 +55,10 @@ print_tune_result(char *msg, bool tune_ok,
 
 
 void start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p);
+void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time);
 void stop_rx_cmd(void);
 void restart_streaming(void);
+void restart_streaming_at(uint32_t time);
 bool is_streaming(void);
 
 void handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len);
index a4bc06d58cf5cc523e4c3b171ca314dc5f635998..e7dde524a2fcbc6d3b112a101a7ce006db4a1041 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -154,7 +154,7 @@ restart_streaming(void)
   dsp_rx_regs->rx_command =
     MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
              streaming_items_per_frame,
-             1, 1);                            
+             1, 1);
 
   dsp_rx_regs->rx_time = 0;            // enqueue second command
 }
@@ -187,6 +187,11 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p)
 }
 
 
+void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time)
+{}
+void restart_streaming_at(uint32_t time)
+{}
+
 void
 stop_rx_cmd(void)
 {
@@ -224,7 +229,7 @@ setup_tx()
  * that we didn't handle the packet.  A bit of a kludge
  * but it should work.
  */
-bool 
+bool
 fw_sets_seqno_inspector(dbsm_t *sm, int buf_this)      // returns false
 {
   uint32_t *p = buffer_ram(buf_this);
@@ -259,22 +264,22 @@ int test_ram()
 {
   int i,j,k;
   output_regs->ram_page = 1<<10;
-  
+
   extram[0] = 0xDEADBEEF;
   extram[1] = 0xF00D1234;
   extram[7] = 0x76543210;
-  
+
   output_regs->ram_page = 2<<10;
   extram[7] = 0x55555555;
   extram[1] = 0xaaaaaaaa;
   extram[0] = 0xeeeeeeee;
-  
+
   output_regs->ram_page = 1<<10;
-  
+
   i = extram[0];
   k = extram[1];
   j = extram[7];
-  
+
   if((i != 0xDEADBEEF)||(j!=0x76543210)||(k!=0xF00D1234)) {
     puts("RAM FAIL1!\n");
     puthex32_nl(i);
@@ -282,7 +287,7 @@ int test_ram()
     puthex32_nl(k);
     return 0;
   }
-  
+
   output_regs->ram_page = 2<<10;
 
   j = extram[7];
@@ -306,7 +311,7 @@ int test_sd()
     puts("FAILED INIT of Card\n");
     return 0;
   }
-  
+
   unsigned char buf[512];
   i = sd_read_block(2048,buf);
   if(i == 0) {
index e7da984c5e2d1218a1c7ed319faa15b212a986af..4c284b7c926cd3c3d4d7a73f030f04d52fdacab4 100644 (file)
@@ -160,7 +160,7 @@ restart_streaming(void)
   dsp_rx_regs->rx_command =
     MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
              streaming_items_per_frame,
-             1, 1);                            
+             1, 1);
 
   dsp_rx_regs->rx_time = 0;            // enqueue second command
 }
@@ -192,6 +192,10 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p)
   restart_streaming();
 }
 
+void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time)
+{}
+void restart_streaming_at(uint32_t time)
+{}
 
 void
 stop_rx_cmd(void)
@@ -230,7 +234,7 @@ setup_tx()
  * that we didn't handle the packet.  A bit of a kludge
  * but it should work.
  */
-bool 
+bool
 fw_sets_seqno_inspector(dbsm_t *sm, int buf_this)      // returns false
 {
   uint32_t *p = buffer_ram(buf_this);
@@ -310,7 +314,7 @@ main(void)
 
 
   //output_regs->flush_icache = 1;
+
   // initialize double buffering state machine for DSP RX -> Ethernet
 
   if (FW_SETS_SEQNO){
index 7816f7a653e5fc28a071a8e128d0ba527748a214..aa4a3f33cc3fed38bd89ec4e5933e9014de3b76d 100644 (file)
@@ -152,7 +152,7 @@ restart_streaming(void)
   dsp_rx_regs->rx_command =
     MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
              streaming_items_per_frame,
-             1, 1);                            
+             1, 1);
 
   dsp_rx_regs->rx_time = 0;            // enqueue second command
 }
@@ -184,6 +184,10 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p)
   restart_streaming();
 }
 
+void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time)
+{}
+void restart_streaming_at(uint32_t time)
+{}
 
 void
 stop_rx_cmd(void)
@@ -222,7 +226,7 @@ setup_tx()
  * that we didn't handle the packet.  A bit of a kludge
  * but it should work.
  */
-bool 
+bool
 fw_sets_seqno_inspector(dbsm_t *sm, int buf_this)      // returns false
 {
   uint32_t *p = buffer_ram(buf_this);
@@ -302,7 +306,7 @@ main(void)
 
 
   //output_regs->flush_icache = 1;
+
   // initialize double buffering state machine for DSP RX -> Ethernet
 
   if (FW_SETS_SEQNO){
index b2487ed89d38f7f5c8b8a9266ffea44861f389e7..975f314bd94c0152b9f2423c1b1b366c92038dbb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009 Free Software Foundation, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -152,7 +152,35 @@ restart_streaming(void)
   dsp_rx_regs->rx_command =
     MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
              streaming_items_per_frame,
-             1, 1);                            
+             1, 1);
+
+  dsp_rx_regs->rx_time = 0;            // enqueue second command
+}
+
+void
+restart_streaming_at(uint32_t time)
+{
+  // setup RX DSP regs
+  dsp_rx_regs->clear_state = 1;                        // reset
+
+  streaming_p = true;
+  streaming_frame_count = FRAMES_PER_CMD;
+
+  dsp_rx_regs->rx_command =
+    MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
+             streaming_items_per_frame,
+             0, 1);                    // set "chain" bit
+
+  // kick off the state machine
+  dbsm_start(&dsp_rx_sm);
+
+  dsp_rx_regs->rx_time = time;         // enqueue first of two commands
+
+  // make sure this one and the rest have the "now" and "chain" bits set.
+  dsp_rx_regs->rx_command =
+    MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
+             streaming_items_per_frame,
+             1, 1);
 
   dsp_rx_regs->rx_time = 0;            // enqueue second command
 }
@@ -184,6 +212,33 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p)
   restart_streaming();
 }
 
+void
+start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time)
+{
+  host_mac_addr = *host;       // remember who we're sending to
+
+  /*
+   * Construct  ethernet header and word0 and preload into two buffers
+   */
+  u2_eth_packet_t      pkt;
+  memset(&pkt, 0, sizeof(pkt));
+  pkt.ehdr.dst = *host;
+  pkt.ehdr.src = *ethernet_mac_addr();
+  pkt.ehdr.ethertype = U2_ETHERTYPE;
+  u2p_set_word0(&pkt.fixed, 0, 0);
+  // DSP RX will fill in timestamp
+
+  memcpy_wa(buffer_ram(DSP_RX_BUF_0), &pkt, sizeof(pkt));
+  memcpy_wa(buffer_ram(DSP_RX_BUF_1), &pkt, sizeof(pkt));
+
+
+  if (FW_SETS_SEQNO)
+    fw_seqno = 0;
+
+  streaming_items_per_frame = p->items_per_frame;
+  restart_streaming_at(time);
+}
+
 
 void
 stop_rx_cmd(void)
@@ -222,7 +277,7 @@ setup_tx()
  * that we didn't handle the packet.  A bit of a kludge
  * but it should work.
  */
-bool 
+bool
 fw_sets_seqno_inspector(dbsm_t *sm, int buf_this)      // returns false
 {
   uint32_t *p = buffer_ram(buf_this);
index 7f1f9a796dc0669be1c520cc0664c6fd117dd2db..53ff03ce404740cce7d7f1449ed06b0327dcb4f8 100644 (file)
@@ -17,6 +17,12 @@ dnl along with GNU Radio; see the file COPYING.  If not, write to
 dnl the Free Software Foundation, Inc., 51 Franklin Street,
 dnl Boston, MA 02110-1301, USA.
 
+dnl Fix 2.64 cross compile detection for AVR and RTEMS
+dnl by not trying to compile fopen.
+m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64],
+  [m4_foreach([_GCC_LANG], [C, C++, Fortran, Fortran 77],
+     [m4_define([_AC_LANG_IO_PROGRAM(]_GCC_LANG[)], m4_defn([AC_LANG_PROGRAM(]_GCC_LANG[)]))])]) 
+
 AC_DEFUN([GRC_USRP2_FIRMWARE],[
     dnl we use  --enable-usrp2-firmware to enable this
     GRC_ENABLE(usrp2-firmware)
index 925a34f399b06f77db829de0c936711ee9b36fe9..a0bfc5cfb6a23c45ebf67019370d88a3c81180b2 100644 (file)
@@ -69,7 +69,9 @@ struct db_base *all_dboards[] = {
   &db_rfx_2400_tx,
   &db_rfx_2400_rx,
   &db_tvrx1,
+#if 0
   &db_tvrx2,
+#endif
   &db_tvrx3,
   &db_dbsrx,
   &db_xcvr2450_tx,
index ba70b6402cdb9e8c78f2f9332608d1c8fa17f287..49bf758835f6230eb145018de46e01c431244974 100644 (file)
@@ -28,7 +28,7 @@ bool tvrx_set_freq(struct db_base *db, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc);
 bool tvrx_set_gain(struct db_base *db, u2_fxpt_gain_t gain);
 
 #define I2C_ADDR 0x60
-#define ref_freq (U2_DOUBLE_TO_FXPT_FREQ(4e6)/640*8)
+#define REF_FREQ (U2_DOUBLE_TO_FXPT_FREQ(4e6)/640*8)
 
 #define ref_div 640  /* choices are 640, 512, 1024 */
 
@@ -101,6 +101,7 @@ struct db_tvrx1 db_tvrx1 = {
   .common.second_if = U2_DOUBLE_TO_FXPT_FREQ(5.75e6),
 };
 
+#if 0
 struct db_tvrx2 db_tvrx2 = {
   .base.dbid = 0x000c,
   .base.is_tx = false,
@@ -113,7 +114,7 @@ struct db_tvrx2 db_tvrx2 = {
   .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(1),
   .base.is_quadrature = false,
   .base.i_and_q_swapped = false,
-  .base.spectrum_inverted = true,
+  .base.spectrum_inverted = false,
   .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0),
   .base.init = tvrx_init,
   .base.set_freq = tvrx_set_freq,
@@ -125,8 +126,9 @@ struct db_tvrx2 db_tvrx2 = {
   // .base.atr_tx_delay =
   // .base.atr_rx_delay =
   .common.first_if = U2_DOUBLE_TO_FXPT_FREQ(44e6),
-  .common.second_if = U2_DOUBLE_TO_FXPT_FREQ(44e6),
+  .common.second_if = U2_DOUBLE_TO_FXPT_FREQ(56e6),    // Fs - 44e6
 };
+#endif
 
 struct db_tvrx3 db_tvrx3 = {
   .base.dbid = 0x0040,
@@ -140,7 +142,7 @@ struct db_tvrx3 db_tvrx3 = {
   .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(1),
   .base.is_quadrature = false,
   .base.i_and_q_swapped = false,
-  .base.spectrum_inverted = true,
+  .base.spectrum_inverted = false,
   .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0),
   .base.init = tvrx_init,
   .base.set_freq = tvrx_set_freq,
@@ -152,7 +154,7 @@ struct db_tvrx3 db_tvrx3 = {
   // .base.atr_tx_delay =
   // .base.atr_rx_delay =
   .common.first_if = U2_DOUBLE_TO_FXPT_FREQ(44e6),
-  .common.second_if = U2_DOUBLE_TO_FXPT_FREQ(44e6),
+  .common.second_if = U2_DOUBLE_TO_FXPT_FREQ(56e6),    // Fs - 44e6
 };
 
 bool
@@ -173,25 +175,25 @@ tvrx_set_freq(struct db_base *dbb, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc)
   struct db_tvrx_dummy *db = (struct db_tvrx_dummy *) dbb;
 
   u2_fxpt_freq_t target_lo_freq = freq + db->common.first_if;
-  int N_DIV = u2_fxpt_freq_round_to_int(((1LL<<20) * target_lo_freq)/ref_freq);
+  int n_div = u2_fxpt_freq_round_to_int(((1LL<<20) * target_lo_freq)/REF_FREQ);
   
-  u2_fxpt_freq_t actual_lo_freq = ref_freq * N_DIV;
+  u2_fxpt_freq_t actual_lo_freq = REF_FREQ * n_div;
   u2_fxpt_freq_t actual_freq = actual_lo_freq - db->common.first_if;
-  if(N_DIV > 32767)
+  if(n_div > 32767)
     return false;
 
   if (0)
-    printf("N_DIV = %d, actual_freq = %d, actual_lo_freq = %d\n",
-          N_DIV, u2_fxpt_freq_round_to_int(actual_freq),
+    printf("n_div = %d, actual_freq = %d, actual_lo_freq = %d\n",
+          n_div, u2_fxpt_freq_round_to_int(actual_freq),
           u2_fxpt_freq_round_to_int(actual_lo_freq));
 
   unsigned char buf[4];
-  buf[0] = (N_DIV>>8) & 0xff;
-  buf[1] = N_DIV & 0xff;
+  buf[0] = (n_div>>8) & 0xff;
+  buf[1] = n_div & 0xff;
   buf[2] = control_byte_1;
-  buf[3] = (freq < U2_DOUBLE_TO_FXPT_FREQ(158e6)) ? 0xa8 :  // VHF LOW
-    (freq < U2_DOUBLE_TO_FXPT_FREQ(464e6)) ? 0x98 :  // VHF HIGH
-    0x38;  // UHF
+  buf[3] = ((actual_freq < U2_DOUBLE_TO_FXPT_FREQ(158e6)) ? 0xa8 :  // VHF LOW
+           (actual_freq < U2_DOUBLE_TO_FXPT_FREQ(464e6)) ? 0x98 :  // VHF HIGH
+           0x38);  // UHF
 
   *dc = actual_freq - db->common.second_if;
   return i2c_write(I2C_ADDR,buf,4);
index ffdf8d66073102dac7a347acffe10b04b8a83823..a48af903533c2dbb24991c8540a917520887037c 100644 (file)
@@ -250,8 +250,8 @@ static void
 set_reg_lpf(struct db_xcvr2450_dummy *db){
   int reg_lpf = (
     (db->common->d_rssi_hbw<<15)  |
-    (db->common->d_txlpf_bw<<10)  |
-    (db->common->d_rxlpf_bw<<9)   |
+    (db->common->d_txlpf_bw<<9)  |
+    (db->common->d_rxlpf_bw<<7)   |
     (db->common->d_rxlpf_fine<<4) | 7);
   send_reg(reg_lpf);
 }
index 78a4330d2ffce689f267ba9f3702f834164bcbea..0d0cf04f6853e5bdc128be550fa11e19a58e24cf 100644 (file)
@@ -175,6 +175,10 @@ typedef struct {
   volatile uint32_t last_line[NBUFFERS]; // last line xfer'd in buffer
   volatile uint32_t status;             // error and done flags
   volatile uint32_t hw_config;          // see below
+  volatile uint32_t dummy[3];
+  volatile uint32_t irqs;
+  volatile uint32_t pri_enc_bp_status;
+  volatile uint32_t cycle_count;
 } buffer_pool_status_t;
 
 #define buffer_pool_status ((buffer_pool_status_t *) BUFFER_POOL_STATUS_BASE)
diff --git a/usrp2/fpga/control_lib/pic.v b/usrp2/fpga/control_lib/pic.v
new file mode 100644 (file)
index 0000000..9b9944d
--- /dev/null
@@ -0,0 +1,183 @@
+
+// Heavily modified by M. Ettus, 2009, little original code remains
+// Modified by M. Ettus, 2008 for 32 bit width
+
+/////////////////////////////////////////////////////////////////////
+////                                                             ////
+////  OpenCores         Simple Programmable Interrupt Controller ////
+////                                                             ////
+////  Author: Richard Herveille                                  ////
+////          richard@asics.ws                                   ////
+////          www.asics.ws                                       ////
+////                                                             ////
+/////////////////////////////////////////////////////////////////////
+////                                                             ////
+//// Copyright (C) 2002 Richard Herveille                        ////
+////                    richard@asics.ws                         ////
+////                                                             ////
+//// This source file may be used and distributed without        ////
+//// restriction provided that this copyright statement is not   ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer.////
+////                                                             ////
+////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
+//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
+//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
+//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
+//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
+//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
+//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
+//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
+//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
+//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
+//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
+//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
+//// POSSIBILITY OF SUCH DAMAGE.                                 ////
+////                                                             ////
+/////////////////////////////////////////////////////////////////////
+//
+// This is a simple Programmable Interrupt Controller.
+// The number of interrupts is depending on the databus size.
+// There's one interrupt input per databit (i.e. 16 interrupts for a 16
+// bit databus).
+// All attached devices share the same CPU priority level.
+//
+//
+//
+// Registers:
+//
+// 0x00: EdgeEnable Register
+//       bits 7:0 R/W  Edge Enable '1' = edge triggered interrupt source
+//                                 '0' = level triggered interrupt source
+// 0x01: PolarityRegister
+//       bits 7:0 R/W Polarity     '1' = high level / rising edge
+//                                 '0' = low level / falling edge
+// 0x02: MaskRegister
+//       bits 7:0 R/W Mask         '1' = interrupt masked (disabled)
+//                                 '0' = interrupt not masked (enabled)
+// 0x03: PendingRegister
+//       bits 7:0 R/W Pending      '1' = interrupt pending
+//                                 '0' = no interrupt pending
+//
+// A CPU interrupt is generated when an interrupt is pending and its
+// MASK bit is cleared.
+//
+//
+//
+// HOWTO:
+//
+// Clearing pending interrupts:
+// Writing a '1' to a bit in the interrupt pending register clears the
+// interrupt. Make sure to clear the interrupt at the source before
+// writing to the interrupt pending register. Otherwise the interrupt
+// will be set again.
+//
+// Priority based interrupts:
+// Upon reception of an interrupt, check the interrupt register and
+// determine the highest priority interrupt. Mask all interrupts from the
+// current level to the lowest level. This negates the interrupt line, and
+// makes sure only interrupts with a higher level are triggered. After
+// completion of the interrupt service routine, clear the interrupt source,
+// the interrupt bit in the pending register, and restore the MASK register
+// to it's previous state.
+//
+// Addapt the core for fewer interrupt sources:
+// If less than 8 interrupt sources are required, than the 'is' parameter
+// can be set to the amount of required interrupts. Interrupts are mapped
+// starting at the LSBs. So only the 'is' LSBs per register are valid. All
+// other bits (i.e. the 8-'is' MSBs) are set to zero '0'.
+// Codesize is approximately linear to the amount of interrupts. I.e. using
+// 4 instead of 8 interrupt sources reduces the size by approx. half.
+//
+
+
+module pic
+  (input clk_i, input rst_i, input cyc_i, input stb_i,
+   input [2:0] adr_i, 
+   input we_i, 
+   input [31:0] dat_i, 
+   output reg [31:0] dat_o, 
+   output reg ack_o, 
+   output reg int_o,
+   input [31:0] irq
+   );
+
+   reg [31:0]  pol, edgen, pending, mask;   // register bank
+   reg [31:0]  lirq, dirq;                  // latched irqs, delayed latched irqs
+   
+   // latch interrupt inputs
+   always @(posedge clk_i)
+     lirq <=  irq;
+   
+   // generate delayed latched irqs
+   always @(posedge clk_i)
+     dirq <=  lirq;
+
+   // generate actual triggers
+   function trigger;
+      input    edgen, pol, lirq, dirq;
+      reg      edge_irq, level_irq;
+      begin
+        edge_irq  = pol ? (lirq & ~dirq) : (dirq & ~lirq);
+        level_irq = pol ? lirq : ~lirq;
+        trigger = edgen ? edge_irq : level_irq;
+      end
+   endfunction
+   
+   reg  [31:0] irq_event;
+   integer     n;
+   always @(posedge clk_i)
+     for(n = 0; n < 32; n = n+1)
+       irq_event[n] <=  trigger(edgen[n], pol[n], lirq[n], dirq[n]);
+
+   // generate wishbone register bank writes
+   wire        wb_acc = cyc_i & stb_i;                   // WISHBONE access
+   wire        wb_wr  = wb_acc & we_i;                   // WISHBONE write access
+
+   always @(posedge clk_i)
+     if (rst_i)
+       begin
+          pol   <=  0;              // clear polarity register
+          edgen <=  0;              // clear edge enable register
+          mask  <=  0;              // mask all interrupts
+       end
+     else if(wb_wr)                               // wishbone write cycle??
+       case (adr_i) // synopsys full_case parallel_case
+         3'd0 : edgen <=  dat_i;        // EDGE-ENABLE register
+         3'd1 : pol   <=  dat_i;        // POLARITY register
+         3'd2 : mask  <=  dat_i;        // MASK register
+         3'd3 : ;                       // PENDING register is a special case (see below)
+        3'd4 : ;                       // Priority encoded live (pending & ~mask)
+       endcase
+
+   // pending register is a special case
+   always @(posedge clk_i)
+     if (rst_i)
+       pending <=  0;            // clear all pending interrupts
+     else if ( wb_wr & (adr_i == 3'd3) )
+       pending <=  (pending & ~dat_i) | irq_event;
+     else
+       pending <=  pending | irq_event;
+
+   wire [31:0] live_enc;
+   priority_enc priority_enc ( .in(pending & ~mask), .out(live_enc) );
+   
+   always @(posedge clk_i)
+      case (adr_i) // synopsys full_case parallel_case
+        3'd0 : dat_o <= edgen;
+        3'd1 : dat_o <= pol;
+        3'd2 : dat_o <= mask;
+        3'd3 : dat_o <= pending;
+       3'd4 : dat_o <= live_enc;
+      endcase
+
+   always @(posedge clk_i)
+     ack_o <=  wb_acc & !ack_o;
+
+   always @(posedge clk_i)
+     if(rst_i)
+       int_o <=  0;
+     else
+       int_o <=  |(pending & ~mask);
+   
+endmodule
diff --git a/usrp2/fpga/control_lib/priority_enc.v b/usrp2/fpga/control_lib/priority_enc.v
new file mode 100644 (file)
index 0000000..9161924
--- /dev/null
@@ -0,0 +1,44 @@
+
+module priority_enc
+  (input [31:0] in,
+   output reg [31:0] out);
+
+   always @*
+     casex(in)
+       32'b1xxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 31;
+       32'b01xx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 30;
+       32'b001x_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 29;
+       32'b0001_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 28;
+       32'b0000_1xxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 27;
+       32'b0000_01xx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 26;
+       32'b0000_001x_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 25;
+       32'b0000_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 24;
+       32'b0000_0000_1xxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 23;
+       32'b0000_0000_01xx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 22;
+       32'b0000_0000_001x_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 21;
+       32'b0000_0000_0001_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 20;
+       32'b0000_0000_0000_1xxx_xxxx_xxxx_xxxx_xxxx : out <= 19;
+       32'b0000_0000_0000_01xx_xxxx_xxxx_xxxx_xxxx : out <= 18;
+       32'b0000_0000_0000_001x_xxxx_xxxx_xxxx_xxxx : out <= 17;
+       32'b0000_0000_0000_0001_xxxx_xxxx_xxxx_xxxx : out <= 16;
+       32'b0000_0000_0000_0000_1xxx_xxxx_xxxx_xxxx : out <= 15;
+       32'b0000_0000_0000_0000_01xx_xxxx_xxxx_xxxx : out <= 14;
+       32'b0000_0000_0000_0000_001x_xxxx_xxxx_xxxx : out <= 13;
+       32'b0000_0000_0000_0000_0001_xxxx_xxxx_xxxx : out <= 12;
+       32'b0000_0000_0000_0000_0000_1xxx_xxxx_xxxx : out <= 11;
+       32'b0000_0000_0000_0000_0000_01xx_xxxx_xxxx : out <= 10;
+       32'b0000_0000_0000_0000_0000_001x_xxxx_xxxx : out <=  9;
+       32'b0000_0000_0000_0000_0000_0001_xxxx_xxxx : out <=  8;
+       32'b0000_0000_0000_0000_0000_0000_1xxx_xxxx : out <=  7;
+       32'b0000_0000_0000_0000_0000_0000_01xx_xxxx : out <=  6;
+       32'b0000_0000_0000_0000_0000_0000_001x_xxxx : out <=  5;
+       32'b0000_0000_0000_0000_0000_0000_0001_xxxx : out <=  4;
+       32'b0000_0000_0000_0000_0000_0000_0000_1xxx : out <=  3;
+       32'b0000_0000_0000_0000_0000_0000_0000_01xx : out <=  2;
+       32'b0000_0000_0000_0000_0000_0000_0000_001x : out <=  1;
+       32'b0000_0000_0000_0000_0000_0000_0000_0001 : out <=  0;
+       32'b0000_0000_0000_0000_0000_0000_0000_0000 : out <= 32'hFFFF_FFFF;
+       default : out <= 32'hFFFF_FFFF;
+     endcase // casex (in)
+   
+endmodule // priority_enc
index 03016e9b3cbaafb46d786a9373049eb6a075ca06..fd17a10a7f7a6ba421870b56188f867d9405501b 100755 (executable)
@@ -158,6 +158,7 @@ module u2_core
        
    wire        serdes_link_up;
    wire        epoch;
+   wire [31:0]         irq;
    
    // ///////////////////////////////////////////////////////////////////////////////////////////////
    // Wishbone Single Master INTERCON
@@ -278,6 +279,7 @@ module u2_core
                 .wb_we_o(ram_loader_we),.wb_ack_i(ram_loader_ack),
                 .ram_loader_done_o(ram_loader_done));
 
+   // /////////////////////////////////////////////////////////////////////////
    // Processor
    aeMB_core_BE #(.ISIZ(16),.DSIZ(16),.MUL(0),.BSF(1))
      aeMB (.sys_clk_i(wb_clk), .sys_rst_i(wb_rst),
@@ -292,6 +294,7 @@ module u2_core
    
    assign       bus_error = m0_err | m0_rty;
    
+   // /////////////////////////////////////////////////////////////////////////
    // Dual Ported RAM -- D-Port is Slave #0 on main Wishbone
    // I-port connects directly to processor and ram loader
 
@@ -314,6 +317,7 @@ module u2_core
    setting_reg #(.my_addr(7)) sr_icache (.clk(wb_clk),.rst(wb_rst),.strobe(set_stb),.addr(set_addr),
                                         .in(set_data),.out(),.changed(flush_icache));
 
+   // /////////////////////////////////////////////////////////////////////////
    // Buffer Pool, slave #1
    wire         rd0_ready_i, rd0_ready_o;
    wire         rd1_ready_i, rd1_ready_o;
@@ -353,6 +357,10 @@ module u2_core
       .rd3_data_o(rd3_dat), .rd3_flags_o(rd3_flags), .rd3_ready_i(rd3_ready_i), .rd3_ready_o(rd3_ready_o)
       );
 
+   wire [31:0]          status_enc;
+   priority_enc priority_enc (.in({16'b0,status[15:0]}), .out(status_enc));
+   
+   // /////////////////////////////////////////////////////////////////////////
    // SPI -- Slave #2
    spi_top shared_spi
      (.wb_clk_i(wb_clk),.wb_rst_i(wb_rst),.wb_adr_i(s2_adr[4:0]),.wb_dat_i(s2_dat_o),
@@ -361,6 +369,7 @@ module u2_core
       .ss_pad_o({sen_tx_db,sen_tx_adc,sen_tx_dac,sen_rx_db,sen_rx_adc,sen_rx_dac,sen_dac,sen_clk}),
       .sclk_pad_o(sclk),.mosi_pad_o(mosi),.miso_pad_i(miso) );
 
+   // /////////////////////////////////////////////////////////////////////////
    // I2C -- Slave #3
    i2c_master_top #(.ARST_LVL(1)) 
      i2c (.wb_clk_i(wb_clk),.wb_rst_i(wb_rst),.arst_i(1'b0), 
@@ -372,6 +381,7 @@ module u2_core
 
    assign       s3_dat_i[31:8] = 24'd0;
    
+   // /////////////////////////////////////////////////////////////////////////
    // GPIOs -- Slave #4
    nsgpio nsgpio(.clk_i(wb_clk),.rst_i(wb_rst),
                 .cyc_i(s4_cyc),.stb_i(s4_stb),.adr_i(s4_adr[3:0]),.we_i(s4_we),
@@ -379,19 +389,24 @@ module u2_core
                 .atr(atr_lines),.debug_0(debug_gpio_0),.debug_1(debug_gpio_1),
                 .gpio( {io_tx,io_rx} ) );
 
-   // Buffer Pool Status -- Slave #5
+   // /////////////////////////////////////////////////////////////////////////
+   // Buffer Pool Status -- Slave #5   
+   
+   reg [31:0]   cycle_count;
+   always @(posedge wb_clk)
+     if(wb_rst)
+       cycle_count <= 0;
+     else
+       cycle_count <= cycle_count + 1;
+   
    wb_readback_mux buff_pool_status
-     (.wb_clk_i(wb_clk),
-      .wb_rst_i(wb_rst),
-      .wb_stb_i(s5_stb),
-      .wb_adr_i(s5_adr),
-      .wb_dat_o(s5_dat_i),
-      .wb_ack_o(s5_ack),
+     (.wb_clk_i(wb_clk), .wb_rst_i(wb_rst), .wb_stb_i(s5_stb),
+      .wb_adr_i(s5_adr), .wb_dat_o(s5_dat_i), .wb_ack_o(s5_ack),
       
       .word00(status_b0),.word01(status_b1),.word02(status_b2),.word03(status_b3),
       .word04(status_b4),.word05(status_b5),.word06(status_b6),.word07(status_b7),
       .word08(status),.word09({sim_mode,27'b0,clock_divider[3:0]}),.word10(32'b0),
-      .word11(32'b0),.word12(32'b0),.word13(32'b0),.word14(32'b0),.word15(32'b0)
+      .word11(32'b0),.word12(32'b0),.word13(irq),.word14(status_enc),.word15(cycle_count)
       );
 
    // /////////////////////////////////////////////////////////////////////////
@@ -457,13 +472,14 @@ module u2_core
    // /////////////////////////////////////////////////////////////////////////
    // Interrupt Controller, Slave #8
 
-   wire [15:0]          irq={{4'b0, clk_status, serdes_link_up, uart_tx_int, uart_rx_int},
-                     {pps_int,overrun,underrun,PHY_INTn,i2c_int,spi_int,timer_int,buffer_int}};
+   assign irq= {{8'b0},
+               {8'b0},
+               {4'b0, clk_status, serdes_link_up, uart_tx_int, uart_rx_int},
+               {pps_int,overrun,underrun,PHY_INTn,i2c_int,spi_int,timer_int,buffer_int}};
    
-   simple_pic #(.is(16),.dwidth(32)) simple_pic
-     (.clk_i(wb_clk),.rst_i(wb_rst),.cyc_i(s8_cyc),.stb_i(s8_stb),.adr_i(s8_adr[3:2]),
-      .we_i(s8_we),.dat_i(s8_dat_o),.dat_o(s8_dat_i),.ack_o(s8_ack),.int_o(proc_int),
-      .irq(irq) );
+   pic pic(.clk_i(wb_clk),.rst_i(wb_rst),.cyc_i(s8_cyc),.stb_i(s8_stb),.adr_i(s8_adr[3:2]),
+          .we_i(s8_we),.dat_i(s8_dat_o),.dat_o(s8_dat_i),.ack_o(s8_ack),.int_o(proc_int),
+          .irq(irq) );
         
    // /////////////////////////////////////////////////////////////////////////
    // Master Timer, Slave #9
index 94681f6cd028f08ded39b2e974d29b035d1b8d67..4358d7c56ef5d838fa2f503483331bca4f910480 100644 (file)
@@ -82,6 +82,8 @@ control_lib/sd_spi.v \
 control_lib/sd_spi_wb.v \
 control_lib/wb_bridge_16_32.v \
 control_lib/reset_sync.v \
+control_lib/priority_enc.v \
+control_lib/pic.v \
 simple_gemac/simple_gemac_wrapper.v \
 simple_gemac/simple_gemac.v \
 simple_gemac/simple_gemac_wb.v \
@@ -132,7 +134,6 @@ opencores/i2c/rtl/verilog/i2c_master_byte_ctrl.v \
 opencores/i2c/rtl/verilog/i2c_master_defines.v \
 opencores/i2c/rtl/verilog/i2c_master_top.v \
 opencores/i2c/rtl/verilog/timescale.v \
-opencores/simple_pic/rtl/simple_pic.v \
 opencores/spi/rtl/verilog/spi_clgen.v \
 opencores/spi/rtl/verilog/spi_defines.v \
 opencores/spi/rtl/verilog/spi_shift.v \
index 7a612f945bba06380af6cccb9df9c8a7997dff4d..2d9e2a4b0350b83bc09a39e3ef54e042daffe863 100644 (file)
@@ -60,7 +60,7 @@ namespace usrp2 {
    *
    * \returns a vector of properties, 1 entry for each matching USRP2 found.
    */
-  props_vector_t find(const std::string &ifc, const std::string &mac_addr=""); 
+  props_vector_t find(const std::string &ifc, const std::string &mac_addr="");
 
   class tune_result;
 
@@ -79,10 +79,10 @@ namespace usrp2 {
 
     /*!
      * Shared pointer to this class
-     */ 
+     */
     typedef boost::shared_ptr<usrp2> sptr;
-    /*! 
+
+    /*!
      * Static function to return an instance of usrp2 as a shared pointer
      *
      * \param ifc   Network interface name, e.g., "eth0"
@@ -96,7 +96,7 @@ namespace usrp2 {
     /*!
      * Class destructor
      */
-    ~usrp2();  
+    ~usrp2();
 
     /*!
      * Returns the MAC address associated with this USRP
@@ -120,10 +120,10 @@ namespace usrp2 {
      */
     bool set_rx_gain(double gain);
 
-    //! return minimum Rx gain 
+    //! return minimum Rx gain
     double rx_gain_min();
 
-    //! return maximum Rx gain 
+    //! return maximum Rx gain
     double rx_gain_max();
 
     //! return Rx gain db_per_step
@@ -160,7 +160,7 @@ namespace usrp2 {
 
     /*!
      * Set received sample format
-     *   
+     *
      *    domain: complex or real
      *      type: floating, fixed point, or raw
      *     depth: bits per sample
@@ -172,12 +172,33 @@ namespace usrp2 {
     /*!
      * Start streaming receive mode.  USRP2 will send a continuous stream of
      * DSP pipeline samples to host.  Call rx_samples(...) to access.
-     * 
+     *
      * \param channel          Stream channel number (0-30)
      * \param items_per_frame  Number of 32-bit items per frame.
      */
     bool start_rx_streaming(unsigned int channel=0, unsigned int items_per_frame=0);
-  
+
+    /*!
+     * Start streaming receive mode at specified timestamp. USRP2 will send a
+     * continuous stream of DSP pipeline samples to host. Call rx_samples(...)
+     * to access.
+     *
+     * \param channel          Stream channel number (0-30)
+     * \param items_per_frame  Number of 32-bit items per frame.
+     * \param time             Timestamp to start streaming at
+     */
+    bool start_rx_streaming_at(unsigned int channel=0, unsigned int items_per_frame=0, unsigned int time=0);
+
+    /*!
+     * Sync to PPS and start streaming receive mode at specified timestamp.
+     * Just like calling sync_to_pps() and start_rx_streaming_at().
+     *
+     * \param channel          Stream channel number (0-30)
+     * \param items_per_frame  Number of 32-bit items per frame.
+     * \param time             Timestamp to start streaming at
+     */
+    bool sync_and_start_rx_streaming_at(unsigned int channel=0, unsigned int items_per_frame=0, uint32_t time=0);
+
     /*!
      * Stop streaming receive mode.
      */
@@ -193,7 +214,7 @@ namespace usrp2 {
      * Returns number of times receive overruns have occurred
      */
     unsigned int rx_overruns();
-    
+
     /*!
      * Returns total number of missing frames from overruns.
      */
@@ -210,10 +231,10 @@ namespace usrp2 {
      */
     bool set_tx_gain(double gain);
 
-    //! return minimum Tx gain 
+    //! return minimum Tx gain
     double tx_gain_min();
 
-    //! return maximum Tx gain 
+    //! return maximum Tx gain
     double tx_gain_max();
 
     //! return Tx gain db_per_step
@@ -255,7 +276,7 @@ namespace usrp2 {
 
     /*!
      * Set transmit sample format
-     *   
+     *
      *    domain: complex or real
      *      type: floating, fixed point, or raw
      *     depth: bits per sample
@@ -272,7 +293,7 @@ namespace usrp2 {
      * \param nsamples is the number of samples to transmit
      * \param metadata provides the timestamp and flags
      *
-     * The complex<float> samples are converted to the appropriate 
+     * The complex<float> samples are converted to the appropriate
      * "on the wire" representation, depending on the current USRP2
      * configuration.  Typically, this is big-endian 16-bit I & Q.
      */
@@ -400,12 +421,12 @@ namespace usrp2 {
      *
      * \param addr      32-bit aligned address.  Only the lower 16-bits are significant.
      * \param words     Number of 32-bit words
-     * 
+     *
      * \returns         Vector of 32-bit read values
      *
      * WARNING: Attempts to read memory from addresses that do not correspond to RAM or
      * memory-mapped peripherals may cause the USRP2 to hang, requiring a power cycle.
-     * 
+     *
      */
     std::vector<uint32_t> peek32(uint32_t addr, uint32_t words);
 
@@ -419,7 +440,7 @@ namespace usrp2 {
      *
      * WARNING: Attempts to read memory from addresses that do not correspond to RAM or
      * memory-mapped peripherals may cause the USRP2 to hang, requiring a power cycle.
-     * 
+     *
      */
     bool poke32(uint32_t addr, const std::vector<uint32_t> &data);
 
@@ -587,7 +608,7 @@ namespace usrp2 {
 
     // Only class members can instantiate this class
     usrp2(const std::string &ifc, props *p, size_t rx_bufsize);
-  
+
     // All private state is held in opaque pointer
     std::auto_ptr<impl> d_impl;
   };
index 8769e4522f2e7dcfe38cba6170eef5065c0b1c36..46ce791ea3019915432ca498b639db143b4c2343 100644 (file)
@@ -33,27 +33,35 @@ namespace usrp2 {
   /*!
    * OP_CONFIG_RX_V2 command packet
    */
-  struct op_config_rx_v2_cmd 
+  struct op_config_rx_v2_cmd
   {
     u2_eth_packet_t   h;
     op_config_rx_v2_t op;
     op_generic_t      eop;
   };
 
-  struct op_start_rx_streaming_cmd 
+  struct op_start_rx_streaming_cmd
   {
     u2_eth_packet_t        h;
     op_start_rx_streaming_t op;
     op_generic_t           eop;
   };
-    
+
+  struct op_sync_and_start_rx_streaming_cmd
+  {
+    u2_eth_packet_t        h;
+    op_generic_t            sync_op;
+    op_start_rx_streaming_t rx_op;
+    op_generic_t           eop;
+  };
+
   struct op_stop_rx_cmd {
     u2_eth_packet_t h;
     op_generic_t    op;
     op_generic_t    eop;
   };
 
-  struct op_config_tx_v2_cmd 
+  struct op_config_tx_v2_cmd
   {
     u2_eth_packet_t   h;
     op_config_tx_v2_t op;
@@ -67,7 +75,7 @@ namespace usrp2 {
     op_generic_t      eop;
   };
 
-  struct op_burn_mac_addr_cmd 
+  struct op_burn_mac_addr_cmd
   {
     u2_eth_packet_t    h;
     op_burn_mac_addr_t op;
@@ -113,20 +121,20 @@ namespace usrp2 {
 
   /*!
    * Control mechanism to allow API calls to block waiting for reply packets
-   */    
+   */
   class pending_reply
   {
   private:
     unsigned int    d_rid;
     void           *d_buffer;
     size_t         d_len;
-    
+
     // d_mutex is used with d_cond and also protects d_complete
     omni_mutex      d_mutex;
     omni_condition  d_cond;
     bool           d_complete;
 
-  public:  
+  public:
     /*!
      * Construct a pending reply from the reply ID, response packet
      * buffer, and buffer length.
@@ -165,7 +173,7 @@ namespace usrp2 {
      */
     size_t len() const { return d_len; }
   };
-  
+
 } // namespace usrp2
 
 #endif /* INCLUDED_CONTROL_H */
index a2a9ecc1158a5b5a2483bca6ae111c38109506b4..801a436a396b5c9a0fc615b08304d61fbf2278a5 100644 (file)
@@ -62,7 +62,7 @@ namespace usrp2 {
       else {
        if (key == p->key)      // found it
          return usrp2::sptr(p->value);
-       else                    
+       else
          ++p;                  // keep looking
       }
     }
@@ -90,15 +90,15 @@ namespace usrp2 {
     p.addr[3] = 0x85;
     p.addr[4] = 0x30;
     p.addr[5] = 0x00;
-    
+
     int len = s.size();
     switch (len) {
-      
+
     case 5:
       if (sscanf(s.c_str(), "%hhx:%hhx", &p.addr[4], &p.addr[5]) != 2)
        return false;
       break;
-      
+
     case 17:
       if (sscanf(s.c_str(), "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
                 &p.addr[0], &p.addr[1], &p.addr[2],
@@ -109,7 +109,7 @@ namespace usrp2 {
     default:
       return false;
     }
-    
+
     char buf[128];
     snprintf(buf, sizeof(buf),
             "%02x:%02x:%02x:%02x:%02x:%02x",
@@ -148,13 +148,13 @@ namespace usrp2 {
   {
     // NOP
   }
-  
+
   // Public class destructor.  d_impl will auto-delete.
   usrp2::~usrp2()
   {
     // NOP
   }
-  
+
   std::string
   usrp2::mac_addr()
   {
@@ -169,12 +169,12 @@ namespace usrp2 {
 
   // Receive
 
-  bool 
+  bool
   usrp2::set_rx_gain(double gain)
   {
     return d_impl->set_rx_gain(gain);
   }
-  
+
   double
   usrp2::rx_gain_min()
   {
@@ -204,7 +204,7 @@ namespace usrp2 {
   {
     return d_impl->set_rx_center_freq(frequency, result);
   }
-  
+
   double
   usrp2::rx_freq_min()
   {
@@ -222,7 +222,7 @@ namespace usrp2 {
   {
     return d_impl->set_rx_decim(decimation_factor);
   }
-  
+
   int
   usrp2::rx_decim()
   {
@@ -234,13 +234,25 @@ namespace usrp2 {
   {
     return d_impl->set_rx_scale_iq(scale_i, scale_q);
   }
-  
+
   bool
   usrp2::start_rx_streaming(unsigned int channel, unsigned int items_per_frame)
   {
     return d_impl->start_rx_streaming(channel, items_per_frame);
   }
-  
+
+  bool
+  usrp2::start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time)
+  {
+    return d_impl->start_rx_streaming_at(channel, items_per_frame,time);
+  }
+
+  bool
+  usrp2::sync_and_start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time)
+  {
+    return d_impl->sync_and_start_rx_streaming_at(channel, items_per_frame, time);
+  }
+
   bool
   usrp2::rx_samples(unsigned int channel, rx_sample_handler *handler)
   {
@@ -258,7 +270,7 @@ namespace usrp2 {
   {
     return d_impl->rx_overruns();
   }
-  
+
   unsigned int
   usrp2::rx_missing()
   {
@@ -267,12 +279,12 @@ namespace usrp2 {
 
   // Transmit
 
-  bool 
+  bool
   usrp2::set_tx_gain(double gain)
   {
     return d_impl->set_tx_gain(gain);
   }
-  
+
   double
   usrp2::tx_gain_min()
   {
@@ -302,7 +314,7 @@ namespace usrp2 {
   {
     return d_impl->set_tx_center_freq(frequency, result);
   }
-  
+
   double
   usrp2::tx_freq_min()
   {
@@ -321,7 +333,7 @@ namespace usrp2 {
   {
     return d_impl->set_tx_interp(interpolation_factor);
   }
-  
+
   int
   usrp2::tx_interp()
   {
@@ -339,7 +351,7 @@ namespace usrp2 {
   {
     return d_impl->set_tx_scale_iq(scale_i, scale_q);
   }
-  
+
   bool
   usrp2::tx_32fc(unsigned int channel,
                 const std::complex<float> *samples,
@@ -404,7 +416,7 @@ namespace usrp2 {
   {
     return d_impl->rx_daughterboard_id(dbid);
   }
-  
+
 
   // low level methods
 
index 3d030432429c42d270743697840161552f4db43f..a74707634cd4c7c73ffc0d5320f2afe17a49a796 100644 (file)
@@ -106,7 +106,7 @@ namespace usrp2 {
     //assert((((uintptr_t) p) % 4) == 0);              // must be 4-byte aligned
 
     u2_fixed_hdr_t *fh = static_cast<u2_fixed_hdr_t *>(p);
-    
+
     // FIXME unaligned loads!
     md->word0 = u2p_word0(fh);
     md->timestamp = u2p_timestamp(fh);
@@ -131,13 +131,13 @@ namespace usrp2 {
   usrp2::impl::impl(const std::string &ifc, props *p, size_t rx_bufsize)
     : d_eth_buf(new eth_buffer(rx_bufsize)), d_interface_name(ifc), d_pf(0), d_bg_thread(0),
       d_bg_running(false), d_rx_seqno(-1), d_tx_seqno(0), d_next_rid(0),
-      d_num_rx_frames(0), d_num_rx_missing(0), d_num_rx_overruns(0), d_num_rx_bytes(0), 
+      d_num_rx_frames(0), d_num_rx_missing(0), d_num_rx_overruns(0), d_num_rx_bytes(0),
       d_num_enqueued(0), d_enqueued_mutex(), d_bg_pending_cond(&d_enqueued_mutex),
       d_channel_rings(NCHANS), d_tx_interp(0), d_rx_decim(0), d_dont_enqueue(true)
   {
     if (!d_eth_buf->open(ifc, htons(U2_ETHERTYPE)))
       throw std::runtime_error("Unable to register USRP2 protocol");
-    
+
     d_addr = p->addr;
 
     // Create a packet filter for U2_ETHERTYPE packets sourced from target USRP2
@@ -146,7 +146,7 @@ namespace usrp2 {
     d_pf = pktfilter::make_ethertype_inbound_target(U2_ETHERTYPE, (const unsigned char*)&(usrp_mac.addr));
     if (!d_pf || !d_eth_buf->attach_pktfilter(d_pf))
       throw std::runtime_error("Unable to attach packet filter.");
-    
+
     if (USRP2_IMPL_DEBUG)
       std::cerr << "usrp2 constructor: using USRP2 at " << d_addr << std::endl;
 
@@ -199,12 +199,12 @@ namespace usrp2 {
 
     if (!set_rx_decim(12))
       std::cerr << "usrp2::ctor set_rx_decim failed\n";
-      
+
     // set workable defaults for scaling
     if (!set_rx_scale_iq(DEFAULT_RX_SCALE, DEFAULT_RX_SCALE))
       std::cerr << "usrp2::ctor set_rx_scale_iq failed\n";
   }
-  
+
   usrp2::impl::~impl()
   {
     stop_bg();
@@ -212,17 +212,17 @@ namespace usrp2 {
     delete d_pf;
     d_eth_buf->close();
     delete d_eth_buf;
-    
+
     if (USRP2_IMPL_DEBUG) {
       std::cerr << std::endl
-                << "usrp2 destructor: received " << d_num_rx_frames 
+                << "usrp2 destructor: received " << d_num_rx_frames
                << " frames, with " << d_num_rx_missing << " lost ("
                << (d_num_rx_frames == 0 ? 0 : (int)(100.0*d_num_rx_missing/d_num_rx_frames))
                << "%), totaling " << d_num_rx_bytes
                << " bytes" << std::endl;
     }
   }
-  
+
   bool
   usrp2::impl::parse_mac_addr(const std::string &s, u2_mac_addr_t *p)
   {
@@ -232,14 +232,14 @@ namespace usrp2 {
     p->addr[3] = 0x85;
     p->addr[4] = 0x30;
     p->addr[5] = 0x00;
-    
+
     int len = s.size();
-    
+
     switch (len){
-      
+
     case 5:
       return sscanf(s.c_str(), "%hhx:%hhx", &p->addr[4], &p->addr[5]) == 2;
-      
+
     case 17:
       return sscanf(s.c_str(), "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
                    &p->addr[0], &p->addr[1], &p->addr[2],
@@ -248,36 +248,36 @@ namespace usrp2 {
       return false;
     }
   }
-  
+
   void
   usrp2::impl::init_et_hdrs(u2_eth_packet_t *p, const std::string &dst)
   {
     p->ehdr.ethertype = htons(U2_ETHERTYPE);
-    parse_mac_addr(dst, &p->ehdr.dst); 
+    parse_mac_addr(dst, &p->ehdr.dst);
     memcpy(&p->ehdr.src, d_eth_buf->mac(), 6);
     p->thdr.flags = 0; // FIXME transport header values?
     p->thdr.seqno = d_tx_seqno++;
     p->thdr.ack = 0;
   }
-  
-  void 
+
+  void
   usrp2::impl::init_etf_hdrs(u2_eth_packet_t *p, const std::string &dst,
                             int word0_flags, int chan, uint32_t timestamp)
   {
     init_et_hdrs(p, dst);
     u2p_set_word0(&p->fixed, word0_flags, chan);
     u2p_set_timestamp(&p->fixed, timestamp);
-    
+
     if (chan == CONTROL_CHAN) { // no sequence numbers, back it out
       p->thdr.seqno = 0;
       d_tx_seqno--;
     }
   }
-  
+
   void
   usrp2::impl::init_config_rx_v2_cmd(op_config_rx_v2_cmd *cmd)
   {
-    memset(cmd, 0, sizeof(*cmd)); 
+    memset(cmd, 0, sizeof(*cmd));
     init_etf_hdrs(&cmd->h, d_addr, 0, CONTROL_CHAN, -1);
     cmd->op.opcode = OP_CONFIG_RX_V2;
     cmd->op.len = sizeof(cmd->op);
@@ -289,7 +289,7 @@ namespace usrp2 {
   void
   usrp2::impl::init_config_tx_v2_cmd(op_config_tx_v2_cmd *cmd)
   {
-    memset(cmd, 0, sizeof(*cmd)); 
+    memset(cmd, 0, sizeof(*cmd));
     init_etf_hdrs(&cmd->h, d_addr, 0, CONTROL_CHAN, -1);
     cmd->op.opcode = OP_CONFIG_TX_V2;
     cmd->op.len = sizeof(cmd->op);
@@ -320,7 +320,7 @@ namespace usrp2 {
   usrp2::impl::transmit_cmd_and_wait(void *cmd, size_t len, pending_reply *p, double secs)
   {
     d_pending_replies[p->rid()] = p;
-    
+
     if (!transmit_cmd(cmd, len)){
       d_pending_replies[p->rid()] = 0;
       return false;
@@ -340,11 +340,11 @@ namespace usrp2 {
   {
     d_bg_running = false;
     d_bg_pending_cond.signal();
-    
+
     void *dummy_status;
-    d_bg_thread->join(&dummy_status);  
+    d_bg_thread->join(&dummy_status);
   }
-  
+
   void
   usrp2::impl::bg_loop()
   {
@@ -356,10 +356,10 @@ namespace usrp2 {
       // rings, and signal blocked API threads
       int res = d_eth_buf->rx_frames(this, 100); // FIXME magic timeout
       if (res == eth_buffer::EB_ERROR)
-       break;  
+       break;
 
       // Wait for user API thread(s) to process all enqueued packets.
-      // The channel ring thread that decrements d_num_enqueued to zero 
+      // The channel ring thread that decrements d_num_enqueued to zero
       // will signal this thread to continue.
       {
         omni_mutex_lock l(d_enqueued_mutex);
@@ -369,7 +369,7 @@ namespace usrp2 {
     }
     d_bg_running = false;
   }
-  
+
   //
   // passed to eth_buffer::rx_frames
   //
@@ -401,11 +401,11 @@ namespace usrp2 {
   {
     // point to beginning of payload (subpackets)
     unsigned char *p = (unsigned char *)base + sizeof(u2_eth_packet_t);
-    
+
     // FIXME (p % 4) == 2.  Not good.  Must watch for unaligned loads.
 
     // FIXME iterate over payload, handling more than a single subpacket.
-    
+
     int opcode = p[0];
     unsigned int oplen = p[1];
     unsigned int rid = p[2];
@@ -417,8 +417,8 @@ namespace usrp2 {
        std::cerr << "usrp2: mismatched command reply length (expected: "
                  << buflen << " got: " << oplen << "). "
                  << "op = " << opcode_to_string(opcode) << std::endl;
-      }     
-    
+      }
+
       // Copy reply into caller's buffer
       memcpy(rp->buffer(), p, std::min(oplen, buflen));
       rp->notify_completion();
@@ -430,26 +430,26 @@ namespace usrp2 {
     DEBUG_LOG("l");
     return data_handler::RELEASE;
   }
-  
+
   data_handler::result
   usrp2::impl::handle_data_packet(const void *base, size_t len)
   {
     u2_eth_samples_t *pkt = (u2_eth_samples_t *)base;
     d_num_rx_frames++;
     d_num_rx_bytes += len;
-    
+
     /* --- FIXME start of fake transport layer handler --- */
 
     if (d_rx_seqno != -1) {
       int expected_seqno = (d_rx_seqno + 1) & 0xFF;
-      int seqno = pkt->hdrs.thdr.seqno; 
-      
+      int seqno = pkt->hdrs.thdr.seqno;
+
       if (seqno != expected_seqno) {
        ::write(2, "S", 1); // missing sequence number
        int missing = seqno - expected_seqno;
        if (missing < 0)
          missing += 256;
-       
+
        d_num_rx_overruns++;
        d_num_rx_missing += missing;
       }
@@ -469,9 +469,9 @@ namespace usrp2 {
        DEBUG_LOG("!");
        return data_handler::RELEASE;   // discard packet, no channel handler
       }
-      
+
       // Strip off ethernet header and transport header and enqueue the rest
-      
+
       size_t offset = offsetof(u2_eth_samples_t, hdrs.fixed);
       if (d_channel_rings[chan]->enqueue(&pkt->hdrs.fixed, len-offset)) {
        inc_enqueued();
@@ -481,7 +481,7 @@ namespace usrp2 {
       else {
        DEBUG_LOG("!");
        return data_handler::RELEASE;   // discard, no room in channel ring
-      }        
+      }
       return data_handler::RELEASE;
     }
   }
@@ -491,7 +491,7 @@ namespace usrp2 {
   //                          Receive
   // ----------------------------------------------------------------
 
-  bool 
+  bool
   usrp2::impl::set_rx_gain(double gain)
   {
     op_config_rx_v2_cmd cmd;
@@ -500,7 +500,7 @@ namespace usrp2 {
     init_config_rx_v2_cmd(&cmd);
     cmd.op.valid = htons(CFGV_GAIN);
     cmd.op.gain = htons(u2_double_to_fxpt_gain(gain));
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -508,7 +508,7 @@ namespace usrp2 {
     bool success = (ntohx(reply.ok) == 1);
     return success;
   }
-  
+
   bool
   usrp2::impl::set_rx_lo_offset(double frequency)
   {
@@ -527,7 +527,7 @@ namespace usrp2 {
 
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -547,7 +547,7 @@ namespace usrp2 {
     u2_fxpt_freq_t fxpt = u2_double_to_fxpt_freq(frequency);
     cmd.op.freq_hi = htonl(u2_fxpt_freq_hi(fxpt));
     cmd.op.freq_lo = htonl(u2_fxpt_freq_lo(fxpt));
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -555,18 +555,18 @@ namespace usrp2 {
     bool success = (ntohx(reply.ok) == 1);
     if (result && success) {
       result->baseband_freq =
-        u2_fxpt_freq_to_double( 
-         u2_fxpt_freq_from_hilo(ntohl(reply.baseband_freq_hi), 
+        u2_fxpt_freq_to_double(
+         u2_fxpt_freq_from_hilo(ntohl(reply.baseband_freq_hi),
                                 ntohl(reply.baseband_freq_lo)));
 
       result->dxc_freq =
-        u2_fxpt_freq_to_double( 
-         u2_fxpt_freq_from_hilo(ntohl(reply.ddc_freq_hi), 
+        u2_fxpt_freq_to_double(
+         u2_fxpt_freq_from_hilo(ntohl(reply.ddc_freq_hi),
                                 ntohl(reply.ddc_freq_lo)));
 
       result->residual_freq =
-        u2_fxpt_freq_to_double( 
-        u2_fxpt_freq_from_hilo(ntohl(reply.residual_freq_hi), 
+        u2_fxpt_freq_to_double(
+        u2_fxpt_freq_from_hilo(ntohl(reply.residual_freq_hi),
                                ntohl(reply.residual_freq_lo)));
 
       result->spectrum_inverted = (bool)(ntohx(reply.inverted) == 1);
@@ -574,7 +574,7 @@ namespace usrp2 {
 
     return success;
   }
-  
+
   bool
   usrp2::impl::set_rx_decim(int decimation_factor)
   {
@@ -584,7 +584,7 @@ namespace usrp2 {
     init_config_rx_v2_cmd(&cmd);
     cmd.op.valid = htons(CFGV_INTERP_DECIM);
     cmd.op.decim = htonl(decimation_factor);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -594,7 +594,7 @@ namespace usrp2 {
       d_rx_decim = decimation_factor;
     return success;
   }
-  
+
   bool
   usrp2::impl::set_rx_scale_iq(int scale_i, int scale_q)
   {
@@ -604,7 +604,7 @@ namespace usrp2 {
     init_config_rx_v2_cmd(&cmd);
     cmd.op.valid = htons(CFGV_SCALE_IQ);
     cmd.op.scale_iq = htonl(((scale_i & 0xffff) << 16) | (scale_q & 0xffff));
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -612,7 +612,7 @@ namespace usrp2 {
     bool success = (ntohx(reply.ok) == 1);
     return success;
   }
-  
+
   bool
   usrp2::impl::start_rx_streaming(unsigned int channel, unsigned int items_per_frame)
   {
@@ -635,10 +635,10 @@ namespace usrp2 {
                  << " already streaming" << std::endl;
        return false;
       }
-      
+
       if (items_per_frame == 0)
        items_per_frame = U2_MAX_SAMPLES;               // minimize overhead
-      
+
       op_start_rx_streaming_cmd cmd;
       op_generic_t reply;
 
@@ -650,13 +650,13 @@ namespace usrp2 {
       cmd.op.items_per_frame = htonl(items_per_frame);
       cmd.eop.opcode = OP_EOP;
       cmd.eop.len = sizeof(cmd.eop);
-    
+
       d_dont_enqueue = false;
       bool success = false;
       pending_reply p(cmd.op.rid, &reply, sizeof(reply));
       success = transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT);
       success = success && (ntohx(reply.ok) == 1);
-      
+
       if (success)
        d_channel_rings[channel] = ring_sptr(new ring(d_eth_buf->max_frames()));
       else
@@ -666,7 +666,111 @@ namespace usrp2 {
       return success;
     }
   }
-  
+
+  bool
+  usrp2::impl::start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time)
+  {
+    if (channel > MAX_CHAN) {
+      std::cerr << "usrp2: invalid channel number (" << channel
+               << ")" << std::endl;
+      return false;
+    }
+
+    if (channel > 0) { // until firmware supports multiple streams
+      std::cerr << "usrp2: channel " << channel
+               << " not implemented" << std::endl;
+      return false;
+    }
+
+    {
+      omni_mutex_lock l(d_channel_rings_mutex);
+      if (d_channel_rings[channel]) {
+       std::cerr << "usrp2: channel " << channel
+                 << " already streaming" << std::endl;
+       return false;
+      }
+
+      if (items_per_frame == 0)
+       items_per_frame = U2_MAX_SAMPLES;               // minimize overhead
+
+      op_start_rx_streaming_cmd cmd;
+      op_generic_t reply;
+
+      memset(&cmd, 0, sizeof(cmd));
+      init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, time);
+      cmd.op.opcode = OP_START_RX_STREAMING;
+      cmd.op.len = sizeof(cmd.op);
+      cmd.op.rid = d_next_rid++;
+      cmd.op.items_per_frame = htonl(items_per_frame);
+      cmd.eop.opcode = OP_EOP;
+      cmd.eop.len = sizeof(cmd.eop);
+
+      bool success = false;
+      pending_reply p(cmd.op.rid, &reply, sizeof(reply));
+      success = transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT);
+      success = success && (ntohx(reply.ok) == 1);
+
+      if (success)
+       d_channel_rings[channel] = ring_sptr(new ring(d_eth_buf->max_frames()));
+
+      return success;
+    }
+  }
+
+  bool
+  usrp2::impl::sync_and_start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time)
+  {
+
+    if (channel > MAX_CHAN) {
+      std::cerr << "usrp2: invalid channel number (" << channel
+               << ")" << std::endl;
+      return false;
+    }
+
+    if (channel > 0) { // until firmware supports multiple streams
+      std::cerr << "usrp2: channel " << channel
+               << " not implemented" << std::endl;
+      return false;
+    }
+
+    {
+      omni_mutex_lock l(d_channel_rings_mutex);
+      if (d_channel_rings[channel]) {
+       std::cerr << "usrp2: channel " << channel
+                 << " already streaming" << std::endl;
+       return false;
+      }
+
+      if (items_per_frame == 0)
+       items_per_frame = U2_MAX_SAMPLES;               // minimize overhead
+
+      op_sync_and_start_rx_streaming_cmd cmd;
+      op_generic_t reply;
+
+      memset(&cmd, 0, sizeof(cmd));
+      init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, time);
+      cmd.sync_op.opcode = OP_SYNC_TO_PPS;
+      cmd.sync_op.len = sizeof(cmd.sync_op);
+      cmd.sync_op.rid = d_next_rid++;
+      cmd.rx_op.opcode = OP_START_RX_STREAMING;
+      cmd.rx_op.len = sizeof(cmd.rx_op);
+      cmd.rx_op.rid = d_next_rid++;
+      cmd.rx_op.items_per_frame = htonl(items_per_frame);
+      cmd.eop.opcode = OP_EOP;
+      cmd.eop.len = sizeof(cmd.eop);
+
+      bool success = false;
+      pending_reply p(cmd.sync_op.rid, &reply, sizeof(reply));
+      success = transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT);
+      success = success && (ntohx(reply.ok) == 1);
+
+      if (success)
+       d_channel_rings[channel] = ring_sptr(new ring(d_eth_buf->max_frames()));
+
+      return success;
+    }
+  }
+
   bool
   usrp2::impl::stop_rx_streaming(unsigned int channel)
   {
@@ -698,7 +802,7 @@ namespace usrp2 {
       cmd.op.rid = d_next_rid++;
       cmd.eop.opcode = OP_EOP;
       cmd.eop.len = sizeof(cmd.eop);
-    
+
       bool success = false;
       pending_reply p(cmd.op.rid, &reply, sizeof(reply));
       success = transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT);
@@ -717,25 +821,25 @@ namespace usrp2 {
                 << " )" << std::endl;
       return false;
     }
-    
+
     if (channel > 0) {
       std::cerr << "usrp2: channel " << channel
                 << " not implemented" << std::endl;
       return false;
     }
-    
+
     ring_sptr rp = d_channel_rings[channel];
     if (!rp){
       std::cerr << "usrp2: channel " << channel
                 << " not receiving" << std::endl;
       return false;
     }
-    
+
     // Wait for frames available in channel ring
     DEBUG_LOG("W");
     rp->wait_for_not_empty();
     DEBUG_LOG("s");
-    
+
     // Iterate through frames and present to user
     void *p;
     size_t frame_len_in_bytes;
@@ -791,7 +895,7 @@ namespace usrp2 {
   //                           Transmit
   // ----------------------------------------------------------------
 
-  bool 
+  bool
   usrp2::impl::set_tx_gain(double gain)
   {
     op_config_tx_v2_cmd cmd;
@@ -800,7 +904,7 @@ namespace usrp2 {
     init_config_tx_v2_cmd(&cmd);
     cmd.op.valid = htons(CFGV_GAIN);
     cmd.op.gain = htons(u2_double_to_fxpt_gain(gain));
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -808,7 +912,7 @@ namespace usrp2 {
     bool success = (ntohx(reply.ok) == 1);
     return success;
   }
-  
+
   bool
   usrp2::impl::set_tx_lo_offset(double frequency)
   {
@@ -827,7 +931,7 @@ namespace usrp2 {
 
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -847,7 +951,7 @@ namespace usrp2 {
     u2_fxpt_freq_t fxpt = u2_double_to_fxpt_freq(frequency);
     cmd.op.freq_hi = htonl(u2_fxpt_freq_hi(fxpt));
     cmd.op.freq_lo = htonl(u2_fxpt_freq_lo(fxpt));
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -855,18 +959,18 @@ namespace usrp2 {
     bool success = (ntohx(reply.ok) == 1);
     if (result && success) {
       result->baseband_freq =
-        u2_fxpt_freq_to_double( 
-         u2_fxpt_freq_from_hilo(ntohl(reply.baseband_freq_hi), 
+        u2_fxpt_freq_to_double(
+         u2_fxpt_freq_from_hilo(ntohl(reply.baseband_freq_hi),
                                 ntohl(reply.baseband_freq_lo)));
 
       result->dxc_freq =
-        u2_fxpt_freq_to_double( 
-         u2_fxpt_freq_from_hilo(ntohl(reply.duc_freq_hi), 
+        u2_fxpt_freq_to_double(
+         u2_fxpt_freq_from_hilo(ntohl(reply.duc_freq_hi),
                                 ntohl(reply.duc_freq_lo)));
 
       result->residual_freq =
-        u2_fxpt_freq_to_double( 
-        u2_fxpt_freq_from_hilo(ntohl(reply.residual_freq_hi), 
+        u2_fxpt_freq_to_double(
+        u2_fxpt_freq_from_hilo(ntohl(reply.residual_freq_hi),
                                ntohl(reply.residual_freq_lo)));
 
       result->spectrum_inverted = (bool)(ntohx(reply.inverted) == 1);
@@ -874,7 +978,7 @@ namespace usrp2 {
 
     return success;
   }
-  
+
   bool
   usrp2::impl::set_tx_interp(int interpolation_factor)
   {
@@ -884,7 +988,7 @@ namespace usrp2 {
     init_config_tx_v2_cmd(&cmd);
     cmd.op.valid = htons(CFGV_INTERP_DECIM);
     cmd.op.interp = htonl(interpolation_factor);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -901,7 +1005,7 @@ namespace usrp2 {
 
     return success;
   }
-  
+
   void
   usrp2::impl::default_tx_scale_iq(int interpolation_factor, int *scale_i, int *scale_q)
   {
@@ -914,7 +1018,7 @@ namespace usrp2 {
 
     // Calculate dsp_core_tx gain absent scale multipliers
     float gain = (1.65*i*i*i)/(4096*pow(2, ceil(log2(i*i*i))));
-    
+
     // Calculate closest multiplier constant to reverse gain
     int scale = (int)rint(1.0/gain);
     // fprintf(stderr, "if=%i i=%i gain=%f scale=%i\n", interpolation_factor, i, gain, scale);
@@ -935,7 +1039,7 @@ namespace usrp2 {
     init_config_tx_v2_cmd(&cmd);
     cmd.op.valid = htons(CFGV_SCALE_IQ);
     cmd.op.scale_iq = htonl(((scale_i & 0xffff) << 16) | (scale_q & 0xffff));
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -1063,7 +1167,7 @@ namespace usrp2 {
     cmd.op.flags = flags;
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -1137,10 +1241,10 @@ namespace usrp2 {
     dst->dbid = ntohl(src->dbid);
 
     dst->freq_min =
-      u2_fxpt_freq_to_double(u2_fxpt_freq_from_hilo(ntohl(src->freq_min_hi), 
+      u2_fxpt_freq_to_double(u2_fxpt_freq_from_hilo(ntohl(src->freq_min_hi),
                                                    ntohl(src->freq_min_lo)));
     dst->freq_max =
-      u2_fxpt_freq_to_double(u2_fxpt_freq_from_hilo(ntohl(src->freq_max_hi), 
+      u2_fxpt_freq_to_double(u2_fxpt_freq_from_hilo(ntohl(src->freq_max_hi),
                                                    ntohl(src->freq_max_lo)));
 
     dst->gain_min = u2_fxpt_gain_to_double(ntohs(src->gain_min));
@@ -1161,7 +1265,7 @@ namespace usrp2 {
     cmd.op.rid = d_next_rid++;
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -1188,7 +1292,7 @@ namespace usrp2 {
     cmd.op.rid = d_next_rid++;
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -1210,7 +1314,7 @@ namespace usrp2 {
     cmd.op.ok = enable ? 1 : 0;
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -1225,7 +1329,7 @@ namespace usrp2 {
     // fprintf(stderr, "usrp2::peek: addr=%08X words=%u\n", addr, words);
 
     if (addr % 4 != 0) {
-      fprintf(stderr, "usrp2::peek: addr (=%08X) must be 32-bit word aligned\n", addr); 
+      fprintf(stderr, "usrp2::peek: addr (=%08X) must be 32-bit word aligned\n", addr);
       return result;
     }
 
@@ -1267,7 +1371,7 @@ namespace usrp2 {
   usrp2::impl::poke32(uint32_t addr, const std::vector<uint32_t> &data)
   {
     if (addr % 4 != 0) {
-      fprintf(stderr, "usrp2::poke32: addr (=%08X) must be 32-bit word aligned\n", addr); 
+      fprintf(stderr, "usrp2::poke32: addr (=%08X) must be 32-bit word aligned\n", addr);
       return false;
     }
 
@@ -1339,7 +1443,7 @@ namespace usrp2 {
     cmd.op.rid = d_next_rid++;
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -1368,7 +1472,7 @@ namespace usrp2 {
     cmd.op.mask = htons(mask);
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -1401,7 +1505,7 @@ namespace usrp2 {
     memcpy(&cmd.op.sels, sels.c_str(), 16);
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -1430,7 +1534,7 @@ namespace usrp2 {
     cmd.op.mask = htons(mask);
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -1459,7 +1563,7 @@ namespace usrp2 {
     cmd.op.mask = 0;  // not used
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
@@ -1496,7 +1600,7 @@ namespace usrp2 {
     cmd.op.mask = 0;  // not used
     cmd.eop.opcode = OP_EOP;
     cmd.eop.len = sizeof(cmd.eop);
-    
+
     pending_reply p(cmd.op.rid, &reply, sizeof(reply));
     if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
       return false;
index ed71a6ba33903c09589b342ea75cdccb8c1fcf34..d78a00db472bb9f8bf4deb571c1dbcb5aa1a766e 100644 (file)
@@ -30,7 +30,7 @@
 #define MAX_SUBPKT_LEN 252
 
 namespace usrp2 {
-  
+
   class eth_buffer;
   class pktfilter;
   class usrp2_thread;
@@ -62,7 +62,7 @@ namespace usrp2 {
     std::string    d_addr;       // FIXME: use u2_mac_addr_t instead
     usrp2_thread  *d_bg_thread;
     volatile bool  d_bg_running; // TODO: multistate if needed
-    
+
     int            d_rx_seqno;
     int            d_tx_seqno;
     int            d_next_rid;
@@ -84,7 +84,7 @@ namespace usrp2 {
     db_info       d_tx_db_info;
     db_info       d_rx_db_info;
 
-    int                   d_tx_interp;         // shadow tx interp 
+    int                   d_tx_interp;         // shadow tx interp
     int                   d_rx_decim;          // shadow rx decim
 
     bool          d_dont_enqueue;
@@ -93,13 +93,13 @@ namespace usrp2 {
       omni_mutex_lock l(d_enqueued_mutex);
       d_num_enqueued++;
     }
-    
+
     void dec_enqueued() {
       omni_mutex_lock l(d_enqueued_mutex);
       if (--d_num_enqueued == 0)
         d_bg_pending_cond.signal();
     }
-    
+
     static bool parse_mac_addr(const std::string &s, u2_mac_addr_t *p);
     void init_et_hdrs(u2_eth_packet_t *p, const std::string &dst);
     void init_etf_hdrs(u2_eth_packet_t *p, const std::string &dst,
@@ -118,7 +118,7 @@ namespace usrp2 {
   public:
     impl(const std::string &ifc, props *p, size_t rx_bufsize);
     ~impl();
-    
+
     void bg_loop();
 
     std::string mac_addr() const { return d_addr; } // FIXME: convert from u2_mac_addr_t
@@ -143,6 +143,8 @@ namespace usrp2 {
     bool write_gpio(int bank, uint16_t value, uint16_t mask);
     bool read_gpio(int bank, uint16_t *value);
     bool start_rx_streaming(unsigned int channel, unsigned int items_per_frame);
+    bool start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time);
+    bool sync_and_start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time);
     bool rx_samples(unsigned int channel, rx_sample_handler *handler);
     bool flush_rx_samples(unsigned int channel);
     bool stop_rx_streaming(unsigned int channel);
@@ -196,7 +198,7 @@ namespace usrp2 {
     std::vector<uint32_t> peek32(uint32_t addr, uint32_t words);
     bool poke32(uint32_t addr, const std::vector<uint32_t> &data);
   };
-  
+
 } // namespace usrp2
 
 #endif /* INCLUDED_USRP2_IMPL_H */
index aa2846af53a3ca392e90421a2a32dc798b1b5712..ddf82abcfc9f26ecdaea7a952bf0e4c505c13816 100644 (file)
@@ -24,6 +24,8 @@
 #endif
 #include <vrt/copiers.h>
 #include <arpa/inet.h>
+#include <assert.h>
+#include <string.h>
 
 namespace vrt {
 
index 0eb2042d8f33796096e645db3f44b1e8504bdd18..bd1d92e530ca2b0eac929cd85e78738ed3210265 100644 (file)
@@ -112,12 +112,6 @@ namespace vrt {
 #include "expanded_header_switch_body.h"
     }
 
-    /* is this a if context packet? */
-    if (h->if_context_p()){
-        *payload = p;
-        *n32_bit_words_payload = n32_bit_words_packet;
-    }
-
     return true;
   }
 
index f75db311115f222e956cad58ffc9210f5b5269ff..2d741e908f668bc8960b65c6e6fb9d109bf5e463 100644 (file)
@@ -30,7 +30,7 @@
 #include <stdexcept>
 
 static void
-print_words(FILE *fp, size_t offset, uint32_t *buf, size_t n)
+print_words(FILE *fp, size_t offset, const uint32_t *buf, size_t n)
 {
   size_t i;
   for (i = 0; i < n; i++){
@@ -85,27 +85,31 @@ namespace vrt {
 
   vrt_data_handler::~vrt_data_handler(){}
 
+  // N.B., There may be more than 1 VRT packet in a frame (usually IF-Context packets)
   data_handler::result
   vrt_data_handler::operator()(const void *base, size_t len)
   {
-#if 0
-    print_words(0, (uint32_t *)base, len/(sizeof(uint32_t)));
-    return 0;
-#else
-    const uint32_t *payload;
-    size_t n32_bit_words;
-    expanded_header hdr;
-    if (!expanded_header::parse((const uint32_t*) base, len/(sizeof(uint32_t)),
-                               &hdr, &payload, &n32_bit_words)){
-      if (1){
-       fprintf(stderr, "vrt_data_handler: malformed VRT packet!\n");
-       print_words(stderr, 0, (uint32_t *)base, len/(sizeof(uint32_t)));
+    const uint32_t *word_base = (const uint32_t *) base;
+    size_t word_len = len/(sizeof(uint32_t));
+
+    bool want_more = true;
+    while (word_len > 0 && want_more){
+      const uint32_t *payload;
+      size_t n32_bit_words;
+      expanded_header hdr;
+      if (!expanded_header::parse(word_base, word_len,
+                                 &hdr, &payload, &n32_bit_words)){
+       if (1){
+         fprintf(stderr, "vrt_data_handler: malformed VRT packet!\n");
+         print_words(stderr, 0, word_base, word_len);
+       }
+       return 0;
       }
-      return 0;
+      want_more = (*d_handler)(payload, n32_bit_words, &hdr);
+      word_base += hdr.pkt_size();
+      word_len -= hdr.pkt_size();
     }
-    bool want_more = (*d_handler)(payload, n32_bit_words, &hdr);
     return !want_more ? data_handler::DONE : 0;
-#endif
   }