Merge branch 'wip/term' of git@gnuradio.org:jcorgan
authorJohnathan Corgan <jcorgan@corganenterprises.com>
Tue, 3 Nov 2009 15:15:14 +0000 (07:15 -0800)
committerJohnathan Corgan <jcorgan@corganenterprises.com>
Tue, 3 Nov 2009 15:15:14 +0000 (07:15 -0800)
* 'wip/term' of git@gnuradio.org:jcorgan:
  gr-wxgui: cleanup for merge
  Consolidated termsink into one class
  Basic terminal window that takes raw text on input msgq and appends it
  Add placeholder panel for console, use old style window size
  Created skeleton wxgui term window component

54 files changed:
config/grc_gr_noaa.m4
gnuradio-core/src/lib/filter/Makefile.am
gnuradio-core/src/lib/filter/filter.i
gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc
gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc [new file with mode: 0644]
gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h [new file with mode: 0644]
gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.i [new file with mode: 0644]
gnuradio-core/src/python/gnuradio/blks2impl/generic_usrp.py
gnuradio-examples/grc/demod/pam_timing.grc
gr-noaa/Makefile.am
gr-noaa/README
gr-noaa/apps/.gitignore
gr-noaa/apps/Makefile.am
gr-noaa/apps/demod_hrpt_file.grc
gr-noaa/apps/demod_hrpt_file.py
gr-noaa/apps/file_rx_hrpt.grc [new file with mode: 0644]
gr-noaa/apps/file_rx_hrpt.py [new file with mode: 0755]
gr-noaa/apps/usrp_rx_hrpt.cfg [deleted file]
gr-noaa/apps/usrp_rx_hrpt.grc
gr-noaa/apps/usrp_rx_hrpt.py
gr-noaa/apps/usrp_rx_hrpt2.grc [deleted file]
gr-noaa/apps/usrp_rx_hrpt2.py [deleted file]
gr-noaa/apps/usrp_rx_hrpt_nogui.grc
gr-noaa/apps/usrp_rx_hrpt_nogui.py
gr-noaa/grc/Makefile.am
gr-noaa/grc/noaa_hrpt_sync_fb.xml [deleted file]
gr-noaa/lib/Makefile.am
gr-noaa/lib/noaa_hrpt_deframer.cc
gr-noaa/lib/noaa_hrpt_deframer.h
gr-noaa/lib/noaa_hrpt_sync_fb.cc [deleted file]
gr-noaa/lib/noaa_hrpt_sync_fb.h [deleted file]
gr-noaa/oct/.gitignore [new file with mode: 0644]
gr-noaa/oct/Makefile.am [new file with mode: 0644]
gr-noaa/oct/frames-to-png.sh [new file with mode: 0755]
gr-noaa/oct/frames_to_ppm.m [new file with mode: 0644]
gr-noaa/swig/Makefile.am
gr-noaa/swig/noaa_hrpt_sync_fb.i [deleted file]
gr-noaa/swig/noaa_swig.i
gr-utils/src/python/usrp_siggen.py
gr-utils/src/python/usrp_siggen_gui.py
grc/blocks/block_tree.xml
grc/blocks/gr_pfb_clock_sync.xml
usrp/host/include/usrp/usrp_prims.h
usrp/host/lib/Makefile.am
usrp/host/lib/db_wbxng_adf4350.cc
usrp/host/lib/db_wbxng_adf4350_regs.cc
usrp/host/lib/db_wbxng_adf4350_regs.h
usrp/host/lib/fusb_libusb1.cc
usrp/host/lib/usrp_basic.cc [new file with mode: 0644]
usrp/host/lib/usrp_basic_common.cc [deleted file]
usrp/host/lib/usrp_basic_libusb0.cc [deleted file]
usrp/host/lib/usrp_basic_libusb1.cc [deleted file]
usrp/host/lib/usrp_prims_libusb0.cc
usrp/host/lib/usrp_prims_libusb1.cc

index b00579ff589b5fc10c311312b81cef4464e7b3d9..69d0aad556b7374e464df8e9f7c7680ca45b4180 100644 (file)
@@ -30,6 +30,7 @@ AC_DEFUN([GRC_GR_NOAA],[
        gr-noaa/apps/Makefile \
        gr-noaa/grc/Makefile \
        gr-noaa/lib/Makefile \
+       gr-noaa/oct/Makefile \
        gr-noaa/python/Makefile \
        gr-noaa/swig/Makefile \
     ])
index d5afd571bac31bd10aba7d3f30858bae6a9b130f..9cd6e9f389b85178a1610125d35fecd9f52311c5 100644 (file)
@@ -206,7 +206,8 @@ libfilter_la_common_SOURCES =               \
        gr_pfb_decimator_ccf.cc         \
        gr_pfb_interpolator_ccf.cc      \
        gr_pfb_arb_resampler_ccf.cc     \
-       gr_pfb_clock_sync_ccf.cc
+       gr_pfb_clock_sync_ccf.cc        \
+       gr_pfb_clock_sync_fff.cc
 
 libfilter_qa_la_common_SOURCES =       \
        qa_filter.cc                    \
@@ -286,7 +287,8 @@ grinclude_HEADERS =                         \
        gr_pfb_decimator_ccf.h          \
        gr_pfb_interpolator_ccf.h       \
        gr_pfb_arb_resampler_ccf.h      \
-       gr_pfb_clock_sync_ccf.h
+       gr_pfb_clock_sync_ccf.h         \
+       gr_pfb_clock_sync_fff.h
 
 noinst_HEADERS =                       \
        assembly.h                      \
@@ -342,6 +344,7 @@ swiginclude_HEADERS =                       \
        gr_pfb_interpolator_ccf.i       \
        gr_pfb_arb_resampler_ccf.i      \
        gr_pfb_clock_sync_ccf.i         \
+       gr_pfb_clock_sync_fff.i         \
        $(GENERATED_I)
 endif
 
index 91f55c5142610326c137b57510a13490ce7d7141..bdfb8fa8d2d20d342adbf745a8a2455cba74a811 100644 (file)
@@ -37,6 +37,7 @@
 #include <gr_pfb_interpolator_ccf.h>
 #include <gr_pfb_arb_resampler_ccf.h>
 #include <gr_pfb_clock_sync_ccf.h>
+#include <gr_pfb_clock_sync_fff.h>
 %}
 
 %include "gr_iir_filter_ffd.i"
@@ -58,5 +59,6 @@
 %include "gr_pfb_interpolator_ccf.i"
 %include "gr_pfb_arb_resampler_ccf.i"
 %include "gr_pfb_clock_sync_ccf.i"
+%include "gr_pfb_clock_sync_fff.i"
 
 %include "filter_generated.i"
index 433b7d6133f4c04e6991e6af34d94dd44fe68e2e..59454afe5fa60b02f88af37577ae6101f9b6eccd 100644 (file)
@@ -45,8 +45,8 @@ gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain,
                                                                max_rate_deviation));
 }
 
-int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)};
-std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int));
+static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)};
+static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int));
 gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (double sps, float gain,
                                              const std::vector<float> &taps,
                                              unsigned int filter_size,
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc
new file mode 100644 (file)
index 0000000..d1d2f05
--- /dev/null
@@ -0,0 +1,281 @@
+/* -*- 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <cstdio>
+#include <cmath>
+
+#include <gr_pfb_clock_sync_fff.h>
+#include <gr_fir_fff.h>
+#include <gr_fir_util.h>
+#include <gr_io_signature.h>
+#include <gr_math.h>
+
+gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain,
+                                                      const std::vector<float> &taps,
+                                                      unsigned int filter_size,
+                                                      float init_phase,
+                                                      float max_rate_deviation)
+{
+  return gr_pfb_clock_sync_fff_sptr (new gr_pfb_clock_sync_fff (sps, gain, taps,
+                                                               filter_size,
+                                                               init_phase,
+                                                               max_rate_deviation));
+}
+
+static int ios[] = {sizeof(float), sizeof(float), sizeof(float), sizeof(float)};
+static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int));
+gr_pfb_clock_sync_fff::gr_pfb_clock_sync_fff (double sps, float gain,
+                                             const std::vector<float> &taps,
+                                             unsigned int filter_size,
+                                             float init_phase,
+                                             float max_rate_deviation)
+  : gr_block ("pfb_clock_sync_fff",
+             gr_make_io_signature (1, 1, sizeof(float)),
+             gr_make_io_signaturev (1, 4, iosig)),
+    d_updated (false), d_nfilters(filter_size),
+    d_max_dev(max_rate_deviation)
+{
+  d_nfilters = filter_size;
+  d_sps = floor(sps);
+
+  // Store the last filter between calls to work
+  // The accumulator keeps track of overflow to increment the stride correctly.
+  // set it here to the fractional difference based on the initial phaes
+  set_alpha(gain);
+  set_beta(0.25*gain*gain);
+  d_k = init_phase;
+  d_rate = (sps-floor(sps))*(double)d_nfilters;
+  d_rate_i = (int)floor(d_rate);
+  d_rate_f = d_rate - (float)d_rate_i;
+  d_filtnum = (int)floor(d_k);
+
+  d_filters = std::vector<gr_fir_fff*>(d_nfilters);
+  d_diff_filters = std::vector<gr_fir_fff*>(d_nfilters);
+
+  // Create an FIR filter for each channel and zero out the taps
+  std::vector<float> vtaps(0, d_nfilters);
+  for(int i = 0; i < d_nfilters; i++) {
+    d_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps);
+    d_diff_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps);
+  }
+
+  // Now, actually set the filters' taps
+  std::vector<float> dtaps;
+  create_diff_taps(taps, dtaps);
+  set_taps(taps, d_taps, d_filters);
+  set_taps(dtaps, d_dtaps, d_diff_filters);
+}
+
+gr_pfb_clock_sync_fff::~gr_pfb_clock_sync_fff ()
+{
+  for(int i = 0; i < d_nfilters; i++) {
+    delete d_filters[i];
+  }
+}
+
+void
+gr_pfb_clock_sync_fff::set_taps (const std::vector<float> &newtaps,
+                                std::vector< std::vector<float> > &ourtaps,
+                                std::vector<gr_fir_fff*> &ourfilter)
+{
+  int i,j;
+
+  unsigned int ntaps = newtaps.size();
+  d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters);
+
+  // Create d_numchan vectors to store each channel's taps
+  ourtaps.resize(d_nfilters);
+  
+  // Make a vector of the taps plus fill it out with 0's to fill
+  // each polyphase filter with exactly d_taps_per_filter
+  std::vector<float> tmp_taps;
+  tmp_taps = newtaps;
+  while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) {
+    tmp_taps.push_back(0.0);
+  }
+  
+  // Partition the filter
+  for(i = 0; i < d_nfilters; i++) {
+    // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out
+    ourtaps[d_nfilters-1-i] = std::vector<float>(d_taps_per_filter, 0);
+    for(j = 0; j < d_taps_per_filter; j++) {
+      ourtaps[d_nfilters - 1 - i][j] = tmp_taps[i + j*d_nfilters];
+    }
+    
+    // Build a filter for each channel and add it's taps to it
+    ourfilter[i]->set_taps(ourtaps[d_nfilters-1-i]);
+  }
+
+  // Set the history to ensure enough input items for each filter
+  set_history (d_taps_per_filter + d_sps);
+
+  d_updated = true;
+}
+
+void
+gr_pfb_clock_sync_fff::create_diff_taps(const std::vector<float> &newtaps,
+                                       std::vector<float> &difftaps)
+{
+  float maxtap = 1e-20;
+  difftaps.clear();
+  difftaps.push_back(0); //newtaps[0]);
+  for(unsigned int i = 1; i < newtaps.size()-1; i++) {
+    float tap = newtaps[i+1] - newtaps[i-1];
+    difftaps.push_back(tap);
+    if(tap > maxtap) {
+      maxtap = tap;
+    }
+  }
+  difftaps.push_back(0);//-newtaps[newtaps.size()-1]);
+
+  // Scale the differential taps; helps scale error term to better update state
+  // FIXME: should this be scaled this way or use the same gain as the taps?
+  for(unsigned int i = 0; i < difftaps.size(); i++) {
+    difftaps[i] /= maxtap;
+  }
+}
+
+void
+gr_pfb_clock_sync_fff::print_taps()
+{
+  int i, j;
+  printf("[ ");
+  for(i = 0; i < d_nfilters; i++) {
+    printf("[%.4e, ", d_taps[i][0]);
+    for(j = 1; j < d_taps_per_filter-1; j++) {
+      printf("%.4e,", d_taps[i][j]);
+    }
+    printf("%.4e],", d_taps[i][j]);
+  }
+  printf(" ]\n");
+}
+
+void
+gr_pfb_clock_sync_fff::print_diff_taps()
+{
+  int i, j;
+  printf("[ ");
+  for(i = 0; i < d_nfilters; i++) {
+    printf("[%.4e, ", d_dtaps[i][0]);
+    for(j = 1; j < d_taps_per_filter-1; j++) {
+      printf("%.4e,", d_dtaps[i][j]);
+    }
+    printf("%.4e],", d_dtaps[i][j]);
+  }
+  printf(" ]\n");
+}
+
+
+std::vector<float>
+gr_pfb_clock_sync_fff::channel_taps(int channel)
+{
+  std::vector<float> taps;
+  for(int i = 0; i < d_taps_per_filter; i++) {
+    taps.push_back(d_taps[channel][i]);
+  }
+  return taps;
+}
+
+std::vector<float>
+gr_pfb_clock_sync_fff::diff_channel_taps(int channel)
+{
+  std::vector<float> taps;
+  for(int i = 0; i < d_taps_per_filter; i++) {
+    taps.push_back(d_dtaps[channel][i]);
+  }
+  return taps;
+}
+
+
+int
+gr_pfb_clock_sync_fff::general_work (int noutput_items,
+                                    gr_vector_int &ninput_items,
+                                    gr_vector_const_void_star &input_items,
+                                    gr_vector_void_star &output_items)
+{
+  float *in = (float *) input_items[0];
+  float *out = (float *) output_items[0];
+
+  float *err, *outrate, *outk;
+  if(output_items.size() > 2) {
+    err = (float *) output_items[1];
+    outrate = (float*)output_items[2];
+    outk = (float*)output_items[3];
+  }
+  
+  if (d_updated) {
+    d_updated = false;
+    return 0;               // history requirements may have changed.
+  }
+
+  // We need this many to process one output
+  int nrequired = ninput_items[0] - d_taps_per_filter;
+
+  int i = 0, count = 0;
+  float error;
+
+  // produce output as long as we can and there are enough input samples
+  while((i < noutput_items) && (count < nrequired)) {
+    d_filtnum = (int)floor(d_k);
+
+    // Keep the current filter number in [0, d_nfilters]
+    // If we've run beyond the last filter, wrap around and go to next sample
+    // If we've go below 0, wrap around and go to previous sample
+    while(d_filtnum >= d_nfilters) {
+      d_k -= d_nfilters;
+      d_filtnum -= d_nfilters;
+      count += 1;
+    }
+    while(d_filtnum < 0) {
+      d_k += d_nfilters;
+      d_filtnum += d_nfilters;
+      count -= 1;
+    }
+
+    out[i] = d_filters[d_filtnum]->filter(&in[count]);
+    float diff = d_diff_filters[d_filtnum]->filter(&in[count]);
+    error  = out[i] * diff;
+
+    // Run the control loop to update the current phase (k) and tracking rate
+    d_k = d_k + d_alpha*error + d_rate_i + d_rate_f;
+    d_rate_f = d_rate_f + d_beta*error;
+    
+    // Keep our rate within a good range
+    d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev);
+
+    i++;
+    count += (int)floor(d_sps);
+
+    if(output_items.size() > 2) {
+      err[i] = error;
+      outrate[i] = d_rate_f;
+      outk[i] = d_k;
+    }
+  }
+  consume_each(count);
+
+  return i;
+}
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h
new file mode 100644 (file)
index 0000000..913f798
--- /dev/null
@@ -0,0 +1,128 @@
+/* -*- 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_GR_PFB_CLOCK_SYNC_FFF_H
+#define        INCLUDED_GR_PFB_CLOCK_SYNC_FFF_H
+
+#include <gr_block.h>
+
+class gr_pfb_clock_sync_fff;
+typedef boost::shared_ptr<gr_pfb_clock_sync_fff> gr_pfb_clock_sync_fff_sptr;
+gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain,
+                                                      const std::vector<float> &taps,
+                                                      unsigned int filter_size=32,
+                                                      float init_phase=0,
+                                                      float max_rate_deviation=1.5);
+
+class gr_fir_fff;
+
+/*!
+ * \class gr_pfb_clock_sync_fff
+ *
+ * \brief Timing synchronizer using polyphase filterbanks
+ *
+ * \ingroup filter_blk
+ * 
+ */
+
+class gr_pfb_clock_sync_fff : public gr_block
+{
+ private:
+  /*!
+   * Build the polyphase filterbank timing synchronizer.
+   */
+  friend gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain,
+                                                               const std::vector<float> &taps,
+                                                               unsigned int filter_size,
+                                                               float init_phase,
+                                                               float max_rate_deviation);
+
+  bool                    d_updated;
+  double                   d_sps;
+  double                   d_sample_num;
+  float                    d_alpha;
+  float                    d_beta;
+  int                      d_nfilters;
+  std::vector<gr_fir_fff*> d_filters;
+  std::vector<gr_fir_fff*> d_diff_filters;
+  std::vector< std::vector<float> > d_taps;
+  std::vector< std::vector<float> > d_dtaps;
+  float                    d_k;
+  float                    d_rate;
+  float                    d_rate_i;
+  float                    d_rate_f;
+  float                    d_max_dev;
+  int                      d_filtnum;
+  int                      d_taps_per_filter;
+
+  /*!
+   * Build the polyphase filterbank timing synchronizer.
+   */
+  gr_pfb_clock_sync_fff (double sps, float gain,
+                        const std::vector<float> &taps,
+                        unsigned int filter_size,
+                        float init_phase,
+                        float max_rate_deviation);
+  
+  void create_diff_taps(const std::vector<float> &newtaps,
+                       std::vector<float> &difftaps);
+
+public:
+  ~gr_pfb_clock_sync_fff ();
+  
+  /*!
+   * Resets the filterbank's filter taps with the new prototype filter
+   */
+  void set_taps (const std::vector<float> &taps,
+                std::vector< std::vector<float> > &ourtaps,
+                std::vector<gr_fir_fff*> &ourfilter);
+  std::vector<float> channel_taps(int channel);
+  std::vector<float> diff_channel_taps(int channel);
+
+  /*!
+   * Print all of the filterbank taps to screen.
+   */
+  void print_taps();
+  void print_diff_taps();
+
+  void set_alpha(float alpha)
+  {
+    d_alpha = alpha;
+  }
+  void set_beta(float beta)
+  {
+    d_beta = beta;
+  }
+
+  void set_max_rate_deviation(float m)
+  {
+    d_max_dev = m;
+  }
+  
+  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
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.i b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.i
new file mode 100644 (file)
index 0000000..d6bb787
--- /dev/null
@@ -0,0 +1,54 @@
+/* -*- 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,pfb_clock_sync_fff);
+
+gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain,
+                                                      const std::vector<float> &taps,
+                                                      unsigned int filter_size=32,
+                                                      float init_phase=0,
+                                                      float max_rate_deviation=1.5);
+
+class gr_pfb_clock_sync_fff : public gr_block
+{
+ private:
+  gr_pfb_clock_sync_fff (double sps, float gain,
+                        const std::vector<float> &taps,
+                        unsigned int filter_size,
+                        float init_phase,
+                        float max_rate_deviation);
+
+ public:
+  ~gr_pfb_clock_sync_fff ();
+
+  void set_taps (const std::vector<float> &taps,
+                std::vector< std::vector<float> > &ourtaps,
+                std::vector<gr_fir_fff*> &ourfilter);
+
+  std::vector<float> channel_taps(int channel);
+  std::vector<float> diff_channel_taps(int channel);
+  void print_taps();
+  void print_diff_taps();
+  void set_alpha(float alpha);
+  void set_beta(float beta);
+  void set_max_rate_deviation(float m);
+};
index 5abbaf9eb7e70e7e4ddfa97d7032fa0fa87f6016..82d1eca13a5cdb4458f5ae31d873f353ec68bdc8 100644 (file)
@@ -121,12 +121,6 @@ class _generic_usrp_base(object):
     def set_auto_tr(self, enable):
         if self._type == USRP1_TYPE: return self._subdev.set_auto_tr(enable)
 
-    def __del__(self):
-        try: # Avoid weak reference error
-            del self._u
-            del self._subdev
-        except: pass
-
 ########################################################################
 # generic usrp source
 ########################################################################
index 4e2a2f8614dbc5bb3b1e69424b577c98eaf43b52..149e4c706843154ab35ce55fc78af2464c2f383e 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version='1.0' encoding='ASCII'?>
 <flow_graph>
-  <timestamp>Mon Oct 12 17:54:59 2009</timestamp>
+  <timestamp>Sat Oct 31 10:26:48 2009</timestamp>
   <block>
     <key>options</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>wxgui_scopesink2</key>
-    <param>
-      <key>id</key>
-      <value>wxgui_scopesink2_0_0_0_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>float</value>
-    </param>
-    <param>
-      <key>title</key>
-      <value>Scope Plot</value>
-    </param>
-    <param>
-      <key>samp_rate</key>
-      <value>samp_rate</value>
-    </param>
-    <param>
-      <key>v_scale</key>
-      <value>1.25</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>False</value>
-    </param>
-    <param>
-      <key>num_inputs</key>
-      <value>1</value>
-    </param>
-    <param>
-      <key>grid_pos</key>
-      <value></value>
-    </param>
-    <param>
-      <key>notebook</key>
-      <value>notebook_0,2</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(1111, 767)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>wxgui_scopesink2</key>
-    <param>
-      <key>id</key>
-      <value>wxgui_scopesink2_0_0_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>float</value>
-    </param>
-    <param>
-      <key>title</key>
-      <value>Scope Plot</value>
-    </param>
-    <param>
-      <key>samp_rate</key>
-      <value>samp_rate</value>
-    </param>
-    <param>
-      <key>v_scale</key>
-      <value>9</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>False</value>
-    </param>
-    <param>
-      <key>num_inputs</key>
-      <value>1</value>
-    </param>
-    <param>
-      <key>grid_pos</key>
-      <value></value>
-    </param>
-    <param>
-      <key>notebook</key>
-      <value>notebook_0,1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(1112, 881)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>gr_channel_model</key>
     <param>
       <value>0</value>
     </param>
   </block>
-  <block>
-    <key>gr_throttle</key>
-    <param>
-      <key>id</key>
-      <value>gr_throttle_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>complex</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>(290, 575)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>notebook</key>
     <param>
       <key>v_scale</key>
       <value>.5</value>
     </param>
+    <param>
+      <key>v_offset</key>
+      <value>0</value>
+    </param>
     <param>
       <key>t_scale</key>
       <value>0</value>
       <key>num_inputs</key>
       <value>1</value>
     </param>
+    <param>
+      <key>win_size</key>
+      <value></value>
+    </param>
     <param>
       <key>grid_pos</key>
       <value></value>
     </param>
   </block>
   <block>
-    <key>wxgui_scopesink2</key>
+    <key>variable</key>
     <param>
       <key>id</key>
-      <value>wxgui_scopesink2_0</value>
+      <value>nfilts</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>type</key>
-      <value>complex</value>
+      <key>value</key>
+      <value>32</value>
     </param>
     <param>
-      <key>title</key>
-      <value>Scope Plot</value>
+      <key>_coordinate</key>
+      <value>(435, 686)</value>
     </param>
     <param>
-      <key>samp_rate</key>
-      <value>samp_rate</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>variable_slider</key>
     <param>
-      <key>v_scale</key>
+      <key>id</key>
+      <value>noise_amp</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>label</key>
+      <value>Channel Noise</value>
+    </param>
+    <param>
+      <key>value</key>
       <value>0</value>
     </param>
     <param>
-      <key>t_scale</key>
+      <key>min</key>
       <value>0</value>
     </param>
     <param>
-      <key>ac_couple</key>
-      <value>False</value>
+      <key>max</key>
+      <value>1.0</value>
     </param>
     <param>
-      <key>xy_mode</key>
-      <value>False</value>
+      <key>num_steps</key>
+      <value>1000</value>
     </param>
     <param>
-      <key>num_inputs</key>
-      <value>1</value>
+      <key>style</key>
+      <value>wx.SL_HORIZONTAL</value>
+    </param>
+    <param>
+      <key>converver</key>
+      <value>float_converter</value>
     </param>
     <param>
       <key>grid_pos</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(1116, 500)</value>
+      <value>(168, 684)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>variable</key>
+    <key>variable_slider</key>
     <param>
       <key>id</key>
-      <value>nfilts</value>
+      <value>interpratio</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>value</key>
-      <value>32</value>
+      <key>label</key>
+      <value>Timing Offset</value>
     </param>
     <param>
-      <key>_coordinate</key>
-      <value>(435, 686)</value>
+      <key>value</key>
+      <value>1.00</value>
     </param>
     <param>
-      <key>_rotation</key>
-      <value>0</value>
+      <key>min</key>
+      <value>0.99</value>
     </param>
-  </block>
-  <block>
-    <key>gr_pfb_clock_sync_ccf</key>
     <param>
-      <key>id</key>
-      <value>gr_pfb_clock_sync_ccf_0</value>
+      <key>max</key>
+      <value>1.01</value>
     </param>
     <param>
-      <key>_enabled</key>
-      <value>True</value>
+      <key>num_steps</key>
+      <value>1000</value>
     </param>
     <param>
-      <key>sps</key>
-      <value>spb</value>
+      <key>style</key>
+      <value>wx.SL_HORIZONTAL</value>
     </param>
     <param>
-      <key>alpha</key>
-      <value>alpha</value>
+      <key>converver</key>
+      <value>float_converter</value>
     </param>
     <param>
-      <key>beta</key>
-      <value>beta</value>
+      <key>grid_pos</key>
+      <value></value>
     </param>
     <param>
-      <key>taps</key>
-      <value>rrctaps</value>
+      <key>notebook</key>
+      <value></value>
     </param>
     <param>
-      <key>filter_size</key>
-      <value>nfilts</value>
+      <key>_coordinate</key>
+      <value>(40, 684)</value>
     </param>
     <param>
-      <key>init_phase</key>
-      <value>16</value>
-    </param>
+      <key>_rotation</key>
+      <value>180</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
     <param>
-      <key>max_dev</key>
-      <value>1.5</value>
+      <key>id</key>
+      <value>spb_gen</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>4</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(512, 527)</value>
+      <value>(119, 841)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_slider</key>
     <param>
       <key>id</key>
-      <value>noise_amp</value>
+      <value>beta</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>label</key>
-      <value>Channel Noise</value>
+      <value>Timing Beta</value>
     </param>
     <param>
       <key>value</key>
     </param>
     <param>
       <key>min</key>
-      <value>0</value>
+      <value>0.0</value>
     </param>
     <param>
       <key>max</key>
-      <value>1.0</value>
+      <value>0.1</value>
     </param>
     <param>
       <key>num_steps</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(168, 684)</value>
+      <value>(668, 5)</value>
     </param>
     <param>
       <key>_rotation</key>
-      <value>0</value>
+      <value>180</value>
     </param>
   </block>
   <block>
     <key>variable_slider</key>
     <param>
       <key>id</key>
-      <value>interpratio</value>
+      <value>alpha</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>label</key>
-      <value>Timing Offset</value>
+      <value>Timing Alpha</value>
     </param>
     <param>
       <key>value</key>
-      <value>1.00</value>
+      <value>0</value>
     </param>
     <param>
       <key>min</key>
-      <value>0.99</value>
+      <value>0</value>
     </param>
     <param>
       <key>max</key>
-      <value>1.01</value>
+      <value>1</value>
     </param>
     <param>
       <key>num_steps</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(40, 684)</value>
+      <value>(552, 4)</value>
     </param>
     <param>
       <key>_rotation</key>
-      <value>180</value>
+      <value>0</value>
     </param>
   </block>
   <block>
-    <key>variable</key>
+    <key>root_raised_cosine_filter</key>
     <param>
       <key>id</key>
-      <value>spb_gen</value>
+      <value>root_raised_cosine_filter_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>value</key>
-      <value>4</value>
+      <key>type</key>
+      <value>interp_fir_filter_ccf</value>
+    </param>
+    <param>
+      <key>decim</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>interp</key>
+      <value>spb_gen</value>
+    </param>
+    <param>
+      <key>gain</key>
+      <value>2*spb_gen</value>
+    </param>
+    <param>
+      <key>samp_rate</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>sym_rate</key>
+      <value>1./spb_gen</value>
+    </param>
+    <param>
+      <key>alpha</key>
+      <value>0.35</value>
+    </param>
+    <param>
+      <key>ntaps</key>
+      <value>11*spb_gen</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(119, 841)</value>
+      <value>(834, 157)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>variable_slider</key>
+    <key>blks2_pfb_arb_resampler_ccf</key>
     <param>
       <key>id</key>
-      <value>beta</value>
+      <value>blks2_pfb_arb_resampler_ccf_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>label</key>
-      <value>Timing Beta</value>
+      <key>rate</key>
+      <value>float(spb)/float(spb_gen)</value>
     </param>
     <param>
-      <key>value</key>
-      <value>0</value>
+      <key>taps</key>
+      <value>firdes.low_pass(128, 128, 0.45, 0.1)</value>
     </param>
     <param>
-      <key>min</key>
-      <value>0.0</value>
+      <key>size</key>
+      <value>128</value>
     </param>
     <param>
-      <key>max</key>
-      <value>0.1</value>
+      <key>_coordinate</key>
+      <value>(617, 374)</value>
     </param>
     <param>
-      <key>num_steps</key>
-      <value>1000</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>gr_multiply_const_vxx</key>
     <param>
-      <key>style</key>
-      <value>wx.SL_HORIZONTAL</value>
+      <key>id</key>
+      <value>gr_multiply_const_vxx_0</value>
     </param>
     <param>
-      <key>converver</key>
-      <value>float_converter</value>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
-      <key>grid_pos</key>
-      <value></value>
+      <key>type</key>
+      <value>complex</value>
     </param>
     <param>
-      <key>notebook</key>
-      <value></value>
+      <key>const</key>
+      <value>sig_amp</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(668, 5)</value>
+      <value>(1096, 197)</value>
     </param>
     <param>
       <key>_rotation</key>
-      <value>180</value>
+      <value>0</value>
     </param>
   </block>
   <block>
-    <key>variable_slider</key>
+    <key>variable</key>
     <param>
       <key>id</key>
-      <value>alpha</value>
+      <value>pam_amp</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>label</key>
-      <value>Timing Alpha</value>
+      <key>value</key>
+      <value>2</value>
     </param>
     <param>
-      <key>value</key>
-      <value>0</value>
+      <key>_coordinate</key>
+      <value>(223, 9)</value>
     </param>
     <param>
-      <key>min</key>
+      <key>_rotation</key>
       <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>variable</key>
     <param>
-      <key>max</key>
-      <value>1</value>
+      <key>id</key>
+      <value>spb</value>
     </param>
     <param>
-      <key>num_steps</key>
-      <value>1000</value>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
-      <key>style</key>
-      <value>wx.SL_HORIZONTAL</value>
+      <key>value</key>
+      <value>4.1</value>
     </param>
     <param>
-      <key>converver</key>
-      <value>float_converter</value>
+      <key>_coordinate</key>
+      <value>(32, 842)</value>
     </param>
     <param>
-      <key>grid_pos</key>
-      <value></value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>variable</key>
     <param>
-      <key>notebook</key>
-      <value></value>
+      <key>id</key>
+      <value>sig_amp</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>1</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(552, 4)</value>
+      <value>(315, 9)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>wxgui_scopesink2</key>
     <param>
       <key>id</key>
-      <value>wxgui_scopesink2_0_0</value>
+      <value>wxgui_scopesink2_0</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>type</key>
-      <value>float</value>
+      <value>complex</value>
     </param>
     <param>
       <key>title</key>
-      <value>Error</value>
+      <value>Scope Plot</value>
     </param>
     <param>
       <key>samp_rate</key>
     </param>
     <param>
       <key>v_scale</key>
-      <value>3</value>
+      <value>0</value>
+    </param>
+    <param>
+      <key>v_offset</key>
+      <value>0</value>
     </param>
     <param>
       <key>t_scale</key>
       <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>notebook_0,0</value>
+      <value></value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(1110, 651)</value>
+      <value>(1116, 500)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>root_raised_cosine_filter</key>
+    <key>gr_throttle</key>
     <param>
       <key>id</key>
-      <value>root_raised_cosine_filter_0</value>
+      <value>gr_throttle_0</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>type</key>
-      <value>interp_fir_filter_ccf</value>
+      <value>complex</value>
     </param>
     <param>
-      <key>decim</key>
+      <key>samples_per_second</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>vlen</key>
       <value>1</value>
     </param>
     <param>
-      <key>interp</key>
-      <value>spb_gen</value>
+      <key>_coordinate</key>
+      <value>(290, 575)</value>
     </param>
     <param>
-      <key>gain</key>
-      <value>2*spb_gen</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>wxgui_scopesink2</key>
     <param>
-      <key>samp_rate</key>
-      <value>1.0</value>
+      <key>id</key>
+      <value>wxgui_scopesink2_0_0</value>
     </param>
     <param>
-      <key>sym_rate</key>
-      <value>1./spb_gen</value>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
-      <key>alpha</key>
-      <value>0.35</value>
+      <key>type</key>
+      <value>float</value>
     </param>
     <param>
-      <key>ntaps</key>
-      <value>11*spb_gen</value>
+      <key>title</key>
+      <value>Error</value>
     </param>
     <param>
-      <key>_coordinate</key>
-      <value>(834, 157)</value>
+      <key>samp_rate</key>
+      <value>samp_rate</value>
     </param>
     <param>
-      <key>_rotation</key>
+      <key>v_scale</key>
+      <value>3</value>
+    </param>
+    <param>
+      <key>v_offset</key>
       <value>0</value>
     </param>
-  </block>
-  <block>
-    <key>blks2_pfb_arb_resampler_ccf</key>
     <param>
-      <key>id</key>
-      <value>blks2_pfb_arb_resampler_ccf_0</value>
+      <key>t_scale</key>
+      <value>0</value>
     </param>
     <param>
-      <key>_enabled</key>
-      <value>True</value>
+      <key>ac_couple</key>
+      <value>False</value>
     </param>
     <param>
-      <key>rate</key>
-      <value>float(spb)/float(spb_gen)</value>
+      <key>xy_mode</key>
+      <value>False</value>
     </param>
     <param>
-      <key>taps</key>
-      <value>firdes.low_pass(128, 128, 0.45, 0.1)</value>
+      <key>num_inputs</key>
+      <value>1</value>
     </param>
     <param>
-      <key>size</key>
-      <value>128</value>
+      <key>win_size</key>
+      <value></value>
+    </param>
+    <param>
+      <key>grid_pos</key>
+      <value></value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value>notebook_0,0</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(617, 374)</value>
+      <value>(1110, 651)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>gr_multiply_const_vxx</key>
+    <key>wxgui_scopesink2</key>
     <param>
       <key>id</key>
-      <value>gr_multiply_const_vxx_0</value>
+      <value>wxgui_scopesink2_0_0_0_0</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>type</key>
-      <value>complex</value>
+      <value>float</value>
     </param>
     <param>
-      <key>const</key>
-      <value>sig_amp</value>
+      <key>title</key>
+      <value>Scope Plot</value>
     </param>
     <param>
-      <key>vlen</key>
+      <key>samp_rate</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>v_scale</key>
+      <value>1.25</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>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>notebook_0,2</value>
+    </param>
     <param>
       <key>_coordinate</key>
-      <value>(1096, 197)</value>
+      <value>(1111, 767)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>variable</key>
+    <key>gr_pfb_clock_sync_xxx</key>
     <param>
       <key>id</key>
-      <value>pam_amp</value>
+      <value>gr_pfb_clock_sync_xxx_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>value</key>
-      <value>2</value>
+      <key>type</key>
+      <value>ccf</value>
+    </param>
+    <param>
+      <key>sps</key>
+      <value>spb</value>
+    </param>
+    <param>
+      <key>alpha</key>
+      <value>alpha</value>
+    </param>
+    <param>
+      <key>beta</key>
+      <value>beta</value>
+    </param>
+    <param>
+      <key>taps</key>
+      <value>rrctaps</value>
+    </param>
+    <param>
+      <key>filter_size</key>
+      <value>nfilts</value>
+    </param>
+    <param>
+      <key>init_phase</key>
+      <value>16</value>
+    </param>
+    <param>
+      <key>max_dev</key>
+      <value>1.5</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(223, 9)</value>
+      <value>(512, 527)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>variable</key>
+    <key>wxgui_scopesink2</key>
     <param>
       <key>id</key>
-      <value>spb</value>
+      <value>wxgui_scopesink2_0_0_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>value</key>
-      <value>4.1</value>
+      <key>type</key>
+      <value>float</value>
     </param>
     <param>
-      <key>_coordinate</key>
-      <value>(32, 842)</value>
+      <key>title</key>
+      <value>Scope Plot</value>
     </param>
     <param>
-      <key>_rotation</key>
+      <key>samp_rate</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>v_scale</key>
+      <value>9</value>
+    </param>
+    <param>
+      <key>v_offset</key>
       <value>0</value>
     </param>
-  </block>
-  <block>
-    <key>variable</key>
     <param>
-      <key>id</key>
-      <value>sig_amp</value>
+      <key>t_scale</key>
+      <value>0</value>
     </param>
     <param>
-      <key>_enabled</key>
-      <value>True</value>
+      <key>ac_couple</key>
+      <value>False</value>
     </param>
     <param>
-      <key>value</key>
+      <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>notebook_0,1</value>
+    </param>
     <param>
       <key>_coordinate</key>
-      <value>(315, 9)</value>
+      <value>(1112, 881)</value>
     </param>
     <param>
       <key>_rotation</key>
       <value>0</value>
     </param>
   </block>
-  <connection>
-    <source_block_id>gr_pfb_clock_sync_ccf_0</source_block_id>
-    <sink_block_id>wxgui_scopesink2_0_0</sink_block_id>
-    <source_key>1</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>gr_pfb_clock_sync_ccf_0</source_block_id>
-    <sink_block_id>wxgui_scopesink2_0_0_0</sink_block_id>
-    <source_key>3</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>gr_pfb_clock_sync_ccf_0</source_block_id>
-    <sink_block_id>wxgui_scopesink2_0_0_0_0</sink_block_id>
-    <source_key>2</source_key>
-    <sink_key>0</sink_key>
-  </connection>
   <connection>
     <source_block_id>random_source_x_0</source_block_id>
     <sink_block_id>gr_uchar_to_float_0</sink_block_id>
     <source_key>0</source_key>
     <sink_key>0</sink_key>
   </connection>
-  <connection>
-    <source_block_id>gr_throttle_0</source_block_id>
-    <sink_block_id>gr_pfb_clock_sync_ccf_0</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>gr_pfb_clock_sync_ccf_0</source_block_id>
-    <sink_block_id>wxgui_scopesink2_0</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
   <connection>
     <source_block_id>gr_add_xx_0</source_block_id>
     <sink_block_id>gr_float_to_complex_0</sink_block_id>
     <source_key>0</source_key>
     <sink_key>0</sink_key>
   </connection>
+  <connection>
+    <source_block_id>gr_pfb_clock_sync_xxx_0</source_block_id>
+    <sink_block_id>wxgui_scopesink2_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_throttle_0</source_block_id>
+    <sink_block_id>gr_pfb_clock_sync_xxx_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_pfb_clock_sync_xxx_0</source_block_id>
+    <sink_block_id>wxgui_scopesink2_0_0</sink_block_id>
+    <source_key>1</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_pfb_clock_sync_xxx_0</source_block_id>
+    <sink_block_id>wxgui_scopesink2_0_0_0_0</sink_block_id>
+    <source_key>2</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_pfb_clock_sync_xxx_0</source_block_id>
+    <sink_block_id>wxgui_scopesink2_0_0_0</sink_block_id>
+    <source_key>3</source_key>
+    <sink_key>0</sink_key>
+  </connection>
 </flow_graph>
index f3f4f6a38fcbe7dc61a2face1d4d6f3384616184..854ce147663fe5d1f8e8ebb2af71a800e4fb0792 100644 (file)
@@ -21,7 +21,7 @@
 
 include $(top_srcdir)/Makefile.common
 
-SUBDIRS = lib grc
+SUBDIRS = lib grc oct
 
 if PYTHON
 SUBDIRS += swig python apps
index fada3550a314818ba7abc56038610e78838643c3..29d11f59349ac5d6f19e1e77d96a5c45a7f10b4f 100644 (file)
@@ -15,20 +15,22 @@ HRPT minor frames into a file.  The file stores a series of 11090 word,
 16-bits per word corresponding to the HRPT minor frame format (only the
 lower 10-bits per word are significant.)
 
-The script file by default uses USRP side A, 1698 MHz, at decimation 16. A
-configuration file 'usrp_rx_hrpt.cfg' in the current working directory will
-allow changing this, as well as implementing persistent storage of GUI
+The script file by default uses USRP side A, 1698 MHz, at decimation 16. The
+gnuradio configuration file ~/.gnuradio/config.conf, section 'usrp_rx_hrpt.cfg',
+will allow changing this, as well as implementing persistent storage of GUI
 entered parameters from invocation to invocation.
 
 The present HRPT demodulator is only tested at decimation 16.  The only other
-valid decimation rates are 24 and 32, which may word but with more bit
+valid decimation rates are 24 and 32, which may work but with more bit
 errors.  No other decimation rates will work.
 
-usrp_rx_hrpt2.py
-----------------
 
-This GUI script uses fewer graphical displays to reduce CPU consumption on
-slower machines, but otherwise operates identically to userp_rx_hrpt.py.
+file_rx_hrpt.py
+---------------
+
+This GUI script operates like usrp_rx_hrpt.py, but reads from a pre-captured
+data file supplied by -F on the command line.
+
 
 usrp_rx_hrpt_nogui.py
 ---------------------
@@ -37,6 +39,7 @@ This non-GUI script operates without a display and requires that all parameters
 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
 ------------------
 
@@ -53,11 +56,11 @@ Options:
                         Set Decimation [default=16]
   -p PLL_ALPHA, --pll-alpha=PLL_ALPHA
                         Set pll_alpha [default=50m]
-  -s SYNC_ALPHA, --sync-alpha=SYNC_ALPHA
-                        Set sync_alpha [default=50m]
-  -F FILENAME, --filename=FILENAME
+  -s CLOCK_ALPHA, --clock-alpha=CLOCK_ALPHA
+                        Set clock_alpha [default=50m]
+  -F INPUT_FILENAME, --input-filename=INPUT_FILENAME
                         Set Filename [default=usrp.dat]
-  -o OUTPUT, --output=OUTPUT
+  -o OUTPUT_FILENAME, --output-filename=OUTPUT_FILENAME
                         Set Output [default=frames.dat]
 
 
index 773a6df9baff964b04b810b12fd29d8339efc790..6bd1ab99593a948cca795ade1958a165d832b87a 100644 (file)
@@ -1 +1,2 @@
 *.dat
+*.txt
\ No newline at end of file
index b9787a92c48859c27fcacbdd64257b17480263f0..961b09afabe5fa9e243867393fd7ec0c2d2e189d 100644 (file)
@@ -25,15 +25,15 @@ if PYTHON
 
 dist_bin_SCRIPTS = \
        demod_hrpt_file.py \
+       file_rx_hrpt.py \
        usrp_rx_hrpt.py \
-       usrp_rx_hrpt2.py \
        usrp_rx_hrpt_nogui.py \
        usrp_rx_lrit.py
 
 EXTRA_DIST = \
+       file_rx_hrpt.grc \
        demod_hrpt_file.grc \
        usrp_rx_hrpt.grc \
-       usrp_rx_hrpt2.grc \
        usrp_rx_hrpt_nogui.grc \
        usrp_rx_lrit.grc
 endif
index 7a0bbe892e915d0ad3a9fa16efd400af9c141e14..3c5e3efa4ec5dbb0655a598e92d8703d41b38bc7 100644 (file)
@@ -1,23 +1,55 @@
 <?xml version='1.0' encoding='ASCII'?>
 <flow_graph>
-  <timestamp>Sun Oct  4 08:40:03 2009</timestamp>
+  <timestamp>Mon Nov  2 07:06:57 2009</timestamp>
   <block>
-    <key>variable</key>
+    <key>options</key>
     <param>
       <key>id</key>
-      <value>max_sync_offset</value>
+      <value>demod_hrpt_file</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>value</key>
-      <value>0.01</value>
+      <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>(705, 19)</value>
+      <value>(10, 10)</value>
     </param>
     <param>
       <key>_rotation</key>
@@ -51,7 +83,7 @@
     <key>variable</key>
     <param>
       <key>id</key>
-      <value>hs</value>
+      <value>sym_rate</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>int(sps/2.0)</value>
+      <value>600*1109</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(499, 19)</value>
+      <value>(301, 19)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable</key>
     <param>
       <key>id</key>
-      <value>sym_rate</value>
+      <value>hs</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>600*1109</value>
+      <value>int(sps/2.0)</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(301, 19)</value>
+      <value>(499, 19)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>parameter</key>
+    <key>variable</key>
     <param>
       <key>id</key>
-      <value>filename</value>
+      <value>max_clock_offset</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>label</key>
-      <value>Filename</value>
+      <key>value</key>
+      <value>0.1</value>
     </param>
     <param>
-      <key>value</key>
-      <value>usrp.dat</value>
+      <key>_coordinate</key>
+      <value>(710, 17)</value>
     </param>
     <param>
-      <key>type</key>
-      <value>string</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>import</key>
     <param>
-      <key>short_id</key>
-      <value>F</value>
+      <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>(200, 101)</value>
+      <value>(11, 103)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>parameter</key>
     <param>
       <key>id</key>
-      <value>output</value>
+      <value>decim</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>label</key>
-      <value>Output</value>
+      <value>decim</value>
     </param>
     <param>
       <key>value</key>
-      <value>frames.dat</value>
+      <value>16</value>
     </param>
     <param>
       <key>type</key>
-      <value>string</value>
+      <value>intx</value>
     </param>
     <param>
       <key>short_id</key>
-      <value>o</value>
+      <value>d</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(302, 101)</value>
+      <value>(202, 102)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>gr_float_to_complex</key>
+    <key>parameter</key>
     <param>
       <key>id</key>
-      <value>f2c</value>
+      <value>pll_alpha</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>vlen</key>
-      <value>1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(832, 363)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
+      <key>label</key>
+      <value>pll_alpha</value>
     </param>
-  </block>
-  <block>
-    <key>virtual_sink</key>
     <param>
-      <key>id</key>
-      <value>samples_sink</value>
+      <key>value</key>
+      <value>0.05</value>
     </param>
     <param>
-      <key>_enabled</key>
-      <value>True</value>
+      <key>type</key>
+      <value>eng_float</value>
     </param>
     <param>
-      <key>stream_id</key>
-      <value>samples</value>
+      <key>short_id</key>
+      <value>p</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(1070, 376)</value>
+      <value>(294, 101)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_sync_fb</key>
+    <key>parameter</key>
     <param>
       <key>id</key>
-      <value>sync</value>
+      <value>clock_alpha</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>alpha</key>
-      <value>sync_alpha</value>
+      <key>label</key>
+      <value>clock_alpha</value>
     </param>
     <param>
-      <key>beta</key>
-      <value>sync_alpha**2/4.0</value>
+      <key>value</key>
+      <value>0.05</value>
     </param>
     <param>
-      <key>sps</key>
-      <value>sps</value>
+      <key>type</key>
+      <value>eng_float</value>
     </param>
     <param>
-      <key>max_offset</key>
-      <value>max_sync_offset</value>
+      <key>short_id</key>
+      <value>a</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(813, 455)</value>
+      <value>(395, 101)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_deframer</key>
+    <key>parameter</key>
     <param>
       <key>id</key>
-      <value>deframer</value>
+      <value>sync_alpha</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>_coordinate</key>
-      <value>(1037, 483)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_file_sink</key>
-    <param>
-      <key>id</key>
-      <value>file_sink</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
+      <key>label</key>
+      <value>sync_alpha</value>
     </param>
     <param>
-      <key>file</key>
-      <value>output</value>
+      <key>value</key>
+      <value>0.05</value>
     </param>
     <param>
       <key>type</key>
-      <value>short</value>
+      <value>eng_float</value>
     </param>
     <param>
-      <key>vlen</key>
-      <value>1</value>
+      <key>short_id</key>
+      <value>s</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(1238, 479)</value>
+      <value>(508, 102)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_decoder</key>
+    <key>parameter</key>
     <param>
       <key>id</key>
-      <value>decoder</value>
+      <value>input_filename</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>_coordinate</key>
-      <value>(1237, 542)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_deinterleave</key>
-    <param>
-      <key>id</key>
-      <value>deinterleave</value>
+      <key>label</key>
+      <value>input_filename</value>
     </param>
     <param>
-      <key>_enabled</key>
-      <value>True</value>
+      <key>value</key>
+      <value>usrp.dat</value>
     </param>
     <param>
       <key>type</key>
-      <value>float</value>
-    </param>
-    <param>
-      <key>num_streams</key>
-      <value>2</value>
+      <value>string</value>
     </param>
     <param>
-      <key>vlen</key>
-      <value>1</value>
+      <key>short_id</key>
+      <value>F</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(628, 363)</value>
+      <value>(618, 102)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>parameter</key>
     <param>
       <key>id</key>
-      <value>decim</value>
+      <value>output_filename</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>label</key>
-      <value>Decimation</value>
+      <value>output_filename</value>
     </param>
     <param>
       <key>value</key>
-      <value>16</value>
+      <value>frames.dat</value>
     </param>
     <param>
       <key>type</key>
-      <value>intx</value>
+      <value>string</value>
     </param>
     <param>
       <key>short_id</key>
-      <value>d</value>
+      <value>o</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(415, 101)</value>
+      <value>(726, 102)</value>
     </param>
     <param>
       <key>_rotation</key>
-      <value>0</value>
+      <value>180</value>
     </param>
   </block>
   <block>
-    <key>parameter</key>
+    <key>gr_file_source</key>
     <param>
       <key>id</key>
-      <value>pll_alpha</value>
+      <value>file_source</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>label</key>
-      <value></value>
+      <key>file</key>
+      <value>input_filename</value>
     </param>
     <param>
-      <key>value</key>
-      <value>0.05</value>
+      <key>type</key>
+      <value>short</value>
     </param>
     <param>
-      <key>type</key>
-      <value>eng_float</value>
+      <key>repeat</key>
+      <value>False</value>
     </param>
     <param>
-      <key>short_id</key>
-      <value>p</value>
+      <key>vlen</key>
+      <value>1</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(527, 101)</value>
+      <value>(62, 306)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>parameter</key>
+    <key>gr_interleaved_short_to_complex</key>
     <param>
       <key>id</key>
-      <value>sync_alpha</value>
+      <value>cs2cf</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>label</key>
-      <value></value>
+      <key>_coordinate</key>
+      <value>(297, 318)</value>
     </param>
     <param>
-      <key>value</key>
-      <value>0.05</value>
+      <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>eng_float</value>
+      <value>complex</value>
     </param>
     <param>
-      <key>short_id</key>
-      <value>s</value>
+      <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>(615, 99)</value>
+      <value>(538, 290)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(606, 463)</value>
+      <value>(720, 297)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>virtual_source</key>
+    <key>gr_moving_average_xx</key>
     <param>
       <key>id</key>
-      <value>samples_source</value>
+      <value>gr_moving_average_xx_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>stream_id</key>
-      <value>samples</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(164, 479)</value>
+      <key>type</key>
+      <value>float</value>
     </param>
     <param>
-      <key>_rotation</key>
-      <value>0</value>
+      <key>length</key>
+      <value>hs</value>
     </param>
-  </block>
-  <block>
-    <key>gr_short_to_float</key>
     <param>
-      <key>id</key>
-      <value>s2f</value>
+      <key>scale</key>
+      <value>1.0/hs</value>
     </param>
     <param>
-      <key>_enabled</key>
-      <value>True</value>
+      <key>max_iter</key>
+      <value>4000</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(365, 380)</value>
+      <value>(949, 297)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>gr_file_source</key>
+    <key>gr_clock_recovery_mm_xx</key>
     <param>
       <key>id</key>
-      <value>file_source</value>
+      <value>gr_clock_recovery_mm_xx_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
-    <param>
-      <key>file</key>
-      <value>filename</value>
-    </param>
     <param>
       <key>type</key>
-      <value>short</value>
+      <value>float</value>
     </param>
     <param>
-      <key>repeat</key>
-      <value>False</value>
+      <key>omega</key>
+      <value>sps/2.0</value>
     </param>
     <param>
-      <key>vlen</key>
-      <value>1</value>
+      <key>gain_omega</key>
+      <value>clock_alpha**2/4.0</value>
     </param>
     <param>
-      <key>_coordinate</key>
-      <value>(162, 368)</value>
+      <key>mu</key>
+      <value>0.5</value>
     </param>
     <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>mf_taps</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
+      <key>gain_mu</key>
+      <value>clock_alpha</value>
     </param>
     <param>
-      <key>value</key>
-      <value>[-0.5/hs,]*hs+[0.5/hs,]*hs</value>
+      <key>omega_relative_limit</key>
+      <value>max_clock_offset</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(829, 21)</value>
+      <value>(1158, 281)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>gr_fir_filter_xxx</key>
+    <key>gr_file_sink</key>
     <param>
       <key>id</key>
-      <value>gr_fir_filter_xxx_0</value>
+      <value>gr_file_sink_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>type</key>
-      <value>ccc</value>
+      <key>file</key>
+      <value>output_filename</value>
     </param>
     <param>
-      <key>decim</key>
-      <value>1</value>
+      <key>type</key>
+      <value>short</value>
     </param>
     <param>
-      <key>taps</key>
-      <value>mf_taps</value>
+      <key>vlen</key>
+      <value>1</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(359, 471)</value>
+      <value>(732, 615)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>import</key>
+    <key>noaa_hrpt_decoder</key>
     <param>
       <key>id</key>
-      <value>import_0</value>
+      <value>noaa_hrpt_decoder_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
-    <param>
-      <key>import</key>
-      <value>import math</value>
-    </param>
     <param>
       <key>_coordinate</key>
-      <value>(11, 111)</value>
+      <value>(730, 537)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>options</key>
+    <key>gr_binary_slicer_fb</key>
     <param>
       <key>id</key>
-      <value>demod_hrpt_file</value>
+      <value>gr_binary_slicer_fb_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>title</key>
-      <value>USRP HRPT Receiver</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>
+      <key>_coordinate</key>
+      <value>(112, 537)</value>
     </param>
     <param>
-      <key>category</key>
-      <value>Custom</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_deframer</key>
     <param>
-      <key>run_options</key>
-      <value>run</value>
+      <key>id</key>
+      <value>noaa_hrpt_deframer_0</value>
     </param>
     <param>
-      <key>run</key>
+      <key>_enabled</key>
       <value>True</value>
     </param>
-    <param>
-      <key>realtime_scheduling</key>
-      <value></value>
-    </param>
     <param>
       <key>_coordinate</key>
-      <value>(10, 10)</value>
+      <value>(536, 537)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <connection>
-    <source_block_id>deframer</source_block_id>
-    <sink_block_id>file_sink</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>sync</source_block_id>
-    <sink_block_id>deframer</sink_block_id>
+    <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>pll</source_block_id>
-    <sink_block_id>sync</sink_block_id>
+    <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>deinterleave</source_block_id>
-    <sink_block_id>f2c</sink_block_id>
-    <source_key>1</source_key>
-    <sink_key>1</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>deinterleave</source_block_id>
-    <sink_block_id>f2c</sink_block_id>
+    <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>deframer</source_block_id>
-    <sink_block_id>decoder</sink_block_id>
+    <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>f2c</source_block_id>
-    <sink_block_id>samples_sink</sink_block_id>
+    <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>gr_fir_filter_xxx_0</source_block_id>
+    <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>samples_source</source_block_id>
-    <sink_block_id>gr_fir_filter_xxx_0</sink_block_id>
+    <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>s2f</source_block_id>
-    <sink_block_id>deinterleave</sink_block_id>
+    <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>file_source</source_block_id>
-    <sink_block_id>s2f</sink_block_id>
+    <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>
index d5535186839d37ddbe62ef31fb4561e1daa22a21..d866501716ae564b05d3e0573aa8983fac348be7 100755 (executable)
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 ##################################################
 # Gnuradio Python Flow Graph
-# Title: USRP HRPT Receiver
-# Generated: Sun Oct  4 08:40:03 2009
+# Title: Demod Hrpt File
+# Generated: Mon Nov  2 07:06:57 2009
 ##################################################
 
 from gnuradio import eng_notation
@@ -11,21 +11,22 @@ from gnuradio import noaa
 from gnuradio.eng_option import eng_option
 from gnuradio.gr import firdes
 from optparse import OptionParser
-import math
+import math, os
 
 class demod_hrpt_file(gr.top_block):
 
-       def __init__(self, filename="usrp.dat", output="frames.dat", decim=16, pll_alpha=0.05, sync_alpha=0.05):
-               gr.top_block.__init__(self, "USRP HRPT Receiver")
+       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.filename = filename
-               self.output = output
                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
@@ -33,44 +34,36 @@ class demod_hrpt_file(gr.top_block):
                self.sym_rate = sym_rate = 600*1109
                self.sample_rate = sample_rate = 64e6/decim
                self.sps = sps = sample_rate/sym_rate
-               self.hs = hs = int(sps/2.0)
-               self.mf_taps = mf_taps = [-0.5/hs,]*hs+[0.5/hs,]*hs
-               self.max_sync_offset = max_sync_offset = 0.01
+               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.decoder = noaa.hrpt_decoder()
-               self.deframer = noaa.hrpt_deframer()
-               self.deinterleave = gr.deinterleave(gr.sizeof_float*1)
-               self.f2c = gr.float_to_complex(1)
-               self.file_sink = gr.file_sink(gr.sizeof_short*1, output)
-               self.file_source = gr.file_source(gr.sizeof_short*1, filename, False)
-               self.gr_fir_filter_xxx_0 = gr.fir_filter_ccc(1, (mf_taps))
+               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)
-               self.s2f = gr.short_to_float()
-               self.sync = noaa.hrpt_sync_fb(sync_alpha, sync_alpha**2/4.0, sps, max_sync_offset)
 
                ##################################################
                # Connections
                ##################################################
-               self.connect((self.deframer, 0), (self.file_sink, 0))
-               self.connect((self.sync, 0), (self.deframer, 0))
-               self.connect((self.pll, 0), (self.sync, 0))
-               self.connect((self.deinterleave, 1), (self.f2c, 1))
-               self.connect((self.deinterleave, 0), (self.f2c, 0))
-               self.connect((self.deframer, 0), (self.decoder, 0))
-               self.connect((self.gr_fir_filter_xxx_0, 0), (self.pll, 0))
-               self.connect((self.f2c, 0), (self.gr_fir_filter_xxx_0, 0))
-               self.connect((self.s2f, 0), (self.deinterleave, 0))
-               self.connect((self.file_source, 0), (self.s2f, 0))
-
-       def set_filename(self, filename):
-               self.filename = filename
-
-       def set_output(self, output):
-               self.output = output
+               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
@@ -81,10 +74,19 @@ class demod_hrpt_file(gr.top_block):
                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
-               self.sync.set_alpha(self.sync_alpha)
-               self.sync.set_beta(self.sync_alpha**2/4.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_sym_rate(self, sym_rate):
                self.sym_rate = sym_rate
@@ -98,36 +100,34 @@ class demod_hrpt_file(gr.top_block):
        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_hs(self, hs):
-               self.hs = hs
-               self.set_mf_taps([-0.5/self.hs,]*self.hs+[0.5/self.hs,]*self.hs)
-
-       def set_mf_taps(self, mf_taps):
-               self.mf_taps = mf_taps
-               self.gr_fir_filter_xxx_0.set_taps((self.mf_taps))
-
-       def set_max_sync_offset(self, max_sync_offset):
-               self.max_sync_offset = max_sync_offset
-               self.sync.set_max_offset(self.max_sync_offset)
+       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", "--filename", dest="filename", type="string", default="usrp.dat",
-               help="Set Filename [default=%default]")
-       parser.add_option("-o", "--output", dest="output", type="string", default="frames.dat",
-               help="Set Output [default=%default]")
        parser.add_option("-d", "--decim", dest="decim", type="intx", default=16,
-               help="Set Decimation [default=%default]")
+               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(filename=options.filename, output=options.output, decim=options.decim, pll_alpha=options.pll_alpha, sync_alpha=options.sync_alpha)
+       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()
 
diff --git a/gr-noaa/apps/file_rx_hrpt.grc b/gr-noaa/apps/file_rx_hrpt.grc
new file mode 100644 (file)
index 0000000..f341437
--- /dev/null
@@ -0,0 +1,1229 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+  <timestamp>Mon Nov  2 08:30:47 2009</timestamp>
+  <block>
+    <key>options</key>
+    <param>
+      <key>id</key>
+      <value>file_rx_hrpt</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>USRP HRPT Receiver</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>wx_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>(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>
+      <key>id</key>
+      <value>virtual_source_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>stream_id</key>
+      <value>baseband</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(173, 971)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>wxgui_scopesink2</key>
+    <param>
+      <key>id</key>
+      <value>demod_scope</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>float</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>Post-Demod</value>
+    </param>
+    <param>
+      <key>samp_rate</key>
+      <value>sym_rate*2.0</value>
+    </param>
+    <param>
+      <key>v_scale</key>
+      <value>0.5</value>
+    </param>
+    <param>
+      <key>v_offset</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>t_scale</key>
+      <value>10.0/sym_rate</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>0, 0, 1, 1</value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value>displays, 1</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(666, 542)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>180</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>(873, 696)</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>(682, 713)</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>(469, 713)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>virtual_sink</key>
+    <param>
+      <key>id</key>
+      <value>virtual_sink_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>stream_id</key>
+      <value>baseband</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1142, 728)</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>_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>config_filename</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>os.environ['HOME']+'/.gnuradio/config.conf'</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(13, 159)</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, 110)</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-6</value>
+    </param>
+    <param>
+      <key>reference</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>gain</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>max_gain</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(301, 705)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_interleaved_short_to_complex</key>
+    <param>
+      <key>id</key>
+      <value>gr_interleaved_short_to_complex_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(73, 733)</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>sample_rate</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(75, 679)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>180</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_file_source</key>
+    <param>
+      <key>id</key>
+      <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>repeat</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(76, 613)</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>(198, 107)</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>(308, 107)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_slider</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>saved_pll_alpha</value>
+    </param>
+    <param>
+      <key>min</key>
+      <value>0.0</value>
+    </param>
+    <param>
+      <key>max</key>
+      <value>0.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>0, 0, 1, 1</value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(397, 108)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable_slider</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>saved_clock_alpha</value>
+    </param>
+    <param>
+      <key>min</key>
+      <value>0.0</value>
+    </param>
+    <param>
+      <key>max</key>
+      <value>0.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>0, 1, 1, 1</value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(539, 105)</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.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>(363, 254)</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>(527, 256)</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>(689, 257)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>notebook</key>
+    <param>
+      <key>id</key>
+      <value>displays</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <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>complex</value>
+    </param>
+    <param>
+      <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>noaa_hrpt_deframer</key>
+    <param>
+      <key>id</key>
+      <value>deframer</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(762, 975)</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>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>deframer</source_block_id>
+    <sink_block_id>frame_sink</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>deframer</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_clock_recovery_mm_xx_0</source_block_id>
+    <sink_block_id>virtual_sink_0</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>demod_scope</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>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>agc</source_block_id>
+    <sink_block_id>rx_fft</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_interleaved_short_to_complex_0</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>throttle</source_block_id>
+    <sink_block_id>gr_interleaved_short_to_complex_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_file_source_0</source_block_id>
+    <sink_block_id>throttle</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>deframer</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+</flow_graph>
diff --git a/gr-noaa/apps/file_rx_hrpt.py b/gr-noaa/apps/file_rx_hrpt.py
new file mode 100755 (executable)
index 0000000..1513141
--- /dev/null
@@ -0,0 +1,307 @@
+#!/usr/bin/env python
+##################################################
+# Gnuradio Python Flow Graph
+# Title: USRP HRPT Receiver
+# Generated: Mon Nov  2 08:30:47 2009
+##################################################
+
+from gnuradio import eng_notation
+from gnuradio import gr
+from gnuradio import noaa
+from gnuradio import window
+from gnuradio.eng_option import eng_option
+from gnuradio.gr import firdes
+from gnuradio.wxgui import fftsink2
+from gnuradio.wxgui import forms
+from gnuradio.wxgui import scopesink2
+from grc_gnuradio import wxgui as grc_wxgui
+from optparse import OptionParser
+import ConfigParser
+import math, os
+import wx
+
+class file_rx_hrpt(grc_wxgui.top_block_gui):
+
+       def __init__(self, input_filename='usrp.dat', decim=16):
+               grc_wxgui.top_block_gui.__init__(self, title="USRP HRPT Receiver")
+
+               ##################################################
+               # Parameters
+               ##################################################
+               self.input_filename = input_filename
+               self.decim = decim
+
+               ##################################################
+               # Variables
+               ##################################################
+               self.sym_rate = sym_rate = 600*1109
+               self.sample_rate = sample_rate = 64e6/decim
+               self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/config.conf'
+               self.sps = sps = sample_rate/sym_rate
+               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
+               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
+               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'
+               self.output_filename = output_filename
+               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)
+               self.clock_alpha = clock_alpha = saved_clock_alpha
+
+               ##################################################
+               # Notebooks
+               ##################################################
+               self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
+               self.displays.AddPage(grc_wxgui.Panel(self.displays), "Spectrum")
+               self.displays.AddPage(grc_wxgui.Panel(self.displays), "Demod")
+               self.GridAdd(self.displays, 1, 0, 1, 2)
+
+               ##################################################
+               # Controls
+               ##################################################
+               _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
+               self._pll_alpha_text_box = forms.text_box(
+                       parent=self.GetWin(),
+                       sizer=_pll_alpha_sizer,
+                       value=self.pll_alpha,
+                       callback=self.set_pll_alpha,
+                       label="PLL Alpha",
+                       converter=forms.float_converter(),
+                       proportion=0,
+               )
+               self._pll_alpha_slider = forms.slider(
+                       parent=self.GetWin(),
+                       sizer=_pll_alpha_sizer,
+                       value=self.pll_alpha,
+                       callback=self.set_pll_alpha,
+                       minimum=0.0,
+                       maximum=0.5,
+                       num_steps=100,
+                       style=wx.SL_HORIZONTAL,
+                       cast=float,
+                       proportion=1,
+               )
+               self.GridAdd(_pll_alpha_sizer, 0, 0, 1, 1)
+               _clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
+               self._clock_alpha_text_box = forms.text_box(
+                       parent=self.GetWin(),
+                       sizer=_clock_alpha_sizer,
+                       value=self.clock_alpha,
+                       callback=self.set_clock_alpha,
+                       label="Clock Alpha",
+                       converter=forms.float_converter(),
+                       proportion=0,
+               )
+               self._clock_alpha_slider = forms.slider(
+                       parent=self.GetWin(),
+                       sizer=_clock_alpha_sizer,
+                       value=self.clock_alpha,
+                       callback=self.set_clock_alpha,
+                       minimum=0.0,
+                       maximum=0.5,
+                       num_steps=100,
+                       style=wx.SL_HORIZONTAL,
+                       cast=float,
+                       proportion=1,
+               )
+               self.GridAdd(_clock_alpha_sizer, 0, 1, 1, 1)
+
+               ##################################################
+               # Blocks
+               ##################################################
+               self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0)
+               self.decoder = noaa.hrpt_decoder()
+               self.deframer = noaa.hrpt_deframer()
+               self.demod_scope = scopesink2.scope_sink_f(
+                       self.displays.GetPage(1).GetWin(),
+                       title="Post-Demod",
+                       sample_rate=sym_rate*2.0,
+                       v_scale=0.5,
+                       v_offset=0,
+                       t_scale=10.0/sym_rate,
+                       ac_couple=False,
+                       xy_mode=False,
+                       num_inputs=1,
+               )
+               self.displays.GetPage(1).GridAdd(self.demod_scope.win, 0, 0, 1, 1)
+               self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename)
+               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_source_0 = gr.file_source(gr.sizeof_short*1, input_filename, False)
+               self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex()
+               self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
+               self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
+               self.rx_fft = fftsink2.fft_sink_c(
+                       self.displays.GetPage(0).GetWin(),
+                       baseband_freq=0,
+                       y_per_div=5,
+                       y_divs=8,
+                       ref_level=-5,
+                       ref_scale=2.0,
+                       sample_rate=sample_rate,
+                       fft_size=1024,
+                       fft_rate=15,
+                       average=True,
+                       avg_alpha=0.1,
+                       title="RX Spectrum",
+                       peak_hold=False,
+                       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)
+
+               ##################################################
+               # Connections
+               ##################################################
+               self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0))
+               self.connect((self.deframer, 0), (self.frame_sink, 0))
+               self.connect((self.deframer, 0), (self.decoder, 0))
+               self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.demod_scope, 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.agc, 0), (self.pll, 0))
+               self.connect((self.agc, 0), (self.rx_fft, 0))
+               self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0))
+               self.connect((self.throttle, 0), (self.gr_interleaved_short_to_complex_0, 0))
+               self.connect((self.gr_file_source_0, 0), (self.throttle, 0))
+               self.connect((self.gr_binary_slicer_fb_0, 0), (self.deframer, 0))
+
+       def set_input_filename(self, input_filename):
+               self.input_filename = input_filename
+
+       def set_decim(self, decim):
+               self.decim = decim
+               self.set_sample_rate(64e6/self.decim)
+
+       def set_sym_rate(self, sym_rate):
+               self.sym_rate = sym_rate
+               self.set_sps(self.sample_rate/self.sym_rate)
+               self.demod_scope.set_sample_rate(self.sym_rate*2.0)
+
+       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)
+
+       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._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._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._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)
+
+       def set_saved_pll_alpha(self, saved_pll_alpha):
+               self.saved_pll_alpha = saved_pll_alpha
+               self.set_pll_alpha(self.saved_pll_alpha)
+
+       def set_saved_clock_alpha(self, saved_clock_alpha):
+               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)
+               self.pll.set_beta(self.pll_alpha**2/4.0)
+               self._pll_alpha_slider.set_value(self.pll_alpha)
+               self._pll_alpha_text_box.set_value(self.pll_alpha)
+               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'))
+
+       def set_output_filename(self, output_filename):
+               self.output_filename = output_filename
+               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_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)
+
+       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_slider.set_value(self.clock_alpha)
+               self._clock_alpha_text_box.set_value(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'))
+
+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("-d", "--decim", dest="decim", type="intx", default=16,
+               help="Set decim [default=%default]")
+       (options, args) = parser.parse_args()
+       tb = file_rx_hrpt(input_filename=options.input_filename, decim=options.decim)
+       tb.Run(True)
+
diff --git a/gr-noaa/apps/usrp_rx_hrpt.cfg b/gr-noaa/apps/usrp_rx_hrpt.cfg
deleted file mode 100644 (file)
index 69f3c0b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-[output]
-filename = frames.dat
-
-[demod]
-pll_alpha = 0.05
-sync_alpha = 0.05
-
-[usrp]
-freq = 1698000000.0
-decim = 16
-side = A
-gain = 35.0
-
index d0687971617cb7683ac64d177f9fc232e4f34645..ac7a87a1608e3d275be08efed4f1f0dc456282d4 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version='1.0' encoding='ASCII'?>
 <flow_graph>
-  <timestamp>Sun Sep 27 13:37:22 2009</timestamp>
+  <timestamp>Mon Nov  2 08:31:09 2009</timestamp>
   <block>
     <key>options</key>
     <param>
       <key>category</key>
       <value>Custom</value>
     </param>
+    <param>
+      <key>run_options</key>
+      <value>prompt</value>
+    </param>
     <param>
       <key>run</key>
       <value>True</value>
       <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</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(11, 76)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>'usrp_rx_hrpt.cfg'</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(12, 129)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
   <block>
     <key>variable</key>
     <param>
     </param>
   </block>
   <block>
-    <key>variable_slider</key>
+    <key>variable_static_text</key>
     <param>
       <key>id</key>
-      <value>sync_alpha</value>
+      <value>side_text</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>label</key>
-      <value>SYNC Alpha</value>
+      <value>USRP Side</value>
     </param>
     <param>
       <key>value</key>
-      <value>saved_sync_alpha</value>
-    </param>
-    <param>
-      <key>min</key>
-      <value>0.0</value>
-    </param>
-    <param>
-      <key>max</key>
-      <value>0.5</value>
-    </param>
-    <param>
-      <key>num_steps</key>
-      <value>100</value>
+      <value>side</value>
     </param>
     <param>
-      <key>style</key>
-      <value>wx.SL_HORIZONTAL</value>
+      <key>converver</key>
+      <value>str_converter</value>
     </param>
     <param>
-      <key>converver</key>
-      <value>float_converter</value>
+      <key>formatter</key>
+      <value>None</value>
     </param>
     <param>
       <key>grid_pos</key>
-      <value>0, 3, 1, 1</value>
+      <value>1, 0, 1, 1</value>
     </param>
     <param>
       <key>notebook</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(618, 106)</value>
+      <value>(828, 20)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_static_text</key>
     <param>
       <key>id</key>
-      <value>side_text</value>
+      <value>decim_text</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>label</key>
-      <value>USRP Side</value>
+      <value>Decimation</value>
     </param>
     <param>
       <key>value</key>
-      <value>side</value>
+      <value>decim</value>
     </param>
     <param>
       <key>converver</key>
-      <value>str_converter</value>
+      <value>float_converter</value>
     </param>
     <param>
       <key>formatter</key>
     </param>
     <param>
       <key>grid_pos</key>
-      <value>1, 0, 1, 1</value>
+      <value>1, 1, 1, 1</value>
     </param>
     <param>
       <key>notebook</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(828, 20)</value>
+      <value>(973, 20)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>variable_config</key>
+    <key>variable</key>
     <param>
       <key>id</key>
-      <value>side</value>
+      <value>config_filename</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>'A'</value>
+      <value>os.environ['HOME']+'/.gnuradio/config.conf'</value>
     </param>
     <param>
-      <key>type</key>
-      <value>string</value>
+      <key>_coordinate</key>
+      <value>(12, 129)</value>
     </param>
     <param>
-      <key>config_file</key>
-      <value>config_filename</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>import</key>
     <param>
-      <key>section</key>
-      <value>'usrp'</value>
+      <key>id</key>
+      <value>import_0</value>
     </param>
     <param>
-      <key>option</key>
-      <value>'side'</value>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
-      <key>writeback</key>
-      <value>side</value>
+      <key>import</key>
+      <value>import math, os</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(194, 253)</value>
+      <value>(11, 76)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>decim</value>
+      <value>saved_freq</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>16</value>
+      <value>1698e6</value>
     </param>
     <param>
       <key>type</key>
     </param>
     <param>
       <key>section</key>
-      <value>'usrp'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
-      <value>'decim'</value>
+      <value>'freq'</value>
     </param>
     <param>
       <key>writeback</key>
-      <value>decim</value>
+      <value>freq</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(351, 255)</value>
+      <value>(507, 258)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>saved_freq</value>
+      <value>saved_gain</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>1698e6</value>
+      <value>35</value>
     </param>
     <param>
       <key>type</key>
     </param>
     <param>
       <key>section</key>
-      <value>'usrp'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
-      <value>'freq'</value>
+      <value>'gain'</value>
     </param>
     <param>
       <key>writeback</key>
-      <value>freq</value>
+      <value>gain</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(507, 258)</value>
+      <value>(664, 259)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>saved_gain</value>
+      <value>output_filename</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>35</value>
+      <value>'frames.dat'</value>
     </param>
     <param>
       <key>type</key>
-      <value>real</value>
+      <value>string</value>
     </param>
     <param>
       <key>config_file</key>
     </param>
     <param>
       <key>section</key>
-      <value>'usrp'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
-      <value>'gain'</value>
+      <value>'filename'</value>
     </param>
     <param>
       <key>writeback</key>
-      <value>gain</value>
+      <value>output_filename</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(664, 259)</value>
+      <value>(1139, 259)</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>max_clock_offset</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>0.05</value>
+      <value>0.1</value>
     </param>
     <param>
-      <key>type</key>
-      <value>real</value>
+      <key>_coordinate</key>
+      <value>(705, 19)</value>
     </param>
     <param>
-      <key>config_file</key>
-      <value>config_filename</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>variable_slider</key>
     <param>
-      <key>section</key>
-      <value>'demod'</value>
+      <key>id</key>
+      <value>clock_alpha</value>
     </param>
     <param>
-      <key>option</key>
-      <value>'pll_alpha'</value>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
-      <key>writeback</key>
-      <value>pll_alpha</value>
+      <key>label</key>
+      <value>Clock Alpha</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>saved_clock_alpha</value>
+    </param>
+    <param>
+      <key>min</key>
+      <value>0.0</value>
+    </param>
+    <param>
+      <key>max</key>
+      <value>0.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>0, 3, 1, 1</value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value></value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(823, 258)</value>
+      <value>(618, 106)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>saved_sync_alpha</value>
+      <value>saved_pll_alpha</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>section</key>
-      <value>'demod'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
-      <value>'sync_alpha'</value>
+      <value>'pll_alpha'</value>
     </param>
     <param>
       <key>writeback</key>
-      <value>sync_alpha</value>
+      <value>pll_alpha</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(981, 258)</value>
+      <value>(823, 258)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>output_filename</value>
+      <value>saved_clock_alpha</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>'frames.dat'</value>
+      <value>0.05</value>
     </param>
     <param>
       <key>type</key>
-      <value>string</value>
+      <value>real</value>
     </param>
     <param>
       <key>config_file</key>
     </param>
     <param>
       <key>section</key>
-      <value>'output'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
-      <value>'filename'</value>
+      <value>'clock_alpha'</value>
     </param>
     <param>
       <key>writeback</key>
-      <value>output_filename</value>
+      <value>clock_alpha</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(1139, 259)</value>
+      <value>(981, 258)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>variable_static_text</key>
+    <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>decim_text</value>
+      <value>decim</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>label</key>
-      <value>Decimation</value>
+      <key>value</key>
+      <value>16</value>
     </param>
     <param>
-      <key>value</key>
-      <value>decim</value>
+      <key>type</key>
+      <value>real</value>
     </param>
     <param>
-      <key>converver</key>
-      <value>float_converter</value>
+      <key>config_file</key>
+      <value>config_filename</value>
     </param>
     <param>
-      <key>formatter</key>
-      <value>None</value>
+      <key>section</key>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
-      <key>grid_pos</key>
-      <value>1, 1, 1, 1</value>
+      <key>option</key>
+      <value>'decim'</value>
     </param>
     <param>
-      <key>notebook</key>
-      <value></value>
+      <key>writeback</key>
+      <value>decim</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(973, 20)</value>
+      <value>(351, 255)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>variable</key>
+    <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>max_sync_offset</value>
+      <value>side</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>0.01</value>
+      <value>'A'</value>
     </param>
     <param>
-      <key>_coordinate</key>
-      <value>(705, 19)</value>
+      <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>
     </param>
     <param>
       <key>labels</key>
-      <value>['RX','Demod']</value>
+      <value>['Spectrum','Demod']</value>
     </param>
     <param>
       <key>grid_pos</key>
-      <value>2, 0, 1, 4</value>
+      <value>2,0,1,4</value>
     </param>
     <param>
       <key>notebook</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(15, 237)</value>
+      <value>(12, 249)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_sync_fb</key>
+    <key>gr_file_sink</key>
     <param>
       <key>id</key>
-      <value>sync</value>
+      <value>frame_sink</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>alpha</key>
-      <value>sync_alpha</value>
-    </param>
-    <param>
-      <key>beta</key>
-      <value>sync_alpha**2/4.0</value>
+      <key>file</key>
+      <value>output_filename</value>
     </param>
     <param>
-      <key>sps</key>
-      <value>sps</value>
+      <key>type</key>
+      <value>short</value>
     </param>
     <param>
-      <key>max_offset</key>
-      <value>max_sync_offset</value>
+      <key>vlen</key>
+      <value>1</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(840, 715)</value>
+      <value>(973, 1024)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_deframer</key>
+    <key>virtual_source</key>
     <param>
       <key>id</key>
-      <value>deframer</value>
+      <value>virtual_source_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
+    <param>
+      <key>stream_id</key>
+      <value>baseband</value>
+    </param>
     <param>
       <key>_coordinate</key>
-      <value>(1071, 743)</value>
+      <value>(173, 971)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_decoder</key>
+    <key>wxgui_scopesink2</key>
     <param>
       <key>id</key>
-      <value>decoder</value>
+      <value>demod_scope</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>_coordinate</key>
-      <value>(1274, 743)</value>
+      <key>type</key>
+      <value>float</value>
     </param>
     <param>
-      <key>_rotation</key>
-      <value>0</value>
+      <key>title</key>
+      <value>Post-Demod</value>
     </param>
-  </block>
-  <block>
-    <key>gr_file_sink</key>
     <param>
-      <key>id</key>
-      <value>frame_sink</value>
+      <key>samp_rate</key>
+      <value>sym_rate*2.0</value>
     </param>
     <param>
-      <key>_enabled</key>
-      <value>True</value>
+      <key>v_scale</key>
+      <value>0.5</value>
     </param>
     <param>
-      <key>file</key>
-      <value>output_filename</value>
+      <key>v_offset</key>
+      <value>0</value>
     </param>
     <param>
-      <key>type</key>
-      <value>short</value>
+      <key>t_scale</key>
+      <value>10.0/sym_rate</value>
     </param>
     <param>
-      <key>vlen</key>
-      <value>1</value>
+      <key>ac_couple</key>
+      <value>False</value>
     </param>
     <param>
-      <key>_coordinate</key>
-      <value>(1273, 851)</value>
+      <key>xy_mode</key>
+      <value>False</value>
     </param>
     <param>
-      <key>_rotation</key>
-      <value>0</value>
+      <key>num_inputs</key>
+      <value>1</value>
     </param>
-  </block>
-  <block>
-    <key>variable</key>
     <param>
-      <key>id</key>
-      <value>mf_taps</value>
+      <key>win_size</key>
+      <value></value>
     </param>
     <param>
-      <key>_enabled</key>
-      <value>True</value>
+      <key>grid_pos</key>
+      <value>0, 0, 1, 1</value>
     </param>
     <param>
-      <key>value</key>
-      <value>[-0.5/hs,]*hs+[0.5/hs]*hs</value>
+      <key>notebook</key>
+      <value>displays, 1</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(792, 158)</value>
+      <value>(666, 542)</value>
     </param>
     <param>
       <key>_rotation</key>
-      <value>0</value>
+      <value>180</value>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_pll_cf</key>
+    <key>gr_clock_recovery_mm_xx</key>
     <param>
       <key>id</key>
-      <value>pll</value>
+      <value>gr_clock_recovery_mm_xx_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>alpha</key>
-      <value>pll_alpha</value>
+      <key>type</key>
+      <value>float</value>
     </param>
     <param>
-      <key>beta</key>
-      <value>pll_alpha**2/4.0</value>
+      <key>omega</key>
+      <value>sps/2.0</value>
     </param>
     <param>
-      <key>max_offset</key>
-      <value>max_carrier_offset</value>
+      <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>(632, 723)</value>
+      <value>(873, 696)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>gr_fir_filter_xxx</key>
+    <key>gr_moving_average_xx</key>
     <param>
       <key>id</key>
-      <value>gr_fir_filter_xxx_0</value>
+      <value>gr_moving_average_xx_0</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>type</key>
-      <value>ccc</value>
+      <value>float</value>
     </param>
     <param>
-      <key>decim</key>
-      <value>1</value>
+      <key>length</key>
+      <value>hs</value>
     </param>
     <param>
-      <key>taps</key>
-      <value>mf_taps</value>
+      <key>scale</key>
+      <value>1.0/hs</value>
+    </param>
+    <param>
+      <key>max_iter</key>
+      <value>4000</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(400, 731)</value>
+      <value>(682, 713)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>usrp_simple_source_x</key>
+    <key>noaa_hrpt_pll_cf</key>
     <param>
       <key>id</key>
-      <value>usrp_source</value>
+      <value>pll</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>type</key>
-      <value>complex</value>
+      <key>alpha</key>
+      <value>pll_alpha</value>
     </param>
     <param>
-      <key>format</key>
-      <value></value>
+      <key>beta</key>
+      <value>pll_alpha**2/4.0</value>
     </param>
     <param>
-      <key>which</key>
+      <key>max_offset</key>
+      <value>max_carrier_offset</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(469, 713)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
       <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>virtual_sink</key>
     <param>
-      <key>decimation</key>
-      <value>decim</value>
+      <key>id</key>
+      <value>virtual_sink_0</value>
     </param>
     <param>
-      <key>frequency</key>
-      <value>freq</value>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
-      <key>lo_offset</key>
-      <value>float('inf')</value>
+      <key>stream_id</key>
+      <value>baseband</value>
     </param>
     <param>
-      <key>gain</key>
-      <value>gain</value>
+      <key>_coordinate</key>
+      <value>(1142, 728)</value>
     </param>
     <param>
-      <key>side</key>
-      <value>side</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_decoder</key>
     <param>
-      <key>rx_ant</key>
-      <value>RXA</value>
+      <key>id</key>
+      <value>decoder</value>
     </param>
     <param>
-      <key>hb_filters</key>
-      <value></value>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(28, 699)</value>
+      <value>(974, 925)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(240, 715)</value>
+      <value>(301, 705)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>wxgui_scopesink2</key>
+    <key>usrp_simple_source_x</key>
     <param>
       <key>id</key>
-      <value>rx_scope</value>
+      <value>usrp_source</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>complex</value>
     </param>
     <param>
-      <key>title</key>
-      <value>RX Waveform</value>
+      <key>format</key>
+      <value></value>
     </param>
     <param>
-      <key>samp_rate</key>
-      <value>sample_rate</value>
+      <key>which</key>
+      <value>0</value>
     </param>
     <param>
-      <key>v_scale</key>
-      <value>0</value>
+      <key>decimation</key>
+      <value>decim</value>
     </param>
     <param>
-      <key>t_scale</key>
-      <value>20.0/sample_rate</value>
+      <key>frequency</key>
+      <value>freq</value>
     </param>
     <param>
-      <key>ac_couple</key>
-      <value>False</value>
+      <key>lo_offset</key>
+      <value>float('inf')</value>
     </param>
     <param>
-      <key>xy_mode</key>
-      <value>False</value>
+      <key>gain</key>
+      <value>gain</value>
     </param>
     <param>
-      <key>num_inputs</key>
-      <value>1</value>
+      <key>side</key>
+      <value>side</value>
     </param>
     <param>
-      <key>grid_pos</key>
-      <value>1, 0, 1, 1</value>
+      <key>rx_ant</key>
+      <value>RXA</value>
     </param>
     <param>
-      <key>notebook</key>
-      <value>displays, 0</value>
+      <key>hb_filters</key>
+      <value></value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(406, 838)</value>
+      <value>(89, 689)</value>
     </param>
     <param>
       <key>_rotation</key>
       <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>_coordinate</key>
-      <value>(406, 466)</value>
+      <value>(477, 457)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>wxgui_scopesink2</key>
+    <key>gr_binary_slicer_fb</key>
     <param>
       <key>id</key>
-      <value>pll_scope</value>
+      <value>gr_binary_slicer_fb_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>type</key>
-      <value>float</value>
-    </param>
-    <param>
-      <key>title</key>
-      <value>Demod Waveform</value>
-    </param>
-    <param>
-      <key>samp_rate</key>
-      <value>sample_rate</value>
-    </param>
-    <param>
-      <key>v_scale</key>
-      <value>0.5</value>
-    </param>
-    <param>
-      <key>t_scale</key>
-      <value>20.0/sample_rate</value>
-    </param>
-    <param>
-      <key>ac_couple</key>
-      <value>False</value>
-    </param>
-    <param>
-      <key>xy_mode</key>
-      <value>False</value>
+      <key>_coordinate</key>
+      <value>(393, 975)</value>
     </param>
     <param>
-      <key>num_inputs</key>
-      <value>1</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_deframer</key>
     <param>
-      <key>grid_pos</key>
-      <value>0, 0, 1, 1</value>
+      <key>id</key>
+      <value>deframer</value>
     </param>
     <param>
-      <key>notebook</key>
-      <value>displays, 1</value>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(605, 552)</value>
+      <value>(762, 975)</value>
     </param>
     <param>
       <key>_rotation</key>
-      <value>180</value>
+      <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>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
   <connection>
     <source_block_id>deframer</source_block_id>
     <sink_block_id>frame_sink</sink_block_id>
     <sink_key>0</sink_key>
   </connection>
   <connection>
-    <source_block_id>sync</source_block_id>
-    <sink_block_id>deframer</sink_block_id>
+    <source_block_id>deframer</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>pll</source_block_id>
-    <sink_block_id>sync</sink_block_id>
+    <source_block_id>gr_clock_recovery_mm_xx_0</source_block_id>
+    <sink_block_id>virtual_sink_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>pll_scope</sink_block_id>
+    <source_block_id>gr_clock_recovery_mm_xx_0</source_block_id>
+    <sink_block_id>demod_scope</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>rx_scope</sink_block_id>
+    <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>agc</source_block_id>
-    <sink_block_id>rx_fft</sink_block_id>
+    <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>deframer</source_block_id>
-    <sink_block_id>decoder</sink_block_id>
+    <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>agc</source_block_id>
-    <sink_block_id>gr_fir_filter_xxx_0</sink_block_id>
+    <source_block_id>usrp_source</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>gr_fir_filter_xxx_0</source_block_id>
-    <sink_block_id>pll</sink_block_id>
+    <source_block_id>agc</source_block_id>
+    <sink_block_id>rx_fft</sink_block_id>
     <source_key>0</source_key>
     <sink_key>0</sink_key>
   </connection>
   <connection>
-    <source_block_id>usrp_source</source_block_id>
-    <sink_block_id>agc</sink_block_id>
+    <source_block_id>gr_binary_slicer_fb_0</source_block_id>
+    <sink_block_id>deframer</sink_block_id>
     <source_key>0</source_key>
     <sink_key>0</sink_key>
   </connection>
index ae70f25c8ce0d3733b2a10ca392207d323d4185f..a5f9a8e946148febdbca5407b72e0b754cd39e14 100755 (executable)
@@ -2,12 +2,13 @@
 ##################################################
 # Gnuradio Python Flow Graph
 # Title: USRP HRPT Receiver
-# Generated: Sun Sep 27 13:37:23 2009
+# Generated: Mon Nov  2 08:31:10 2009
 ##################################################
 
 from gnuradio import eng_notation
 from gnuradio import gr
 from gnuradio import noaa
+from gnuradio import window
 from gnuradio.eng_option import eng_option
 from gnuradio.gr import firdes
 from gnuradio.wxgui import fftsink2
@@ -17,7 +18,7 @@ from grc_gnuradio import usrp as grc_usrp
 from grc_gnuradio import wxgui as grc_wxgui
 from optparse import OptionParser
 import ConfigParser
-import math
+import math, os
 import wx
 
 class usrp_rx_hrpt(grc_wxgui.top_block_gui):
@@ -28,10 +29,10 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                ##################################################
                # Variables
                ##################################################
-               self.config_filename = config_filename = 'usrp_rx_hrpt.cfg'
+               self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/config.conf'
                self._decim_config = ConfigParser.ConfigParser()
                self._decim_config.read(config_filename)
-               try: decim = self._decim_config.getfloat('usrp', 'decim')
+               try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim')
                except: decim = 16
                self.decim = decim
                self.sym_rate = sym_rate = 600*1109
@@ -39,79 +40,55 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self.sps = sps = sample_rate/sym_rate
                self._side_config = ConfigParser.ConfigParser()
                self._side_config.read(config_filename)
-               try: side = self._side_config.get('usrp', 'side')
+               try: side = self._side_config.get('usrp_rx_hrpt', 'side')
                except: side = 'A'
                self.side = side
-               self._saved_sync_alpha_config = ConfigParser.ConfigParser()
-               self._saved_sync_alpha_config.read(config_filename)
-               try: saved_sync_alpha = self._saved_sync_alpha_config.getfloat('demod', 'sync_alpha')
-               except: saved_sync_alpha = 0.05
-               self.saved_sync_alpha = saved_sync_alpha
                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('demod', 'pll_alpha')
+               try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha')
                except: saved_pll_alpha = 0.05
                self.saved_pll_alpha = saved_pll_alpha
                self._saved_gain_config = ConfigParser.ConfigParser()
                self._saved_gain_config.read(config_filename)
-               try: saved_gain = self._saved_gain_config.getfloat('usrp', 'gain')
+               try: saved_gain = self._saved_gain_config.getfloat('usrp_rx_hrpt', 'gain')
                except: saved_gain = 35
                self.saved_gain = saved_gain
                self._saved_freq_config = ConfigParser.ConfigParser()
                self._saved_freq_config.read(config_filename)
-               try: saved_freq = self._saved_freq_config.getfloat('usrp', 'freq')
+               try: saved_freq = self._saved_freq_config.getfloat('usrp_rx_hrpt', 'freq')
                except: saved_freq = 1698e6
                self.saved_freq = saved_freq
-               self.hs = hs = int(sps/2.0)
-               self.sync_alpha = sync_alpha = saved_sync_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
+               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('output', 'filename')
+               try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename')
                except: output_filename = 'frames.dat'
                self.output_filename = output_filename
-               self.mf_taps = mf_taps = [-0.5/hs,]*hs+[0.5/hs]*hs
-               self.max_sync_offset = max_sync_offset = 0.01
+               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)
                self.gain = gain = saved_gain
                self.freq = freq = saved_freq
                self.decim_text = decim_text = decim
+               self.clock_alpha = clock_alpha = saved_clock_alpha
 
                ##################################################
                # Notebooks
                ##################################################
                self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
-               self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX")
+               self.displays.AddPage(grc_wxgui.Panel(self.displays), "Spectrum")
                self.displays.AddPage(grc_wxgui.Panel(self.displays), "Demod")
                self.GridAdd(self.displays, 2, 0, 1, 4)
 
                ##################################################
                # Controls
                ##################################################
-               _sync_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
-               self._sync_alpha_text_box = forms.text_box(
-                       parent=self.GetWin(),
-                       sizer=_sync_alpha_sizer,
-                       value=self.sync_alpha,
-                       callback=self.set_sync_alpha,
-                       label="SYNC Alpha",
-                       converter=forms.float_converter(),
-                       proportion=0,
-               )
-               self._sync_alpha_slider = forms.slider(
-                       parent=self.GetWin(),
-                       sizer=_sync_alpha_sizer,
-                       value=self.sync_alpha,
-                       callback=self.set_sync_alpha,
-                       minimum=0.0,
-                       maximum=0.5,
-                       num_steps=100,
-                       style=wx.SL_HORIZONTAL,
-                       cast=float,
-                       proportion=1,
-               )
-               self.GridAdd(_sync_alpha_sizer, 0, 3, 1, 1)
                self._side_text_static_text = forms.static_text(
                        parent=self.GetWin(),
                        value=self.side_text,
@@ -182,6 +159,29 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                        converter=forms.float_converter(),
                )
                self.GridAdd(self._decim_text_static_text, 1, 1, 1, 1)
+               _clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
+               self._clock_alpha_text_box = forms.text_box(
+                       parent=self.GetWin(),
+                       sizer=_clock_alpha_sizer,
+                       value=self.clock_alpha,
+                       callback=self.set_clock_alpha,
+                       label="Clock Alpha",
+                       converter=forms.float_converter(),
+                       proportion=0,
+               )
+               self._clock_alpha_slider = forms.slider(
+                       parent=self.GetWin(),
+                       sizer=_clock_alpha_sizer,
+                       value=self.clock_alpha,
+                       callback=self.set_clock_alpha,
+                       minimum=0.0,
+                       maximum=0.5,
+                       num_steps=100,
+                       style=wx.SL_HORIZONTAL,
+                       cast=float,
+                       proportion=1,
+               )
+               self.GridAdd(_clock_alpha_sizer, 0, 3, 1, 1)
 
                ##################################################
                # Blocks
@@ -189,20 +189,23 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0)
                self.decoder = noaa.hrpt_decoder()
                self.deframer = noaa.hrpt_deframer()
-               self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename)
-               self.gr_fir_filter_xxx_0 = gr.fir_filter_ccc(1, (mf_taps))
-               self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
-               self.pll_scope = scopesink2.scope_sink_f(
+               self.demod_scope = scopesink2.scope_sink_f(
                        self.displays.GetPage(1).GetWin(),
-                       title="Demod Waveform",
-                       sample_rate=sample_rate,
+                       title="Post-Demod",
+                       sample_rate=sym_rate*2.0,
                        v_scale=0.5,
-                       t_scale=20.0/sample_rate,
+                       v_offset=0,
+                       t_scale=10.0/sym_rate,
                        ac_couple=False,
                        xy_mode=False,
                        num_inputs=1,
                )
-               self.displays.GetPage(1).GridAdd(self.pll_scope.win, 0, 0, 1, 1)
+               self.displays.GetPage(1).GridAdd(self.demod_scope.win, 0, 0, 1, 1)
+               self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename)
+               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_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
+               self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
                self.rx_fft = fftsink2.fft_sink_c(
                        self.displays.GetPage(0).GetWin(),
                        baseband_freq=freq,
@@ -217,20 +220,9 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                        avg_alpha=0.1,
                        title="RX Spectrum",
                        peak_hold=False,
+                       size=(640, 360),
                )
                self.displays.GetPage(0).GridAdd(self.rx_fft.win, 0, 0, 1, 1)
-               self.rx_scope = scopesink2.scope_sink_c(
-                       self.displays.GetPage(0).GetWin(),
-                       title="RX Waveform",
-                       sample_rate=sample_rate,
-                       v_scale=0,
-                       t_scale=20.0/sample_rate,
-                       ac_couple=False,
-                       xy_mode=False,
-                       num_inputs=1,
-               )
-               self.displays.GetPage(0).GridAdd(self.rx_scope.win, 1, 0, 1, 1)
-               self.sync = noaa.hrpt_sync_fb(sync_alpha, sync_alpha**2/4.0, sps, max_sync_offset)
                self.usrp_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA")
                self.usrp_source.set_decim_rate(decim)
                self.usrp_source.set_frequency(freq, verbose=True)
@@ -239,104 +231,100 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                ##################################################
                # Connections
                ##################################################
+               self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0))
                self.connect((self.deframer, 0), (self.frame_sink, 0))
-               self.connect((self.sync, 0), (self.deframer, 0))
-               self.connect((self.pll, 0), (self.sync, 0))
-               self.connect((self.pll, 0), (self.pll_scope, 0))
-               self.connect((self.agc, 0), (self.rx_scope, 0))
-               self.connect((self.agc, 0), (self.rx_fft, 0))
                self.connect((self.deframer, 0), (self.decoder, 0))
-               self.connect((self.agc, 0), (self.gr_fir_filter_xxx_0, 0))
-               self.connect((self.gr_fir_filter_xxx_0, 0), (self.pll, 0))
+               self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.demod_scope, 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.agc, 0), (self.pll, 0))
                self.connect((self.usrp_source, 0), (self.agc, 0))
+               self.connect((self.agc, 0), (self.rx_fft, 0))
+               self.connect((self.gr_binary_slicer_fb_0, 0), (self.deframer, 0))
 
        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'):
-                       self._side_config.add_section('usrp')
-               self._side_config.set('usrp', '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'):
-                       self._decim_config.add_section('usrp')
-               self._decim_config.set('usrp', 'decim', str(self.decim))
-               self._decim_config.write(open(self.config_filename, 'w'))
                self._saved_freq_config = ConfigParser.ConfigParser()
                self._saved_freq_config.read(self.config_filename)
-               if not self._saved_freq_config.has_section('usrp'):
-                       self._saved_freq_config.add_section('usrp')
-               self._saved_freq_config.set('usrp', 'freq', str(self.freq))
+               if not self._saved_freq_config.has_section('usrp_rx_hrpt'):
+                       self._saved_freq_config.add_section('usrp_rx_hrpt')
+               self._saved_freq_config.set('usrp_rx_hrpt', 'freq', str(self.freq))
                self._saved_freq_config.write(open(self.config_filename, 'w'))
                self._saved_gain_config = ConfigParser.ConfigParser()
                self._saved_gain_config.read(self.config_filename)
-               if not self._saved_gain_config.has_section('usrp'):
-                       self._saved_gain_config.add_section('usrp')
-               self._saved_gain_config.set('usrp', 'gain', str(self.gain))
+               if not self._saved_gain_config.has_section('usrp_rx_hrpt'):
+                       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._saved_pll_alpha_config = ConfigParser.ConfigParser()
-               self._saved_pll_alpha_config.read(self.config_filename)
-               if not self._saved_pll_alpha_config.has_section('demod'):
-                       self._saved_pll_alpha_config.add_section('demod')
-               self._saved_pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha))
-               self._saved_pll_alpha_config.write(open(self.config_filename, 'w'))
-               self._saved_sync_alpha_config = ConfigParser.ConfigParser()
-               self._saved_sync_alpha_config.read(self.config_filename)
-               if not self._saved_sync_alpha_config.has_section('demod'):
-                       self._saved_sync_alpha_config.add_section('demod')
-               self._saved_sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha))
-               self._saved_sync_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('output'):
-                       self._output_filename_config.add_section('output')
-               self._output_filename_config.set('output', 'filename', str(self.output_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'):
+                       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._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._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'))
 
        def set_decim(self, decim):
                self.decim = decim
                self.set_sample_rate(64e6/self.decim)
+               self.set_decim_text(self.decim)
                self._decim_config = ConfigParser.ConfigParser()
                self._decim_config.read(self.config_filename)
-               if not self._decim_config.has_section('usrp'):
-                       self._decim_config.add_section('usrp')
-               self._decim_config.set('usrp', 'decim', str(self.decim))
+               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.set_decim_text(self.decim)
                self.usrp_source.set_decim_rate(self.decim)
 
        def set_sym_rate(self, sym_rate):
                self.sym_rate = sym_rate
                self.set_sps(self.sample_rate/self.sym_rate)
+               self.demod_scope.set_sample_rate(self.sym_rate*2.0)
 
        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_scope.set_sample_rate(self.sample_rate)
                self.rx_fft.set_sample_rate(self.sample_rate)
-               self.pll_scope.set_sample_rate(self.sample_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_side(self, side):
                self.side = side
                self.set_side_text(self.side)
                self._side_config = ConfigParser.ConfigParser()
                self._side_config.read(self.config_filename)
-               if not self._side_config.has_section('usrp'):
-                       self._side_config.add_section('usrp')
-               self._side_config.set('usrp', 'side', str(self.side))
+               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_saved_sync_alpha(self, saved_sync_alpha):
-               self.saved_sync_alpha = saved_sync_alpha
-               self.set_sync_alpha(self.saved_sync_alpha)
-
        def set_saved_pll_alpha(self, saved_pll_alpha):
                self.saved_pll_alpha = saved_pll_alpha
                self.set_pll_alpha(self.saved_pll_alpha)
@@ -349,22 +337,9 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self.saved_freq = saved_freq
                self.set_freq(self.saved_freq)
 
-       def set_hs(self, hs):
-               self.hs = hs
-               self.set_mf_taps([-0.5/self.hs,]*self.hs+[0.5/self.hs]*self.hs)
-
-       def set_sync_alpha(self, sync_alpha):
-               self.sync_alpha = sync_alpha
-               self._sync_alpha_slider.set_value(self.sync_alpha)
-               self._sync_alpha_text_box.set_value(self.sync_alpha)
-               self._saved_sync_alpha_config = ConfigParser.ConfigParser()
-               self._saved_sync_alpha_config.read(self.config_filename)
-               if not self._saved_sync_alpha_config.has_section('demod'):
-                       self._saved_sync_alpha_config.add_section('demod')
-               self._saved_sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha))
-               self._saved_sync_alpha_config.write(open(self.config_filename, 'w'))
-               self.sync.set_alpha(self.sync_alpha)
-               self.sync.set_beta(self.sync_alpha**2/4.0)
+       def set_saved_clock_alpha(self, saved_clock_alpha):
+               self.saved_clock_alpha = saved_clock_alpha
+               self.set_clock_alpha(self.saved_clock_alpha)
 
        def set_side_text(self, side_text):
                self.side_text = side_text
@@ -376,9 +351,9 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self._pll_alpha_text_box.set_value(self.pll_alpha)
                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('demod'):
-                       self._saved_pll_alpha_config.add_section('demod')
-               self._saved_pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha))
+               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)
@@ -387,32 +362,31 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self.output_filename = output_filename
                self._output_filename_config = ConfigParser.ConfigParser()
                self._output_filename_config.read(self.config_filename)
-               if not self._output_filename_config.has_section('output'):
-                       self._output_filename_config.add_section('output')
-               self._output_filename_config.set('output', 'filename', str(self.output_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_mf_taps(self, mf_taps):
-               self.mf_taps = mf_taps
-               self.gr_fir_filter_xxx_0.set_taps((self.mf_taps))
-
-       def set_max_sync_offset(self, max_sync_offset):
-               self.max_sync_offset = max_sync_offset
-               self.sync.set_max_offset(self.max_sync_offset)
+       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)
+
        def set_gain(self, gain):
                self.gain = gain
                self._gain_slider.set_value(self.gain)
                self._gain_text_box.set_value(self.gain)
                self._saved_gain_config = ConfigParser.ConfigParser()
                self._saved_gain_config.read(self.config_filename)
-               if not self._saved_gain_config.has_section('usrp'):
-                       self._saved_gain_config.add_section('usrp')
-               self._saved_gain_config.set('usrp', 'gain', str(self.gain))
+               if not self._saved_gain_config.has_section('usrp_rx_hrpt'):
+                       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.usrp_source.set_gain(self.gain)
 
@@ -421,9 +395,9 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self._freq_text_box.set_value(self.freq)
                self._saved_freq_config = ConfigParser.ConfigParser()
                self._saved_freq_config.read(self.config_filename)
-               if not self._saved_freq_config.has_section('usrp'):
-                       self._saved_freq_config.add_section('usrp')
-               self._saved_freq_config.set('usrp', 'freq', str(self.freq))
+               if not self._saved_freq_config.has_section('usrp_rx_hrpt'):
+                       self._saved_freq_config.add_section('usrp_rx_hrpt')
+               self._saved_freq_config.set('usrp_rx_hrpt', 'freq', str(self.freq))
                self._saved_freq_config.write(open(self.config_filename, 'w'))
                self.usrp_source.set_frequency(self.freq)
                self.rx_fft.set_baseband_freq(self.freq)
@@ -432,6 +406,19 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui):
                self.decim_text = decim_text
                self._decim_text_static_text.set_value(self.decim_text)
 
+       def set_clock_alpha(self, clock_alpha):
+               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._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]")
        (options, args) = parser.parse_args()
diff --git a/gr-noaa/apps/usrp_rx_hrpt2.grc b/gr-noaa/apps/usrp_rx_hrpt2.grc
deleted file mode 100644 (file)
index d42a9ea..0000000
+++ /dev/null
@@ -1,1418 +0,0 @@
-<?xml version='1.0' encoding='ASCII'?>
-<flow_graph>
-  <timestamp>Sun Sep 27 13:32:47 2009</timestamp>
-  <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_slider</key>
-    <param>
-      <key>id</key>
-      <value>gain</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>label</key>
-      <value>RX Gain</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>saved_gain</value>
-    </param>
-    <param>
-      <key>min</key>
-      <value>0</value>
-    </param>
-    <param>
-      <key>max</key>
-      <value>100</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>0, 1, 1, 1</value>
-    </param>
-    <param>
-      <key>notebook</key>
-      <value></value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(340, 106)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable_text_box</key>
-    <param>
-      <key>id</key>
-      <value>freq</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>label</key>
-      <value>Frequency</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>saved_freq</value>
-    </param>
-    <param>
-      <key>converver</key>
-      <value>float_converter</value>
-    </param>
-    <param>
-      <key>formatter</key>
-      <value>None</value>
-    </param>
-    <param>
-      <key>grid_pos</key>
-      <value>0, 0, 1, 1</value>
-    </param>
-    <param>
-      <key>notebook</key>
-      <value></value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(199, 106)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable_slider</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>saved_pll_alpha</value>
-    </param>
-    <param>
-      <key>min</key>
-      <value>0.0</value>
-    </param>
-    <param>
-      <key>max</key>
-      <value>0.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>0, 2, 1, 1</value>
-    </param>
-    <param>
-      <key>notebook</key>
-      <value></value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(479, 106)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable_slider</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>saved_sync_alpha</value>
-    </param>
-    <param>
-      <key>min</key>
-      <value>0.0</value>
-    </param>
-    <param>
-      <key>max</key>
-      <value>0.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>0, 3, 1, 1</value>
-    </param>
-    <param>
-      <key>notebook</key>
-      <value></value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(618, 106)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable_static_text</key>
-    <param>
-      <key>id</key>
-      <value>side_text</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>label</key>
-      <value>USRP Side</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>side</value>
-    </param>
-    <param>
-      <key>converver</key>
-      <value>str_converter</value>
-    </param>
-    <param>
-      <key>formatter</key>
-      <value>None</value>
-    </param>
-    <param>
-      <key>grid_pos</key>
-      <value>1, 0, 1, 1</value>
-    </param>
-    <param>
-      <key>notebook</key>
-      <value></value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(828, 20)</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'</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>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'</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_freq</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>1698e6</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'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'freq'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>freq</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(507, 258)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable_config</key>
-    <param>
-      <key>id</key>
-      <value>saved_gain</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>35</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'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'gain'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>gain</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(664, 259)</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.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>'demod'</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_sync_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>'demod'</value>
-    </param>
-    <param>
-      <key>option</key>
-      <value>'sync_alpha'</value>
-    </param>
-    <param>
-      <key>writeback</key>
-      <value>sync_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.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>'output'</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_static_text</key>
-    <param>
-      <key>id</key>
-      <value>decim_text</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>label</key>
-      <value>Decimation</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>decim</value>
-    </param>
-    <param>
-      <key>converver</key>
-      <value>float_converter</value>
-    </param>
-    <param>
-      <key>formatter</key>
-      <value>None</value>
-    </param>
-    <param>
-      <key>grid_pos</key>
-      <value>1, 1, 1, 1</value>
-    </param>
-    <param>
-      <key>notebook</key>
-      <value></value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(973, 20)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>max_sync_offset</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>0.01</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>
-      <key>id</key>
-      <value>config_filename</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>'usrp_rx_hrpt.cfg'</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(12, 160)</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</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(11, 102)</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>(664, 809)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>noaa_hrpt_sync_fb</key>
-    <param>
-      <key>id</key>
-      <value>sync</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>alpha</key>
-      <value>sync_alpha</value>
-    </param>
-    <param>
-      <key>beta</key>
-      <value>sync_alpha**2/4.0</value>
-    </param>
-    <param>
-      <key>sps</key>
-      <value>sps</value>
-    </param>
-    <param>
-      <key>max_offset</key>
-      <value>max_sync_offset</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(865, 801)</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>(1283, 937)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>noaa_hrpt_deframer</key>
-    <param>
-      <key>id</key>
-      <value>deframer</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(1091, 829)</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>_coordinate</key>
-      <value>(1281, 829)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>wxgui_scopesink2</key>
-    <param>
-      <key>id</key>
-      <value>pll_scope</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>float</value>
-    </param>
-    <param>
-      <key>title</key>
-      <value>Demod Waveform</value>
-    </param>
-    <param>
-      <key>samp_rate</key>
-      <value>sample_rate</value>
-    </param>
-    <param>
-      <key>v_scale</key>
-      <value>0.5</value>
-    </param>
-    <param>
-      <key>t_scale</key>
-      <value>20.0/sample_rate</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>grid_pos</key>
-      <value>2,0,1,4</value>
-    </param>
-    <param>
-      <key>notebook</key>
-      <value></value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(631, 632)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>180</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-6</value>
-    </param>
-    <param>
-      <key>reference</key>
-      <value>1.0</value>
-    </param>
-    <param>
-      <key>gain</key>
-      <value>1.0</value>
-    </param>
-    <param>
-      <key>max_gain</key>
-      <value>1.0</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(269, 801)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_fir_filter_xxx</key>
-    <param>
-      <key>id</key>
-      <value>gr_fir_filter_xxx_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>ccc</value>
-    </param>
-    <param>
-      <key>decim</key>
-      <value>1</value>
-    </param>
-    <param>
-      <key>taps</key>
-      <value>mf_taps</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(418, 817)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>variable</key>
-    <param>
-      <key>id</key>
-      <value>mf_taps</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>value</key>
-      <value>[-0.5/hs,]*hs+[0.5/hs,]*hs</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(830, 154)</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>False</value>
-    </param>
-    <param>
-      <key>file</key>
-      <value>'usrp.dat'</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>(215, 490)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_deinterleave</key>
-    <param>
-      <key>id</key>
-      <value>gr_deinterleave_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>False</value>
-    </param>
-    <param>
-      <key>type</key>
-      <value>float</value>
-    </param>
-    <param>
-      <key>num_streams</key>
-      <value>2</value>
-    </param>
-    <param>
-      <key>vlen</key>
-      <value>1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(598, 485)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_float_to_complex</key>
-    <param>
-      <key>id</key>
-      <value>gr_float_to_complex_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>False</value>
-    </param>
-    <param>
-      <key>vlen</key>
-      <value>1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(801, 485)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>gr_short_to_float</key>
-    <param>
-      <key>id</key>
-      <value>s2f</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>False</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(393, 502)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>virtual_sink</key>
-    <param>
-      <key>id</key>
-      <value>sample_stream</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>False</value>
-    </param>
-    <param>
-      <key>stream_id</key>
-      <value>samples</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(1027, 498)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>usrp_simple_source_x</key>
-    <param>
-      <key>id</key>
-      <value>usrp_source</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</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>decim</value>
-    </param>
-    <param>
-      <key>frequency</key>
-      <value>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>side</value>
-    </param>
-    <param>
-      <key>rx_ant</key>
-      <value>RXA</value>
-    </param>
-    <param>
-      <key>hb_filters</key>
-      <value></value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(63, 785)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>virtual_source</key>
-    <param>
-      <key>id</key>
-      <value>virtual_source_0</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>False</value>
-    </param>
-    <param>
-      <key>stream_id</key>
-      <value>samples</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(69, 671)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <block>
-    <key>options</key>
-    <param>
-      <key>id</key>
-      <value>usrp_rx_hrpt2</value>
-    </param>
-    <param>
-      <key>_enabled</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>title</key>
-      <value>USRP HRPT Receiver</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>wx_gui</value>
-    </param>
-    <param>
-      <key>category</key>
-      <value>Custom</value>
-    </param>
-    <param>
-      <key>run</key>
-      <value>True</value>
-    </param>
-    <param>
-      <key>realtime_scheduling</key>
-      <value>1</value>
-    </param>
-    <param>
-      <key>_coordinate</key>
-      <value>(10, 10)</value>
-    </param>
-    <param>
-      <key>_rotation</key>
-      <value>0</value>
-    </param>
-  </block>
-  <connection>
-    <source_block_id>gr_fir_filter_xxx_0</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>agc</source_block_id>
-    <sink_block_id>gr_fir_filter_xxx_0</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>usrp_source</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>deframer</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>pll</source_block_id>
-    <sink_block_id>pll_scope</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>sync</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>sync</source_block_id>
-    <sink_block_id>deframer</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>deframer</source_block_id>
-    <sink_block_id>frame_sink</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>virtual_source_0</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>file_source</source_block_id>
-    <sink_block_id>s2f</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>s2f</source_block_id>
-    <sink_block_id>gr_deinterleave_0</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>gr_deinterleave_0</source_block_id>
-    <sink_block_id>gr_float_to_complex_0</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>gr_deinterleave_0</source_block_id>
-    <sink_block_id>gr_float_to_complex_0</sink_block_id>
-    <source_key>1</source_key>
-    <sink_key>1</sink_key>
-  </connection>
-  <connection>
-    <source_block_id>gr_float_to_complex_0</source_block_id>
-    <sink_block_id>sample_stream</sink_block_id>
-    <source_key>0</source_key>
-    <sink_key>0</sink_key>
-  </connection>
-</flow_graph>
diff --git a/gr-noaa/apps/usrp_rx_hrpt2.py b/gr-noaa/apps/usrp_rx_hrpt2.py
deleted file mode 100755 (executable)
index 3193351..0000000
+++ /dev/null
@@ -1,401 +0,0 @@
-#!/usr/bin/env python
-##################################################
-# Gnuradio Python Flow Graph
-# Title: USRP HRPT Receiver
-# Generated: Sun Sep 27 13:32:48 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 gnuradio.wxgui import forms
-from gnuradio.wxgui import scopesink2
-from grc_gnuradio import usrp as grc_usrp
-from grc_gnuradio import wxgui as grc_wxgui
-from optparse import OptionParser
-import ConfigParser
-import math
-import wx
-
-class usrp_rx_hrpt2(grc_wxgui.top_block_gui):
-
-       def __init__(self):
-               grc_wxgui.top_block_gui.__init__(self, title="USRP HRPT Receiver")
-
-               ##################################################
-               # Variables
-               ##################################################
-               self.config_filename = config_filename = 'usrp_rx_hrpt.cfg'
-               self._decim_config = ConfigParser.ConfigParser()
-               self._decim_config.read(config_filename)
-               try: decim = self._decim_config.getfloat('usrp', 'decim')
-               except: decim = 16
-               self.decim = decim
-               self.sym_rate = sym_rate = 600*1109
-               self.sample_rate = sample_rate = 64e6/decim
-               self.sps = sps = sample_rate/sym_rate
-               self._side_config = ConfigParser.ConfigParser()
-               self._side_config.read(config_filename)
-               try: side = self._side_config.get('usrp', 'side')
-               except: side = 'A'
-               self.side = side
-               self._saved_sync_alpha_config = ConfigParser.ConfigParser()
-               self._saved_sync_alpha_config.read(config_filename)
-               try: saved_sync_alpha = self._saved_sync_alpha_config.getfloat('demod', 'sync_alpha')
-               except: saved_sync_alpha = 0.05
-               self.saved_sync_alpha = saved_sync_alpha
-               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('demod', 'pll_alpha')
-               except: saved_pll_alpha = 0.05
-               self.saved_pll_alpha = saved_pll_alpha
-               self._saved_gain_config = ConfigParser.ConfigParser()
-               self._saved_gain_config.read(config_filename)
-               try: saved_gain = self._saved_gain_config.getfloat('usrp', 'gain')
-               except: saved_gain = 35
-               self.saved_gain = saved_gain
-               self._saved_freq_config = ConfigParser.ConfigParser()
-               self._saved_freq_config.read(config_filename)
-               try: saved_freq = self._saved_freq_config.getfloat('usrp', 'freq')
-               except: saved_freq = 1698e6
-               self.saved_freq = saved_freq
-               self.hs = hs = int(sps/2.0)
-               self.sync_alpha = sync_alpha = saved_sync_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('output', 'filename')
-               except: output_filename = 'frames.dat'
-               self.output_filename = output_filename
-               self.mf_taps = mf_taps = [-0.5/hs,]*hs+[0.5/hs,]*hs
-               self.max_sync_offset = max_sync_offset = 0.01
-               self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate
-               self.gain = gain = saved_gain
-               self.freq = freq = saved_freq
-               self.decim_text = decim_text = decim
-
-               ##################################################
-               # Controls
-               ##################################################
-               _sync_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
-               self._sync_alpha_text_box = forms.text_box(
-                       parent=self.GetWin(),
-                       sizer=_sync_alpha_sizer,
-                       value=self.sync_alpha,
-                       callback=self.set_sync_alpha,
-                       label="SYNC Alpha",
-                       converter=forms.float_converter(),
-                       proportion=0,
-               )
-               self._sync_alpha_slider = forms.slider(
-                       parent=self.GetWin(),
-                       sizer=_sync_alpha_sizer,
-                       value=self.sync_alpha,
-                       callback=self.set_sync_alpha,
-                       minimum=0.0,
-                       maximum=0.5,
-                       num_steps=100,
-                       style=wx.SL_HORIZONTAL,
-                       cast=float,
-                       proportion=1,
-               )
-               self.GridAdd(_sync_alpha_sizer, 0, 3, 1, 1)
-               self._side_text_static_text = forms.static_text(
-                       parent=self.GetWin(),
-                       value=self.side_text,
-                       callback=self.set_side_text,
-                       label="USRP Side",
-                       converter=forms.str_converter(),
-               )
-               self.GridAdd(self._side_text_static_text, 1, 0, 1, 1)
-               _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
-               self._pll_alpha_text_box = forms.text_box(
-                       parent=self.GetWin(),
-                       sizer=_pll_alpha_sizer,
-                       value=self.pll_alpha,
-                       callback=self.set_pll_alpha,
-                       label="PLL Alpha",
-                       converter=forms.float_converter(),
-                       proportion=0,
-               )
-               self._pll_alpha_slider = forms.slider(
-                       parent=self.GetWin(),
-                       sizer=_pll_alpha_sizer,
-                       value=self.pll_alpha,
-                       callback=self.set_pll_alpha,
-                       minimum=0.0,
-                       maximum=0.5,
-                       num_steps=100,
-                       style=wx.SL_HORIZONTAL,
-                       cast=float,
-                       proportion=1,
-               )
-               self.GridAdd(_pll_alpha_sizer, 0, 2, 1, 1)
-               _gain_sizer = wx.BoxSizer(wx.VERTICAL)
-               self._gain_text_box = forms.text_box(
-                       parent=self.GetWin(),
-                       sizer=_gain_sizer,
-                       value=self.gain,
-                       callback=self.set_gain,
-                       label="RX Gain",
-                       converter=forms.float_converter(),
-                       proportion=0,
-               )
-               self._gain_slider = forms.slider(
-                       parent=self.GetWin(),
-                       sizer=_gain_sizer,
-                       value=self.gain,
-                       callback=self.set_gain,
-                       minimum=0,
-                       maximum=100,
-                       num_steps=100,
-                       style=wx.SL_HORIZONTAL,
-                       cast=float,
-                       proportion=1,
-               )
-               self.GridAdd(_gain_sizer, 0, 1, 1, 1)
-               self._freq_text_box = forms.text_box(
-                       parent=self.GetWin(),
-                       value=self.freq,
-                       callback=self.set_freq,
-                       label="Frequency",
-                       converter=forms.float_converter(),
-               )
-               self.GridAdd(self._freq_text_box, 0, 0, 1, 1)
-               self._decim_text_static_text = forms.static_text(
-                       parent=self.GetWin(),
-                       value=self.decim_text,
-                       callback=self.set_decim_text,
-                       label="Decimation",
-                       converter=forms.float_converter(),
-               )
-               self.GridAdd(self._decim_text_static_text, 1, 1, 1, 1)
-
-               ##################################################
-               # Blocks
-               ##################################################
-               self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0)
-               self.decoder = noaa.hrpt_decoder()
-               self.deframer = noaa.hrpt_deframer()
-               self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename)
-               self.gr_fir_filter_xxx_0 = gr.fir_filter_ccc(1, (mf_taps))
-               self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
-               self.pll_scope = scopesink2.scope_sink_f(
-                       self.GetWin(),
-                       title="Demod Waveform",
-                       sample_rate=sample_rate,
-                       v_scale=0.5,
-                       t_scale=20.0/sample_rate,
-                       ac_couple=False,
-                       xy_mode=False,
-                       num_inputs=1,
-               )
-               self.GridAdd(self.pll_scope.win, 2, 0, 1, 4)
-               self.sync = noaa.hrpt_sync_fb(sync_alpha, sync_alpha**2/4.0, sps, max_sync_offset)
-               self.usrp_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA")
-               self.usrp_source.set_decim_rate(decim)
-               self.usrp_source.set_frequency(freq, verbose=True)
-               self.usrp_source.set_gain(gain)
-
-               ##################################################
-               # Connections
-               ##################################################
-               self.connect((self.gr_fir_filter_xxx_0, 0), (self.pll, 0))
-               self.connect((self.agc, 0), (self.gr_fir_filter_xxx_0, 0))
-               self.connect((self.usrp_source, 0), (self.agc, 0))
-               self.connect((self.deframer, 0), (self.decoder, 0))
-               self.connect((self.pll, 0), (self.pll_scope, 0))
-               self.connect((self.pll, 0), (self.sync, 0))
-               self.connect((self.sync, 0), (self.deframer, 0))
-               self.connect((self.deframer, 0), (self.frame_sink, 0))
-
-       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'):
-                       self._side_config.add_section('usrp')
-               self._side_config.set('usrp', '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'):
-                       self._decim_config.add_section('usrp')
-               self._decim_config.set('usrp', 'decim', str(self.decim))
-               self._decim_config.write(open(self.config_filename, 'w'))
-               self._saved_freq_config = ConfigParser.ConfigParser()
-               self._saved_freq_config.read(self.config_filename)
-               if not self._saved_freq_config.has_section('usrp'):
-                       self._saved_freq_config.add_section('usrp')
-               self._saved_freq_config.set('usrp', 'freq', str(self.freq))
-               self._saved_freq_config.write(open(self.config_filename, 'w'))
-               self._saved_gain_config = ConfigParser.ConfigParser()
-               self._saved_gain_config.read(self.config_filename)
-               if not self._saved_gain_config.has_section('usrp'):
-                       self._saved_gain_config.add_section('usrp')
-               self._saved_gain_config.set('usrp', 'gain', str(self.gain))
-               self._saved_gain_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('demod'):
-                       self._saved_pll_alpha_config.add_section('demod')
-               self._saved_pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha))
-               self._saved_pll_alpha_config.write(open(self.config_filename, 'w'))
-               self._saved_sync_alpha_config = ConfigParser.ConfigParser()
-               self._saved_sync_alpha_config.read(self.config_filename)
-               if not self._saved_sync_alpha_config.has_section('demod'):
-                       self._saved_sync_alpha_config.add_section('demod')
-               self._saved_sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha))
-               self._saved_sync_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('output'):
-                       self._output_filename_config.add_section('output')
-               self._output_filename_config.set('output', '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._decim_config = ConfigParser.ConfigParser()
-               self._decim_config.read(self.config_filename)
-               if not self._decim_config.has_section('usrp'):
-                       self._decim_config.add_section('usrp')
-               self._decim_config.set('usrp', 'decim', str(self.decim))
-               self._decim_config.write(open(self.config_filename, 'w'))
-               self.set_decim_text(self.decim)
-               self.usrp_source.set_decim_rate(self.decim)
-
-       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)
-               self.pll_scope.set_sample_rate(self.sample_rate)
-
-       def set_sps(self, sps):
-               self.sps = sps
-               self.set_hs(int(self.sps/2.0))
-
-       def set_side(self, side):
-               self.side = side
-               self.set_side_text(self.side)
-               self._side_config = ConfigParser.ConfigParser()
-               self._side_config.read(self.config_filename)
-               if not self._side_config.has_section('usrp'):
-                       self._side_config.add_section('usrp')
-               self._side_config.set('usrp', 'side', str(self.side))
-               self._side_config.write(open(self.config_filename, 'w'))
-
-       def set_saved_sync_alpha(self, saved_sync_alpha):
-               self.saved_sync_alpha = saved_sync_alpha
-               self.set_sync_alpha(self.saved_sync_alpha)
-
-       def set_saved_pll_alpha(self, saved_pll_alpha):
-               self.saved_pll_alpha = saved_pll_alpha
-               self.set_pll_alpha(self.saved_pll_alpha)
-
-       def set_saved_gain(self, saved_gain):
-               self.saved_gain = saved_gain
-               self.set_gain(self.saved_gain)
-
-       def set_saved_freq(self, saved_freq):
-               self.saved_freq = saved_freq
-               self.set_freq(self.saved_freq)
-
-       def set_hs(self, hs):
-               self.hs = hs
-               self.set_mf_taps([-0.5/self.hs,]*self.hs+[0.5/self.hs,]*self.hs)
-
-       def set_sync_alpha(self, sync_alpha):
-               self.sync_alpha = sync_alpha
-               self._sync_alpha_slider.set_value(self.sync_alpha)
-               self._sync_alpha_text_box.set_value(self.sync_alpha)
-               self._saved_sync_alpha_config = ConfigParser.ConfigParser()
-               self._saved_sync_alpha_config.read(self.config_filename)
-               if not self._saved_sync_alpha_config.has_section('demod'):
-                       self._saved_sync_alpha_config.add_section('demod')
-               self._saved_sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha))
-               self._saved_sync_alpha_config.write(open(self.config_filename, 'w'))
-               self.sync.set_alpha(self.sync_alpha)
-               self.sync.set_beta(self.sync_alpha**2/4.0)
-
-       def set_side_text(self, side_text):
-               self.side_text = side_text
-               self._side_text_static_text.set_value(self.side_text)
-
-       def set_pll_alpha(self, pll_alpha):
-               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._saved_pll_alpha_config = ConfigParser.ConfigParser()
-               self._saved_pll_alpha_config.read(self.config_filename)
-               if not self._saved_pll_alpha_config.has_section('demod'):
-                       self._saved_pll_alpha_config.add_section('demod')
-               self._saved_pll_alpha_config.set('demod', '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
-               self._output_filename_config = ConfigParser.ConfigParser()
-               self._output_filename_config.read(self.config_filename)
-               if not self._output_filename_config.has_section('output'):
-                       self._output_filename_config.add_section('output')
-               self._output_filename_config.set('output', 'filename', str(self.output_filename))
-               self._output_filename_config.write(open(self.config_filename, 'w'))
-
-       def set_mf_taps(self, mf_taps):
-               self.mf_taps = mf_taps
-               self.gr_fir_filter_xxx_0.set_taps((self.mf_taps))
-
-       def set_max_sync_offset(self, max_sync_offset):
-               self.max_sync_offset = max_sync_offset
-               self.sync.set_max_offset(self.max_sync_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_gain(self, gain):
-               self.gain = gain
-               self._gain_slider.set_value(self.gain)
-               self._gain_text_box.set_value(self.gain)
-               self._saved_gain_config = ConfigParser.ConfigParser()
-               self._saved_gain_config.read(self.config_filename)
-               if not self._saved_gain_config.has_section('usrp'):
-                       self._saved_gain_config.add_section('usrp')
-               self._saved_gain_config.set('usrp', 'gain', str(self.gain))
-               self._saved_gain_config.write(open(self.config_filename, 'w'))
-               self.usrp_source.set_gain(self.gain)
-
-       def set_freq(self, freq):
-               self.freq = freq
-               self._freq_text_box.set_value(self.freq)
-               self._saved_freq_config = ConfigParser.ConfigParser()
-               self._saved_freq_config.read(self.config_filename)
-               if not self._saved_freq_config.has_section('usrp'):
-                       self._saved_freq_config.add_section('usrp')
-               self._saved_freq_config.set('usrp', 'freq', str(self.freq))
-               self._saved_freq_config.write(open(self.config_filename, 'w'))
-               self.usrp_source.set_frequency(self.freq)
-
-       def set_decim_text(self, decim_text):
-               self.decim_text = decim_text
-               self._decim_text_static_text.set_value(self.decim_text)
-
-if __name__ == '__main__':
-       parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
-       (options, args) = parser.parse_args()
-       if gr.enable_realtime_scheduling() != gr.RT_OK:
-               print "Error: failed to enable realtime scheduling."
-       tb = usrp_rx_hrpt2()
-       tb.Run(True)
-
index fadc2d1da51cec6f82cbe18b8fbc1b6cdcd0643c..02d509f08d99bd7b644cbd8a664a3913b2b9264a 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version='1.0' encoding='ASCII'?>
 <flow_graph>
-  <timestamp>Sun Sep 27 10:13:25 2009</timestamp>
+  <timestamp>Mon Nov  2 08:31:35 2009</timestamp>
   <block>
     <key>options</key>
     <param>
@@ -13,7 +13,7 @@
     </param>
     <param>
       <key>title</key>
-      <value>USRP HRPT Receiver</value>
+      <value></value>
     </param>
     <param>
       <key>author</key>
       <key>category</key>
       <value>Custom</value>
     </param>
+    <param>
+      <key>run_options</key>
+      <value>prompt</value>
+    </param>
     <param>
       <key>run</key>
       <value>True</value>
     <key>variable</key>
     <param>
       <key>id</key>
-      <value>max_sync_offset</value>
+      <value>max_clock_offset</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>0.01</value>
+      <value>0.1</value>
     </param>
     <param>
       <key>_coordinate</key>
     </param>
     <param>
       <key>value</key>
-      <value>'usrp_rx_hrpt.cfg'</value>
+      <value>os.environ['HOME']+'/.gnuradio/config.conf'</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(12, 167)</value>
+      <value>(13, 162)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
     <param>
       <key>import</key>
-      <value>import math</value>
+      <value>import math, os</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(11, 112)</value>
+      <value>(11, 109)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>output_filename</value>
+      <value>clock_alpha</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>'frames.dat'</value>
+      <value>0.05</value>
     </param>
     <param>
       <key>type</key>
-      <value>string</value>
+      <value>real</value>
     </param>
     <param>
       <key>config_file</key>
     </param>
     <param>
       <key>section</key>
-      <value>'output'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
-      <value>'filename'</value>
+      <value>'clock_alpha'</value>
     </param>
     <param>
       <key>writeback</key>
-      <value>output_filename</value>
+      <value>clock_alpha</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(1146, 122)</value>
+      <value>(986, 101)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>sync_alpha</value>
+      <value>gain</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>0.05</value>
+      <value>35</value>
     </param>
     <param>
       <key>type</key>
     </param>
     <param>
       <key>section</key>
-      <value>'demod'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
-      <value>'sync_alpha'</value>
+      <value>'gain'</value>
     </param>
     <param>
       <key>writeback</key>
-      <value>sync_alpha</value>
+      <value>gain</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(988, 121)</value>
+      <value>(668, 101)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>pll_alpha</value>
+      <value>freq</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>0.05</value>
+      <value>1698e6</value>
     </param>
     <param>
       <key>type</key>
     </param>
     <param>
       <key>section</key>
-      <value>'demod'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
-      <value>'pll_alpha'</value>
+      <value>'freq'</value>
     </param>
     <param>
       <key>writeback</key>
-      <value>pll_alpha</value>
+      <value>freq</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(830, 121)</value>
+      <value>(511, 100)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>gain</value>
+      <value>decim</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>35</value>
+      <value>16</value>
     </param>
     <param>
       <key>type</key>
     </param>
     <param>
       <key>section</key>
-      <value>'usrp'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
-      <value>'gain'</value>
+      <value>'decim'</value>
     </param>
     <param>
       <key>writeback</key>
-      <value>gain</value>
+      <value>decim</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(671, 122)</value>
+      <value>(355, 97)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>freq</value>
+      <value>output_filename</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>1698e6</value>
+      <value>'frames.dat'</value>
     </param>
     <param>
       <key>type</key>
-      <value>real</value>
+      <value>string</value>
     </param>
     <param>
       <key>config_file</key>
     </param>
     <param>
       <key>section</key>
-      <value>'usrp'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
-      <value>'freq'</value>
+      <value>'filename'</value>
     </param>
     <param>
       <key>writeback</key>
-      <value>freq</value>
+      <value>output_filename</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(514, 121)</value>
+      <value>(1143, 101)</value>
     </param>
     <param>
       <key>_rotation</key>
     <key>variable_config</key>
     <param>
       <key>id</key>
-      <value>decim</value>
+      <value>pll_alpha</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>value</key>
-      <value>16</value>
+      <value>0.05</value>
     </param>
     <param>
       <key>type</key>
     </param>
     <param>
       <key>section</key>
-      <value>'usrp'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
-      <value>'decim'</value>
+      <value>'pll_alpha'</value>
     </param>
     <param>
       <key>writeback</key>
-      <value>decim</value>
+      <value>pll_alpha</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(358, 118)</value>
+      <value>(827, 100)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
     <param>
       <key>section</key>
-      <value>'usrp'</value>
+      <value>'usrp_rx_hrpt'</value>
     </param>
     <param>
       <key>option</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(201, 116)</value>
+      <value>(198, 95)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_decoder</key>
+    <key>gr_agc_xx</key>
     <param>
       <key>id</key>
-      <value>decoder</value>
+      <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-6</value>
+    </param>
+    <param>
+      <key>reference</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>gain</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>max_gain</key>
+      <value>1.0</value>
+    </param>
     <param>
       <key>_coordinate</key>
-      <value>(1247, 347)</value>
+      <value>(339, 434)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(29, 303)</value>
+      <value>(127, 418)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>variable</key>
+    <key>gr_clock_recovery_mm_xx</key>
     <param>
       <key>id</key>
-      <value>mf_taps</value>
+      <value>gr_clock_recovery_mm_xx_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>value</key>
-      <value>[-0.5/hs,]*hs+[0.5/hs,]*hs</value>
+      <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>(825, 19)</value>
+      <value>(920, 426)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>gr_agc_xx</key>
+    <key>gr_moving_average_xx</key>
     <param>
       <key>id</key>
-      <value>agc</value>
+      <value>gr_moving_average_xx_0</value>
     </param>
     <param>
       <key>_enabled</key>
     </param>
     <param>
       <key>type</key>
-      <value>complex</value>
+      <value>float</value>
     </param>
     <param>
-      <key>rate</key>
-      <value>1e-6</value>
+      <key>length</key>
+      <value>hs</value>
     </param>
     <param>
-      <key>reference</key>
-      <value>1.0</value>
+      <key>scale</key>
+      <value>1.0/hs</value>
     </param>
     <param>
-      <key>gain</key>
-      <value>1.0</value>
+      <key>max_iter</key>
+      <value>4000</value>
     </param>
     <param>
-      <key>max_gain</key>
-      <value>1.0</value>
+      <key>_coordinate</key>
+      <value>(720, 442)</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>(246, 319)</value>
+      <value>(507, 442)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_deframer</key>
+    <key>virtual_sink</key>
     <param>
       <key>id</key>
-      <value>deframer</value>
+      <value>virtual_sink_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
+    <param>
+      <key>stream_id</key>
+      <value>baseband</value>
+    </param>
     <param>
       <key>_coordinate</key>
-      <value>(1060, 347)</value>
+      <value>(1180, 457)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(1251, 454)</value>
+      <value>(1026, 722)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_sync_fb</key>
+    <key>virtual_source</key>
     <param>
       <key>id</key>
-      <value>sync</value>
+      <value>virtual_source_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>alpha</key>
-      <value>sync_alpha</value>
-    </param>
-    <param>
-      <key>beta</key>
-      <value>sync_alpha**2/4.0</value>
-    </param>
-    <param>
-      <key>sps</key>
-      <value>sps</value>
-    </param>
-    <param>
-      <key>max_offset</key>
-      <value>max_sync_offset</value>
+      <key>stream_id</key>
+      <value>baseband</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(833, 319)</value>
+      <value>(226, 669)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>noaa_hrpt_pll_cf</key>
+    <key>noaa_hrpt_decoder</key>
     <param>
       <key>id</key>
-      <value>pll</value>
+      <value>decoder</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>(638, 327)</value>
+      <value>(1027, 623)</value>
     </param>
     <param>
       <key>_rotation</key>
     </param>
   </block>
   <block>
-    <key>gr_fir_filter_xxx</key>
+    <key>gr_binary_slicer_fb</key>
     <param>
       <key>id</key>
-      <value>gr_fir_filter_xxx_0</value>
+      <value>gr_binary_slicer_fb_0</value>
     </param>
     <param>
       <key>_enabled</key>
       <value>True</value>
     </param>
     <param>
-      <key>type</key>
-      <value>ccc</value>
+      <key>_coordinate</key>
+      <value>(446, 673)</value>
     </param>
     <param>
-      <key>decim</key>
-      <value>1</value>
+      <key>_rotation</key>
+      <value>0</value>
     </param>
+  </block>
+  <block>
+    <key>noaa_hrpt_deframer</key>
     <param>
-      <key>taps</key>
-      <value>mf_taps</value>
+      <key>id</key>
+      <value>deframer</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(402, 335)</value>
+      <value>(815, 673)</value>
     </param>
     <param>
       <key>_rotation</key>
     <sink_key>0</sink_key>
   </connection>
   <connection>
-    <source_block_id>deframer</source_block_id>
-    <sink_block_id>decoder</sink_block_id>
+    <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>pll</source_block_id>
-    <sink_block_id>sync</sink_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>sync</source_block_id>
-    <sink_block_id>deframer</sink_block_id>
+    <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>gr_clock_recovery_mm_xx_0</source_block_id>
+    <sink_block_id>virtual_sink_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>virtual_source_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>
     <sink_key>0</sink_key>
   </connection>
   <connection>
-    <source_block_id>agc</source_block_id>
-    <sink_block_id>gr_fir_filter_xxx_0</sink_block_id>
+    <source_block_id>deframer</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_fir_filter_xxx_0</source_block_id>
-    <sink_block_id>pll</sink_block_id>
+    <source_block_id>gr_binary_slicer_fb_0</source_block_id>
+    <sink_block_id>deframer</sink_block_id>
     <source_key>0</source_key>
     <sink_key>0</sink_key>
   </connection>
index 9917847bb81d7b03f8844d8c4a7552a8610a851f..4dc32dbda9df8686c3f346ba5a9f124bb73d3643 100755 (executable)
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 ##################################################
 # Gnuradio Python Flow Graph
-# Title: USRP HRPT Receiver
-# Generated: Sun Sep 27 10:13:25 2009
+# Title: Usrp Rx Hrpt Nogui
+# Generated: Mon Nov  2 08:31:35 2009
 ##################################################
 
 from gnuradio import eng_notation
@@ -13,59 +13,58 @@ from gnuradio.gr import firdes
 from grc_gnuradio import usrp as grc_usrp
 from optparse import OptionParser
 import ConfigParser
-import math
+import math, os
 
 class usrp_rx_hrpt_nogui(gr.top_block):
 
        def __init__(self):
-               gr.top_block.__init__(self, "USRP HRPT Receiver")
+               gr.top_block.__init__(self, "Usrp Rx Hrpt Nogui")
 
                ##################################################
                # Variables
                ##################################################
-               self.config_filename = config_filename = 'usrp_rx_hrpt.cfg'
+               self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/config.conf'
                self._decim_config = ConfigParser.ConfigParser()
                self._decim_config.read(config_filename)
-               try: decim = self._decim_config.getfloat('usrp', 'decim')
+               try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim')
                except: decim = 16
                self.decim = decim
                self.sym_rate = sym_rate = 600*1109
                self.sample_rate = sample_rate = 64e6/decim
                self.sps = sps = sample_rate/sym_rate
-               self.hs = hs = int(sps/2.0)
-               self._sync_alpha_config = ConfigParser.ConfigParser()
-               self._sync_alpha_config.read(config_filename)
-               try: sync_alpha = self._sync_alpha_config.getfloat('demod', 'sync_alpha')
-               except: sync_alpha = 0.05
-               self.sync_alpha = sync_alpha
                self._side_config = ConfigParser.ConfigParser()
                self._side_config.read(config_filename)
-               try: side = self._side_config.get('usrp', 'side')
+               try: side = self._side_config.get('usrp_rx_hrpt', 'side')
                except: side = 'A'
                self.side = side
                self._pll_alpha_config = ConfigParser.ConfigParser()
                self._pll_alpha_config.read(config_filename)
-               try: pll_alpha = self._pll_alpha_config.getfloat('demod', 'pll_alpha')
+               try: pll_alpha = self._pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha')
                except: pll_alpha = 0.05
                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('output', 'filename')
+               try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename')
                except: output_filename = 'frames.dat'
                self.output_filename = output_filename
-               self.mf_taps = mf_taps = [-0.5/hs,]*hs+[0.5/hs,]*hs
-               self.max_sync_offset = max_sync_offset = 0.01
+               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)
                self._gain_config = ConfigParser.ConfigParser()
                self._gain_config.read(config_filename)
-               try: gain = self._gain_config.getfloat('usrp', 'gain')
+               try: gain = self._gain_config.getfloat('usrp_rx_hrpt', 'gain')
                except: gain = 35
                self.gain = gain
                self._freq_config = ConfigParser.ConfigParser()
                self._freq_config.read(config_filename)
-               try: freq = self._freq_config.getfloat('usrp', 'freq')
+               try: freq = self._freq_config.getfloat('usrp_rx_hrpt', 'freq')
                except: freq = 1698e6
                self.freq = freq
+               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
+               self.clock_alpha = clock_alpha
 
                ##################################################
                # Blocks
@@ -74,9 +73,10 @@ class usrp_rx_hrpt_nogui(gr.top_block):
                self.decoder = noaa.hrpt_decoder()
                self.deframer = noaa.hrpt_deframer()
                self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename)
-               self.gr_fir_filter_xxx_0 = gr.fir_filter_ccc(1, (mf_taps))
+               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_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
                self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
-               self.sync = noaa.hrpt_sync_fb(sync_alpha, sync_alpha**2/4.0, sps, max_sync_offset)
                self.usrp_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA")
                self.usrp_source.set_decim_rate(decim)
                self.usrp_source.set_frequency(freq, verbose=True)
@@ -86,56 +86,57 @@ class usrp_rx_hrpt_nogui(gr.top_block):
                # Connections
                ##################################################
                self.connect((self.usrp_source, 0), (self.agc, 0))
-               self.connect((self.deframer, 0), (self.decoder, 0))
-               self.connect((self.pll, 0), (self.sync, 0))
-               self.connect((self.sync, 0), (self.deframer, 0))
+               self.connect((self.agc, 0), (self.pll, 0))
+               self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
+               self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0))
+               self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0))
                self.connect((self.deframer, 0), (self.frame_sink, 0))
-               self.connect((self.agc, 0), (self.gr_fir_filter_xxx_0, 0))
-               self.connect((self.gr_fir_filter_xxx_0, 0), (self.pll, 0))
+               self.connect((self.deframer, 0), (self.decoder, 0))
+               self.connect((self.gr_binary_slicer_fb_0, 0), (self.deframer, 0))
 
        def set_config_filename(self, config_filename):
                self.config_filename = config_filename
-               self._output_filename_config = ConfigParser.ConfigParser()
-               self._output_filename_config.read(self.config_filename)
-               if not self._output_filename_config.has_section('output'):
-                       self._output_filename_config.add_section('output')
-               self._output_filename_config.set('output', 'filename', str(self.output_filename))
-               self._output_filename_config.write(open(self.config_filename, 'w'))
-               self._sync_alpha_config = ConfigParser.ConfigParser()
-               self._sync_alpha_config.read(self.config_filename)
-               if not self._sync_alpha_config.has_section('demod'):
-                       self._sync_alpha_config.add_section('demod')
-               self._sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha))
-               self._sync_alpha_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('demod'):
-                       self._pll_alpha_config.add_section('demod')
-               self._pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha))
-               self._pll_alpha_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._gain_config = ConfigParser.ConfigParser()
                self._gain_config.read(self.config_filename)
-               if not self._gain_config.has_section('usrp'):
-                       self._gain_config.add_section('usrp')
-               self._gain_config.set('usrp', 'gain', str(self.gain))
+               if not self._gain_config.has_section('usrp_rx_hrpt'):
+                       self._gain_config.add_section('usrp_rx_hrpt')
+               self._gain_config.set('usrp_rx_hrpt', 'gain', str(self.gain))
                self._gain_config.write(open(self.config_filename, 'w'))
                self._freq_config = ConfigParser.ConfigParser()
                self._freq_config.read(self.config_filename)
-               if not self._freq_config.has_section('usrp'):
-                       self._freq_config.add_section('usrp')
-               self._freq_config.set('usrp', 'freq', str(self.freq))
+               if not self._freq_config.has_section('usrp_rx_hrpt'):
+                       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._decim_config = ConfigParser.ConfigParser()
                self._decim_config.read(self.config_filename)
-               if not self._decim_config.has_section('usrp'):
-                       self._decim_config.add_section('usrp')
-               self._decim_config.set('usrp', 'decim', str(self.decim))
+               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'):
-                       self._side_config.add_section('usrp')
-               self._side_config.set('usrp', 'side', str(self.side))
+               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_decim(self, decim):
@@ -143,9 +144,9 @@ class usrp_rx_hrpt_nogui(gr.top_block):
                self.set_sample_rate(64e6/self.decim)
                self._decim_config = ConfigParser.ConfigParser()
                self._decim_config.read(self.config_filename)
-               if not self._decim_config.has_section('usrp'):
-                       self._decim_config.add_section('usrp')
-               self._decim_config.set('usrp', 'decim', str(self.decim))
+               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)
 
@@ -161,38 +162,24 @@ class usrp_rx_hrpt_nogui(gr.top_block):
        def set_sps(self, sps):
                self.sps = sps
                self.set_hs(int(self.sps/2.0))
-
-       def set_hs(self, hs):
-               self.hs = hs
-               self.set_mf_taps([-0.5/self.hs,]*self.hs+[0.5/self.hs,]*self.hs)
-
-       def set_sync_alpha(self, sync_alpha):
-               self.sync_alpha = sync_alpha
-               self._sync_alpha_config = ConfigParser.ConfigParser()
-               self._sync_alpha_config.read(self.config_filename)
-               if not self._sync_alpha_config.has_section('demod'):
-                       self._sync_alpha_config.add_section('demod')
-               self._sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha))
-               self._sync_alpha_config.write(open(self.config_filename, 'w'))
-               self.sync.set_alpha(self.sync_alpha)
-               self.sync.set_beta(self.sync_alpha**2/4.0)
+               self.gr_clock_recovery_mm_xx_0.set_omega(self.sps/2.0)
 
        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'):
-                       self._side_config.add_section('usrp')
-               self._side_config.set('usrp', 'side', str(self.side))
+               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_alpha_config = ConfigParser.ConfigParser()
                self._pll_alpha_config.read(self.config_filename)
-               if not self._pll_alpha_config.has_section('demod'):
-                       self._pll_alpha_config.add_section('demod')
-               self._pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha))
+               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)
@@ -201,30 +188,29 @@ class usrp_rx_hrpt_nogui(gr.top_block):
                self.output_filename = output_filename
                self._output_filename_config = ConfigParser.ConfigParser()
                self._output_filename_config.read(self.config_filename)
-               if not self._output_filename_config.has_section('output'):
-                       self._output_filename_config.add_section('output')
-               self._output_filename_config.set('output', 'filename', str(self.output_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_mf_taps(self, mf_taps):
-               self.mf_taps = mf_taps
-               self.gr_fir_filter_xxx_0.set_taps((self.mf_taps))
-
-       def set_max_sync_offset(self, max_sync_offset):
-               self.max_sync_offset = max_sync_offset
-               self.sync.set_max_offset(self.max_sync_offset)
+       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)
+
        def set_gain(self, gain):
                self.gain = gain
                self._gain_config = ConfigParser.ConfigParser()
                self._gain_config.read(self.config_filename)
-               if not self._gain_config.has_section('usrp'):
-                       self._gain_config.add_section('usrp')
-               self._gain_config.set('usrp', 'gain', str(self.gain))
+               if not self._gain_config.has_section('usrp_rx_hrpt'):
+                       self._gain_config.add_section('usrp_rx_hrpt')
+               self._gain_config.set('usrp_rx_hrpt', 'gain', str(self.gain))
                self._gain_config.write(open(self.config_filename, 'w'))
                self.usrp_source.set_gain(self.gain)
 
@@ -232,12 +218,23 @@ class usrp_rx_hrpt_nogui(gr.top_block):
                self.freq = freq
                self._freq_config = ConfigParser.ConfigParser()
                self._freq_config.read(self.config_filename)
-               if not self._freq_config.has_section('usrp'):
-                       self._freq_config.add_section('usrp')
-               self._freq_config.set('usrp', 'freq', str(self.freq))
+               if not self._freq_config.has_section('usrp_rx_hrpt'):
+                       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.usrp_source.set_frequency(self.freq)
 
+       def set_clock_alpha(self, clock_alpha):
+               self.clock_alpha = 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]")
        (options, args) = parser.parse_args()
index a290204b0a45c7950590f88d8c7d1b1e6b86031d..73a0282311649799d710c580c7418758532e43cd 100644 (file)
@@ -26,6 +26,5 @@ grcblocksdir = $(grc_blocksdir)
 dist_grcblocks_DATA = \
        noaa_hrpt_decoder.xml \
        noaa_hrpt_deframer.xml \
-       noaa_hrpt_pll_cf.xml \
-       noaa_hrpt_sync_fb.xml
+       noaa_hrpt_pll_cf.xml
 
diff --git a/gr-noaa/grc/noaa_hrpt_sync_fb.xml b/gr-noaa/grc/noaa_hrpt_sync_fb.xml
deleted file mode 100644 (file)
index e066e34..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0"?>
-<block>
-  <name>HRPT SYNC</name>
-  <key>noaa_hrpt_sync_fb</key>
-  <category>NOAA</category>
-  <import>from gnuradio import noaa</import>
-  <make>noaa.hrpt_sync_fb($alpha, $beta, $sps, $max_offset)</make>
-  <callback>set_alpha($alpha)</callback>
-  <callback>set_beta($beta)</callback>
-  <callback>set_max_offset($max_offset)</callback>
-  <param>
-    <name>Alpha</name>
-    <key>alpha</key>
-    <type>real</type>
-  </param>
-  <param>
-    <name>Beta</name>
-    <key>beta</key>
-    <type>real</type>
-  </param>
-  <param>
-    <name>Samples/Symbol</name>
-    <key>sps</key>
-    <type>real</type>
-  </param>
-  <param>
-    <name>Max Offset</name>
-    <key>max_offset</key>
-    <type>real</type>
-  </param>
-  <sink>
-    <name>in</name>
-    <type>float</type>
-  </sink>
-  <source>
-    <name>out</name>
-    <type>byte</type>
-  </source>
-</block>
index 6435d192e93876b8086fc06e8e3aa3b0e3c6306c..4ef4eb87bdaf884ddeb3862a05f17d3fec38be34 100644 (file)
@@ -31,8 +31,7 @@ lib_LTLIBRARIES = \
 libgnuradio_noaa_la_SOURCES = \
        noaa_hrpt_decoder.cc \
        noaa_hrpt_deframer.cc \
-       noaa_hrpt_pll_cf.cc \
-       noaa_hrpt_sync_fb.cc
+       noaa_hrpt_pll_cf.cc
 
 libgnuradio_noaa_la_LIBADD = \
        $(GNURADIO_CORE_LA)
@@ -42,5 +41,4 @@ libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
 grinclude_HEADERS = \
        noaa_hrpt_decoder.h \
        noaa_hrpt_deframer.h \
-       noaa_hrpt_pll_cf.h \
-       noaa_hrpt_sync_fb.h
+       noaa_hrpt_pll_cf.h
\ No newline at end of file
index 91c94d2a6425540b3df2446f7eace9c4f73fc0b7..e79894869bb7568043a2f1c40ee2e224eaf20393 100644 (file)
@@ -55,6 +55,8 @@ noaa_hrpt_deframer::noaa_hrpt_deframer()
             gr_make_io_signature(1, 1, sizeof(short)))
 {
   set_output_multiple(6); // room for writing full sync when received
+  d_mid_bit = true;
+  d_last_bit = 0;
   enter_idle();
 }
 
@@ -86,38 +88,48 @@ noaa_hrpt_deframer::general_work(int noutput_items,
   int i = 0, j = 0;
   while (i < ninputs && j < noutput_items) {
     char bit = in[i++];
-
-    switch (d_state) {
-    case ST_IDLE:
-      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;
-       enter_synced();
-      }
-      break;
-
-    case ST_SYNCED:
-      d_word = (d_word << 1) | bit; // MSB transmitted first
-      if (--d_bit_count == 0) {
-       out[j++] = d_word;
-       d_word = 0;
-       d_bit_count = HRPT_BITS_PER_WORD;
-       if (--d_word_count == 0) {
-         fprintf(stderr, "...done\n");
-         enter_idle();
+    char diff = bit^d_last_bit;
+    d_last_bit = bit;
+
+    // Wait for transition if not synced, otherwise, alternate bits
+    if (d_mid_bit && (diff | (d_state == ST_SYNCED))) {
+      switch (d_state) {
+      case ST_IDLE:
+       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;
+         enter_synced();
        }
+       break;
+       
+      case ST_SYNCED:
+       d_word = (d_word << 1) | bit; // MSB transmitted first
+       if (--d_bit_count == 0) {
+         out[j++] = d_word;
+         d_word = 0;
+         d_bit_count = HRPT_BITS_PER_WORD;
+         if (--d_word_count == 0) {
+           fprintf(stderr, "...done\n");
+           enter_idle();
+         }
+       }
+       break;
+       
+      default:
+       throw std::runtime_error("noaa_hrpt_deframer: bad state\n");
       }
-      break;
 
-    default:
-      throw std::runtime_error("noaa_hrpt_deframer: bad state\n");
+      d_mid_bit = false;
+    }
+    else {
+      d_mid_bit = true;
     }
   }
 
index 0aeb16a2db51cc78e263ad2acd4dfb97b5332aa2..43abba0e9152bb383c728d07e1766a14d8870b88 100644 (file)
@@ -41,6 +41,8 @@ class noaa_hrpt_deframer : public gr_block
   noaa_hrpt_deframer();
 
   unsigned int       d_state;
+  bool               d_mid_bit;
+  unsigned char      d_last_bit;
   unsigned int       d_bit_count;
   unsigned int       d_word_count;
   unsigned long long d_shifter;     // 60 bit sync word
diff --git a/gr-noaa/lib/noaa_hrpt_sync_fb.cc b/gr-noaa/lib/noaa_hrpt_sync_fb.cc
deleted file mode 100644 (file)
index 9c655b0..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* -*- 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <noaa_hrpt_sync_fb.h>
-#include <gr_io_signature.h>
-
-inline int signum(float f)
-{
-  return f >= 0.0 ? 1 : -1;
-}
-
-noaa_hrpt_sync_fb_sptr
-noaa_make_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset)
-{
-  return gnuradio::get_initial_sptr(new noaa_hrpt_sync_fb(alpha, beta, sps, max_offset));
-}
-
-noaa_hrpt_sync_fb::noaa_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset)
-  : gr_block("noaa_hrpt_sync_fb",
-            gr_make_io_signature(1, 1, sizeof(float)),
-            gr_make_io_signature(1, 1, sizeof(char))),
-    d_alpha(alpha), d_beta(beta), 
-    d_sps(sps), d_max_offset(max_offset),
-    d_phase(0.0), d_freq(1.0/sps),
-    d_last_sign(1)
-{
-}
-
-int
-noaa_hrpt_sync_fb::general_work(int noutput_items,
-                               gr_vector_int &ninput_items,
-                               gr_vector_const_void_star &input_items,
-                               gr_vector_void_star &output_items)
-{
-  int ninputs = ninput_items[0];
-  const float *in = (const float *)input_items[0];
-  char *out = (char *)output_items[0];
-
-  int i = 0, j = 0;
-  while (i < ninputs && j < noutput_items) {
-    float sample = in[i++];
-    int sign = signum(sample);
-    d_phase += d_freq;
-
-    // Train on zero crossings in center region of symbol
-    if (sign != d_last_sign) {
-      float phase_err = 0.0;
-      if (d_phase > 0.25 && d_phase < 0.75)
-       phase_err = d_phase-0.5;
-      else if (d_phase >= 0.75)
-       phase_err = d_phase - 1.0;
-      else
-       phase_err = d_phase;
-
-      d_phase -= phase_err*d_alpha;        // 1st order phase adjustment
-      d_freq -= phase_err*d_beta;          // 2nd order frequency adjustment
-
-      d_last_sign = sign;
-    }
-
-    if (d_phase > 1.0) {
-      if (sample < 0.0)
-       out[j++] = 1;
-      else
-       out[j++] = 0;
-      d_phase -= 1.0;
-    }
-  }
-
-  consume_each(i);
-  return j;
-}
diff --git a/gr-noaa/lib/noaa_hrpt_sync_fb.h b/gr-noaa/lib/noaa_hrpt_sync_fb.h
deleted file mode 100644 (file)
index a9416b9..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- 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_SYNC_FB_H
-#define INCLUDED_NOAA_HRPT_SYNC_FB_H
-
-#include <gr_block.h>
-
-class noaa_hrpt_sync_fb;
-typedef boost::shared_ptr<noaa_hrpt_sync_fb> noaa_hrpt_sync_fb_sptr;
-
-noaa_hrpt_sync_fb_sptr
-noaa_make_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset);
-
-class noaa_hrpt_sync_fb : public gr_block
-{
-  friend noaa_hrpt_sync_fb_sptr noaa_make_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset);
-  noaa_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset);
-
-  float d_alpha;               // 1st order loop constant
-  float d_beta;                        // 2nd order loop constant
-  float d_sps;                  // samples per symbol
-  float d_max_offset;          // Maximum frequency offset for d_sps, samples/symbol
-  float d_phase;               // Instantaneous symbol phase
-  float d_freq;                        // Instantaneous symbol frequency, samples/symbol
-  int   d_last_sign;            // Tracks zero crossings
-
- public:
-  int general_work(int noutput_items,
-                  gr_vector_int &ninput_items,
-                  gr_vector_const_void_star &input_items,
-                  gr_vector_void_star &output_items);
-
-  void set_alpha(float alpha) { d_alpha = alpha; }
-  void set_beta(float beta) { d_beta = beta; }
-  void set_max_offset(float max_offset) { d_max_offset = max_offset; }
-};
-
-#endif /* INCLUDED_NOAA_HRPT_SYNC_FB_H */
diff --git a/gr-noaa/oct/.gitignore b/gr-noaa/oct/.gitignore
new file mode 100644 (file)
index 0000000..b336cc7
--- /dev/null
@@ -0,0 +1,2 @@
+/Makefile
+/Makefile.in
diff --git a/gr-noaa/oct/Makefile.am b/gr-noaa/oct/Makefile.am
new file mode 100644 (file)
index 0000000..2f6e4e5
--- /dev/null
@@ -0,0 +1,26 @@
+#
+# 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
+
+EXTRA_DIST = \
+       frames_to_ppm.m \
+       frames-to-png.sh
diff --git a/gr-noaa/oct/frames-to-png.sh b/gr-noaa/oct/frames-to-png.sh
new file mode 100755 (executable)
index 0000000..cb3e3fb
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+octave --eval frames_to_ppm
+
+convert chan1.ppm chan1.png && rm chan1.ppm
+convert chan2.ppm chan2.png && rm chan2.ppm
+convert chan3.ppm chan3.png && rm chan3.ppm
+convert chan4.ppm chan4.png && rm chan4.ppm
+convert chan5.ppm chan5.png && rm chan5.ppm
diff --git a/gr-noaa/oct/frames_to_ppm.m b/gr-noaa/oct/frames_to_ppm.m
new file mode 100644 (file)
index 0000000..aeb22fa
--- /dev/null
@@ -0,0 +1,85 @@
+% -*- octave -*-
+%
+% 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.
+% 
+
+% Extract AVHRR images from HRPT frames.dat
+clear
+
+fid = fopen('frames.dat');
+dat = fread(fid, 'uint16');
+
+frame_len = 11090;
+
+len = floor(length(dat) / frame_len);
+
+chan1 = zeros(len, 2048);
+
+start = 751;
+stop = 10986;
+
+for line = 1:len
+  chan1(line, 1:2048) = dat(start:5:stop)';
+  start = start + frame_len;
+  stop = stop + frame_len;
+end
+start = 752;
+stop = 10987;
+
+for line = 1:len
+  chan2(line, 1:2048) = dat(start:5:stop)';
+start = start + frame_len;
+stop = stop + frame_len;
+end
+start = 753;
+stop = 10988;
+
+for line = 1:len
+  chan3(line, 1:2048) = dat(start:5:stop)';
+  start = start + frame_len;
+  stop = stop + frame_len;
+end
+start = 754;
+stop = 10989;
+
+for line = 1:len
+  chan4(line, 1:2048) = dat(start:5:stop)';
+start = start + frame_len;
+stop = stop + frame_len;
+end
+start = 755;
+stop = 10990;
+
+for line = 1:len
+  chan5(line, 1:2048) = dat(start:5:stop)';
+  start = start + frame_len;
+  stop = stop + frame_len;
+end
+
+colormap(gray) 
+saveimage("chan1.ppm", chan1/4, 'ppm')
+saveimage("chan2.ppm", chan2/4, 'ppm')
+saveimage("chan3.ppm", chan3/4, 'ppm')
+saveimage("chan4.ppm", chan4/4, 'ppm')
+saveimage("chan5.ppm", chan5/4, 'ppm')
index 3ac7879d641cc2e013ae856eeae0525a86b8e2bb..73645e92bf2ee16d5260c6d4cb5f49499ebaafa8 100644 (file)
@@ -54,8 +54,7 @@ noaa_swig_python = \
 noaa_swig_swiginclude_headers =        \
        noaa_hrpt_decoder.i \
        noaa_hrpt_deframer.i \
-       noaa_hrpt_pll_cf.i \
-       noaa_hrpt_sync_fb.i
+       noaa_hrpt_pll_cf.i
 
 include $(top_srcdir)/Makefile.swig
 
diff --git a/gr-noaa/swig/noaa_hrpt_sync_fb.i b/gr-noaa/swig/noaa_hrpt_sync_fb.i
deleted file mode 100644 (file)
index a8e5b21..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(noaa,hrpt_sync_fb)
-
-noaa_hrpt_sync_fb_sptr
-noaa_make_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset);
-
-class noaa_hrpt_sync_fb : public gr_sync_block
-{
-private:
-  noaa_hrpt_sync_fb();
-
-public:
-  void set_alpha(float alpha);
-  void set_beta(float beta);
-  void set_max_offset(float min_freq);
-};
index e6497bc468314bc1776dceb42d69c0fa25e58135..8fe814a67a2cab6d15cf3694df47147b253281d8 100644 (file)
 #include <noaa_hrpt_decoder.h>
 #include <noaa_hrpt_deframer.h>
 #include <noaa_hrpt_pll_cf.h>
-#include <noaa_hrpt_sync_fb.h>
 %}
 
 %include "noaa_hrpt_decoder.i"
 %include "noaa_hrpt_deframer.i"
 %include "noaa_hrpt_pll_cf.i"
-%include "noaa_hrpt_sync_fb.i"
+
index 8ee8cfd2ad4696d9fd1ba586dc8d62e8c96da9c3..da83da770d43429457dc2316f442abb77c34cda1 100755 (executable)
@@ -305,7 +305,7 @@ def get_options():
     return (options, args)
 
 # If this script is executed, the following runs. If it is imported, the below does not run.
-if __name__ == "__main__":
+def main():
     if gr.enable_realtime_scheduling() != gr.RT_OK:
         print "Note: failed to enable realtime scheduling, continuing"
     
@@ -318,9 +318,14 @@ if __name__ == "__main__":
         print e
         sys.exit(1)
 
-    # Run it
-    try:
-        tb.run()
-
-    except KeyboardInterrupt:
-        pass
+    tb.start()
+    raw_input('Press Enter to quit: ')
+    tb.stop()
+    tb.wait()
+
+# Make sure to create the top block (tb) within a function:
+# That code in main will allow tb to go out of scope on return,
+# which will call the decontructor on usrp and stop transmit.
+# Whats odd is that grc works fine with tb in the __main__,
+# perhaps its because the try/except clauses around tb.
+if __name__ == "__main__": main()
index 40848fbeee3aa0d7764de5f5d92a63731084b711..47d47bdb3def7ed0eb4159b58913b41d359cb597 100755 (executable)
@@ -284,7 +284,7 @@ class app_gui(pubsub):
         self.vbox.AddSpacer(5)
         self.vbox.AddStretchSpacer()
 
-if __name__ == "__main__":
+def main():
     try:
         # Get command line parameters
         (options, args) = usrp_siggen.get_options()
@@ -308,3 +308,10 @@ if __name__ == "__main__":
     except RuntimeError, e:
         print e
         sys.exit(1)
+
+# Make sure to create the top block (tb) within a function:
+# That code in main will allow tb to go out of scope on return,
+# which will call the decontructor on usrp and stop transmit.
+# Whats odd is that grc works fine with tb in the __main__,
+# perhaps its because the try/except clauses around tb.
+if __name__ == "__main__": main()
index 5d1d510239d84833dadcfb839454888df26ceb0a..fc074cb69101e0577bf4e84b060a2ef008baf7dc 100644 (file)
        <cat>
                <name>Synchronizers</name>
                <block>gr_clock_recovery_mm_xx</block>
-               <block>gr_pfb_clock_sync_ccf</block>
+               <block>gr_pfb_clock_sync_xxx</block>
 
                <block>gr_costas_loop_cc</block>
                <block>gr_dd_mpsk_sync_cc</block>
index 9cb909acd165128d86590df655bf4c2355153b38..26cacfb3e001a3b1ea4a8333d8de435f590df0c7 100644 (file)
@@ -6,14 +6,34 @@
  -->
 <block>
        <name>Polyphase Clock Sync</name>
-       <key>gr_pfb_clock_sync_ccf</key>
+       <key>gr_pfb_clock_sync_xxx</key>
        <import>from gnuradio import gr</import>
-       <make>gr.pfb_clock_sync_ccf($sps, $alpha, $taps, $filter_size, $init_phase, $max_dev)
+       <make>gr.pfb_clock_sync_$(type)($sps, $alpha, $taps, $filter_size, $init_phase, $max_dev)
 self.$(id).set_beta($beta)</make>
        <callback>set_taps($taps)</callback>
        <callback>set_alpha($alpha)</callback>
        <callback>set_beta($beta)</callback>
 
+       <param>
+               <name>Type</name>
+               <key>type</key>
+               <type>enum</type>
+               <option>
+                       <name>Complex->Complex (Real Taps)</name>
+                       <key>ccf</key>
+                       <opt>input:complex</opt>
+                       <opt>output:complex</opt>
+                       <opt>taps:real_vector</opt>
+               </option>
+               <option>
+                       <name>Float->Float (Real Taps)</name>
+                       <key>fff</key>
+                       <opt>input:float</opt>
+                       <opt>output:float</opt>
+                       <opt>taps:real_vector</opt>
+               </option>
+       </param>
+
        <param>
                <name>Samples/Symbol</name>
                <key>sps</key>
@@ -51,11 +71,11 @@ self.$(id).set_beta($beta)</make>
        </param>
        <sink>
                <name>in</name>
-               <type>complex</type>
+               <type>$type.input</type>
        </sink>
        <source>
                <name>out</name>
-               <type>complex</type>
+               <type>$type.output</type>
        </source>
        <source>
                <name>err</name>
index 323287d02afdfa3d1725bd2ae6d7a51cc8fece0d..4780d00049e64a68ae2a7d3c01f05a76362a0f76 100644 (file)
@@ -53,6 +53,15 @@ enum usrp_load_status_t { ULS_ERROR = 0, ULS_OK, ULS_ALREADY_LOADED };
 
 void usrp_one_time_init (libusb_context **ctx = NULL);
 
+/*!
+ * \brief deinitialize libusb
+ *
+ * libusb-0.1: No effect
+ *
+ * libusb-1.0: Deinitialize context ctx 
+ */
+void usrp_deinit (libusb_context *ctx);
+
 /*
  * force a rescan of the buses and devices
  */
index 72312ebbb37b8a8d2f8b70c558d06f4d2d17cc19..e80f27112d3a346f76bcc935e5e7d8ebaea1bc7b 100644 (file)
@@ -61,8 +61,7 @@ BUILT_SOURCES += usrp_dbid.cc \
 generic_CODE =                                 \
        fusb_generic.cc                 \
        fusb_sysconfig_generic.cc       \
-       usrp_prims_libusb0.cc           \
-       usrp_basic_libusb0.cc
+       usrp_prims_libusb0.cc           
 
 darwin_CODE =                          \
        fusb_darwin.cc                  \
@@ -72,34 +71,29 @@ darwin_CODE =                               \
        circular_linked_list.h          \
        darwin_libusb.h                 \
        mld_threads.h                   \
-       usrp_prims_libusb0.cc           \
-       usrp_basic_libusb0.cc
+       usrp_prims_libusb0.cc           
 
 
 win32_CODE =                           \
        fusb_win32.cc                   \
        fusb_sysconfig_win32.cc         \
-       usrp_prims_libusb0.cc           \
-       usrp_basic_libusb0.cc
+       usrp_prims_libusb0.cc           
 
 
 linux_CODE =                           \
        fusb_linux.cc                   \
        fusb_sysconfig_linux.cc         \
-       usrp_prims_libusb0.cc           \
-       usrp_basic_libusb0.cc
+       usrp_prims_libusb0.cc           
 
 ra_wb_CODE =                           \
        fusb_ra_wb.cc                   \
        fusb_sysconfig_ra_wb.cc         \
-       usrp_prims_libusb0.cc           \
-       usrp_basic_libusb0.cc
+       usrp_prims_libusb0.cc           
 
 libusb1_CODE =                         \
        fusb_libusb1.cc                 \
        fusb_sysconfig_libusb1.cc       \
-       usrp_prims_libusb1.cc           \
-       usrp_basic_libusb1.cc
+       usrp_prims_libusb1.cc           
 
 #
 # include each <foo>_CODE entry here...
@@ -116,14 +110,14 @@ EXTRA_libusrp_la_SOURCES =                \
 libusrp_la_common_SOURCES =            \
        fusb.cc                         \
        md5.c                           \
-       usrp_basic_common.cc            \
+       usrp_basic.cc                   \
        usrp_config.cc                  \
        usrp_dbid.cc                    \
        usrp_local_sighandler.cc        \
        usrp_prims_common.cc            \
        usrp_standard.cc                \
-       db_wbxng_adf4350.cc                     \
-       db_wbxng_adf4350_regs.cc                        \
+       db_wbxng_adf4350.cc             \
+       db_wbxng_adf4350_regs.cc        \
        db_boards.cc                    \
        db_base.cc                      \
        db_basic.cc                     \
index af4eac573512e2260d283bdd57b70dbaa82d958d..2cec972b0fc82a0468e0e56963384853ba573220 100644 (file)
@@ -34,7 +34,7 @@
 #define MAX_RF_DIV uint8_t(16)                                          /* max rf divider, divides rf output */
 #define MIN_VCO_FREQ FREQ_C(2.2e9)                                      /* minimum vco freq */
 #define MAX_VCO_FREQ FREQ_C(4.4e9)                                      /* minimum vco freq */
-#define MAX_FREQ MAX_VCO_FREQ                                           /* upper bound freq (rf div = 1) */
+#define MAX_FREQ DIV_ROUND(MAX_VCO_FREQ, 1)                                           /* upper bound freq (rf div = 1) */
 #define MIN_FREQ DIV_ROUND(MIN_VCO_FREQ, MAX_RF_DIV)                    /* calculated lower bound freq */
 
 #define CE_PIN        (1 << 3)
@@ -133,6 +133,12 @@ adf4350::_set_freq(freq_t freq)
 {
     /* Set the frequency by setting int, frac, mod, r, div */
     if (freq > MAX_FREQ || freq < MIN_FREQ) return false;
+    int min_int_div = 23;
+    d_regs->d_prescaler = 0;
+    if (freq > FREQ_C(3e9)) {
+        min_int_div = 75;
+        d_regs->d_prescaler = 1;
+    }
     /* Ramp up the RF divider until the VCO is within range. */
     d_regs->d_divider_select = 0;
     while (freq < MIN_VCO_FREQ){
@@ -159,7 +165,7 @@ adf4350::_set_freq(freq_t freq)
             d_regs->d_mod, d_regs->d_10_bit_r_counter, (1 << d_regs->d_divider_select)
         );
         */
-    }while(d_regs->d_int < MIN_INT_DIV);
+    }while(d_regs->d_int < min_int_div);
     /* calculate the band select so PFD is under 125 KHz */
     d_regs->d_8_bit_band_select_clock_divider_value = \
         INPUT_REF_FREQ/(FREQ_C(30e3)*d_regs->d_10_bit_r_counter) + 1;
index 11dcf88169ab4601ba8361beae75ff66eea2056e..696b7c1d483a5ce481badbfd8b52eea188d39379 100644 (file)
@@ -9,7 +9,6 @@
 
 /* reg 0 */
 /* reg 1 */
-const uint8_t adf4350_regs::s_prescaler = 0;
 const uint16_t adf4350_regs::s_phase = 0;
 /* reg 2 */
 const uint8_t adf4350_regs::s_low_noise_and_low_spur_modes = 0;
@@ -32,9 +31,9 @@ const uint16_t adf4350_regs::s_12_bit_clock_divider_value = 0;
 const uint8_t adf4350_regs::s_feedback_select = 1;
 const uint8_t adf4350_regs::s_vco_power_down = 0;
 const uint8_t adf4350_regs::s_mtld = 0;
-const uint8_t adf4350_regs::s_aux_output_select = 0;
-const uint8_t adf4350_regs::s_aux_output_enable = 1;
-const uint8_t adf4350_regs::s_aux_output_power = 3;
+const uint8_t adf4350_regs::s_aux_output_select = 1;
+const uint8_t adf4350_regs::s_aux_output_enable = 0;
+const uint8_t adf4350_regs::s_aux_output_power = 0;
 const uint8_t adf4350_regs::s_rf_output_enable = 1;
 const uint8_t adf4350_regs::s_output_power = 3;
 /* reg 5 */
@@ -47,6 +46,7 @@ adf4350_regs::adf4350_regs(adf4350* _adf4350){
     d_int = uint16_t(100);
     d_frac = 0;
     /* reg 1 */
+    d_prescaler = uint8_t(0);
     d_mod = uint16_t(0xfff);                      /* max fractional accuracy */
     /* reg 2 */
     d_10_bit_r_counter = uint16_t(2);
@@ -73,7 +73,7 @@ adf4350_regs::_load_register(uint8_t addr){
                        _reg_shift(d_int, 15)                           |
                        _reg_shift(d_frac, 3)); break;
                case 1: data = (
-                       _reg_shift(s_prescaler, 27)                     |
+                       _reg_shift(d_prescaler, 27)                     |
                        _reg_shift(s_phase, 15)                         |
                        _reg_shift(d_mod, 3)); break;
                case 2: data = (
index dc941ee8758ba980059b90f5c839ec7d7518c675..3973b4d6baac9dee44418f67652145577f6420a9 100644 (file)
@@ -25,7 +25,7 @@ public:
     uint16_t d_int;
     uint16_t d_frac;
     /* reg 1 */
-    static const uint8_t s_prescaler;
+    uint8_t d_prescaler;
     static const uint16_t s_phase;
     uint16_t d_mod;
     /* reg 2 */
index 4846f51a5618dacc54b7f4ef15ecc6df69ce759b..77070845115d5fa2057637827d0c0d51cf021f5c 100644 (file)
@@ -279,6 +279,9 @@ fusb_devhandle_libusb1::_reap (bool ok_to_block_p)
   int ret;
   struct timeval tv;
 
+  // Save pending size
+  int pnd_size = d_pending_rqsts.size();
+
   if (ok_to_block_p) {
     tv.tv_sec = 2;
     tv.tv_usec =  0;
@@ -293,7 +296,12 @@ fusb_devhandle_libusb1::_reap (bool ok_to_block_p)
     return false;
   }
 
-  return true;
+  // Check that a pending transfer was removed
+  if (pnd_size > d_pending_rqsts.size())
+    return true;
+  else {
+    return false;
+  }
 }
 
 void
diff --git a/usrp/host/lib/usrp_basic.cc b/usrp/host/lib/usrp_basic.cc
new file mode 100644 (file)
index 0000000..5b2f7ff
--- /dev/null
@@ -0,0 +1,1538 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2003,2004,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "usrp/usrp_basic.h"
+#include "usrp/usrp_prims.h"
+#include "usrp_interfaces.h"
+#include "fpga_regs_common.h"
+#include "fpga_regs_standard.h"
+#include "fusb.h"
+#include "db_boards.h"
+#include <stdexcept>
+#include <assert.h>
+#include <math.h>
+#include <ad9862.h>
+#include <string.h>
+#include <cstdio>
+
+using namespace ad9862;
+
+#define NELEM(x) (sizeof (x) / sizeof (x[0]))
+
+// These set the buffer size used for each end point using the fast
+// usb interface.  The kernel ends up locking down this much memory.
+
+static const int FUSB_BUFFER_SIZE = fusb_sysconfig::default_buffer_size();
+static const int FUSB_BLOCK_SIZE = fusb_sysconfig::max_block_size();
+static const int FUSB_NBLOCKS    = FUSB_BUFFER_SIZE / FUSB_BLOCK_SIZE;
+
+
+static const double POLLING_INTERVAL = 0.1;    // seconds
+
+////////////////////////////////////////////////////////////////
+
+static libusb_device_handle *
+open_rx_interface (libusb_device *dev)
+{
+  libusb_device_handle *udh = usrp_open_rx_interface (dev);
+  if (udh == 0){
+    fprintf (stderr, "usrp_basic_rx: can't open rx interface\n");
+  }
+  return udh;
+}
+
+static libusb_device_handle *
+open_tx_interface (libusb_device *dev)
+{
+  libusb_device_handle *udh = usrp_open_tx_interface (dev);
+  if (udh == 0){
+    fprintf (stderr, "usrp_basic_tx: can't open tx interface\n");
+  }
+  return udh;
+}
+
+//////////////////////////////////////////////////////////////////
+//
+//                     usrp_basic
+//
+////////////////////////////////////////////////////////////////
+
+// Given:
+//   CLKIN = 64 MHz
+//   CLKSEL pin = high
+//
+// These settings give us:
+//   CLKOUT1 = CLKIN = 64 MHz
+//   CLKOUT2 = CLKIN = 64 MHz
+//   ADC is clocked at  64 MHz
+//   DAC is clocked at 128 MHz
+
+static unsigned char common_regs[] = {
+  REG_GENERAL,         0,
+  REG_DLL,             (DLL_DISABLE_INTERNAL_XTAL_OSC
+                        | DLL_MULT_2X
+                        | DLL_FAST),
+  REG_CLKOUT,          CLKOUT2_EQ_DLL_OVER_2,
+  REG_AUX_ADC_CLK,     AUX_ADC_CLK_CLK_OVER_4
+};
+
+usrp_basic::usrp_basic (int which_board,
+                       libusb_device_handle *
+                       open_interface (libusb_device *dev),
+                       const std::string fpga_filename,
+                       const std::string firmware_filename)
+  : d_udh (0), d_ctx (0),
+    d_usb_data_rate (16000000),        // SWAG, see below
+    d_bytes_per_poll ((int) (POLLING_INTERVAL * d_usb_data_rate)),
+    d_verbose (false), d_fpga_master_clock_freq(64000000), d_db(2)
+{
+  /*
+   * SWAG: Scientific Wild Ass Guess.
+   *
+   * d_usb_data_rate is used only to determine how often to poll for over- and
+   * under-runs. We defualt it to 1/2  of our best case.  Classes derived from
+   * usrp_basic (e.g., usrp_standard_tx and usrp_standard_rx) call
+   * set_usb_data_rate() to tell us the actual rate. This doesn't change our
+   * throughput, that's determined by the signal processing code in the FPGA
+   * (which we know nothing about), and the system limits determined by libusb,
+   * fusb_*, and the underlying drivers.
+   */
+  memset (d_fpga_shadows, 0, sizeof (d_fpga_shadows));
+
+  usrp_one_time_init (&d_ctx);
+
+  if (!usrp_load_standard_bits (which_board, false, fpga_filename,
+                                firmware_filename, d_ctx))
+    throw std::runtime_error ("usrp_basic/usrp_load_standard_bits");
+
+  libusb_device *dev = usrp_find_device (which_board, false, d_ctx);
+  if (dev == 0){
+    fprintf (stderr, "usrp_basic: can't find usrp[%d]\n", which_board);
+    throw std::runtime_error ("usrp_basic/usrp_find_device");
+  }
+
+  if (!(usrp_usrp_p(dev) && usrp_hw_rev(dev) >= 1)){
+    fprintf (stderr, "usrp_basic: sorry, this code only works with USRP revs >= 1\n");
+    throw std::runtime_error ("usrp_basic/bad_rev");
+  }
+
+  if ((d_udh = open_interface (dev)) == 0)
+    throw std::runtime_error ("usrp_basic/open_interface");
+
+  // initialize registers that are common to rx and tx
+
+  if (!usrp_9862_write_many_all (d_udh, common_regs, sizeof (common_regs))) {
+    fprintf (stderr, "usrp_basic: failed to init common AD9862 regs\n");
+    throw std::runtime_error ("usrp_basic/init_9862");
+  }
+
+  _write_fpga_reg (FR_MODE, 0);                // ensure we're in normal mode
+  _write_fpga_reg (FR_DEBUG_EN, 0);    // disable debug outputs
+
+}
+
+usrp_basic::~usrp_basic ()
+{
+  d_db.resize(0); // forget db shared ptrs
+
+  if (d_udh)
+    usrp_close_interface (d_udh);
+
+  usrp_deinit (d_ctx);
+}
+
+void
+usrp_basic::shutdown_daughterboards()
+{
+  // nuke d'boards before we close down USB in ~usrp_basic
+  // shutdown() will do any board shutdown while the USRP can still
+  // be talked to
+  for(size_t i = 0; i < d_db.size(); i++)
+    for(size_t j = 0; j < d_db[i].size(); j++)
+      d_db[i][j]->shutdown();
+}
+
+void
+usrp_basic::init_db(usrp_basic_sptr u)
+{
+  if (u.get() != this)
+    throw std::invalid_argument("u is not this");
+
+  d_db[0] = instantiate_dbs(d_dbid[0], u, 0);
+  d_db[1] = instantiate_dbs(d_dbid[1], u, 1);
+}
+
+std::vector<db_base_sptr>
+usrp_basic::db(int which_side)
+{
+  which_side &= 0x1;   // clamp it to avoid any reporting any errors
+  return d_db[which_side];
+}
+
+bool
+usrp_basic::is_valid(const usrp_subdev_spec &ss)
+{
+  if (ss.side < 0 || ss.side > 1)
+    return false;
+
+  if (ss.subdev < 0 || ss.subdev >= d_db[ss.side].size())
+    return false;
+
+  return true;
+}
+
+db_base_sptr
+usrp_basic::selected_subdev(const usrp_subdev_spec &ss)
+{
+  if (!is_valid(ss))
+    throw std::invalid_argument("invalid subdev_spec");
+
+  return d_db[ss.side][ss.subdev];
+}
+
+bool
+usrp_basic::start ()
+{
+  return true;         // nop
+}
+
+bool
+usrp_basic::stop ()
+{
+  return true;         // nop
+}
+
+void
+usrp_basic::set_usb_data_rate (int usb_data_rate)
+{
+  d_usb_data_rate = usb_data_rate;
+  d_bytes_per_poll = (int) (usb_data_rate * POLLING_INTERVAL);
+}
+
+bool
+usrp_basic::_write_aux_dac (int slot, int which_dac, int value)
+{
+  return usrp_write_aux_dac (d_udh, slot, which_dac, value);
+}
+
+bool
+usrp_basic::_read_aux_adc (int slot, int which_adc, int *value)
+{
+  return usrp_read_aux_adc (d_udh, slot, which_adc, value);
+}
+
+int
+usrp_basic::_read_aux_adc (int slot, int which_adc)
+{
+  int  value;
+  if (!_read_aux_adc (slot, which_adc, &value))
+    return READ_FAILED;
+
+  return value;
+}
+
+bool
+usrp_basic::write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf)
+{
+  return usrp_eeprom_write (d_udh, i2c_addr, eeprom_offset, buf.data (), buf.size ());
+}
+
+std::string
+usrp_basic::read_eeprom (int i2c_addr, int eeprom_offset, int len)
+{
+  if (len <= 0)
+    return "";
+
+  char buf[len];
+
+  if (!usrp_eeprom_read (d_udh, i2c_addr, eeprom_offset, buf, len))
+    return "";
+
+  return std::string (buf, len);
+}
+
+bool
+usrp_basic::write_i2c (int i2c_addr, const std::string buf)
+{
+  return usrp_i2c_write (d_udh, i2c_addr, buf.data (), buf.size ());
+}
+
+std::string
+usrp_basic::read_i2c (int i2c_addr, int len)
+{
+  if (len <= 0)
+    return "";
+
+  char buf[len];
+
+  if (!usrp_i2c_read (d_udh, i2c_addr, buf, len))
+    return "";
+
+  return std::string (buf, len);
+}
+
+std::string
+usrp_basic::serial_number()
+{
+  return usrp_serial_number(d_udh);
+}
+
+// ----------------------------------------------------------------
+
+bool
+usrp_basic::set_adc_offset (int which_adc, int offset)
+{
+  if (which_adc < 0 || which_adc > 3)
+    return false;
+
+  return _write_fpga_reg (FR_ADC_OFFSET_0 + which_adc, offset);
+}
+
+bool
+usrp_basic::set_dac_offset (int which_dac, int offset, int offset_pin)
+{
+  if (which_dac < 0 || which_dac > 3)
+    return false;
+
+  int which_codec = which_dac >> 1;
+  int tx_a = (which_dac & 0x1) == 0;
+  int lo = ((offset & 0x3) << 6) | (offset_pin & 0x1);
+  int hi = (offset >> 2);
+  bool ok;
+
+  if (tx_a){
+    ok =  _write_9862 (which_codec, REG_TX_A_OFFSET_LO, lo);
+    ok &= _write_9862 (which_codec, REG_TX_A_OFFSET_HI, hi);
+  }
+  else {
+    ok =  _write_9862 (which_codec, REG_TX_B_OFFSET_LO, lo);
+    ok &= _write_9862 (which_codec, REG_TX_B_OFFSET_HI, hi);
+  }
+  return ok;
+}
+
+bool
+usrp_basic::set_adc_buffer_bypass (int which_adc, bool bypass)
+{
+  if (which_adc < 0 || which_adc > 3)
+    return false;
+
+  int codec = which_adc >> 1;
+  int reg = (which_adc & 1) == 0 ? REG_RX_A : REG_RX_B;
+
+  unsigned char cur_rx;
+  unsigned char cur_pwr_dn;
+
+  // If the input buffer is bypassed, we need to power it down too.
+
+  bool ok = _read_9862 (codec, reg, &cur_rx);
+  ok &= _read_9862 (codec, REG_RX_PWR_DN, &cur_pwr_dn);
+  if (!ok)
+    return false;
+
+  if (bypass){
+    cur_rx |= RX_X_BYPASS_INPUT_BUFFER;
+    cur_pwr_dn |= ((which_adc & 1) == 0) ? RX_PWR_DN_BUF_A : RX_PWR_DN_BUF_B;
+  }
+  else {
+    cur_rx &= ~RX_X_BYPASS_INPUT_BUFFER;
+    cur_pwr_dn &= ~(((which_adc & 1) == 0) ? RX_PWR_DN_BUF_A : RX_PWR_DN_BUF_B);
+  }
+
+  ok &= _write_9862 (codec, reg, cur_rx);
+  ok &= _write_9862 (codec, REG_RX_PWR_DN, cur_pwr_dn);
+  return ok;
+}
+
+bool
+usrp_basic::set_dc_offset_cl_enable(int bits, int mask)
+{
+  return _write_fpga_reg(FR_DC_OFFSET_CL_EN,
+                        (d_fpga_shadows[FR_DC_OFFSET_CL_EN] & ~mask) | (bits & mask));
+}
+
+// ----------------------------------------------------------------
+
+bool
+usrp_basic::_write_fpga_reg (int regno, int value)
+{
+  if (d_verbose){
+    fprintf (stdout, "_write_fpga_reg(%3d, 0x%08x)\n", regno, value);
+    fflush (stdout);
+  }
+
+  if (regno >= 0 && regno < MAX_REGS)
+    d_fpga_shadows[regno] = value;
+
+  return usrp_write_fpga_reg (d_udh, regno, value);
+}
+
+bool
+usrp_basic::_write_fpga_reg_masked (int regno, int value, int mask)
+{
+  //Only use this for registers who actually use a mask in the verilog firmware, like FR_RX_MASTER_SLAVE
+  //value is a 16 bits value and mask is a 16 bits mask
+  if (d_verbose){
+    fprintf (stdout, "_write_fpga_reg_masked(%3d, 0x%04x,0x%04x)\n", regno, value, mask);
+    fflush (stdout);
+  }
+
+  if (regno >= 0 && regno < MAX_REGS)
+    d_fpga_shadows[regno] = value;
+
+  return usrp_write_fpga_reg (d_udh, regno, (value & 0xffff) | ((mask & 0xffff)<<16));
+}
+
+
+bool
+usrp_basic::_read_fpga_reg (int regno, int *value)
+{
+  return usrp_read_fpga_reg (d_udh, regno, value);
+}
+
+int
+usrp_basic::_read_fpga_reg (int regno)
+{
+  int value;
+  if (!_read_fpga_reg (regno, &value))
+    return READ_FAILED;
+  return value;
+}
+
+bool
+usrp_basic::_write_9862 (int which_codec, int regno, unsigned char value)
+{
+  if (0 && d_verbose){
+    // FIXME really want to enable logging in usrp_prims:usrp_9862_write
+    fprintf(stdout, "_write_9862(codec = %d, regno = %2d, val = 0x%02x)\n", which_codec, regno, value);
+    fflush(stdout);
+  }
+
+  return usrp_9862_write (d_udh, which_codec, regno, value);
+}
+
+
+bool
+usrp_basic::_read_9862 (int which_codec, int regno, unsigned char *value) const
+{
+  return usrp_9862_read (d_udh, which_codec, regno, value);
+}
+
+int
+usrp_basic::_read_9862 (int which_codec, int regno) const
+{
+  unsigned char value;
+  if (!_read_9862 (which_codec, regno, &value))
+    return READ_FAILED;
+  return value;
+}
+
+bool
+usrp_basic::_write_spi (int optional_header, int enables, int format, std::string buf)
+{
+  return usrp_spi_write (d_udh, optional_header, enables, format,
+                        buf.data(), buf.size());
+}
+
+std::string
+usrp_basic::_read_spi (int optional_header, int enables, int format, int len)
+{
+  if (len <= 0)
+    return "";
+
+  char buf[len];
+
+  if (!usrp_spi_read (d_udh, optional_header, enables, format, buf, len))
+    return "";
+
+  return std::string (buf, len);
+}
+
+
+bool
+usrp_basic::_set_led (int which_led, bool on)
+{
+  return usrp_set_led (d_udh, which_led, on);
+}
+
+bool
+usrp_basic::write_atr_tx_delay(int value)
+{
+  return _write_fpga_reg(FR_ATR_TX_DELAY, value);
+}
+
+bool
+usrp_basic::write_atr_rx_delay(int value)
+{
+  return _write_fpga_reg(FR_ATR_RX_DELAY, value);
+}
+
+/*
+ * ----------------------------------------------------------------
+ * Routines to access and control daughterboard specific i/o
+ * ----------------------------------------------------------------
+ */
+static int
+slot_id_to_oe_reg (int slot_id)
+{
+  static int reg[4]  = { FR_OE_0, FR_OE_1, FR_OE_2, FR_OE_3 };
+  assert (0 <= slot_id && slot_id < 4);
+  return reg[slot_id];
+}
+
+static int
+slot_id_to_io_reg (int slot_id)
+{
+  static int reg[4]  = { FR_IO_0, FR_IO_1, FR_IO_2, FR_IO_3 };
+  assert (0 <= slot_id && slot_id < 4);
+  return reg[slot_id];
+}
+
+static int
+slot_id_to_refclk_reg(int slot_id)
+{
+  static int reg[4]  = { FR_TX_A_REFCLK, FR_RX_A_REFCLK, FR_TX_B_REFCLK, FR_RX_B_REFCLK };
+  assert (0 <= slot_id && slot_id < 4);
+  return reg[slot_id];
+}
+
+static int
+slot_id_to_atr_mask_reg(int slot_id)
+{
+  static int reg[4]  = { FR_ATR_MASK_0, FR_ATR_MASK_1, FR_ATR_MASK_2, FR_ATR_MASK_3 };
+  assert (0 <= slot_id && slot_id < 4);
+  return reg[slot_id];
+}
+
+static int
+slot_id_to_atr_txval_reg(int slot_id)
+{
+  static int reg[4]  = { FR_ATR_TXVAL_0, FR_ATR_TXVAL_1, FR_ATR_TXVAL_2, FR_ATR_TXVAL_3 };
+  assert (0 <= slot_id && slot_id < 4);
+  return reg[slot_id];
+}
+
+static int
+slot_id_to_atr_rxval_reg(int slot_id)
+{
+  static int reg[4]  = { FR_ATR_RXVAL_0, FR_ATR_RXVAL_1, FR_ATR_RXVAL_2, FR_ATR_RXVAL_3 };
+  assert (0 <= slot_id && slot_id < 4);
+  return reg[slot_id];
+}
+
+static int
+to_slot(txrx_t txrx, int which_side)
+{
+  // TX_A = 0
+  // RX_A = 1
+  // TX_B = 2
+  // RX_B = 3
+  return ((which_side & 0x1) << 1) | ((txrx & 0x1) == C_RX);
+}
+
+bool
+usrp_basic::common_set_pga(txrx_t txrx, int which_amp, double gain)
+{
+  if (which_amp < 0 || which_amp > 3)
+    return false;
+
+  gain = std::min(common_pga_max(txrx),
+                 std::max(common_pga_min(txrx), gain));
+
+  int codec = which_amp >> 1;  
+  int int_gain = (int) rint((gain - common_pga_min(txrx)) / common_pga_db_per_step(txrx));
+
+  if (txrx == C_TX){           // 0 and 1 are same, as are 2 and 3
+    return _write_9862(codec, REG_TX_PGA, int_gain);
+  }
+  else {
+    int reg = (which_amp & 1) == 0 ? REG_RX_A : REG_RX_B;
+
+    // read current value to get input buffer bypass flag.
+    unsigned char cur_rx;
+    if (!_read_9862(codec, reg, &cur_rx))
+      return false;
+
+    cur_rx = (cur_rx & RX_X_BYPASS_INPUT_BUFFER) | (int_gain & 0x7f);
+    return _write_9862(codec, reg, cur_rx);
+  }
+}
+
+double
+usrp_basic::common_pga(txrx_t txrx, int which_amp) const
+{
+  if (which_amp < 0 || which_amp > 3)
+    return READ_FAILED;
+
+  if (txrx == C_TX){
+    int codec = which_amp >> 1;
+    unsigned char v;
+    bool ok = _read_9862 (codec, REG_TX_PGA, &v);
+    if (!ok)
+      return READ_FAILED;
+
+    return (pga_db_per_step() * v) + pga_min();
+  }
+  else {
+    int codec = which_amp >> 1;
+    int reg = (which_amp & 1) == 0 ? REG_RX_A : REG_RX_B;
+    unsigned char v;
+    bool ok = _read_9862 (codec, reg, &v);
+    if (!ok)
+      return READ_FAILED;
+
+    return (pga_db_per_step() * (v & 0x1f)) + pga_min();
+  }
+}
+
+double
+usrp_basic::common_pga_min(txrx_t txrx) const
+{
+  if (txrx == C_TX)
+    return -20.0;
+  else
+    return   0.0;
+}
+
+double
+usrp_basic::common_pga_max(txrx_t txrx) const
+{
+  if (txrx == C_TX)
+    return   0.0;
+  else
+    return  20.0;
+}
+
+double
+usrp_basic::common_pga_db_per_step(txrx_t txrx) const
+{
+  if (txrx == C_TX)
+    return  20.0 / 255;
+  else
+    return  20.0 / 20;
+}
+
+bool
+usrp_basic::_common_write_oe(txrx_t txrx, int which_side, int value, int mask)
+{
+  if (! (0 <= which_side && which_side <= 1))
+    return false;
+
+  return _write_fpga_reg(slot_id_to_oe_reg(to_slot(txrx, which_side)),
+                        (mask << 16) | (value & 0xffff));
+}
+
+bool
+usrp_basic::common_write_io(txrx_t txrx, int which_side, int value, int mask)
+{
+  if (! (0 <= which_side && which_side <= 1))
+    return false;
+
+  return _write_fpga_reg(slot_id_to_io_reg(to_slot(txrx, which_side)),
+                        (mask << 16) | (value & 0xffff));
+}
+
+bool
+usrp_basic::common_read_io(txrx_t txrx, int which_side, int *value)
+{
+  if (! (0 <= which_side && which_side <= 1))
+    return false;
+
+  int t;
+  int reg = which_side + 1;    // FIXME, *very* magic number (fix in serial_io.v)
+  bool ok = _read_fpga_reg(reg, &t);
+  if (!ok)
+    return false;
+
+  if (txrx == C_TX){
+    *value = t & 0xffff;               // FIXME, more magic
+    return true;
+  }
+  else {
+    *value = (t >> 16) & 0xffff;       // FIXME, more magic
+    return true;
+  }
+}
+
+int
+usrp_basic::common_read_io(txrx_t txrx, int which_side)
+{
+  int  value;
+  if (!common_read_io(txrx, which_side, &value))
+    return READ_FAILED;
+  return value;
+}
+
+bool
+usrp_basic::common_write_refclk(txrx_t txrx, int which_side, int value)
+{
+  if (! (0 <= which_side && which_side <= 1))
+    return false;
+
+  return _write_fpga_reg(slot_id_to_refclk_reg(to_slot(txrx, which_side)),
+                        value);
+}
+
+bool
+usrp_basic::common_write_atr_mask(txrx_t txrx, int which_side, int value)
+{
+  if (! (0 <= which_side && which_side <= 1))
+    return false;
+
+  return _write_fpga_reg(slot_id_to_atr_mask_reg(to_slot(txrx, which_side)),
+                        value);
+}
+
+bool
+usrp_basic::common_write_atr_txval(txrx_t txrx, int which_side, int value)
+{
+  if (! (0 <= which_side && which_side <= 1))
+    return false;
+
+  return _write_fpga_reg(slot_id_to_atr_txval_reg(to_slot(txrx, which_side)),
+                        value);
+}
+
+bool
+usrp_basic::common_write_atr_rxval(txrx_t txrx, int which_side, int value)
+{
+  if (! (0 <= which_side && which_side <= 1))
+    return false;
+
+  return _write_fpga_reg(slot_id_to_atr_rxval_reg(to_slot(txrx, which_side)),
+                        value);
+}
+
+bool
+usrp_basic::common_write_aux_dac(txrx_t txrx, int which_side, int which_dac, int value)
+{
+  return _write_aux_dac(to_slot(txrx, which_side), which_dac, value);
+}
+
+bool
+usrp_basic::common_read_aux_adc(txrx_t txrx, int which_side, int which_adc, int *value)
+{
+  return _read_aux_adc(to_slot(txrx, which_side), which_adc, value);
+}
+
+int
+usrp_basic::common_read_aux_adc(txrx_t txrx, int which_side, int which_adc)
+{
+  return _read_aux_adc(to_slot(txrx, which_side), which_adc);
+}
+
+
+////////////////////////////////////////////////////////////////
+//
+//                        usrp_basic_rx
+//
+////////////////////////////////////////////////////////////////
+
+static unsigned char rx_init_regs[] = {
+  REG_RX_PWR_DN,       0,
+  REG_RX_A,            0,      // minimum gain = 0x00 (max gain = 0x14)
+  REG_RX_B,            0,      // minimum gain = 0x00 (max gain = 0x14)
+  REG_RX_MISC,         (RX_MISC_HS_DUTY_CYCLE | RX_MISC_CLK_DUTY),
+  REG_RX_IF,           (RX_IF_USE_CLKOUT1
+                        | RX_IF_2S_COMP),
+  REG_RX_DIGITAL,      (RX_DIGITAL_2_CHAN)
+};
+
+
+usrp_basic_rx::usrp_basic_rx (int which_board, int fusb_block_size, int fusb_nblocks,
+                             const std::string fpga_filename,
+                             const std::string firmware_filename
+                             )
+  : usrp_basic (which_board, open_rx_interface, fpga_filename, firmware_filename),
+    d_devhandle (0), d_ephandle (0),
+    d_bytes_seen (0), d_first_read (true),
+    d_rx_enable (false)
+{
+  // initialize rx specific registers
+
+  if (!usrp_9862_write_many_all (d_udh, rx_init_regs, sizeof (rx_init_regs))){
+    fprintf (stderr, "usrp_basic_rx: failed to init AD9862 RX regs\n");
+    throw std::runtime_error ("usrp_basic_rx/init_9862");
+  }
+
+  if (0){
+    // FIXME power down 2nd codec rx path
+    usrp_9862_write (d_udh, 1, REG_RX_PWR_DN, 0x1);    // power down everything
+  }
+
+  // Reset the rx path and leave it disabled.
+  set_rx_enable (false);
+  usrp_set_fpga_rx_reset (d_udh, true);
+  usrp_set_fpga_rx_reset (d_udh, false);
+
+  set_fpga_rx_sample_rate_divisor (2); // usually correct
+
+  set_dc_offset_cl_enable(0xf, 0xf);   // enable DC offset removal control loops
+
+  probe_rx_slots (false);
+
+  //d_db[0] = instantiate_dbs(d_dbid[0], this, 0);
+  //d_db[1] = instantiate_dbs(d_dbid[1], this, 1);
+
+  // check fusb buffering parameters
+
+  if (fusb_block_size < 0 || fusb_block_size > FUSB_BLOCK_SIZE)
+    throw std::out_of_range ("usrp_basic_rx: invalid fusb_block_size");
+
+  if (fusb_nblocks < 0)
+    throw std::out_of_range ("usrp_basic_rx: invalid fusb_nblocks");
+
+  if (fusb_block_size == 0)
+    fusb_block_size = fusb_sysconfig::default_block_size();
+
+  if (fusb_nblocks == 0)
+    fusb_nblocks = std::max (1, FUSB_BUFFER_SIZE / fusb_block_size);
+
+  d_devhandle = fusb_sysconfig::make_devhandle (d_udh, d_ctx);
+  d_ephandle = d_devhandle->make_ephandle (USRP_RX_ENDPOINT, true,
+                                          fusb_block_size, fusb_nblocks);
+
+  write_atr_mask(0, 0);                // zero Rx A Auto Transmit/Receive regs
+  write_atr_txval(0, 0);
+  write_atr_rxval(0, 0);
+  write_atr_mask(1, 0);                // zero Rx B Auto Transmit/Receive regs
+  write_atr_txval(1, 0);
+  write_atr_rxval(1, 0);
+}
+
+static unsigned char rx_fini_regs[] = {
+  REG_RX_PWR_DN,       0x1                             // power down everything
+};
+
+usrp_basic_rx::~usrp_basic_rx ()
+{
+  if (!set_rx_enable (false)){
+    fprintf (stderr, "usrp_basic_rx: set_fpga_rx_enable failed\n");
+  }
+
+  d_ephandle->stop ();
+  delete d_ephandle;
+  delete d_devhandle;
+
+  if (!usrp_9862_write_many_all (d_udh, rx_fini_regs, sizeof (rx_fini_regs))){
+    fprintf (stderr, "usrp_basic_rx: failed to fini AD9862 RX regs\n");
+  }
+
+  shutdown_daughterboards();
+}
+
+
+bool
+usrp_basic_rx::start ()
+{
+  if (!usrp_basic::start ())   // invoke parent's method
+    return false;
+
+  // fire off reads before asserting rx_enable
+
+  if (!d_ephandle->start ()){
+    fprintf (stderr, "usrp_basic_rx: failed to start end point streaming");
+    return false;
+  }
+
+  if (!set_rx_enable (true)){
+    fprintf (stderr, "usrp_basic_rx: set_rx_enable failed\n");
+    return false;
+  }
+
+  return true;
+}
+
+bool
+usrp_basic_rx::stop ()
+{
+  bool ok = usrp_basic::stop();
+
+  if (!set_rx_enable(false)){
+    fprintf (stderr, "usrp_basic_rx: set_rx_enable(false) failed\n");
+    ok = false;
+  }
+
+  if (!d_ephandle->stop()){
+    fprintf (stderr, "usrp_basic_rx: failed to stop end point streaming");
+    ok = false;
+  }
+
+  return ok;
+}
+
+usrp_basic_rx *
+usrp_basic_rx::make (int which_board, int fusb_block_size, int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename)
+{
+  usrp_basic_rx *u = 0;
+
+  try {
+    u = new usrp_basic_rx (which_board, fusb_block_size, fusb_nblocks,
+                          fpga_filename, firmware_filename);
+    return u;
+  }
+  catch (...){
+    delete u;
+    return 0;
+  }
+
+  return u;
+}
+
+bool
+usrp_basic_rx::set_fpga_rx_sample_rate_divisor (unsigned int div)
+{
+  return _write_fpga_reg (FR_RX_SAMPLE_RATE_DIV, div - 1);
+}
+
+
+/*
+ * \brief read data from the D/A's via the FPGA.
+ * \p len must be a multiple of 512 bytes.
+ *
+ * \returns the number of bytes read, or -1 on error.
+ *
+ * If overrun is non-NULL it will be set true iff an RX overrun is detected.
+ */
+int
+usrp_basic_rx::read (void *buf, int len, bool *overrun)
+{
+  int  r;
+
+  if (overrun)
+    *overrun = false;
+
+  if (len < 0 || (len % 512) != 0){
+    fprintf (stderr, "usrp_basic_rx::read: invalid length = %d\n", len);
+    return -1;
+  }
+
+  r = d_ephandle->read (buf, len);
+  if (r > 0)
+    d_bytes_seen += r;
+
+  /*
+   * In many cases, the FPGA reports an rx overrun right after we
+   * enable the Rx path.  If this is our first read, check for the
+   * overrun to clear the condition, then ignore the result.
+   */
+  if (0 && d_first_read){      // FIXME
+    d_first_read = false;
+    bool bogus_overrun;
+    usrp_check_rx_overrun (d_udh, &bogus_overrun);
+  }
+
+  if (overrun != 0 && d_bytes_seen >= d_bytes_per_poll){
+    d_bytes_seen = 0;
+    if (!usrp_check_rx_overrun (d_udh, overrun)){
+      fprintf (stderr, "usrp_basic_rx: usrp_check_rx_overrun failed\n");
+    }
+  }
+
+  return r;
+}
+
+bool
+usrp_basic_rx::set_rx_enable (bool on)
+{
+  d_rx_enable = on;
+  return usrp_set_fpga_rx_enable (d_udh, on);
+}
+
+// conditional disable, return prev state
+bool
+usrp_basic_rx::disable_rx ()
+{
+  bool enabled = rx_enable ();
+  if (enabled)
+    set_rx_enable (false);
+  return enabled;
+}
+
+// conditional set
+void
+usrp_basic_rx::restore_rx (bool on)
+{
+  if (on != rx_enable ())
+    set_rx_enable (on);
+}
+
+void
+usrp_basic_rx::probe_rx_slots (bool verbose)
+{
+  struct usrp_dboard_eeprom    eeprom;
+  static int slot_id_map[2] = { SLOT_RX_A, SLOT_RX_B };
+  static const char *slot_name[2] = { "RX d'board A", "RX d'board B" };
+
+  for (int i = 0; i < 2; i++){
+    int slot_id = slot_id_map [i];
+    const char *msg = 0;
+    usrp_dbeeprom_status_t s = usrp_read_dboard_eeprom (d_udh, slot_id, &eeprom);
+
+    switch (s){
+    case UDBE_OK:
+      d_dbid[i] = eeprom.id;
+      msg = usrp_dbid_to_string (eeprom.id).c_str ();
+      set_adc_offset (2*i+0, eeprom.offset[0]);
+      set_adc_offset (2*i+1, eeprom.offset[1]);
+      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | eeprom.oe);
+      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
+      break;
+
+    case UDBE_NO_EEPROM:
+      d_dbid[i] = -1;
+      msg = "<none>";
+      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
+      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
+      break;
+
+    case UDBE_INVALID_EEPROM:
+      d_dbid[i] = -2;
+      msg = "Invalid EEPROM contents";
+      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
+      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
+      break;
+
+    case UDBE_BAD_SLOT:
+    default:
+      assert (0);
+    }
+
+    if (verbose){
+      fflush (stdout);
+      fprintf (stderr, "%s: %s\n", slot_name[i], msg);
+    }
+  }
+}
+
+bool
+usrp_basic_rx::set_pga (int which_amp, double gain)
+{
+  return common_set_pga(C_RX, which_amp, gain);
+}
+
+double
+usrp_basic_rx::pga(int which_amp) const
+{
+  return common_pga(C_RX, which_amp);
+}
+
+double
+usrp_basic_rx::pga_min() const
+{
+  return common_pga_min(C_RX);
+}
+
+double
+usrp_basic_rx::pga_max() const
+{
+  return common_pga_max(C_RX);
+}
+
+double
+usrp_basic_rx::pga_db_per_step() const
+{
+  return common_pga_db_per_step(C_RX);
+}
+
+bool
+usrp_basic_rx::_write_oe (int which_side, int value, int mask)
+{
+  return _common_write_oe(C_RX, which_side, value, mask);
+}
+
+bool
+usrp_basic_rx::write_io (int which_side, int value, int mask)
+{
+  return common_write_io(C_RX, which_side, value, mask);
+}
+
+bool
+usrp_basic_rx::read_io (int which_side, int *value)
+{
+  return common_read_io(C_RX, which_side, value);
+}
+
+int
+usrp_basic_rx::read_io (int which_side)
+{
+  return common_read_io(C_RX, which_side);
+}
+
+bool
+usrp_basic_rx::write_refclk(int which_side, int value)
+{
+  return common_write_refclk(C_RX, which_side, value);
+}
+
+bool
+usrp_basic_rx::write_atr_mask(int which_side, int value)
+{
+  return common_write_atr_mask(C_RX, which_side, value);
+}
+
+bool
+usrp_basic_rx::write_atr_txval(int which_side, int value)
+{
+  return common_write_atr_txval(C_RX, which_side, value);
+}
+
+bool
+usrp_basic_rx::write_atr_rxval(int which_side, int value)
+{
+  return common_write_atr_rxval(C_RX, which_side, value);
+}
+
+bool
+usrp_basic_rx::write_aux_dac (int which_side, int which_dac, int value)
+{
+  return common_write_aux_dac(C_RX, which_side, which_dac, value);
+}
+
+bool
+usrp_basic_rx::read_aux_adc (int which_side, int which_adc, int *value)
+{
+  return common_read_aux_adc(C_RX, which_side, which_adc, value);
+}
+
+int
+usrp_basic_rx::read_aux_adc (int which_side, int which_adc)
+{
+  return common_read_aux_adc(C_RX, which_side, which_adc);
+}
+
+int
+usrp_basic_rx::block_size () const { return d_ephandle->block_size(); }
+
+////////////////////////////////////////////////////////////////
+//
+//                        usrp_basic_tx
+//
+////////////////////////////////////////////////////////////////
+
+
+//
+// DAC input rate 64 MHz interleaved for a total input rate of 128 MHz
+// DAC input is latched on rising edge of CLKOUT2
+// NCO is disabled
+// interpolate 2x
+// coarse modulator disabled
+//
+
+static unsigned char tx_init_regs[] = {
+  REG_TX_PWR_DN,       0,
+  REG_TX_A_OFFSET_LO,  0,
+  REG_TX_A_OFFSET_HI,  0,
+  REG_TX_B_OFFSET_LO,  0,
+  REG_TX_B_OFFSET_HI,  0,
+  REG_TX_A_GAIN,       (TX_X_GAIN_COARSE_FULL | 0),
+  REG_TX_B_GAIN,       (TX_X_GAIN_COARSE_FULL | 0),
+  REG_TX_PGA,          0xff,                   // maximum gain (0 dB)
+  REG_TX_MISC,         0,
+  REG_TX_IF,           (TX_IF_USE_CLKOUT1
+                        | TX_IF_I_FIRST
+                        | TX_IF_INV_TX_SYNC
+                        | TX_IF_2S_COMP
+                        | TX_IF_INTERLEAVED),
+  REG_TX_DIGITAL,      (TX_DIGITAL_2_DATA_PATHS
+                        | TX_DIGITAL_INTERPOLATE_4X),
+  REG_TX_MODULATOR,    (TX_MODULATOR_DISABLE_NCO
+                        | TX_MODULATOR_COARSE_MODULATION_NONE),
+  REG_TX_NCO_FTW_7_0,  0,
+  REG_TX_NCO_FTW_15_8, 0,
+  REG_TX_NCO_FTW_23_16,        0
+};
+
+usrp_basic_tx::usrp_basic_tx (int which_board, int fusb_block_size, int fusb_nblocks,
+                             const std::string fpga_filename,
+                             const std::string firmware_filename)
+  : usrp_basic (which_board, open_tx_interface, fpga_filename, firmware_filename),
+    d_devhandle (0), d_ephandle (0),
+    d_bytes_seen (0), d_first_write (true),
+    d_tx_enable (false)
+{
+  if (!usrp_9862_write_many_all (d_udh, tx_init_regs, sizeof (tx_init_regs))){
+    fprintf (stderr, "usrp_basic_tx: failed to init AD9862 TX regs\n");
+    throw std::runtime_error ("usrp_basic_tx/init_9862");
+  }
+
+  if (0){
+    // FIXME power down 2nd codec tx path
+    usrp_9862_write (d_udh, 1, REG_TX_PWR_DN,
+                    (TX_PWR_DN_TX_DIGITAL
+                     | TX_PWR_DN_TX_ANALOG_BOTH));
+  }
+
+  // Reset the tx path and leave it disabled.
+  set_tx_enable (false);
+  usrp_set_fpga_tx_reset (d_udh, true);
+  usrp_set_fpga_tx_reset (d_udh, false);
+
+  set_fpga_tx_sample_rate_divisor (4); // we're using interp x4
+
+  probe_tx_slots (false);
+
+  //d_db[0] = instantiate_dbs(d_dbid[0], this, 0);
+  //d_db[1] = instantiate_dbs(d_dbid[1], this, 1);
+
+  // check fusb buffering parameters
+
+  if (fusb_block_size < 0 || fusb_block_size > FUSB_BLOCK_SIZE)
+    throw std::out_of_range ("usrp_basic_rx: invalid fusb_block_size");
+
+  if (fusb_nblocks < 0)
+    throw std::out_of_range ("usrp_basic_rx: invalid fusb_nblocks");
+
+  if (fusb_block_size == 0)
+    fusb_block_size = FUSB_BLOCK_SIZE;
+
+  if (fusb_nblocks == 0)
+    fusb_nblocks = std::max (1, FUSB_BUFFER_SIZE / fusb_block_size);
+
+  d_devhandle = fusb_sysconfig::make_devhandle (d_udh, d_ctx);
+  d_ephandle = d_devhandle->make_ephandle (USRP_TX_ENDPOINT, false,
+                                          fusb_block_size, fusb_nblocks);
+
+  write_atr_mask(0, 0);                // zero Tx A Auto Transmit/Receive regs
+  write_atr_txval(0, 0);
+  write_atr_rxval(0, 0);
+  write_atr_mask(1, 0);                // zero Tx B Auto Transmit/Receive regs
+  write_atr_txval(1, 0);
+  write_atr_rxval(1, 0);
+}
+
+
+static unsigned char tx_fini_regs[] = {
+  REG_TX_PWR_DN,       (TX_PWR_DN_TX_DIGITAL
+                        | TX_PWR_DN_TX_ANALOG_BOTH),
+  REG_TX_MODULATOR,    (TX_MODULATOR_DISABLE_NCO
+                        | TX_MODULATOR_COARSE_MODULATION_NONE)
+};
+
+usrp_basic_tx::~usrp_basic_tx ()
+{
+  d_ephandle->stop ();
+  delete d_ephandle;
+  delete d_devhandle;
+
+  if (!usrp_9862_write_many_all (d_udh, tx_fini_regs, sizeof (tx_fini_regs))){
+    fprintf (stderr, "usrp_basic_tx: failed to fini AD9862 TX regs\n");
+  }
+
+  shutdown_daughterboards();
+}
+
+bool
+usrp_basic_tx::start ()
+{
+  if (!usrp_basic::start ())
+    return false;
+
+  if (!set_tx_enable (true)){
+    fprintf (stderr, "usrp_basic_tx: set_tx_enable failed\n");
+    return false;
+  }
+
+  if (!d_ephandle->start ()){
+    fprintf (stderr, "usrp_basic_tx: failed to start end point streaming");
+    return false;
+  }
+
+  return true;
+}
+
+bool
+usrp_basic_tx::stop ()
+{
+  bool ok = usrp_basic::stop ();
+
+  if (!d_ephandle->stop ()){
+    fprintf (stderr, "usrp_basic_tx: failed to stop end point streaming");
+    ok = false;
+  }
+
+  if (!set_tx_enable (false)){
+    fprintf (stderr, "usrp_basic_tx: set_tx_enable(false) failed\n");
+    ok = false;
+  }
+
+  return ok;
+}
+
+usrp_basic_tx *
+usrp_basic_tx::make (int which_board, int fusb_block_size, int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename)
+{
+  usrp_basic_tx *u = 0;
+
+  try {
+    u = new usrp_basic_tx (which_board, fusb_block_size, fusb_nblocks,
+                          fpga_filename, firmware_filename);
+    return u;
+  }
+  catch (...){
+    delete u;
+    return 0;
+  }
+
+  return u;
+}
+
+bool
+usrp_basic_tx::set_fpga_tx_sample_rate_divisor (unsigned int div)
+{
+  return _write_fpga_reg (FR_TX_SAMPLE_RATE_DIV, div - 1);
+}
+
+/*!
+ * \brief Write data to the A/D's via the FPGA.
+ *
+ * \p len must be a multiple of 512 bytes.
+ * \returns number of bytes written or -1 on error.
+ *
+ * if \p underrun is non-NULL, it will be set to true iff
+ * a transmit underrun condition is detected.
+ */
+int
+usrp_basic_tx::write (const void *buf, int len, bool *underrun)
+{
+  int  r;
+
+  if (underrun)
+    *underrun = false;
+
+  if (len < 0 || (len % 512) != 0){
+    fprintf (stderr, "usrp_basic_tx::write: invalid length = %d\n", len);
+    return -1;
+  }
+
+  r = d_ephandle->write (buf, len);
+  if (r > 0)
+    d_bytes_seen += r;
+
+  /*
+   * In many cases, the FPGA reports an tx underrun right after we
+   * enable the Tx path.  If this is our first write, check for the
+   * underrun to clear the condition, then ignore the result.
+   */
+  if (d_first_write && d_bytes_seen >= 4 * FUSB_BLOCK_SIZE){
+    d_first_write = false;
+    bool bogus_underrun;
+    usrp_check_tx_underrun (d_udh, &bogus_underrun);
+  }
+
+  if (underrun != 0 && d_bytes_seen >= d_bytes_per_poll){
+    d_bytes_seen = 0;
+    if (!usrp_check_tx_underrun (d_udh, underrun)){
+      fprintf (stderr, "usrp_basic_tx: usrp_check_tx_underrun failed\n");
+    }
+  }
+
+  return r;
+}
+
+void
+usrp_basic_tx::wait_for_completion ()
+{
+  d_ephandle->wait_for_completion ();
+}
+
+bool
+usrp_basic_tx::set_tx_enable (bool on)
+{
+  d_tx_enable = on;
+  // fprintf (stderr, "set_tx_enable %d\n", on);
+  return usrp_set_fpga_tx_enable (d_udh, on);
+}
+
+// conditional disable, return prev state
+bool
+usrp_basic_tx::disable_tx ()
+{
+  bool enabled = tx_enable ();
+  if (enabled)
+    set_tx_enable (false);
+  return enabled;
+}
+
+// conditional set
+void
+usrp_basic_tx::restore_tx (bool on)
+{
+  if (on != tx_enable ())
+    set_tx_enable (on);
+}
+
+void
+usrp_basic_tx::probe_tx_slots (bool verbose)
+{
+  struct usrp_dboard_eeprom    eeprom;
+  static int slot_id_map[2] = { SLOT_TX_A, SLOT_TX_B };
+  static const char *slot_name[2] = { "TX d'board A", "TX d'board B" };
+
+  for (int i = 0; i < 2; i++){
+    int slot_id = slot_id_map [i];
+    const char *msg = 0;
+    usrp_dbeeprom_status_t s = usrp_read_dboard_eeprom (d_udh, slot_id, &eeprom);
+
+    switch (s){
+    case UDBE_OK:
+      d_dbid[i] = eeprom.id;
+      msg = usrp_dbid_to_string (eeprom.id).c_str ();
+      // FIXME, figure out interpretation of dc offset for TX d'boards
+      // offset = (eeprom.offset[1] << 16) | (eeprom.offset[0] & 0xffff);
+      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | eeprom.oe);
+      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
+      break;
+
+    case UDBE_NO_EEPROM:
+      d_dbid[i] = -1;
+      msg = "<none>";
+      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
+      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
+      break;
+
+    case UDBE_INVALID_EEPROM:
+      d_dbid[i] = -2;
+      msg = "Invalid EEPROM contents";
+      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
+      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
+      break;
+
+    case UDBE_BAD_SLOT:
+    default:
+      assert (0);
+    }
+
+    if (verbose){
+      fflush (stdout);
+      fprintf (stderr, "%s: %s\n", slot_name[i], msg);
+    }
+  }
+}
+
+bool
+usrp_basic_tx::set_pga (int which_amp, double gain)
+{
+  return common_set_pga(C_TX, which_amp, gain);
+}
+
+double
+usrp_basic_tx::pga (int which_amp) const
+{
+  return common_pga(C_TX, which_amp);
+}
+
+double
+usrp_basic_tx::pga_min() const
+{
+  return common_pga_min(C_TX);
+}
+
+double
+usrp_basic_tx::pga_max() const
+{
+  return common_pga_max(C_TX);
+}
+
+double
+usrp_basic_tx::pga_db_per_step() const
+{
+  return common_pga_db_per_step(C_TX);
+}
+
+bool
+usrp_basic_tx::_write_oe (int which_side, int value, int mask)
+{
+  return _common_write_oe(C_TX, which_side, value, mask);
+}
+
+bool
+usrp_basic_tx::write_io (int which_side, int value, int mask)
+{
+  return common_write_io(C_TX, which_side, value, mask);
+}
+
+bool
+usrp_basic_tx::read_io (int which_side, int *value)
+{
+  return common_read_io(C_TX, which_side, value);
+}
+
+int
+usrp_basic_tx::read_io (int which_side)
+{
+  return common_read_io(C_TX, which_side);
+}
+
+bool
+usrp_basic_tx::write_refclk(int which_side, int value)
+{
+  return common_write_refclk(C_TX, which_side, value);
+}
+
+bool
+usrp_basic_tx::write_atr_mask(int which_side, int value)
+{
+  return common_write_atr_mask(C_TX, which_side, value);
+}
+
+bool
+usrp_basic_tx::write_atr_txval(int which_side, int value)
+{
+  return common_write_atr_txval(C_TX, which_side, value);
+}
+
+bool
+usrp_basic_tx::write_atr_rxval(int which_side, int value)
+{
+  return common_write_atr_rxval(C_TX, which_side, value);
+}
+
+bool
+usrp_basic_tx::write_aux_dac (int which_side, int which_dac, int value)
+{
+  return common_write_aux_dac(C_TX, which_side, which_dac, value);
+}
+
+bool
+usrp_basic_tx::read_aux_adc (int which_side, int which_adc, int *value)
+{
+  return common_read_aux_adc(C_TX, which_side, which_adc, value);
+}
+
+int
+usrp_basic_tx::read_aux_adc (int which_side, int which_adc)
+{
+  return common_read_aux_adc(C_TX, which_side, which_adc);
+}
+
+int
+usrp_basic_tx::block_size () const { return d_ephandle->block_size(); }
+
diff --git a/usrp/host/lib/usrp_basic_common.cc b/usrp/host/lib/usrp_basic_common.cc
deleted file mode 100644 (file)
index 721301d..0000000
+++ /dev/null
@@ -1,1475 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2004,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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "usrp/usrp_basic.h"
-#include "usrp/usrp_prims.h"
-#include "usrp_interfaces.h"
-#include "fpga_regs_common.h"
-#include "fpga_regs_standard.h"
-#include "fusb.h"
-#include "db_boards.h"
-#include <stdexcept>
-#include <assert.h>
-#include <math.h>
-#include <ad9862.h>
-#include <string.h>
-#include <cstdio>
-
-using namespace ad9862;
-
-#define NELEM(x) (sizeof (x) / sizeof (x[0]))
-
-// These set the buffer size used for each end point using the fast
-// usb interface.  The kernel ends up locking down this much memory.
-
-static const int FUSB_BUFFER_SIZE = fusb_sysconfig::default_buffer_size();
-static const int FUSB_BLOCK_SIZE = fusb_sysconfig::max_block_size();
-static const int FUSB_NBLOCKS    = FUSB_BUFFER_SIZE / FUSB_BLOCK_SIZE;
-
-
-static const double POLLING_INTERVAL = 0.1;    // seconds
-
-////////////////////////////////////////////////////////////////
-
-static libusb_device_handle *
-open_rx_interface (libusb_device *dev)
-{
-  libusb_device_handle *udh = usrp_open_rx_interface (dev);
-  if (udh == 0){
-    fprintf (stderr, "usrp_basic_rx: can't open rx interface\n");
-  }
-  return udh;
-}
-
-static libusb_device_handle *
-open_tx_interface (libusb_device *dev)
-{
-  libusb_device_handle *udh = usrp_open_tx_interface (dev);
-  if (udh == 0){
-    fprintf (stderr, "usrp_basic_tx: can't open tx interface\n");
-  }
-  return udh;
-}
-
-
-//////////////////////////////////////////////////////////////////
-//
-//                     usrp_basic
-//
-////////////////////////////////////////////////////////////////
-
-
-// Given:
-//   CLKIN = 64 MHz
-//   CLKSEL pin = high
-//
-// These settings give us:
-//   CLKOUT1 = CLKIN = 64 MHz
-//   CLKOUT2 = CLKIN = 64 MHz
-//   ADC is clocked at  64 MHz
-//   DAC is clocked at 128 MHz
-
-static unsigned char common_regs[] = {
-  REG_GENERAL,         0,
-  REG_DLL,             (DLL_DISABLE_INTERNAL_XTAL_OSC
-                        | DLL_MULT_2X
-                        | DLL_FAST),
-  REG_CLKOUT,          CLKOUT2_EQ_DLL_OVER_2,
-  REG_AUX_ADC_CLK,     AUX_ADC_CLK_CLK_OVER_4
-};
-
-void
-usrp_basic::shutdown_daughterboards()
-{
-  // nuke d'boards before we close down USB in ~usrp_basic
-  // shutdown() will do any board shutdown while the USRP can still
-  // be talked to
-  for(size_t i = 0; i < d_db.size(); i++)
-    for(size_t j = 0; j < d_db[i].size(); j++)
-      d_db[i][j]->shutdown();
-}
-
-void
-usrp_basic::init_db(usrp_basic_sptr u)
-{
-  if (u.get() != this)
-    throw std::invalid_argument("u is not this");
-
-  d_db[0] = instantiate_dbs(d_dbid[0], u, 0);
-  d_db[1] = instantiate_dbs(d_dbid[1], u, 1);
-}
-
-std::vector<db_base_sptr>
-usrp_basic::db(int which_side)
-{
-  which_side &= 0x1;   // clamp it to avoid any reporting any errors
-  return d_db[which_side];
-}
-
-bool
-usrp_basic::is_valid(const usrp_subdev_spec &ss)
-{
-  if (ss.side < 0 || ss.side > 1)
-    return false;
-
-  if (ss.subdev < 0 || ss.subdev >= d_db[ss.side].size())
-    return false;
-
-  return true;
-}
-
-db_base_sptr
-usrp_basic::selected_subdev(const usrp_subdev_spec &ss)
-{
-  if (!is_valid(ss))
-    throw std::invalid_argument("invalid subdev_spec");
-
-  return d_db[ss.side][ss.subdev];
-}
-
-bool
-usrp_basic::start ()
-{
-  return true;         // nop
-}
-
-bool
-usrp_basic::stop ()
-{
-  return true;         // nop
-}
-
-void
-usrp_basic::set_usb_data_rate (int usb_data_rate)
-{
-  d_usb_data_rate = usb_data_rate;
-  d_bytes_per_poll = (int) (usb_data_rate * POLLING_INTERVAL);
-}
-
-bool
-usrp_basic::_write_aux_dac (int slot, int which_dac, int value)
-{
-  return usrp_write_aux_dac (d_udh, slot, which_dac, value);
-}
-
-bool
-usrp_basic::_read_aux_adc (int slot, int which_adc, int *value)
-{
-  return usrp_read_aux_adc (d_udh, slot, which_adc, value);
-}
-
-int
-usrp_basic::_read_aux_adc (int slot, int which_adc)
-{
-  int  value;
-  if (!_read_aux_adc (slot, which_adc, &value))
-    return READ_FAILED;
-
-  return value;
-}
-
-bool
-usrp_basic::write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf)
-{
-  return usrp_eeprom_write (d_udh, i2c_addr, eeprom_offset, buf.data (), buf.size ());
-}
-
-std::string
-usrp_basic::read_eeprom (int i2c_addr, int eeprom_offset, int len)
-{
-  if (len <= 0)
-    return "";
-
-  char buf[len];
-
-  if (!usrp_eeprom_read (d_udh, i2c_addr, eeprom_offset, buf, len))
-    return "";
-
-  return std::string (buf, len);
-}
-
-bool
-usrp_basic::write_i2c (int i2c_addr, const std::string buf)
-{
-  return usrp_i2c_write (d_udh, i2c_addr, buf.data (), buf.size ());
-}
-
-std::string
-usrp_basic::read_i2c (int i2c_addr, int len)
-{
-  if (len <= 0)
-    return "";
-
-  char buf[len];
-
-  if (!usrp_i2c_read (d_udh, i2c_addr, buf, len))
-    return "";
-
-  return std::string (buf, len);
-}
-
-std::string
-usrp_basic::serial_number()
-{
-  return usrp_serial_number(d_udh);
-}
-
-// ----------------------------------------------------------------
-
-bool
-usrp_basic::set_adc_offset (int which_adc, int offset)
-{
-  if (which_adc < 0 || which_adc > 3)
-    return false;
-
-  return _write_fpga_reg (FR_ADC_OFFSET_0 + which_adc, offset);
-}
-
-bool
-usrp_basic::set_dac_offset (int which_dac, int offset, int offset_pin)
-{
-  if (which_dac < 0 || which_dac > 3)
-    return false;
-
-  int which_codec = which_dac >> 1;
-  int tx_a = (which_dac & 0x1) == 0;
-  int lo = ((offset & 0x3) << 6) | (offset_pin & 0x1);
-  int hi = (offset >> 2);
-  bool ok;
-
-  if (tx_a){
-    ok =  _write_9862 (which_codec, REG_TX_A_OFFSET_LO, lo);
-    ok &= _write_9862 (which_codec, REG_TX_A_OFFSET_HI, hi);
-  }
-  else {
-    ok =  _write_9862 (which_codec, REG_TX_B_OFFSET_LO, lo);
-    ok &= _write_9862 (which_codec, REG_TX_B_OFFSET_HI, hi);
-  }
-  return ok;
-}
-
-bool
-usrp_basic::set_adc_buffer_bypass (int which_adc, bool bypass)
-{
-  if (which_adc < 0 || which_adc > 3)
-    return false;
-
-  int codec = which_adc >> 1;
-  int reg = (which_adc & 1) == 0 ? REG_RX_A : REG_RX_B;
-
-  unsigned char cur_rx;
-  unsigned char cur_pwr_dn;
-
-  // If the input buffer is bypassed, we need to power it down too.
-
-  bool ok = _read_9862 (codec, reg, &cur_rx);
-  ok &= _read_9862 (codec, REG_RX_PWR_DN, &cur_pwr_dn);
-  if (!ok)
-    return false;
-
-  if (bypass){
-    cur_rx |= RX_X_BYPASS_INPUT_BUFFER;
-    cur_pwr_dn |= ((which_adc & 1) == 0) ? RX_PWR_DN_BUF_A : RX_PWR_DN_BUF_B;
-  }
-  else {
-    cur_rx &= ~RX_X_BYPASS_INPUT_BUFFER;
-    cur_pwr_dn &= ~(((which_adc & 1) == 0) ? RX_PWR_DN_BUF_A : RX_PWR_DN_BUF_B);
-  }
-
-  ok &= _write_9862 (codec, reg, cur_rx);
-  ok &= _write_9862 (codec, REG_RX_PWR_DN, cur_pwr_dn);
-  return ok;
-}
-
-bool
-usrp_basic::set_dc_offset_cl_enable(int bits, int mask)
-{
-  return _write_fpga_reg(FR_DC_OFFSET_CL_EN,
-                        (d_fpga_shadows[FR_DC_OFFSET_CL_EN] & ~mask) | (bits & mask));
-}
-
-// ----------------------------------------------------------------
-
-bool
-usrp_basic::_write_fpga_reg (int regno, int value)
-{
-  if (d_verbose){
-    fprintf (stdout, "_write_fpga_reg(%3d, 0x%08x)\n", regno, value);
-    fflush (stdout);
-  }
-
-  if (regno >= 0 && regno < MAX_REGS)
-    d_fpga_shadows[regno] = value;
-
-  return usrp_write_fpga_reg (d_udh, regno, value);
-}
-
-bool
-usrp_basic::_write_fpga_reg_masked (int regno, int value, int mask)
-{
-  //Only use this for registers who actually use a mask in the verilog firmware, like FR_RX_MASTER_SLAVE
-  //value is a 16 bits value and mask is a 16 bits mask
-  if (d_verbose){
-    fprintf (stdout, "_write_fpga_reg_masked(%3d, 0x%04x,0x%04x)\n", regno, value, mask);
-    fflush (stdout);
-  }
-
-  if (regno >= 0 && regno < MAX_REGS)
-    d_fpga_shadows[regno] = value;
-
-  return usrp_write_fpga_reg (d_udh, regno, (value & 0xffff) | ((mask & 0xffff)<<16));
-}
-
-
-bool
-usrp_basic::_read_fpga_reg (int regno, int *value)
-{
-  return usrp_read_fpga_reg (d_udh, regno, value);
-}
-
-int
-usrp_basic::_read_fpga_reg (int regno)
-{
-  int value;
-  if (!_read_fpga_reg (regno, &value))
-    return READ_FAILED;
-  return value;
-}
-
-bool
-usrp_basic::_write_9862 (int which_codec, int regno, unsigned char value)
-{
-  if (0 && d_verbose){
-    // FIXME really want to enable logging in usrp_prims:usrp_9862_write
-    fprintf(stdout, "_write_9862(codec = %d, regno = %2d, val = 0x%02x)\n", which_codec, regno, value);
-    fflush(stdout);
-  }
-
-  return usrp_9862_write (d_udh, which_codec, regno, value);
-}
-
-
-bool
-usrp_basic::_read_9862 (int which_codec, int regno, unsigned char *value) const
-{
-  return usrp_9862_read (d_udh, which_codec, regno, value);
-}
-
-int
-usrp_basic::_read_9862 (int which_codec, int regno) const
-{
-  unsigned char value;
-  if (!_read_9862 (which_codec, regno, &value))
-    return READ_FAILED;
-  return value;
-}
-
-bool
-usrp_basic::_write_spi (int optional_header, int enables, int format, std::string buf)
-{
-  return usrp_spi_write (d_udh, optional_header, enables, format,
-                        buf.data(), buf.size());
-}
-
-std::string
-usrp_basic::_read_spi (int optional_header, int enables, int format, int len)
-{
-  if (len <= 0)
-    return "";
-
-  char buf[len];
-
-  if (!usrp_spi_read (d_udh, optional_header, enables, format, buf, len))
-    return "";
-
-  return std::string (buf, len);
-}
-
-
-bool
-usrp_basic::_set_led (int which_led, bool on)
-{
-  return usrp_set_led (d_udh, which_led, on);
-}
-
-bool
-usrp_basic::write_atr_tx_delay(int value)
-{
-  return _write_fpga_reg(FR_ATR_TX_DELAY, value);
-}
-
-bool
-usrp_basic::write_atr_rx_delay(int value)
-{
-  return _write_fpga_reg(FR_ATR_RX_DELAY, value);
-}
-
-/*
- * ----------------------------------------------------------------
- * Routines to access and control daughterboard specific i/o
- * ----------------------------------------------------------------
- */
-static int
-slot_id_to_oe_reg (int slot_id)
-{
-  static int reg[4]  = { FR_OE_0, FR_OE_1, FR_OE_2, FR_OE_3 };
-  assert (0 <= slot_id && slot_id < 4);
-  return reg[slot_id];
-}
-
-static int
-slot_id_to_io_reg (int slot_id)
-{
-  static int reg[4]  = { FR_IO_0, FR_IO_1, FR_IO_2, FR_IO_3 };
-  assert (0 <= slot_id && slot_id < 4);
-  return reg[slot_id];
-}
-
-static int
-slot_id_to_refclk_reg(int slot_id)
-{
-  static int reg[4]  = { FR_TX_A_REFCLK, FR_RX_A_REFCLK, FR_TX_B_REFCLK, FR_RX_B_REFCLK };
-  assert (0 <= slot_id && slot_id < 4);
-  return reg[slot_id];
-}
-
-static int
-slot_id_to_atr_mask_reg(int slot_id)
-{
-  static int reg[4]  = { FR_ATR_MASK_0, FR_ATR_MASK_1, FR_ATR_MASK_2, FR_ATR_MASK_3 };
-  assert (0 <= slot_id && slot_id < 4);
-  return reg[slot_id];
-}
-
-static int
-slot_id_to_atr_txval_reg(int slot_id)
-{
-  static int reg[4]  = { FR_ATR_TXVAL_0, FR_ATR_TXVAL_1, FR_ATR_TXVAL_2, FR_ATR_TXVAL_3 };
-  assert (0 <= slot_id && slot_id < 4);
-  return reg[slot_id];
-}
-
-static int
-slot_id_to_atr_rxval_reg(int slot_id)
-{
-  static int reg[4]  = { FR_ATR_RXVAL_0, FR_ATR_RXVAL_1, FR_ATR_RXVAL_2, FR_ATR_RXVAL_3 };
-  assert (0 <= slot_id && slot_id < 4);
-  return reg[slot_id];
-}
-
-static int
-to_slot(txrx_t txrx, int which_side)
-{
-  // TX_A = 0
-  // RX_A = 1
-  // TX_B = 2
-  // RX_B = 3
-  return ((which_side & 0x1) << 1) | ((txrx & 0x1) == C_RX);
-}
-
-bool
-usrp_basic::common_set_pga(txrx_t txrx, int which_amp, double gain)
-{
-  if (which_amp < 0 || which_amp > 3)
-    return false;
-
-  gain = std::min(common_pga_max(txrx),
-                 std::max(common_pga_min(txrx), gain));
-
-  int codec = which_amp >> 1;  
-  int int_gain = (int) rint((gain - common_pga_min(txrx)) / common_pga_db_per_step(txrx));
-
-  if (txrx == C_TX){           // 0 and 1 are same, as are 2 and 3
-    return _write_9862(codec, REG_TX_PGA, int_gain);
-  }
-  else {
-    int reg = (which_amp & 1) == 0 ? REG_RX_A : REG_RX_B;
-
-    // read current value to get input buffer bypass flag.
-    unsigned char cur_rx;
-    if (!_read_9862(codec, reg, &cur_rx))
-      return false;
-
-    cur_rx = (cur_rx & RX_X_BYPASS_INPUT_BUFFER) | (int_gain & 0x7f);
-    return _write_9862(codec, reg, cur_rx);
-  }
-}
-
-double
-usrp_basic::common_pga(txrx_t txrx, int which_amp) const
-{
-  if (which_amp < 0 || which_amp > 3)
-    return READ_FAILED;
-
-  if (txrx == C_TX){
-    int codec = which_amp >> 1;
-    unsigned char v;
-    bool ok = _read_9862 (codec, REG_TX_PGA, &v);
-    if (!ok)
-      return READ_FAILED;
-
-    return (pga_db_per_step() * v) + pga_min();
-  }
-  else {
-    int codec = which_amp >> 1;
-    int reg = (which_amp & 1) == 0 ? REG_RX_A : REG_RX_B;
-    unsigned char v;
-    bool ok = _read_9862 (codec, reg, &v);
-    if (!ok)
-      return READ_FAILED;
-
-    return (pga_db_per_step() * (v & 0x1f)) + pga_min();
-  }
-}
-
-double
-usrp_basic::common_pga_min(txrx_t txrx) const
-{
-  if (txrx == C_TX)
-    return -20.0;
-  else
-    return   0.0;
-}
-
-double
-usrp_basic::common_pga_max(txrx_t txrx) const
-{
-  if (txrx == C_TX)
-    return   0.0;
-  else
-    return  20.0;
-}
-
-double
-usrp_basic::common_pga_db_per_step(txrx_t txrx) const
-{
-  if (txrx == C_TX)
-    return  20.0 / 255;
-  else
-    return  20.0 / 20;
-}
-
-bool
-usrp_basic::_common_write_oe(txrx_t txrx, int which_side, int value, int mask)
-{
-  if (! (0 <= which_side && which_side <= 1))
-    return false;
-
-  return _write_fpga_reg(slot_id_to_oe_reg(to_slot(txrx, which_side)),
-                        (mask << 16) | (value & 0xffff));
-}
-
-bool
-usrp_basic::common_write_io(txrx_t txrx, int which_side, int value, int mask)
-{
-  if (! (0 <= which_side && which_side <= 1))
-    return false;
-
-  return _write_fpga_reg(slot_id_to_io_reg(to_slot(txrx, which_side)),
-                        (mask << 16) | (value & 0xffff));
-}
-
-bool
-usrp_basic::common_read_io(txrx_t txrx, int which_side, int *value)
-{
-  if (! (0 <= which_side && which_side <= 1))
-    return false;
-
-  int t;
-  int reg = which_side + 1;    // FIXME, *very* magic number (fix in serial_io.v)
-  bool ok = _read_fpga_reg(reg, &t);
-  if (!ok)
-    return false;
-
-  if (txrx == C_TX){
-    *value = t & 0xffff;               // FIXME, more magic
-    return true;
-  }
-  else {
-    *value = (t >> 16) & 0xffff;       // FIXME, more magic
-    return true;
-  }
-}
-
-int
-usrp_basic::common_read_io(txrx_t txrx, int which_side)
-{
-  int  value;
-  if (!common_read_io(txrx, which_side, &value))
-    return READ_FAILED;
-  return value;
-}
-
-bool
-usrp_basic::common_write_refclk(txrx_t txrx, int which_side, int value)
-{
-  if (! (0 <= which_side && which_side <= 1))
-    return false;
-
-  return _write_fpga_reg(slot_id_to_refclk_reg(to_slot(txrx, which_side)),
-                        value);
-}
-
-bool
-usrp_basic::common_write_atr_mask(txrx_t txrx, int which_side, int value)
-{
-  if (! (0 <= which_side && which_side <= 1))
-    return false;
-
-  return _write_fpga_reg(slot_id_to_atr_mask_reg(to_slot(txrx, which_side)),
-                        value);
-}
-
-bool
-usrp_basic::common_write_atr_txval(txrx_t txrx, int which_side, int value)
-{
-  if (! (0 <= which_side && which_side <= 1))
-    return false;
-
-  return _write_fpga_reg(slot_id_to_atr_txval_reg(to_slot(txrx, which_side)),
-                        value);
-}
-
-bool
-usrp_basic::common_write_atr_rxval(txrx_t txrx, int which_side, int value)
-{
-  if (! (0 <= which_side && which_side <= 1))
-    return false;
-
-  return _write_fpga_reg(slot_id_to_atr_rxval_reg(to_slot(txrx, which_side)),
-                        value);
-}
-
-bool
-usrp_basic::common_write_aux_dac(txrx_t txrx, int which_side, int which_dac, int value)
-{
-  return _write_aux_dac(to_slot(txrx, which_side), which_dac, value);
-}
-
-bool
-usrp_basic::common_read_aux_adc(txrx_t txrx, int which_side, int which_adc, int *value)
-{
-  return _read_aux_adc(to_slot(txrx, which_side), which_adc, value);
-}
-
-int
-usrp_basic::common_read_aux_adc(txrx_t txrx, int which_side, int which_adc)
-{
-  return _read_aux_adc(to_slot(txrx, which_side), which_adc);
-}
-
-
-////////////////////////////////////////////////////////////////
-//
-//                        usrp_basic_rx
-//
-////////////////////////////////////////////////////////////////
-
-static unsigned char rx_init_regs[] = {
-  REG_RX_PWR_DN,       0,
-  REG_RX_A,            0,      // minimum gain = 0x00 (max gain = 0x14)
-  REG_RX_B,            0,      // minimum gain = 0x00 (max gain = 0x14)
-  REG_RX_MISC,         (RX_MISC_HS_DUTY_CYCLE | RX_MISC_CLK_DUTY),
-  REG_RX_IF,           (RX_IF_USE_CLKOUT1
-                        | RX_IF_2S_COMP),
-  REG_RX_DIGITAL,      (RX_DIGITAL_2_CHAN)
-};
-
-
-usrp_basic_rx::usrp_basic_rx (int which_board, int fusb_block_size, int fusb_nblocks,
-                             const std::string fpga_filename,
-                             const std::string firmware_filename
-                             )
-  : usrp_basic (which_board, open_rx_interface, fpga_filename, firmware_filename),
-    d_devhandle (0), d_ephandle (0),
-    d_bytes_seen (0), d_first_read (true),
-    d_rx_enable (false)
-{
-  // initialize rx specific registers
-
-  if (!usrp_9862_write_many_all (d_udh, rx_init_regs, sizeof (rx_init_regs))){
-    fprintf (stderr, "usrp_basic_rx: failed to init AD9862 RX regs\n");
-    throw std::runtime_error ("usrp_basic_rx/init_9862");
-  }
-
-  if (0){
-    // FIXME power down 2nd codec rx path
-    usrp_9862_write (d_udh, 1, REG_RX_PWR_DN, 0x1);    // power down everything
-  }
-
-  // Reset the rx path and leave it disabled.
-  set_rx_enable (false);
-  usrp_set_fpga_rx_reset (d_udh, true);
-  usrp_set_fpga_rx_reset (d_udh, false);
-
-  set_fpga_rx_sample_rate_divisor (2); // usually correct
-
-  set_dc_offset_cl_enable(0xf, 0xf);   // enable DC offset removal control loops
-
-  probe_rx_slots (false);
-
-  //d_db[0] = instantiate_dbs(d_dbid[0], this, 0);
-  //d_db[1] = instantiate_dbs(d_dbid[1], this, 1);
-
-  // check fusb buffering parameters
-
-  if (fusb_block_size < 0 || fusb_block_size > FUSB_BLOCK_SIZE)
-    throw std::out_of_range ("usrp_basic_rx: invalid fusb_block_size");
-
-  if (fusb_nblocks < 0)
-    throw std::out_of_range ("usrp_basic_rx: invalid fusb_nblocks");
-
-  if (fusb_block_size == 0)
-    fusb_block_size = fusb_sysconfig::default_block_size();
-
-  if (fusb_nblocks == 0)
-    fusb_nblocks = std::max (1, FUSB_BUFFER_SIZE / fusb_block_size);
-
-  d_devhandle = fusb_sysconfig::make_devhandle (d_udh, d_ctx);
-  d_ephandle = d_devhandle->make_ephandle (USRP_RX_ENDPOINT, true,
-                                          fusb_block_size, fusb_nblocks);
-
-  write_atr_mask(0, 0);                // zero Rx A Auto Transmit/Receive regs
-  write_atr_txval(0, 0);
-  write_atr_rxval(0, 0);
-  write_atr_mask(1, 0);                // zero Rx B Auto Transmit/Receive regs
-  write_atr_txval(1, 0);
-  write_atr_rxval(1, 0);
-}
-
-static unsigned char rx_fini_regs[] = {
-  REG_RX_PWR_DN,       0x1                             // power down everything
-};
-
-usrp_basic_rx::~usrp_basic_rx ()
-{
-  if (!set_rx_enable (false)){
-    fprintf (stderr, "usrp_basic_rx: set_fpga_rx_enable failed\n");
-  }
-
-  d_ephandle->stop ();
-  delete d_ephandle;
-  delete d_devhandle;
-
-  if (!usrp_9862_write_many_all (d_udh, rx_fini_regs, sizeof (rx_fini_regs))){
-    fprintf (stderr, "usrp_basic_rx: failed to fini AD9862 RX regs\n");
-  }
-
-  shutdown_daughterboards();
-}
-
-
-bool
-usrp_basic_rx::start ()
-{
-  if (!usrp_basic::start ())   // invoke parent's method
-    return false;
-
-  // fire off reads before asserting rx_enable
-
-  if (!d_ephandle->start ()){
-    fprintf (stderr, "usrp_basic_rx: failed to start end point streaming");
-    return false;
-  }
-
-  if (!set_rx_enable (true)){
-    fprintf (stderr, "usrp_basic_rx: set_rx_enable failed\n");
-    return false;
-  }
-
-  return true;
-}
-
-bool
-usrp_basic_rx::stop ()
-{
-  bool ok = usrp_basic::stop();
-
-  if (!set_rx_enable(false)){
-    fprintf (stderr, "usrp_basic_rx: set_rx_enable(false) failed\n");
-    ok = false;
-  }
-
-  if (!d_ephandle->stop()){
-    fprintf (stderr, "usrp_basic_rx: failed to stop end point streaming");
-    ok = false;
-  }
-
-  return ok;
-}
-
-usrp_basic_rx *
-usrp_basic_rx::make (int which_board, int fusb_block_size, int fusb_nblocks,
-                    const std::string fpga_filename,
-                    const std::string firmware_filename)
-{
-  usrp_basic_rx *u = 0;
-
-  try {
-    u = new usrp_basic_rx (which_board, fusb_block_size, fusb_nblocks,
-                          fpga_filename, firmware_filename);
-    return u;
-  }
-  catch (...){
-    delete u;
-    return 0;
-  }
-
-  return u;
-}
-
-bool
-usrp_basic_rx::set_fpga_rx_sample_rate_divisor (unsigned int div)
-{
-  return _write_fpga_reg (FR_RX_SAMPLE_RATE_DIV, div - 1);
-}
-
-
-/*
- * \brief read data from the D/A's via the FPGA.
- * \p len must be a multiple of 512 bytes.
- *
- * \returns the number of bytes read, or -1 on error.
- *
- * If overrun is non-NULL it will be set true iff an RX overrun is detected.
- */
-int
-usrp_basic_rx::read (void *buf, int len, bool *overrun)
-{
-  int  r;
-
-  if (overrun)
-    *overrun = false;
-
-  if (len < 0 || (len % 512) != 0){
-    fprintf (stderr, "usrp_basic_rx::read: invalid length = %d\n", len);
-    return -1;
-  }
-
-  r = d_ephandle->read (buf, len);
-  if (r > 0)
-    d_bytes_seen += r;
-
-  /*
-   * In many cases, the FPGA reports an rx overrun right after we
-   * enable the Rx path.  If this is our first read, check for the
-   * overrun to clear the condition, then ignore the result.
-   */
-  if (0 && d_first_read){      // FIXME
-    d_first_read = false;
-    bool bogus_overrun;
-    usrp_check_rx_overrun (d_udh, &bogus_overrun);
-  }
-
-  if (overrun != 0 && d_bytes_seen >= d_bytes_per_poll){
-    d_bytes_seen = 0;
-    if (!usrp_check_rx_overrun (d_udh, overrun)){
-      fprintf (stderr, "usrp_basic_rx: usrp_check_rx_overrun failed\n");
-    }
-  }
-
-  return r;
-}
-
-bool
-usrp_basic_rx::set_rx_enable (bool on)
-{
-  d_rx_enable = on;
-  return usrp_set_fpga_rx_enable (d_udh, on);
-}
-
-// conditional disable, return prev state
-bool
-usrp_basic_rx::disable_rx ()
-{
-  bool enabled = rx_enable ();
-  if (enabled)
-    set_rx_enable (false);
-  return enabled;
-}
-
-// conditional set
-void
-usrp_basic_rx::restore_rx (bool on)
-{
-  if (on != rx_enable ())
-    set_rx_enable (on);
-}
-
-void
-usrp_basic_rx::probe_rx_slots (bool verbose)
-{
-  struct usrp_dboard_eeprom    eeprom;
-  static int slot_id_map[2] = { SLOT_RX_A, SLOT_RX_B };
-  static const char *slot_name[2] = { "RX d'board A", "RX d'board B" };
-
-  for (int i = 0; i < 2; i++){
-    int slot_id = slot_id_map [i];
-    const char *msg = 0;
-    usrp_dbeeprom_status_t s = usrp_read_dboard_eeprom (d_udh, slot_id, &eeprom);
-
-    switch (s){
-    case UDBE_OK:
-      d_dbid[i] = eeprom.id;
-      msg = usrp_dbid_to_string (eeprom.id).c_str ();
-      set_adc_offset (2*i+0, eeprom.offset[0]);
-      set_adc_offset (2*i+1, eeprom.offset[1]);
-      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | eeprom.oe);
-      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
-      break;
-
-    case UDBE_NO_EEPROM:
-      d_dbid[i] = -1;
-      msg = "<none>";
-      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
-      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
-      break;
-
-    case UDBE_INVALID_EEPROM:
-      d_dbid[i] = -2;
-      msg = "Invalid EEPROM contents";
-      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
-      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
-      break;
-
-    case UDBE_BAD_SLOT:
-    default:
-      assert (0);
-    }
-
-    if (verbose){
-      fflush (stdout);
-      fprintf (stderr, "%s: %s\n", slot_name[i], msg);
-    }
-  }
-}
-
-bool
-usrp_basic_rx::set_pga (int which_amp, double gain)
-{
-  return common_set_pga(C_RX, which_amp, gain);
-}
-
-double
-usrp_basic_rx::pga(int which_amp) const
-{
-  return common_pga(C_RX, which_amp);
-}
-
-double
-usrp_basic_rx::pga_min() const
-{
-  return common_pga_min(C_RX);
-}
-
-double
-usrp_basic_rx::pga_max() const
-{
-  return common_pga_max(C_RX);
-}
-
-double
-usrp_basic_rx::pga_db_per_step() const
-{
-  return common_pga_db_per_step(C_RX);
-}
-
-bool
-usrp_basic_rx::_write_oe (int which_side, int value, int mask)
-{
-  return _common_write_oe(C_RX, which_side, value, mask);
-}
-
-bool
-usrp_basic_rx::write_io (int which_side, int value, int mask)
-{
-  return common_write_io(C_RX, which_side, value, mask);
-}
-
-bool
-usrp_basic_rx::read_io (int which_side, int *value)
-{
-  return common_read_io(C_RX, which_side, value);
-}
-
-int
-usrp_basic_rx::read_io (int which_side)
-{
-  return common_read_io(C_RX, which_side);
-}
-
-bool
-usrp_basic_rx::write_refclk(int which_side, int value)
-{
-  return common_write_refclk(C_RX, which_side, value);
-}
-
-bool
-usrp_basic_rx::write_atr_mask(int which_side, int value)
-{
-  return common_write_atr_mask(C_RX, which_side, value);
-}
-
-bool
-usrp_basic_rx::write_atr_txval(int which_side, int value)
-{
-  return common_write_atr_txval(C_RX, which_side, value);
-}
-
-bool
-usrp_basic_rx::write_atr_rxval(int which_side, int value)
-{
-  return common_write_atr_rxval(C_RX, which_side, value);
-}
-
-bool
-usrp_basic_rx::write_aux_dac (int which_side, int which_dac, int value)
-{
-  return common_write_aux_dac(C_RX, which_side, which_dac, value);
-}
-
-bool
-usrp_basic_rx::read_aux_adc (int which_side, int which_adc, int *value)
-{
-  return common_read_aux_adc(C_RX, which_side, which_adc, value);
-}
-
-int
-usrp_basic_rx::read_aux_adc (int which_side, int which_adc)
-{
-  return common_read_aux_adc(C_RX, which_side, which_adc);
-}
-
-int
-usrp_basic_rx::block_size () const { return d_ephandle->block_size(); }
-
-////////////////////////////////////////////////////////////////
-//
-//                        usrp_basic_tx
-//
-////////////////////////////////////////////////////////////////
-
-
-//
-// DAC input rate 64 MHz interleaved for a total input rate of 128 MHz
-// DAC input is latched on rising edge of CLKOUT2
-// NCO is disabled
-// interpolate 2x
-// coarse modulator disabled
-//
-
-static unsigned char tx_init_regs[] = {
-  REG_TX_PWR_DN,       0,
-  REG_TX_A_OFFSET_LO,  0,
-  REG_TX_A_OFFSET_HI,  0,
-  REG_TX_B_OFFSET_LO,  0,
-  REG_TX_B_OFFSET_HI,  0,
-  REG_TX_A_GAIN,       (TX_X_GAIN_COARSE_FULL | 0),
-  REG_TX_B_GAIN,       (TX_X_GAIN_COARSE_FULL | 0),
-  REG_TX_PGA,          0xff,                   // maximum gain (0 dB)
-  REG_TX_MISC,         0,
-  REG_TX_IF,           (TX_IF_USE_CLKOUT1
-                        | TX_IF_I_FIRST
-                        | TX_IF_INV_TX_SYNC
-                        | TX_IF_2S_COMP
-                        | TX_IF_INTERLEAVED),
-  REG_TX_DIGITAL,      (TX_DIGITAL_2_DATA_PATHS
-                        | TX_DIGITAL_INTERPOLATE_4X),
-  REG_TX_MODULATOR,    (TX_MODULATOR_DISABLE_NCO
-                        | TX_MODULATOR_COARSE_MODULATION_NONE),
-  REG_TX_NCO_FTW_7_0,  0,
-  REG_TX_NCO_FTW_15_8, 0,
-  REG_TX_NCO_FTW_23_16,        0
-};
-
-usrp_basic_tx::usrp_basic_tx (int which_board, int fusb_block_size, int fusb_nblocks,
-                             const std::string fpga_filename,
-                             const std::string firmware_filename)
-  : usrp_basic (which_board, open_tx_interface, fpga_filename, firmware_filename),
-    d_devhandle (0), d_ephandle (0),
-    d_bytes_seen (0), d_first_write (true),
-    d_tx_enable (false)
-{
-  if (!usrp_9862_write_many_all (d_udh, tx_init_regs, sizeof (tx_init_regs))){
-    fprintf (stderr, "usrp_basic_tx: failed to init AD9862 TX regs\n");
-    throw std::runtime_error ("usrp_basic_tx/init_9862");
-  }
-
-  if (0){
-    // FIXME power down 2nd codec tx path
-    usrp_9862_write (d_udh, 1, REG_TX_PWR_DN,
-                    (TX_PWR_DN_TX_DIGITAL
-                     | TX_PWR_DN_TX_ANALOG_BOTH));
-  }
-
-  // Reset the tx path and leave it disabled.
-  set_tx_enable (false);
-  usrp_set_fpga_tx_reset (d_udh, true);
-  usrp_set_fpga_tx_reset (d_udh, false);
-
-  set_fpga_tx_sample_rate_divisor (4); // we're using interp x4
-
-  probe_tx_slots (false);
-
-  //d_db[0] = instantiate_dbs(d_dbid[0], this, 0);
-  //d_db[1] = instantiate_dbs(d_dbid[1], this, 1);
-
-  // check fusb buffering parameters
-
-  if (fusb_block_size < 0 || fusb_block_size > FUSB_BLOCK_SIZE)
-    throw std::out_of_range ("usrp_basic_rx: invalid fusb_block_size");
-
-  if (fusb_nblocks < 0)
-    throw std::out_of_range ("usrp_basic_rx: invalid fusb_nblocks");
-
-  if (fusb_block_size == 0)
-    fusb_block_size = FUSB_BLOCK_SIZE;
-
-  if (fusb_nblocks == 0)
-    fusb_nblocks = std::max (1, FUSB_BUFFER_SIZE / fusb_block_size);
-
-  d_devhandle = fusb_sysconfig::make_devhandle (d_udh, d_ctx);
-  d_ephandle = d_devhandle->make_ephandle (USRP_TX_ENDPOINT, false,
-                                          fusb_block_size, fusb_nblocks);
-
-  write_atr_mask(0, 0);                // zero Tx A Auto Transmit/Receive regs
-  write_atr_txval(0, 0);
-  write_atr_rxval(0, 0);
-  write_atr_mask(1, 0);                // zero Tx B Auto Transmit/Receive regs
-  write_atr_txval(1, 0);
-  write_atr_rxval(1, 0);
-}
-
-
-static unsigned char tx_fini_regs[] = {
-  REG_TX_PWR_DN,       (TX_PWR_DN_TX_DIGITAL
-                        | TX_PWR_DN_TX_ANALOG_BOTH),
-  REG_TX_MODULATOR,    (TX_MODULATOR_DISABLE_NCO
-                        | TX_MODULATOR_COARSE_MODULATION_NONE)
-};
-
-usrp_basic_tx::~usrp_basic_tx ()
-{
-  d_ephandle->stop ();
-  delete d_ephandle;
-  delete d_devhandle;
-
-  if (!usrp_9862_write_many_all (d_udh, tx_fini_regs, sizeof (tx_fini_regs))){
-    fprintf (stderr, "usrp_basic_tx: failed to fini AD9862 TX regs\n");
-  }
-
-  shutdown_daughterboards();
-}
-
-bool
-usrp_basic_tx::start ()
-{
-  if (!usrp_basic::start ())
-    return false;
-
-  if (!set_tx_enable (true)){
-    fprintf (stderr, "usrp_basic_tx: set_tx_enable failed\n");
-    return false;
-  }
-
-  if (!d_ephandle->start ()){
-    fprintf (stderr, "usrp_basic_tx: failed to start end point streaming");
-    return false;
-  }
-
-  return true;
-}
-
-bool
-usrp_basic_tx::stop ()
-{
-  bool ok = usrp_basic::stop ();
-
-  if (!d_ephandle->stop ()){
-    fprintf (stderr, "usrp_basic_tx: failed to stop end point streaming");
-    ok = false;
-  }
-
-  if (!set_tx_enable (false)){
-    fprintf (stderr, "usrp_basic_tx: set_tx_enable(false) failed\n");
-    ok = false;
-  }
-
-  return ok;
-}
-
-usrp_basic_tx *
-usrp_basic_tx::make (int which_board, int fusb_block_size, int fusb_nblocks,
-                    const std::string fpga_filename,
-                    const std::string firmware_filename)
-{
-  usrp_basic_tx *u = 0;
-
-  try {
-    u = new usrp_basic_tx (which_board, fusb_block_size, fusb_nblocks,
-                          fpga_filename, firmware_filename);
-    return u;
-  }
-  catch (...){
-    delete u;
-    return 0;
-  }
-
-  return u;
-}
-
-bool
-usrp_basic_tx::set_fpga_tx_sample_rate_divisor (unsigned int div)
-{
-  return _write_fpga_reg (FR_TX_SAMPLE_RATE_DIV, div - 1);
-}
-
-/*!
- * \brief Write data to the A/D's via the FPGA.
- *
- * \p len must be a multiple of 512 bytes.
- * \returns number of bytes written or -1 on error.
- *
- * if \p underrun is non-NULL, it will be set to true iff
- * a transmit underrun condition is detected.
- */
-int
-usrp_basic_tx::write (const void *buf, int len, bool *underrun)
-{
-  int  r;
-
-  if (underrun)
-    *underrun = false;
-
-  if (len < 0 || (len % 512) != 0){
-    fprintf (stderr, "usrp_basic_tx::write: invalid length = %d\n", len);
-    return -1;
-  }
-
-  r = d_ephandle->write (buf, len);
-  if (r > 0)
-    d_bytes_seen += r;
-
-  /*
-   * In many cases, the FPGA reports an tx underrun right after we
-   * enable the Tx path.  If this is our first write, check for the
-   * underrun to clear the condition, then ignore the result.
-   */
-  if (d_first_write && d_bytes_seen >= 4 * FUSB_BLOCK_SIZE){
-    d_first_write = false;
-    bool bogus_underrun;
-    usrp_check_tx_underrun (d_udh, &bogus_underrun);
-  }
-
-  if (underrun != 0 && d_bytes_seen >= d_bytes_per_poll){
-    d_bytes_seen = 0;
-    if (!usrp_check_tx_underrun (d_udh, underrun)){
-      fprintf (stderr, "usrp_basic_tx: usrp_check_tx_underrun failed\n");
-    }
-  }
-
-  return r;
-}
-
-void
-usrp_basic_tx::wait_for_completion ()
-{
-  d_ephandle->wait_for_completion ();
-}
-
-bool
-usrp_basic_tx::set_tx_enable (bool on)
-{
-  d_tx_enable = on;
-  // fprintf (stderr, "set_tx_enable %d\n", on);
-  return usrp_set_fpga_tx_enable (d_udh, on);
-}
-
-// conditional disable, return prev state
-bool
-usrp_basic_tx::disable_tx ()
-{
-  bool enabled = tx_enable ();
-  if (enabled)
-    set_tx_enable (false);
-  return enabled;
-}
-
-// conditional set
-void
-usrp_basic_tx::restore_tx (bool on)
-{
-  if (on != tx_enable ())
-    set_tx_enable (on);
-}
-
-void
-usrp_basic_tx::probe_tx_slots (bool verbose)
-{
-  struct usrp_dboard_eeprom    eeprom;
-  static int slot_id_map[2] = { SLOT_TX_A, SLOT_TX_B };
-  static const char *slot_name[2] = { "TX d'board A", "TX d'board B" };
-
-  for (int i = 0; i < 2; i++){
-    int slot_id = slot_id_map [i];
-    const char *msg = 0;
-    usrp_dbeeprom_status_t s = usrp_read_dboard_eeprom (d_udh, slot_id, &eeprom);
-
-    switch (s){
-    case UDBE_OK:
-      d_dbid[i] = eeprom.id;
-      msg = usrp_dbid_to_string (eeprom.id).c_str ();
-      // FIXME, figure out interpretation of dc offset for TX d'boards
-      // offset = (eeprom.offset[1] << 16) | (eeprom.offset[0] & 0xffff);
-      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | eeprom.oe);
-      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
-      break;
-
-    case UDBE_NO_EEPROM:
-      d_dbid[i] = -1;
-      msg = "<none>";
-      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
-      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
-      break;
-
-    case UDBE_INVALID_EEPROM:
-      d_dbid[i] = -2;
-      msg = "Invalid EEPROM contents";
-      _write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
-      _write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
-      break;
-
-    case UDBE_BAD_SLOT:
-    default:
-      assert (0);
-    }
-
-    if (verbose){
-      fflush (stdout);
-      fprintf (stderr, "%s: %s\n", slot_name[i], msg);
-    }
-  }
-}
-
-bool
-usrp_basic_tx::set_pga (int which_amp, double gain)
-{
-  return common_set_pga(C_TX, which_amp, gain);
-}
-
-double
-usrp_basic_tx::pga (int which_amp) const
-{
-  return common_pga(C_TX, which_amp);
-}
-
-double
-usrp_basic_tx::pga_min() const
-{
-  return common_pga_min(C_TX);
-}
-
-double
-usrp_basic_tx::pga_max() const
-{
-  return common_pga_max(C_TX);
-}
-
-double
-usrp_basic_tx::pga_db_per_step() const
-{
-  return common_pga_db_per_step(C_TX);
-}
-
-bool
-usrp_basic_tx::_write_oe (int which_side, int value, int mask)
-{
-  return _common_write_oe(C_TX, which_side, value, mask);
-}
-
-bool
-usrp_basic_tx::write_io (int which_side, int value, int mask)
-{
-  return common_write_io(C_TX, which_side, value, mask);
-}
-
-bool
-usrp_basic_tx::read_io (int which_side, int *value)
-{
-  return common_read_io(C_TX, which_side, value);
-}
-
-int
-usrp_basic_tx::read_io (int which_side)
-{
-  return common_read_io(C_TX, which_side);
-}
-
-bool
-usrp_basic_tx::write_refclk(int which_side, int value)
-{
-  return common_write_refclk(C_TX, which_side, value);
-}
-
-bool
-usrp_basic_tx::write_atr_mask(int which_side, int value)
-{
-  return common_write_atr_mask(C_TX, which_side, value);
-}
-
-bool
-usrp_basic_tx::write_atr_txval(int which_side, int value)
-{
-  return common_write_atr_txval(C_TX, which_side, value);
-}
-
-bool
-usrp_basic_tx::write_atr_rxval(int which_side, int value)
-{
-  return common_write_atr_rxval(C_TX, which_side, value);
-}
-
-bool
-usrp_basic_tx::write_aux_dac (int which_side, int which_dac, int value)
-{
-  return common_write_aux_dac(C_TX, which_side, which_dac, value);
-}
-
-bool
-usrp_basic_tx::read_aux_adc (int which_side, int which_adc, int *value)
-{
-  return common_read_aux_adc(C_TX, which_side, which_adc, value);
-}
-
-int
-usrp_basic_tx::read_aux_adc (int which_side, int which_adc)
-{
-  return common_read_aux_adc(C_TX, which_side, which_adc);
-}
-
-int
-usrp_basic_tx::block_size () const { return d_ephandle->block_size(); }
-
diff --git a/usrp/host/lib/usrp_basic_libusb0.cc b/usrp/host/lib/usrp_basic_libusb0.cc
deleted file mode 100644 (file)
index 2174805..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2004,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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <usrp/usrp_basic.h>
-#include "usrp/usrp_prims.h"
-#include "usrp_interfaces.h"
-#include "fpga_regs_common.h"
-#include "fpga_regs_standard.h"
-#include "fusb.h"
-#include "db_boards.h"
-#include <usb.h>
-#include <stdexcept>
-#include <assert.h>
-#include <math.h>
-#include <ad9862.h>
-#include <string.h>
-#include <cstdio>
-
-using namespace ad9862;
-
-#define NELEM(x) (sizeof (x) / sizeof (x[0]))
-
-
-static const double POLLING_INTERVAL = 0.1;    // seconds
-
-
-//////////////////////////////////////////////////////////////////
-//
-//                     usrp_basic
-//
-////////////////////////////////////////////////////////////////
-
-
-// Given:
-//   CLKIN = 64 MHz
-//   CLKSEL pin = high
-//
-//   CLKOUT1 = CLKIN = 64 MHz
-//   CLKOUT2 = CLKIN = 64 MHz
-//   ADC is clocked at  64 MHz
-//   DAC is clocked at 128 MHz
-
-static unsigned char common_regs[] = {
-  REG_GENERAL,         0,
-  REG_DLL,             (DLL_DISABLE_INTERNAL_XTAL_OSC
-                        | DLL_MULT_2X
-                        | DLL_FAST),
-  REG_CLKOUT,          CLKOUT2_EQ_DLL_OVER_2,
-  REG_AUX_ADC_CLK,     AUX_ADC_CLK_CLK_OVER_4
-};
-
-
-usrp_basic::usrp_basic (int which_board,
-                       struct usb_dev_handle *
-                       open_interface (struct usb_device *dev),
-                       const std::string fpga_filename,
-                       const std::string firmware_filename)
-  : d_udh (0),
-    d_usb_data_rate (16000000),        // SWAG, see below
-    d_bytes_per_poll ((int) (POLLING_INTERVAL * d_usb_data_rate)),
-    d_verbose (false), d_fpga_master_clock_freq(64000000), d_db(2)
-{
-  /*
-   * SWAG: Scientific Wild Ass Guess.
-   *
-   * d_usb_data_rate is used only to determine how often to poll for over- and under-runs.
-   * We defualt it to 1/2  of our best case.  Classes derived from usrp_basic (e.g.,
-   * usrp_standard_tx and usrp_standard_rx) call set_usb_data_rate() to tell us the
-   * actual rate.  This doesn't change our throughput, that's determined by the signal
-   * processing code in the FPGA (which we know nothing about), and the system limits
-   * determined by libusb, fusb_*, and the underlying drivers.
-   */
-  memset (d_fpga_shadows, 0, sizeof (d_fpga_shadows));
-
-  usrp_one_time_init ();
-
-  if (!usrp_load_standard_bits (which_board, false, fpga_filename, firmware_filename))
-    throw std::runtime_error ("usrp_basic/usrp_load_standard_bits");
-
-  struct usb_device *dev = usrp_find_device (which_board);
-  if (dev == 0){
-    fprintf (stderr, "usrp_basic: can't find usrp[%d]\n", which_board);
-    throw std::runtime_error ("usrp_basic/usrp_find_device");
-  }
-
-  if (!(usrp_usrp_p(dev) && usrp_hw_rev(dev) >= 1)){
-    fprintf (stderr, "usrp_basic: sorry, this code only works with USRP revs >= 1\n");
-    throw std::runtime_error ("usrp_basic/bad_rev");
-  }
-
-  if ((d_udh = open_interface (dev)) == 0)
-    throw std::runtime_error ("usrp_basic/open_interface");
-
-  // initialize registers that are common to rx and tx
-
-  if (!usrp_9862_write_many_all (d_udh, common_regs, sizeof (common_regs))){
-    fprintf (stderr, "usrp_basic: failed to init common AD9862 regs\n");
-    throw std::runtime_error ("usrp_basic/init_9862");
-  }
-
-  _write_fpga_reg (FR_MODE, 0);                // ensure we're in normal mode
-  _write_fpga_reg (FR_DEBUG_EN, 0);    // disable debug outputs
-}
-
-usrp_basic::~usrp_basic ()
-{
-  // shutdown_daughterboards();                // call from ~usrp_basic_{tx,rx}
-
-  d_db.resize(0); // forget db shared ptrs
-
-  if (d_udh)
-    usb_close (d_udh);
-}
-
diff --git a/usrp/host/lib/usrp_basic_libusb1.cc b/usrp/host/lib/usrp_basic_libusb1.cc
deleted file mode 100644 (file)
index 35009dc..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2004,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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <usrp/usrp_basic.h>
-#include "usrp/usrp_prims.h"
-#include "usrp_interfaces.h"
-#include "fpga_regs_common.h"
-#include "fpga_regs_standard.h"
-#include "fusb.h"
-#include "db_boards.h"
-#include <libusb-1.0/libusb.h>
-#include <stdexcept>
-#include <assert.h>
-#include <math.h>
-#include <ad9862.h>
-#include <string.h>
-#include <cstdio>
-
-
-using namespace ad9862;
-
-#define NELEM(x) (sizeof (x) / sizeof (x[0]))
-
-
-static const double POLLING_INTERVAL = 0.1;    // seconds
-
-
-//////////////////////////////////////////////////////////////////
-//
-//                     usrp_basic
-//
-////////////////////////////////////////////////////////////////
-
-
-// Given:
-//   CLKIN = 64 MHz
-//   CLKSEL pin = high
-//
-// These settings give us:
-//   CLKOUT1 = CLKIN = 64 MHz
-//   CLKOUT2 = CLKIN = 64 MHz
-//   ADC is clocked at  64 MHz
-//   DAC is clocked at 128 MHz
-
-static unsigned char common_regs[] = {
-  REG_GENERAL,         0,
-  REG_DLL,             (DLL_DISABLE_INTERNAL_XTAL_OSC
-                        | DLL_MULT_2X
-                        | DLL_FAST),
-  REG_CLKOUT,          CLKOUT2_EQ_DLL_OVER_2,
-  REG_AUX_ADC_CLK,     AUX_ADC_CLK_CLK_OVER_4
-};
-
-usrp_basic::usrp_basic (int which_board,
-                       struct libusb_device_handle *
-                       open_interface (struct libusb_device *dev),
-                       const std::string fpga_filename,
-                       const std::string firmware_filename)
-  : d_udh (0), d_ctx (0),
-    d_usb_data_rate (16000000),        // SWAG, see below
-    d_bytes_per_poll ((int) (POLLING_INTERVAL * d_usb_data_rate)),
-    d_verbose (false), d_fpga_master_clock_freq(64000000), d_db(2)
-{
-  /*
-   * SWAG: Scientific Wild Ass Guess.
-   *
-   * d_usb_data_rate is used only to determine how often to poll for over- and under-runs.
-   * We defualt it to 1/2  of our best case.  Classes derived from usrp_basic (e.g.,
-   * usrp_standard_tx and usrp_standard_rx) call set_usb_data_rate() to tell us the
-   * actual rate.  This doesn't change our throughput, that's determined by the signal
-   * processing code in the FPGA (which we know nothing about), and the system limits
-   * determined by libusb, fusb_*, and the underlying drivers.
-   */
-  memset (d_fpga_shadows, 0, sizeof (d_fpga_shadows));
-
-  usrp_one_time_init (&d_ctx);
-
-  if (!usrp_load_standard_bits (which_board, false, fpga_filename, firmware_filename, d_ctx))
-    throw std::runtime_error ("usrp_basic/usrp_load_standard_bits");
-
-  struct libusb_device *dev = usrp_find_device (which_board, false, d_ctx);
-  if (dev == 0){
-    fprintf (stderr, "usrp_basic: can't find usrp[%d]\n", which_board);
-    throw std::runtime_error ("usrp_basic/usrp_find_device");
-  }
-
-  if (!(usrp_usrp_p(dev) && usrp_hw_rev(dev) >= 1)){
-    fprintf (stderr, "usrp_basic: sorry, this code only works with USRP revs >= 1\n");
-    throw std::runtime_error ("usrp_basic/bad_rev");
-  }
-
-  if ((d_udh = open_interface (dev)) == 0)
-    throw std::runtime_error ("usrp_basic/open_interface");
-
-  // initialize registers that are common to rx and tx
-
-  if (!usrp_9862_write_many_all (d_udh, common_regs, sizeof (common_regs))){
-    fprintf (stderr, "usrp_basic: failed to init common AD9862 regs\n");
-    throw std::runtime_error ("usrp_basic/init_9862");
-  }
-
-  _write_fpga_reg (FR_MODE, 0);                // ensure we're in normal mode
-  _write_fpga_reg (FR_DEBUG_EN, 0);    // disable debug outputs
-
-}
-
-usrp_basic::~usrp_basic ()
-{
-  // shutdown_daughterboards();                // call from ~usrp_basic_{tx,rx}
-
-  d_db.resize(0); // forget db shared ptrs
-
-  if (d_udh)
-    libusb_close (d_udh);
-
-  // Each object _should_ be running in its own context. If running in default
-  // context then leave the instance open as it may be shared.
-
-  if (d_ctx != NULL)
-    libusb_exit (d_ctx);
-}
-
index 7053786d807926a02dd2df84a54b6d96cbf11a49..4d1fd78c97c7f2ee27c40a094c5dfb8ee85cea72 100644 (file)
@@ -105,6 +105,12 @@ usrp_one_time_init (libusb_context **ctx)
   }
 }
 
+void
+usrp_deinit (libusb_context *ctx)
+{
+  // nop
+}
+
 void
 usrp_rescan ()
 {
index fdd497abc6405703c70f2e034e3d35e93b08ad8f..5dfe416e148231a3770781180b9f635fa823fd9c 100644 (file)
@@ -135,6 +135,7 @@ _usb_control_transfer (struct libusb_device_handle *udh, int request_type,
   return ret;
 }
 
+
 // ----------------------------------------------------------------
 
 
@@ -154,13 +155,21 @@ usrp_one_time_init (libusb_context **ctx)
     libusb_set_debug(*ctx, 3);
 }
 
+void
+usrp_deinit (struct libusb_context *ctx)
+{
+  // Each object _should_ be running in its own context. If running in default
+  // context then leave the instance open as it may be shared.
+  if (ctx != NULL)
+    libusb_exit (ctx);
+}
+
 void
 usrp_rescan ()
 {
   // nop
 }
 
-
 struct libusb_device *
 usrp_find_device (int nth, bool fx2_ok_p, libusb_context *ctx)
 {