commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r9905 - in gnuradio/branches/developers/eb/cppdb-wip/g


From: eb
Subject: [Commit-gnuradio] r9905 - in gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src: . not-sure
Date: Sun, 2 Nov 2008 15:43:31 -0700 (MST)

Author: eb
Date: 2008-11-02 15:42:57 -0700 (Sun, 02 Nov 2008)
New Revision: 9905

Added:
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1.i
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.i
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink.i
   
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_base.cc
   
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_base.h
   
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_c.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_c.h
   
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_s.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_s.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source.i
   
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_base.cc
   
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_base.h
   
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_c.cc
   
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_c.h
   
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_s.cc
   
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_s.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.h
Removed:
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1.i
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_base.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_base.i
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink.i
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source.i
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.h
Log:
moved modified code out of way; start with copy of trunk versions

Copied: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1.i 
(from rev 9904, gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1.i)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1.i      
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1.i      
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,134 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+%feature("autodoc", "1");              // generate python docstrings
+
+%include "exception.i"
+%import "gnuradio.i"                           // the common stuff
+
+%{
+#include "gnuradio_swig_bug_workaround.h"      // mandatory bug fix
+#include "usrp1_base.h"
+#include "usrp1_source_base.h"
+#include "usrp1_source_c.h"
+#include "usrp1_source_s.h"
+#include "usrp1_sink_base.h"
+#include "usrp1_sink_c.h"
+#include "usrp1_sink_s.h"
+#include "usrp_standard.h"
+#include "usrp_spi_defs.h"
+#include <db_base.h>
+#include <stdexcept>
+%}
+
+%include <usrp_spi_defs.h>
+%include <usrp1_base.i>
+%include <usrp1_source.i>
+%include <usrp1_sink.i>
+
+%include <db_base.i>
+
+%constant int FPGA_MODE_NORMAL   = usrp_standard_rx::FPGA_MODE_NORMAL;
+%constant int FPGA_MODE_LOOPBACK = usrp_standard_rx::FPGA_MODE_LOOPBACK;
+%constant int FPGA_MODE_COUNTING = usrp_standard_rx::FPGA_MODE_COUNTING;
+
+
+%pythoncode %{
+  import re
+  def selected_subdev(u, spec):
+      return u.selected_subdev(spec)
+  def determine_rx_mux_value(u, spec):
+      return u.determine_rx_mux_value(spec)
+  def determine_tx_mux_value(u, spec):
+      return u.determine_tx_mux_value(spec)
+
+  # This fakes out the source_c(*args) that swig generates and adds **kwargs 
to it.
+  # I wish I knew a cleaner way to convert the list, but I dont.
+  # This problem might be fixable by using the "-keyword" option passed to 
swig during compile time.
+  # However, this function is not well documented and can cause errors with 
overloaded function
+  # (like in shared_ptr.i). While this is kludgey, it solves the keyword 
argument problem.
+
+  def process_args(argslist):
+    # process the doc string to get the argument names and default values
+    p = re.compile("\w+=\S*")
+    m = p.findall(argslist)
+    argslist = list()
+    argsvals = list()
+    for val in m:
+      key = val.split("=")[0]
+      value = val.split("=")[1].strip(",)")
+      try:
+        v = int(value)
+      except ValueError: # convert the hex value
+        try:
+          v = int(value,16)
+        except ValueError, e:
+          v = value.strip("\"")
+      argslist.append(key)
+      argsvals.append(v)
+
+    return (argslist, argsvals)
+
+  def source_c(*args, **kwargs):
+    constructor_args = _usrp.source_c.__doc__
+    constructor_args = constructor_args.split("->")[0]
+    argslist, argsvals = process_args(constructor_args)
+    i = 0
+    for a in argslist:
+        if(kwargs.has_key(a)):
+            argsvals[i] = kwargs[a]
+        i += 1
+    return _usrp.source_c(*argsvals)
+ 
+  def source_s(*args, **kwargs):
+    constructor_args = _usrp.source_s.__doc__
+    constructor_args = constructor_args.split("->")[0]
+    argslist, argsvals = process_args(constructor_args)
+    i = 0
+    for a in argslist:
+        if(kwargs.has_key(a)):
+            argsvals[i] = kwargs[a]
+        i += 1
+    return _usrp.source_s(*argsvals)
+
+  def sink_c(*args, **kwargs):
+    constructor_args = _usrp.sink_c.__doc__
+    constructor_args = constructor_args.split("->")[0]
+    argslist, argsvals = process_args(constructor_args)
+    i = 0
+    for a in argslist:
+        if(kwargs.has_key(a)):
+            argsvals[i] = kwargs[a]
+        i += 1
+    return _usrp.sink_c(*argsvals)
+
+  def sink_s(*args, **kwargs):
+    constructor_args = _usrp.sink_s.__doc__
+    constructor_args = constructor_args.split("->")[0]
+    argslist, argsvals = process_args(constructor_args)
+    i = 0
+    for a in argslist:
+        if(kwargs.has_key(a)):
+            argsvals[i] = kwargs[a]
+        i += 1
+    return _usrp.sink_s(*argsvals)
+%}

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.cc 
(from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_base.cc)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.cc    
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.cc    
    2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,226 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with 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_standard.h>
+#include <usrp1_base.h>
+#include <assert.h>
+
+
+truth_table_element_t::truth_table_element_t(int side, unsigned int uses, 
+                                            bool swap_iq, unsigned int 
mux_val=0)
+  : d_side(side), d_uses(uses), d_swap_iq(swap_iq), d_mux_val(mux_val)
+{
+}
+
+bool
+truth_table_element_t::operator ==(const truth_table_element_t &in)
+{
+  return ((d_side == in.d_side) && (d_uses == in.d_uses)
+         && (d_swap_iq == in.d_swap_iq));
+}
+
+bool
+truth_table_element_t::operator !=(const truth_table_element_t &in)
+{
+  return !(*this == in);
+}
+
+
+
+
+usrp1_base::usrp1_base(const std::string &name, gr_io_signature_sptr insig,
+                      gr_io_signature_sptr outsig)
+  : gr_sync_block (name, insig, outsig)
+{
+}
+
+usrp1_base::~usrp1_base ()
+{
+}
+
+int
+_look_for_usrp(int which)
+{
+  // Try to open the specified usrp.
+
+  // param which: int >= 0 specifying which USRP to open
+  // type which: int
+    
+  // return: Returns version number, or raises RuntimeError
+  // rtype: int
+
+  struct usb_device *d = usrp_find_device(which);
+  if(!d) {
+    throw std::runtime_error("Unable to find USRP");
+  }
+ 
+  return usrp_hw_rev(d);
+}
+
+void
+_ensure_rev2(int which)
+{
+  int v = _look_for_usrp(which);
+  if(!((v == 2) || (v = 4))) {
+    throw std::runtime_error("Sorry, unsupported USRP revision");
+  }
+}
+
+float 
+calc_dxc_freq(float target_freq, float baseband_freq, long fs, bool &inverted)
+{
+  /*
+    Calculate the frequency to use for setting the digital up or down 
converter.
+    
+    @param target_freq: desired RF frequency (Hz)
+    @type  target_freq: number
+    @param baseband_freq: the RF frequency that corresponds to DC in the IF.
+    @type  baseband_freq: number
+    @param fs: converter sample rate
+    @type  fs: number
+    
+    @returns: 2-tuple (ddc_freq, inverted) where ddc_freq is the value
+      for the ddc and inverted is True if we're operating in an inverted
+      Nyquist zone.
+  */
+
+  float delta = target_freq - baseband_freq;
+    
+  if(delta >= 0) {
+    while(delta > fs) {
+      delta -= fs;
+    }
+    if(delta <= fs/2) {
+      inverted = false;
+      return (-delta);         // non-inverted region
+    }
+    else {
+      inverted = true;
+      return (delta - fs);     // inverted region
+    }
+  }
+  else {
+    while(delta < -fs) {
+      delta += fs;
+    }
+    if(delta >= -fs/2) {
+      inverted = false;
+      return (-delta);         // non-inverted region
+    }
+    else {
+      inverted = true;
+      return (delta + fs);     // inverted region
+    }
+  }
+}
+
+
+//******************************************************************************/
+//           Utilities to pick the subdevice tuple (side, spec)
+//******************************************************************************/
+
+std::vector<int> 
+pick_tx_subdevice(usrp_basic *u)
+{
+  /*
+    The user didn't specify a tx subdevice on the command line.
+    Try for one of these, in order: FLEX_400, FLEX_900, FLEX_1200, FLEX_2400,
+    BASIC_TX, whatever's on side A.
+    
+    @return a subdev_spec
+  */
+   
+  int dbid[5] = {USRP_DBID_FLEX_400_TX,
+                USRP_DBID_FLEX_900_TX,
+                USRP_DBID_FLEX_1200_TX,
+                USRP_DBID_FLEX_2400_TX,
+                USRP_DBID_BASIC_TX};
+  
+  return pick_subdev(u, dbid, 5);
+}
+
+std::vector<int> 
+pick_rx_subdevice(usrp_basic *u)
+{
+  /*
+    The user didn't specify an rx subdevice on the command line.
+    Try for one of these, in order: FLEX_400, FLEX_900, FLEX_1200, FLEX_2400,
+    TV_RX, DBS_RX, BASIC_RX, whatever's on side A.
+    
+    @return a subdev_spec
+  */
+  
+  int dbid[9] = {USRP_DBID_FLEX_400_RX,
+                USRP_DBID_FLEX_900_RX,
+                USRP_DBID_FLEX_1200_RX,
+                USRP_DBID_FLEX_2400_RX,
+                USRP_DBID_TV_RX,
+                USRP_DBID_TV_RX_REV_2,
+                USRP_DBID_DBS_RX,
+                USRP_DBID_DBS_RX_REV_2_1,
+                USRP_DBID_BASIC_RX};
+
+  return pick_subdev(u, dbid, 9);
+}
+
+std::vector<int> 
+pick_subdev(usrp_basic *u, int candidates[], int ncandidates)
+{
+  /*
+    @param u:          usrp instance
+    @param candidates: list of dbids
+    @returns: subdev specification
+  */
+
+  std::vector<int> ss(2);
+  
+  int db0 = u->db(0)[0]->dbid();
+  int db1 = u->db(1)[0]->dbid();
+  for(int i=0; i < ncandidates; i++) {
+    if(candidates[i] == db0) {
+      ss[0] = 0;
+      ss[1] = 0;
+      return ss;
+    }
+    if(candidates[i] == db1) {
+      ss[0] = 1;
+      ss[1] = 0;
+      return ss;
+    }
+  }
+  if(db0 >= 0) {
+    ss[0] = 0;
+    ss[1] = 0;
+    return ss;
+  }
+  if(db1 >= 0) {
+    ss[0] = 1;
+    ss[1] = 0;
+    return ss;
+  }
+  
+  throw std::runtime_error("No suitable daughterboard found!");
+}

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.h 
(from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_base.h)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.h 
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.h 
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,397 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with 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_USRP1_BASE_H
+#define INCLUDED_USRP1_BASE_H
+
+#include <stdexcept>
+#include <gr_io_signature.h>
+#include <gr_sync_block.h>
+#include <usrp_standard.h>
+#include <usrp_spi_defs.h>
+#include <usrp_dbid.h>
+#include <usrp_prims.h>
+#include <fpga_regs_standard.h>
+#include <fpga_regs_common.h>
+#include <iostream>
+#include <db_base.h>
+
+class truth_table_element_t 
+{
+public:
+  truth_table_element_t(int side, unsigned int uses, bool swap_iq, unsigned 
int mux_val);
+  bool operator==(const truth_table_element_t &in);
+  bool operator!=(const truth_table_element_t &in);
+
+  unsigned int mux_val() { return d_mux_val; }
+
+private:
+  int          d_side;
+  unsigned int d_uses;
+  bool         d_swap_iq;
+  unsigned int d_mux_val;
+};
+
+/*!
+ * \brief abstract interface to Universal Software Radio Peripheral (Rev 1)
+ */
+
+typedef std::vector<int> subdev_spec_t;
+
+class usrp1_base : public gr_sync_block
+{
+ protected:
+  int d_fpga_caps;
+
+  usrp1_base (const std::string &name, gr_io_signature_sptr insig, 
gr_io_signature_sptr outsig);
+
+ public:
+  //! magic value used on alternate register read interfaces
+  static const int READ_FAILED = -99999;
+
+  virtual ~usrp1_base ();
+
+  std::vector< std::vector<db_base_sptr> > db;
+  
+  virtual std::vector<db_base_sptr> dboard(int which) 
+  { throw std::runtime_error("dboard called from base class\n"); }
+  
+  virtual unsigned int determine_tx_mux_value(const std::vector<int> 
&subdev_spec) 
+  { throw std::runtime_error("determing_tx_value called from base class\n"); }
+  virtual unsigned int determine_rx_mux_value(const std::vector<int> 
&subdev_spec) 
+  { throw std::runtime_error("determing_rx_value called from base class\n"); }
+  virtual db_base_sptr selected_subdev(const std::vector<int> &subdev_spec) 
+  { throw std::runtime_error("selected_subdev called from base class\n"); }
+  
+  virtual bool start() {return false;}
+  virtual bool stop() {return false;}
+
+  virtual bool set_nchannels (unsigned int nchan) {return false;}
+  virtual bool set_mux (unsigned int mux) {return false;}
+
+  virtual void set_verbose (bool verbose) {}
+
+  virtual bool set_tx_freq (int channel, double freq) 
+  { throw std::runtime_error("set_tx_freq called from base class\n"); } 
+  virtual bool set_rx_freq (int channel, double freq) 
+  { throw std::runtime_error("set_rx_freq called from base class\n"); }
+  virtual double tx_freq (int channel) const 
+  { throw std::runtime_error("tx_freq called from base class\n"); }
+  virtual double rx_freq (int channel) const
+  { throw std::runtime_error("rx_freq called from base class\n"); }
+
+  /*!
+   * \brief Set Programmable Gain Amplifier (PGA)
+   *
+   * \param which      which A/D [0,3]
+   * \param gain_in_db gain value (linear in dB)
+   *
+   * gain is rounded to closest setting supported by hardware.
+   *
+   * \returns true iff sucessful.
+   *
+   * \sa pga_min(), pga_max(), pga_db_per_step()
+   */
+  virtual bool set_pga (int which, double gain_in_db) {return false;}
+
+  /*!
+   * \brief Return programmable gain amplifier gain setting in dB.
+   *
+   * \param which      which A/D [0,3]
+   */
+  virtual double pga (int which) const {return 0;}
+
+  /*!
+   * \brief Return minimum legal PGA setting in dB.
+   */
+  virtual double pga_min () const {return 0;}
+
+  /*!
+   * \brief Return maximum legal PGA setting in dB.
+   */
+  virtual double pga_max () const  {return 0;}
+
+  /*!
+   * \brief Return hardware step size of PGA (linear in dB).
+   */
+  virtual double pga_db_per_step () const {return 0;}
+
+  // ACCESSORS
+  
+  virtual long fpga_master_clock_freq() const {return 0;}
+  virtual long converter_rate() const {return 0;}
+
+  virtual int nchannels () const {return 0;}
+  virtual int mux () const {return 0;}
+  virtual int noverruns () const {return 0;}
+
+  /*!
+   * \brief Return daughterboard ID for given daughterboard slot [0,1].
+   *
+   * \return daughterboard id >= 0 if successful
+   * \return -1 if no daugherboard
+   * \return -2 if invalid EEPROM on daughterboard
+   */
+  virtual int daughterboard_id (int which_dboard) const {return 0;}
+
+  /*!
+   * \brief Write auxiliary digital to analog converter.
+   *
+   * \param which_dboard       [0,1] which d'board
+   *                           N.B., SLOT_TX_A and SLOT_RX_A share the same 
AUX DAC's.
+   *                           SLOT_TX_B and SLOT_RX_B share the same AUX 
DAC's.
+   * \param which_dac          [2,3] TX slots must use only 2 and 3.
+   * \param value              [0,4095]
+   * \returns true iff successful
+   */
+  virtual bool write_aux_dac (int which_board, int which_dac, int value) 
{return false;}
+
+  /*!
+   * \brief Read auxiliary analog to digital converter.
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param which_adc          [0,1]
+   * \returns value in the range [0,4095] if successful, else READ_FAILED.
+   */
+  virtual int read_aux_adc (int which_dboard, int which_adc) {return 0;}
+
+  /*!
+   * \brief Write EEPROM on motherboard or any daughterboard.
+   * \param i2c_addr           I2C bus address of EEPROM
+   * \param eeprom_offset      byte offset in EEPROM to begin writing
+   * \param buf                        the data to write
+   * \returns true iff sucessful
+   */
+  virtual bool write_eeprom (int i2c_addr, int eeprom_offset, const 
std::string buf) {return false;}
+
+  /*!
+   * \brief Write EEPROM on motherboard or any daughterboard.
+   * \param i2c_addr           I2C bus address of EEPROM
+   * \param eeprom_offset      byte offset in EEPROM to begin reading
+   * \param len                        number of bytes to read
+   * \returns the data read if successful, else a zero length string.
+   */
+  virtual std::string read_eeprom (int i2c_addr, int eeprom_offset, int len) 
{return NULL;}
+
+  /*!
+   * \brief Write to I2C peripheral
+   * \param i2c_addr           I2C bus address (7-bits)
+   * \param buf                        the data to write
+   * \returns true iff successful
+   * Writes are limited to a maximum of of 64 bytes.
+   */
+  virtual bool write_i2c (int i2c_addr, const std::string buf) { return false;}
+
+  /*!
+   * \brief Read from I2C peripheral
+   * \param i2c_addr           I2C bus address (7-bits)
+   * \param len                        number of bytes to read
+   * \returns the data read if successful, else a zero length string.
+   * Reads are limited to a maximum of of 64 bytes.
+   */
+  virtual std::string read_i2c (int i2c_addr, int len) {return NULL;}
+
+  /*!
+   * \brief Set ADC offset correction
+   * \param which      which ADC[0,3]: 0 = RX_A I, 1 = RX_A Q...
+   * \param offset     16-bit value to subtract from raw ADC input.
+   */
+  virtual bool set_adc_offset (int which, int offset) {return false;}
+
+  /*!
+   * \brief Set DAC offset correction
+   * \param which      which DAC[0,3]: 0 = TX_A I, 1 = TX_A Q...
+   * \param offset     10-bit offset value (ambiguous format:  See AD9862 
datasheet).
+   * \param offset_pin 1-bit value.  If 0 offset applied to -ve differential 
pin;
+   *                                  If 1 offset applied to +ve differential 
pin.
+   */
+  virtual bool set_dac_offset (int which, int offset, int offset_pin) {return 
false;}
+
+  /*!
+   * \brief Control ADC input buffer
+   * \param which      which ADC[0,3]
+   * \param bypass     if non-zero, bypass input buffer and connect input
+   *                   directly to switched cap SHA input of RxPGA.
+   */
+  virtual bool set_adc_buffer_bypass (int which, bool bypass) {return false;}
+
+  /*!
+   * \brief return the usrp's serial number.
+   *
+   * \returns non-zero length string iff successful.
+   */
+  virtual std::string serial_number() {return NULL;}
+
+  /*!
+   * \brief Write direction register (output enables) for pins that go to 
daughterboard.
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param value              value to write into register
+   * \param mask               which bits of value to write into reg
+   *
+   * Each d'board has 16-bits of general purpose i/o.
+   * Setting the bit makes it an output from the FPGA to the d'board.
+   *
+   * This register is initialized based on a value stored in the
+   * d'board EEPROM.  In general, you shouldn't be using this routine
+   * without a very good reason.  Using this method incorrectly will
+   * kill your USRP motherboard and/or daughterboard.
+   */
+  virtual bool _write_oe (int which_dboard, int value, int mask) {return 
false;}
+
+  /*!
+   * \brief Write daughterboard i/o pin value
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param value              value to write into register
+   * \param mask               which bits of value to write into reg
+   */
+  virtual bool write_io (int which_dboard, int value, int mask) {return false;}
+
+  /*!
+   * \brief Read daughterboard i/o pin value
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \returns register value if successful, else READ_FAILED
+   */
+  virtual int read_io (int which_dboard) {return 0;}
+
+    // ----------------------------------------------------------------
+  // internal routines...  
+  // You probably shouldn't be using these...
+  // ----------------------------------------------------------------
+
+  /*!
+   * \brief Write FPGA register.
+   * \param regno      7-bit register number
+   * \param value      32-bit value
+   * \returns true iff successful
+   */
+  virtual bool _write_fpga_reg (int regno, int value) {return false;}  //< 
7-bit regno, 32-bit value
+
+  /*!
+   * \brief Write FPGA register masked.
+   * \param regno      7-bit register number
+   * \param value      16-bit value
+   * \param mask               16-bit mask
+   * \returns true iff successful
+   */
+  virtual bool _write_fpga_reg_masked (int regno, int value, int mask) {return 
false;} //< 7-bit regno, 16-bit value, 16-bit mask
+
+  /*!
+   * \brief Read FPGA register.
+   * \param regno      7-bit register number
+   * \returns register value if successful, else READ_FAILED
+   */
+  virtual int _read_fpga_reg (int regno) {return 0;}
+
+  /*!
+   * \brief Write AD9862 register.
+   * \param which_codec 0 or 1
+   * \param regno      6-bit register number
+   * \param value      8-bit value
+   * \returns true iff successful
+   */
+  virtual bool _write_9862 (int which_codec, int regno, unsigned char value) 
{return false;}
+
+  /*!
+   * \brief Read AD9862 register.
+   * \param which_codec 0 or 1
+   * \param regno      6-bit register number
+   * \returns register value if successful, else READ_FAILED
+   */
+  virtual int  _read_9862 (int which_codec, int regno) const {return 0;}
+
+  /*!
+   * \brief Write data to SPI bus peripheral.
+   *
+   * \param optional_header    0,1 or 2 bytes to write before buf.
+   * \param enables            bitmask of peripherals to write. See 
usrp_spi_defs.h
+   * \param format             transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+   * \param buf                        the data to write
+   * \returns true iff successful
+   * Writes are limited to a maximum of 64 bytes.
+   *
+   * If \p format specifies that optional_header bytes are present, they are
+   * written to the peripheral immediately prior to writing \p buf.
+   */
+  virtual bool _write_spi (int optional_header, int enables, int format, 
std::string buf) {return false;}
+
+  /*
+   * \brief Read data from SPI bus peripheral.
+   *
+   * \param optional_header    0,1 or 2 bytes to write before buf.
+   * \param enables            bitmask of peripheral to read. See 
usrp_spi_defs.h
+   * \param format             transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+   * \param len                        number of bytes to read.  Must be in 
[0,64].
+   * \returns the data read if sucessful, else a zero length string.
+   *
+   * Reads are limited to a maximum of 64 bytes.
+   *
+   * If \p format specifies that optional_header bytes are present, they
+   * are written to the peripheral first.  Then \p len bytes are read from
+   * the peripheral and returned.
+   */
+  virtual std::string _read_spi (int optional_header, int enables, int format, 
int len) {return NULL;}
+
+  //tune_result tune(int chan, db_base *subdev, float target_freq);
+  
+  bool has_rx_halfband()
+  {
+    return (d_fpga_caps & bmFR_RB_CAPS_RX_HAS_HALFBAND) != 0;
+  }
+ 
+  bool has_tx_halfband()
+  {
+    return (d_fpga_caps & bmFR_RB_CAPS_TX_HAS_HALFBAND) != 0;
+  }
+
+  int  nddc()
+  {
+    return (d_fpga_caps & bmFR_RB_CAPS_NDDC_MASK) >> bmFR_RB_CAPS_NDDC_SHIFT;
+  }
+
+  int  nduc()
+  {
+    return (d_fpga_caps & bmFR_RB_CAPS_NDUC_MASK) >> bmFR_RB_CAPS_NDUC_SHIFT;
+  }
+};
+
+
+
+/*
+  # ------------------------------------------------------------------------
+  #                               utilities
+  # ------------------------------------------------------------------------
+*/
+
+
+int _look_for_usrp(int which);
+void _ensure_rev2(int which);
+
+float calc_dxc_freq(float target_freq, float baseband_freq, long fs, bool 
&inverted);
+
+std::vector<int> pick_tx_subdevice(usrp_basic *u);
+std::vector<int> pick_rx_subdevice(usrp_basic *u);
+std::vector<int> pick_subdev(usrp_basic *u, int candidates[], int ncandidates);
+
+#endif /* INCLUDED_USRP1_BASE_H */

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.i 
(from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_base.i)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.i 
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_base.i 
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,111 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+%{
+#include "usrp1_base.h"
+%}
+
+// ================================================================
+//                        abstract classes
+// ================================================================
+namespace std {
+  %template() vector<db_base_sptr>;
+  %template(vect_vect_db) vector< vector<db_base_sptr> >;
+}
+
+class usrp1_base : public gr_sync_block
+{
+ private:
+  usrp_standard_common *d_usrp;
+  int d_fpga_caps;
+  
+ protected:
+  usrp1_base ();
+  
+ public:
+  //! magic value used on alternate register read interfaces
+  static const int READ_FAILED = -99999;
+
+  std::vector< std::vector<db_base_sptr> > db;
+
+  virtual ~usrp1_base ();
+
+  virtual std::vector<db_base_sptr> dboard(int which);
+
+  virtual int determine_tx_mux_value(const std::vector<int> &subdev_spec);
+  virtual int determine_rx_mux_value(const std::vector<int> &subdev_spec);
+  virtual db_base_sptr selected_subdev(const std::vector<int> &subdev_spec);
+
+  virtual bool start() {return false;}
+  virtual bool stop() {return false;}
+
+  virtual bool set_nchannels (unsigned int nchan) {return false;}
+  virtual bool set_mux (unsigned int mux) {return false;}
+
+  virtual void set_verbose (bool verbose) {}
+
+  virtual bool set_tx_freq (int channel, double freq);
+  virtual bool set_rx_freq (int channel, double freq);
+  virtual double tx_freq (int channel) const;
+  virtual double rx_freq (int channel) const;
+
+  virtual bool set_pga (int which, double gain_in_db);
+  virtual double pga (int which) const;
+  virtual double pga_min () const;
+  virtual double pga_max () const;
+  virtual double pga_db_per_step () const;
+
+  // ACCESSORS
+  
+  virtual long fpga_master_clock_freq() const;
+  virtual long converter_rate() const;
+
+  virtual int nchannels () const;
+  virtual int mux () const;
+  virtual int noverruns () const;
+  virtual int daughterboard_id (int which_dboard) const;
+  virtual bool write_aux_dac (int which_board, int which_dac, unsigned int 
value);
+  virtual unsigned int read_aux_adc (int which_dboard, int which_adc);
+  virtual bool write_eeprom (int i2c_addr, int eeprom_offset, const 
std::string buf);
+  virtual std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
+  virtual bool write_i2c (int i2c_addr, const std::string buf);
+  virtual std::string read_i2c (int i2c_addr, int len);
+  virtual bool set_adc_offset (int which, unsigned int offset);
+  virtual bool set_dac_offset (int which, int offset, int offset_pin);
+  virtual bool set_adc_buffer_bypass (int which, bool bypass);
+  virtual std::string serial_number();
+  virtual bool _write_oe (int which_dboard, unsigned int value, unsigned int 
mask);
+  virtual bool write_io (int which_dboard, unsigned int value, unsigned int 
mask);
+  virtual unsigned int read_io (int which_dboard);
+  virtual bool _write_fpga_reg (int regno, unsigned int value);
+  virtual bool _write_fpga_reg_masked (int regno, unsigned int value, int 
mask);
+  virtual unsigned int _read_fpga_reg (int regno);
+  virtual bool _write_9862 (int which_codec, int regno, unsigned char value);
+  virtual unsigned int  _read_9862 (int which_codec, int regno) const;
+  virtual bool _write_spi (int optional_header, int enables, int format, 
std::string buf);
+  virtual std::string _read_spi (int optional_header, int enables, int format, 
int len);
+
+  bool has_rx_halfband();
+  bool has_tx_halfband();
+  int  nddc();
+  int  nduc();
+};

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink.i 
(from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink.i)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink.i 
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink.i 
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,156 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// ================================================================
+//                        abstract classes
+// ================================================================
+
+class usrp1_sink_base : public usrp1_base
+{
+protected:
+  usrp1_sink_base (const std::string &name,
+                  gr_io_signature_sptr input_signature,
+                  int which_board,
+                  unsigned int interp_rate,
+                  int nchan,
+                  int mux,
+                  int fusb_block_size,
+                  int fusb_nblocks,
+                  const std::string fpga_filename,
+                  const std::string firmware_filename
+                  ) throw (std::runtime_error);
+
+  virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
+                                   int  input_index,
+                                   int  input_items_available,
+                                   int  &input_items_consumed,
+                                   void *usrp_buffer,
+                                   int  usrp_buffer_length,
+                                   int  &bytes_written) = 0;
+ public:
+  ~usrp1_sink_base ();
+
+  bool set_interp_rate (unsigned int rate);
+  bool set_nchannels (int nchan);
+  bool set_mux (int mux);
+  bool set_tx_freq (int channel, double freq);
+  void set_verbose (bool verbose);
+
+  // ACCESSORS
+
+  long fpga_master_clock_freq() const;
+  long converter_rate() const;
+  long dac_rate() const;
+  long dac_freq () const;
+
+  unsigned int interp_rate () const;
+  double tx_freq (int channel) const;
+  int nunderruns () const;
+  bool set_pga (int which, double gain_in_db);
+  double pga (int which) const;
+  double pga_min () const;
+  double pga_max () const;
+  double pga_db_per_step () const;
+  int daughterboard_id (int which_dboard) const;
+  bool set_adc_offset (int which, int offset);
+  bool set_dac_offset (int which, int offset, int offset_pin);
+  bool set_adc_buffer_bypass (int which, bool bypass);
+  std::string serial_number();
+  bool _write_oe (int which_dboard, int value, int mask);
+  bool write_io (int which_dboard, int value, int mask);
+  int read_io (int which_dboard);
+
+  bool write_aux_dac (int which_dboard, int which_dac, int value);
+  int read_aux_adc (int which_dboard, int which_adc);
+  bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf);
+  std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
+  bool write_i2c (int i2c_addr, const std::string buf);
+  std::string read_i2c (int i2c_addr, int len);
+
+  bool _write_fpga_reg (int regno, int value);
+  int  _read_fpga_reg (int regno);
+  bool _write_9862 (int which_codec, int regno, unsigned char value);
+  int  _read_9862 (int which_codec, int regno) const;
+  bool _write_spi (int optional_header, int enables, int format, std::string 
buf);
+  std::string _read_spi (int optional_header, int enables, int format, int 
len);
+
+  tune_result tune(int chan, db_base_sptr db, double target_freq);
+};
+
+
+
+// ================================================================
+//                     concrete sinks
+// ================================================================
+
+
+GR_SWIG_BLOCK_MAGIC(usrp1,sink_c)
+
+usrp1_sink_c_sptr
+usrp1_make_sink_c (int which_board=0,
+                  unsigned int interp_rate=128,
+                  int nchan=1,
+                  int mux=0x98,
+                  int fusb_block_size=0,
+                  int fusb_nblocks=0,
+                  const std::string fpga_filename="",
+                  const std::string firmware_filename=""
+                  ) throw (std::runtime_error);
+
+
+class usrp1_sink_c : public usrp1_sink_base {
+ protected:
+  usrp1_sink_c (int which_board, unsigned int interp_rate,
+               int nchan, int mux, int fusb_block_size, int fusb_nblocks,
+               const std::string fpga_filename, const std::string 
fgpa_filename);
+
+ public:
+  ~usrp1_sink_c ();
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(usrp1,sink_s)
+
+usrp1_sink_s_sptr
+usrp1_make_sink_s (int which=0,
+                  unsigned int interp_rate=128,
+                  int nchan=1,
+                  int mux=0x98,
+                  int fusb_block_size=0,
+                  int fusb_nblocks=0,
+                  const std::string fpga_filename="",
+                  const std::string firmware_filename=""
+                  ) throw (std::runtime_error);
+
+
+class usrp1_sink_s : public usrp1_sink_base {
+ protected:
+  usrp1_sink_s (int which_board, unsigned int interp_rate,
+               int nchan, int mux, int fusb_block_size, int fusb_nblocks,
+               const std::string fpga_filename, const std::string 
fgpa_filename);
+
+ public:
+  ~usrp1_sink_s ();
+};
+
+

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_base.cc
 (from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.cc)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_base.cc
                           (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_base.cc
   2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,403 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <usrp1_sink_base.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <assert.h>
+
+static const int OUTPUT_MULTIPLE_SAMPLES = 128;                // DON'T CHANGE 
THIS VALUE!
+
+usrp1_sink_base::usrp1_sink_base (const std::string &name,
+                                 gr_io_signature_sptr input_signature,
+                                 int which,
+                                 unsigned int interp_rate,
+                                 int nchan,
+                                 int mux,
+                                 int fusb_block_size,
+                                 int fusb_nblocks,
+                                 const std::string fpga_filename,
+                                 const std::string firmware_filename
+                                 ) throw (std::runtime_error)
+  : usrp1_base(name, input_signature, gr_make_io_signature (0, 0, 0)),
+    d_nunderruns (0), 
+    d_usrp(usrp_standard_tx::make (which, interp_rate,
+                                  nchan, mux, fusb_block_size,
+                                  fusb_nblocks, fpga_filename,
+                                  firmware_filename))
+{
+  if (!d_usrp.get())
+    throw std::runtime_error ("can't open usrp1");
+
+  db = d_usrp->db();
+
+  // All calls to d_usrp->write must be multiples of 512 bytes.
+
+  set_output_multiple (OUTPUT_MULTIPLE_SAMPLES);
+}
+
+usrp1_sink_base::~usrp1_sink_base ()
+{
+}
+
+unsigned int
+usrp1_sink_base::determine_tx_mux_value(const std::vector<int> &subdev_spec)
+{
+  /*
+    Determine appropriate Tx mux value as a function of the subdevice choosen.
+
+    @param u:           instance of USRP source
+    @param subdev_spec: return value from subdev option parser.  
+    @type  subdev_spec: (side, subdev), where side is 0 or 1 and subdev is 0
+    @returns:           the Rx mux value
+  
+    This is simpler than the rx case.  Either you want to talk
+    to side A or side B.  If you want to talk to both sides at once,
+    determine the value manually.
+  */
+
+  int side = subdev_spec[0];  // side A = 0, side B = 1
+  if(!((side == 0) || (side == 1))) {
+    throw std::runtime_error("Invalid subdev_spec\n");
+  }
+
+  std::vector<db_base_sptr> db = d_usrp->db(side);
+  
+  if(db[0]->i_and_q_swapped()) {
+    unsigned int mask[2] = {0x0089, 0x8900};
+    return mask[side];
+  }
+  else {
+    unsigned int mask[2] = {0x0098, 0x9800};
+    return mask[side];
+  }
+
+}
+
+db_base_sptr
+usrp1_sink_base::selected_subdev(const std::vector<int> &subdev_spec)
+{
+  /*
+    Return the user specified daughterboard subdevice.
+    
+    @param subdev_spec: return value from subdev option parser.
+    @type  subdev_spec: (side, subdev), where side is 0 or 1 and subdev is 0 
or 1
+    @returns: an weakref to an instance derived from db_base
+  */
+
+  std::vector<db_base_sptr> db1 = d_usrp->db(subdev_spec[0]);
+  return db1[subdev_spec[1]];
+}
+
+bool 
+usrp1_sink_base::start()
+{
+  return d_usrp->start();
+}
+
+bool 
+usrp1_sink_base::stop()
+{
+  return d_usrp->stop();
+}
+
+int
+usrp1_sink_base::work (int noutput_items,
+                      gr_vector_const_void_star &input_items,
+                      gr_vector_void_star &output_items)
+{
+  static const int BUFSIZE = 16 * (1L << 10);  // 16kB
+  unsigned char outbuf[BUFSIZE];
+  int          obi = 0;
+  int          input_index = 0;
+  int          input_items_consumed;
+  int          bytes_written;
+  bool         underrun;
+  
+
+  while (input_index < noutput_items){
+  
+    copy_to_usrp_buffer (input_items,
+                        input_index,
+                        noutput_items - input_index,   // input_items_available
+                        input_items_consumed,          // [out]
+                        &outbuf[obi],                  // [out] usrp_buffer
+                        BUFSIZE - obi,                 // usrp_buffer_length
+                        bytes_written);                // [out]
+
+    assert (input_index + input_items_consumed <= noutput_items);
+    assert (obi + bytes_written <= BUFSIZE);
+    
+    input_index += input_items_consumed;
+    obi += bytes_written;
+
+    if (obi >= BUFSIZE){       // flush
+      if (d_usrp->write (outbuf, obi, &underrun) != obi)
+       return -1;              // indicate we're done
+
+      if (underrun){
+       d_nunderruns++;
+       // fprintf (stderr, "usrp1_sink: underrun\n");
+       fputs ("uU", stderr);
+      }
+      obi = 0;
+    }
+  }
+
+  if (obi != 0){
+    assert (obi % 512 == 0);
+    if (d_usrp->write (outbuf, obi, &underrun) != obi)
+      return -1;       // indicate we're done
+
+    if (underrun){
+      d_nunderruns++;
+      // fprintf (stderr, "usrp1_sink: underrun\n");
+      fputs ("uU", stderr);
+    }
+  }
+
+  return noutput_items;
+}
+
+bool
+usrp1_sink_base::set_interp_rate (unsigned int rate)
+{
+  return d_usrp->set_interp_rate (rate);
+}
+
+bool
+usrp1_sink_base::set_nchannels (unsigned int nchan)
+{
+  return d_usrp->set_nchannels (nchan);
+}
+
+bool
+usrp1_sink_base::set_mux (unsigned int mux)
+{
+  return d_usrp->set_mux (mux);
+}
+
+bool
+usrp1_sink_base::set_tx_freq (int channel, double freq)
+{
+  return d_usrp->set_tx_freq (channel, freq);
+}
+
+long
+usrp1_sink_base::fpga_master_clock_freq() const
+{
+  return d_usrp->fpga_master_clock_freq();
+}
+
+long
+usrp1_sink_base::converter_rate () const
+{
+  return d_usrp->converter_rate ();
+}
+
+unsigned int
+usrp1_sink_base::interp_rate () const
+{
+  return d_usrp->interp_rate ();
+}
+
+int
+usrp1_sink_base::nchannels () const
+{
+  return d_usrp->nchannels ();
+}
+
+int
+usrp1_sink_base::mux () const
+{
+  return d_usrp->mux ();
+}
+
+
+double
+usrp1_sink_base::tx_freq (int channel) const
+{
+  return d_usrp->tx_freq (channel);
+}
+
+void
+usrp1_sink_base::set_verbose (bool verbose)
+{  
+  d_usrp->set_verbose (verbose);
+}
+
+bool
+usrp1_sink_base::write_aux_dac (int which_dboard, int which_dac, int value)
+{
+  return d_usrp->write_aux_dac (which_dboard, which_dac, value);
+}
+
+int
+usrp1_sink_base::read_aux_adc (int which_dboard, int which_adc)
+{
+  return d_usrp->read_aux_adc (which_dboard, which_adc);
+}
+
+bool
+usrp1_sink_base::write_eeprom (int i2c_addr, int eeprom_offset, const 
std::string buf)
+{
+  return d_usrp->write_eeprom (i2c_addr, eeprom_offset, buf);
+}
+
+std::string
+usrp1_sink_base::read_eeprom (int i2c_addr, int eeprom_offset, int len)
+{
+  return d_usrp->read_eeprom (i2c_addr, eeprom_offset, len);
+}
+
+bool
+usrp1_sink_base::write_i2c (int i2c_addr, const std::string buf)
+{
+  return d_usrp->write_i2c (i2c_addr, buf);
+}
+
+std::string
+usrp1_sink_base::read_i2c (int i2c_addr, int len)
+{
+  return d_usrp->read_i2c (i2c_addr, len);
+}
+
+bool
+usrp1_sink_base::set_pga (int which, double gain)
+{
+  return d_usrp->set_pga (which, gain);
+}
+
+double
+usrp1_sink_base::pga (int which) const
+{
+  return d_usrp->pga (which);
+}
+
+double
+usrp1_sink_base::pga_min () const
+{
+  return d_usrp->pga_min ();
+}
+
+double
+usrp1_sink_base::pga_max () const
+{
+  return d_usrp->pga_max ();
+}
+
+double
+usrp1_sink_base::pga_db_per_step () const
+{
+  return d_usrp->pga_db_per_step ();
+}
+
+int
+usrp1_sink_base::daughterboard_id (int which) const
+{
+  return d_usrp->daughterboard_id (which);
+}
+
+bool
+usrp1_sink_base::set_adc_offset (int which, int offset)
+{
+  return d_usrp->set_adc_offset (which, offset);
+}
+
+bool
+usrp1_sink_base::set_dac_offset (int which, int offset, int offset_pin)
+{
+  return d_usrp->set_dac_offset (which, offset, offset_pin);
+}
+
+bool
+usrp1_sink_base::set_adc_buffer_bypass (int which, bool bypass)
+{
+  return d_usrp->set_adc_buffer_bypass (which, bypass);
+}
+
+std::string
+usrp1_sink_base::serial_number()
+{
+  return d_usrp->serial_number();
+}
+
+bool
+usrp1_sink_base::_write_oe (int which_dboard, int value, int mask)
+{
+  return d_usrp->_write_oe (which_dboard, value, mask);
+}
+
+bool
+usrp1_sink_base::write_io (int which_dboard, int value, int mask)
+{
+  return d_usrp->write_io (which_dboard, value, mask);
+}
+
+int
+usrp1_sink_base::read_io (int which_dboard)
+{
+  return d_usrp->read_io (which_dboard);
+}
+
+// internal routines...
+
+bool
+usrp1_sink_base::_write_fpga_reg (int regno, int value)
+{
+  return d_usrp->_write_fpga_reg (regno, value);
+}
+
+int
+usrp1_sink_base::_read_fpga_reg (int regno)
+{
+  return d_usrp->_read_fpga_reg (regno);
+}
+
+bool
+usrp1_sink_base::_write_9862 (int which_codec, int regno, unsigned char value)
+{
+  return d_usrp->_write_9862 (which_codec, regno, value);
+}
+
+int
+usrp1_sink_base::_read_9862 (int which_codec, int regno) const
+{
+  return d_usrp->_read_9862 (which_codec, regno);
+}
+
+bool
+usrp1_sink_base::_write_spi (int optional_header, int enables,
+                            int format, std::string buf)
+{
+  return d_usrp->_write_spi (optional_header, enables, format, buf);
+}
+
+std::string
+usrp1_sink_base::_read_spi (int optional_header, int enables, int format, int 
len)
+{
+  return d_usrp->_read_spi (optional_header, enables, format, len);
+}

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_base.h
 (from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.h)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_base.h
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_base.h
    2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,369 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_USRP1_SINK_BASE_H
+#define INCLUDED_USRP1_SINK_BASE_H
+
+#include <usrp1_base.h>
+#include <stdexcept>
+#include <memory>
+
+class usrp_standard_tx;
+
+
+/*!
+ * \brief abstract interface to Universal Software Radio Peripheral Tx path 
(Rev 1)
+ */
+class usrp1_sink_base : public usrp1_base
+{
+ protected:
+  usrp1_sink_base (const std::string &name,
+                  gr_io_signature_sptr input_signature,
+                  int which,
+                  unsigned int interp_rate,
+                  int nchan,
+                  int mux,
+                  int fusb_block_size,
+                  int fusb_nblocks,
+                  const std::string fpga_filename,
+                  const std::string firmware_filename
+                  ) throw (std::runtime_error);
+
+  int d_nunderruns;
+  std::auto_ptr<usrp_standard_tx> d_usrp;
+
+  /*!
+   * \brief convert between input item format and usrp native format
+   *
+   * \param input_items[in]            stream(s) of input items
+   * \param input_index[in]            starting index in input_items
+   * \param input_items_available[in]  number of items available starting at 
item[index]
+   * \param input_items_consumed[out]          number of input items consumed 
by copy
+   * \param usrp_buffer[out]           destination buffer
+   * \param usrp_buffer_length[in]     \p usrp_buffer length in bytes
+   * \param bytes_written[out]         number of bytes written into \p 
usrp_buffer
+   */
+  virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
+                                   int  input_index,
+                                   int  input_items_available,
+                                   int  &input_items_consumed,
+                                   void *usrp_buffer,
+                                   int  usrp_buffer_length,
+                                   int  &bytes_written) = 0;
+
+ public:
+ 
+  ~usrp1_sink_base ();
+
+  // These must be included in here and not usrp1_base because of
+  // usrp_standard_common used in that class
+  std::vector<db_base_sptr> dboard(int which) { return d_usrp->db(which); }
+  db_base_sptr selected_subdev(const std::vector<int> &subdev_spec);  
+  unsigned int determine_tx_mux_value(const std::vector<int> &subdev_spec);
+  usrp_standard_tx * usrp() { return d_usrp.get(); }
+
+  // Wrapper function to call tune from USRP sink class
+  tune_result tune(int chan, db_base_sptr db, double target_freq)
+  { return db->tune(chan, target_freq); }
+
+  int work (int noutput_items,
+           gr_vector_const_void_star &input_items,
+           gr_vector_void_star &output_items);
+
+  bool start();
+  bool stop();
+
+  /*!
+   * \brief Set interpolator rate.  \p rate must be in [4, 1024] and a 
multiple of 4.
+   *
+   * The final complex sample rate across the USB is
+   *   dac_freq () / interp_rate () * nchannels ()
+   */
+  bool set_interp_rate (unsigned int rate);
+  bool set_nchannels (unsigned int nchan);
+  bool set_mux (unsigned int mux);
+
+  /*!
+   * \brief set the frequency of the digital up converter.
+   *
+   * \p channel must be 0.  \p freq is the center frequency in Hz.
+   * It must be in the range [-44M, 44M].  The frequency specified is
+   * quantized.  Use tx_freq to retrieve the actual value used.
+   */
+  bool set_tx_freq (int channel, double freq);
+
+  void set_verbose (bool verbose);
+
+  /*!
+   * \brief Set Programmable Gain Amplifier (PGA)
+   *
+   * \param which      which D/A [0,3]
+   * \param gain_in_db gain value (linear in dB)
+   *
+   * gain is rounded to closest setting supported by hardware.
+   * Note that DAC 0 and DAC 1 share a gain setting as do DAC 2 and DAC 3.
+   * Setting DAC 0 affects DAC 1 and vice versa.  Same with DAC 2 and DAC 3.
+   *
+   * \returns true iff sucessful.
+   *
+   * \sa pga_min(), pga_max(), pga_db_per_step()
+   */
+  bool set_pga (int which, double gain_in_db);
+
+  /*!
+   * \brief Return programmable gain amplifier gain in dB.
+   *
+   * \param which      which D/A [0,3]
+   */
+  double pga (int which) const;
+
+  /*!
+   * \brief Return minimum legal PGA gain in dB.
+   */
+  double pga_min () const;
+
+  /*!
+   * \brief Return maximum legal PGA gain in dB.
+   */
+  double pga_max () const;
+
+  /*!
+   * \brief Return hardware step size of PGA (linear in dB).
+   */
+  double pga_db_per_step () const;
+
+
+  // ACCESSORS
+
+  long fpga_master_clock_freq() const;
+  long converter_rate() const;
+  long dac_rate() const { return converter_rate(); }   // alias
+  long dac_freq() const { return converter_rate(); }   // deprecated alias
+
+  unsigned int interp_rate () const;
+  int nchannels () const;
+  int mux () const;
+  double tx_freq (int channel) const;
+  int nunderruns () const { return d_nunderruns; }
+
+  /*!
+   * \brief Return daughterboard ID for given Rx daughterboard slot [0,1].
+   *
+   * \return daughterboard id >= 0 if successful
+   * \return -1 if no daugherboard
+   * \return -2 if invalid EEPROM on daughterboard
+   */
+  int daughterboard_id (int which_dboard) const;
+
+  /*!
+   * \brief Write auxiliary digital to analog converter.
+   *
+   * \param which_dboard       [0,1] which d'board
+   *                           N.B., SLOT_TX_A and SLOT_RX_A share the same 
AUX DAC's.
+   *                           SLOT_TX_B and SLOT_RX_B share the same AUX 
DAC's.
+   * \param which_dac          [2,3] TX slots must use only 2 and 3.
+   * \param value              [0,4095]
+   * \returns true iff successful
+   */
+  bool write_aux_dac (int which_board, int which_dac, int value);
+
+  /*!
+   * \brief Read auxiliary analog to digital converter.
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param which_adc          [0,1]
+   * \returns value in the range [0,4095] if successful, else READ_FAILED.
+   */
+  int read_aux_adc (int which_dboard, int which_adc);
+
+  /*!
+   * \brief Write EEPROM on motherboard or any daughterboard.
+   * \param i2c_addr           I2C bus address of EEPROM
+   * \param eeprom_offset      byte offset in EEPROM to begin writing
+   * \param buf                        the data to write
+   * \returns true iff sucessful
+   */
+  bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf);
+
+  /*!
+   * \brief Write EEPROM on motherboard or any daughterboard.
+   * \param i2c_addr           I2C bus address of EEPROM
+   * \param eeprom_offset      byte offset in EEPROM to begin reading
+   * \param len                        number of bytes to read
+   * \returns the data read if successful, else a zero length string.
+   */
+  std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
+
+  /*!
+   * \brief Write to I2C peripheral
+   * \param i2c_addr           I2C bus address (7-bits)
+   * \param buf                        the data to write
+   * \returns true iff successful
+   * Writes are limited to a maximum of of 64 bytes.
+   */
+  bool write_i2c (int i2c_addr, const std::string buf);
+
+  /*!
+   * \brief Read from I2C peripheral
+   * \param i2c_addr           I2C bus address (7-bits)
+   * \param len                        number of bytes to read
+   * \returns the data read if successful, else a zero length string.
+   * Reads are limited to a maximum of of 64 bytes.
+   */
+  std::string read_i2c (int i2c_addr, int len);
+
+  /*!
+   * \brief Set ADC offset correction
+   * \param which      which ADC[0,3]: 0 = RX_A I, 1 = RX_A Q...
+   * \param offset     16-bit value to subtract from raw ADC input.
+   */
+  bool set_adc_offset (int which, int offset);
+
+  /*!
+   * \brief Set DAC offset correction
+   * \param which      which DAC[0,3]: 0 = TX_A I, 1 = TX_A Q...
+   * \param offset     10-bit offset value (ambiguous format:  See AD9862 
datasheet).
+   * \param offset_pin 1-bit value.  If 0 offset applied to -ve differential 
pin;
+   *                                  If 1 offset applied to +ve differential 
pin.
+   */
+  bool set_dac_offset (int which, int offset, int offset_pin);
+
+  /*!
+   * \brief Control ADC input buffer
+   * \param which      which ADC[0,3]
+   * \param bypass     if non-zero, bypass input buffer and connect input
+   *                   directly to switched cap SHA input of RxPGA.
+   */
+  bool set_adc_buffer_bypass (int which, bool bypass);
+
+  /*!
+   * \brief return the usrp's serial number.
+   *
+   * \returns non-zero length string iff successful.
+   */
+  std::string serial_number();
+
+  /*!
+   * \brief Write direction register (output enables) for pins that go to 
daughterboard.
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param value              value to write into register
+   * \param mask               which bits of value to write into reg
+   *
+   * Each d'board has 16-bits of general purpose i/o.
+   * Setting the bit makes it an output from the FPGA to the d'board.
+   *
+   * This register is initialized based on a value stored in the
+   * d'board EEPROM.  In general, you shouldn't be using this routine
+   * without a very good reason.  Using this method incorrectly will
+   * kill your USRP motherboard and/or daughterboard.
+   */
+  bool _write_oe (int which_dboard, int value, int mask);
+
+  /*!
+   * \brief Write daughterboard i/o pin value
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param value              value to write into register
+   * \param mask               which bits of value to write into reg
+   */
+  bool write_io (int which_dboard, int value, int mask);
+
+  /*!
+   * \brief Read daughterboard i/o pin value
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \returns register value if successful, else READ_FAILED
+   */
+
+  int read_io (int which_dboard);
+
+  //
+  // internal routines...
+  // You probably shouldn't be using these...
+  //
+  /*!
+   * \brief Write FPGA register.
+   * \param regno      7-bit register number
+   * \param value      32-bit value
+   * \returns true iff successful
+   */
+  bool _write_fpga_reg (int regno, int value); //< 7-bit regno, 32-bit value
+
+  /*!
+   * \brief Read FPGA register.
+   * \param regno      7-bit register number
+   * \returns register value if successful, else READ_FAILED
+   */
+  int  _read_fpga_reg (int regno);
+
+  /*!
+   * \brief Write AD9862 register.
+   * \param which_codec 0 or 1
+   * \param regno      6-bit register number
+   * \param value      8-bit value
+   * \returns true iff successful
+   */
+  bool _write_9862 (int which_codec, int regno, unsigned char value);
+
+  /*!
+   * \brief Read AD9862 register.
+   * \param which_codec 0 or 1
+   * \param regno      6-bit register number
+   * \returns register value if successful, else READ_FAILED
+   */
+  int  _read_9862 (int which_codec, int regno) const;
+
+  /*!
+   * \brief Write data to SPI bus peripheral.
+   *
+   * \param optional_header    0,1 or 2 bytes to write before buf.
+   * \param enables            bitmask of peripherals to write. See 
usrp_spi_defs.h
+   * \param format             transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+   * \param buf                        the data to write
+   * \returns true iff successful
+   * Writes are limited to a maximum of 64 bytes.
+   *
+   * If \p format specifies that optional_header bytes are present, they are
+   * written to the peripheral immediately prior to writing \p buf.
+   */
+  bool _write_spi (int optional_header, int enables, int format, std::string 
buf);
+
+  /*
+   * \brief Read data from SPI bus peripheral.
+   *
+   * \param optional_header    0,1 or 2 bytes to write before buf.
+   * \param enables            bitmask of peripheral to read. See 
usrp_spi_defs.h
+   * \param format             transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+   * \param len                        number of bytes to read.  Must be in 
[0,64].
+   * \returns the data read if sucessful, else a zero length string.
+   *
+   * Reads are limited to a maximum of 64 bytes.
+   *
+   * If \p format specifies that optional_header bytes are present, they
+   * are written to the peripheral first.  Then \p len bytes are read from
+   * the peripheral and returned.
+   */
+  std::string _read_spi (int optional_header, int enables, int format, int 
len);
+};
+
+#endif /* INCLUDED_USRP1_SINK_BASE_H */

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_c.cc 
(from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.cc)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_c.cc  
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_c.cc  
    2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,115 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <usrp1_sink_c.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <usrp_bytesex.h>
+
+usrp1_sink_c_sptr
+usrp1_make_sink_c (int which_board,
+                  unsigned int interp_rate,
+                  int nchan,
+                  int mux,
+                  int fusb_block_size,
+                  int fusb_nblocks,
+                  const std::string fpga_filename,
+                  const std::string firmware_filename
+                  ) throw (std::runtime_error)
+{
+  return usrp1_sink_c_sptr (new usrp1_sink_c (which_board,
+                                             interp_rate,
+                                             nchan,
+                                             mux,
+                                             fusb_block_size,
+                                             fusb_nblocks,
+                                             fpga_filename,
+                                             firmware_filename
+                                             ));
+}
+
+
+
+usrp1_sink_c::usrp1_sink_c (int which_board,
+                           unsigned int interp_rate,
+                           int nchan,
+                           int mux,
+                           int fusb_block_size,
+                           int fusb_nblocks,
+                           const std::string fpga_filename,
+                           const std::string firmware_filename
+                           ) throw (std::runtime_error)
+  : usrp1_sink_base ("usrp1_sink_c",
+                    gr_make_io_signature (1, 1, sizeof (gr_complex)),
+                    which_board, interp_rate, nchan, mux,
+                    fusb_block_size, fusb_nblocks,
+                    fpga_filename, firmware_filename)
+{
+  _ensure_rev2(which_board);
+}
+
+usrp1_sink_c::~usrp1_sink_c ()
+{
+  // NOP
+}
+
+/*
+ * Take one complex input stream and format it into interleaved short I & Q
+ * for the usrp.
+ */
+void
+usrp1_sink_c::copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
+                                  int  input_index,
+                                  int  input_items_available,
+                                  int  &input_items_consumed,  // out
+                                  void *usrp_buffer,
+                                  int  usrp_buffer_length,
+                                  int  &bytes_written)         // out
+{
+  gr_complex *in = &((gr_complex *) input_items[0])[input_index];
+  short *dst = (short *) usrp_buffer;
+
+  static const int usrp_bytes_per_input_item = 2 * sizeof (short); // I & Q
+
+  int nitems = std::min (input_items_available,
+                        usrp_buffer_length / usrp_bytes_per_input_item);
+
+  for (int i = 0; i < nitems; i++){
+    dst[2*i + 0] = host_to_usrp_short((short) real(in[i]));    // FIXME 
saturate?
+    dst[2*i + 1] = host_to_usrp_short((short) imag(in[i]));    // FIXME 
saturate?
+  }
+
+  input_items_consumed = nitems;
+  bytes_written = nitems * usrp_bytes_per_input_item;
+}
+
+/******************************************************************************/
+
+std::vector<int>
+pick_tx_subdevice(usrp1_sink_c_sptr u)
+{
+  return pick_tx_subdevice(u->usrp());
+}

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_c.h 
(from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.h)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_c.h   
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_c.h   
    2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,91 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004, 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_USRP1_SINK_C_H
+#define INCLUDED_USRP1_SINK_C_H
+
+#include <usrp1_sink_base.h>
+
+class usrp1_sink_c;
+typedef boost::shared_ptr<usrp1_sink_c> usrp1_sink_c_sptr;
+
+
+// public shared_ptr constructor
+
+usrp1_sink_c_sptr
+usrp1_make_sink_c (int which_board=0,
+                  unsigned int interp_rate=128,
+                  int nchan=1,
+                  int mux=0x98,
+                  int fusb_block_size=0,
+                  int fusb_nblocks=0,
+                  const std::string fpga_filename="",
+                  const std::string firmware_filename=""
+                  ) throw (std::runtime_error);
+
+
+/*!
+ * \brief interface to Universal Software Radio Peripheral Tx path (Rev 1)
+ *
+ * input: gr_complex
+ */
+class usrp1_sink_c : public usrp1_sink_base {
+ private:
+
+  friend usrp1_sink_c_sptr
+  usrp1_make_sink_c (int which_board,
+                    unsigned int interp_rate,
+                    int nchan,
+                    int mux,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error);
+
+ protected:
+  usrp1_sink_c (int which_board,
+               unsigned int interp_rate,
+               int nchan,
+               int mux,
+               int fusb_block_size,
+               int fusb_nblocks,
+               const std::string fpga_filename,
+               const std::string firmware_filename
+               ) throw (std::runtime_error);
+
+  virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
+                                   int  input_index,
+                                   int  input_items_available,
+                                   int  &input_items_consumed,
+                                   void *usrp_buffer,
+                                   int  usrp_buffer_length,
+                                   int  &bytes_written);
+ public:
+  ~usrp1_sink_c ();
+};
+
+
+std::vector<int> pick_tx_subdevice(usrp1_sink_c_sptr u);
+
+
+#endif /* INCLUDED_USRP1_SINK_C_H */

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_s.cc 
(from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.cc)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_s.cc  
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_s.cc  
    2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,114 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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 <usrp1_sink_s.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <usrp_bytesex.h>
+
+usrp1_sink_s_sptr
+usrp1_make_sink_s (int which_board,
+                  unsigned int interp_rate,
+                  int nchan,
+                  int mux,
+                  int fusb_block_size,
+                  int fusb_nblocks,
+                  const std::string fpga_filename,
+                  const std::string firmware_filename
+                  ) throw (std::runtime_error)
+{
+  return usrp1_sink_s_sptr (new usrp1_sink_s (which_board,
+                                             interp_rate,
+                                             nchan,
+                                             mux,
+                                             fusb_block_size,
+                                             fusb_nblocks,
+                                             fpga_filename,
+                                             firmware_filename
+                                             ));
+}
+
+
+usrp1_sink_s::usrp1_sink_s (int which_board,
+                           unsigned int interp_rate,
+                           int nchan,
+                           int mux,
+                           int fusb_block_size,
+                           int fusb_nblocks,
+                           const std::string fpga_filename,
+                           const std::string firmware_filename
+                           ) throw (std::runtime_error)
+  : usrp1_sink_base ("usrp1_sink_s",
+                    gr_make_io_signature (1, 1, sizeof (short)),
+                    which_board, interp_rate, nchan, mux,
+                    fusb_block_size, fusb_nblocks,
+                    fpga_filename, firmware_filename)
+{
+  _ensure_rev2(which_board);
+  set_output_multiple (512 / sizeof(short));   // don't change
+}
+
+usrp1_sink_s::~usrp1_sink_s ()
+{
+  // NOP
+}
+
+/*
+ * Take one short input stream and format it into interleaved short I & Q
+ * for the usrp.
+ */
+void
+usrp1_sink_s::copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
+                                  int  input_index,
+                                  int  input_items_available,
+                                  int  &input_items_consumed,  // out
+                                  void *usrp_buffer,
+                                  int  usrp_buffer_length,
+                                  int  &bytes_written)         // out
+{
+  short *in = &((short *) input_items[0])[input_index];
+  short *dst = (short *) usrp_buffer;
+
+  static const int usrp_bytes_per_input_item = sizeof (short);
+
+  int nitems = std::min (input_items_available,
+                        usrp_buffer_length / usrp_bytes_per_input_item);
+
+  for (int i = 0; i < nitems; i++){    // FIXME unroll
+    dst[i] = host_to_usrp_short(in[i]);
+  }
+
+  input_items_consumed = nitems;
+  bytes_written = nitems * usrp_bytes_per_input_item;
+}
+
+/******************************************************************************/
+
+std::vector<int>
+pick_tx_subdevice(usrp1_sink_s_sptr u)
+{
+  return pick_tx_subdevice(u->usrp());
+}

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_s.h 
(from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.h)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_s.h   
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_sink_s.h   
    2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_USRP1_SINK_S_H
+#define INCLUDED_USRP1_SINK_S_H
+
+#include <usrp1_sink_base.h>
+
+class usrp1_sink_s;
+typedef boost::shared_ptr<usrp1_sink_s> usrp1_sink_s_sptr;
+
+
+// public shared_ptr constructor
+
+usrp1_sink_s_sptr
+usrp1_make_sink_s (int which_board=0,
+                  unsigned int interp_rate=128,
+                  int nchan=1,
+                  int mux=0x98,
+                  int fusb_block_size=0,
+                  int fusb_nblocks=0,
+                  const std::string fpga_filename="",
+                  const std::string firmware_filename=""
+                  ) throw (std::runtime_error);
+
+/*!
+ * \brief interface to Universal Software Radio Peripheral Tx path (Rev 1)
+ *
+ * input: short
+ */
+class usrp1_sink_s : public usrp1_sink_base {
+ private:
+
+  friend usrp1_sink_s_sptr
+  usrp1_make_sink_s (int which_board,
+                    unsigned int interp_rate,
+                    int nchan,
+                    int mux,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error);
+
+ protected:
+  usrp1_sink_s (int which_board,
+               unsigned int interp_rate,
+               int nchan,
+               int mux,
+               int fusb_block_size,
+               int fusb_nblocks,
+               const std::string fpga_filename,
+               const std::string firmware_filename
+               ) throw (std::runtime_error);
+
+  virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
+                                   int  input_index,
+                                   int  input_items_available,
+                                   int  &input_items_consumed,
+                                   void *usrp_buffer,
+                                   int  usrp_buffer_length,
+                                   int  &bytes_written);
+ public:
+  ~usrp1_sink_s ();
+};
+
+
+std::vector<int> pick_tx_subdevice(usrp1_sink_s_sptr u);
+
+
+#endif /* INCLUDED_USRP1_SINK_S_H */

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source.i 
(from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source.i)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source.i   
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source.i   
    2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,187 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// ================================================================
+//                        abstract classes
+// ================================================================
+
+class usrp1_source_base : public usrp1_base 
+{
+ protected:
+  usrp1_source_base (const std::string &name,
+                    gr_io_signature_sptr output_signature,
+                    int which,
+                    unsigned int decim_rate,
+                    int nchan,
+                    int mux,
+                    int mode,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error);
+
+  virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items) = 0;
+  unsigned int sizeof_basic_sample() const;
+  virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items,
+                                     int output_index,
+                                     int output_items_available,
+                                     int &output_items_produced,
+                                     const void *usrp_buffer,
+                                     int usrp_buffer_length,
+                                     int &bytes_read) = 0;
+
+ public:
+  ~usrp1_source_base ();
+
+  unsigned int determine_rx_mux_value(const std::vector<int> &subdev_spec);
+  db_base_sptr selected_subdev(const std::vector<int> &subdev_spec);
+  usrp_standard_rx * usrp();
+
+  int work (int noutput_items,
+           gr_vector_const_void_star &input_items,
+           gr_vector_void_star &output_items);
+
+  bool start();
+  bool stop();
+
+  bool set_decim_rate (unsigned int rate);
+  bool set_nchannels (unsigned int nchan);
+  bool set_mux (unsigned int mux);
+  bool set_rx_freq (int channel, double freq);
+  bool set_fpga_mode (int mode);
+  void set_verbose (bool verbose);
+  bool set_ddc_phase(int channel, int phase);
+  bool set_pga (int which, double gain_in_db);
+  double pga (int which) const;
+  double pga_min () const;
+  double pga_max () const;
+  double pga_db_per_step () const;
+
+  // ACCESSORS
+
+  long fpga_master_clock_freq() const;
+  long converter_rate() const;
+  long adc_rate() const;
+  long adc_freq() const;
+
+  unsigned int decim_rate () const;
+  int nchannels () const;
+  int mux () const;
+  double rx_freq (int channel) const;
+  int noverruns () const;
+
+  int daughterboard_id (int which_dboard) const;
+  bool write_aux_dac (int which_board, int which_dac, unsigned int value);
+  unsigned int read_aux_adc (int which_dboard, int which_adc);
+  bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf);
+  std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
+  bool write_i2c (int i2c_addr, const std::string buf);
+  std::string read_i2c (int i2c_addr, int len);
+  bool set_adc_offset (int which, unsigned int offset);
+  bool set_dac_offset (int which, int offset, int offset_pin);
+  bool set_adc_buffer_bypass (int which, bool bypass);
+  std::string serial_number();
+  bool _write_oe (int which_dboard, unsigned int value, unsigned int mask);
+  bool write_io (int which_dboard, unsigned int value, unsigned int mask);
+  unsigned int read_io (int which_dboard);
+  bool set_dc_offset_cl_enable(int bits, int mask);
+  bool set_format(unsigned int format);
+  unsigned int format () const;
+
+  static unsigned int make_format(int width=16, int shift=0,
+                                 bool want_q=true, bool bypass_halfband=false);
+  static int format_width(unsigned int format);
+  static int format_shift(unsigned int format);
+  static bool format_want_q(unsigned int format);
+  static bool format_bypass_halfband(unsigned int format);
+
+  bool _write_fpga_reg (int regno, unsigned int value);
+  bool _write_fpga_reg_masked (int regno, unsigned int value, int mask);
+  unsigned int  _read_fpga_reg (int regno);
+  bool _write_9862 (int which_codec, int regno, unsigned char value);
+  unsigned int  _read_9862 (int which_codec, int regno) const;
+  bool _write_spi (int optional_header, int enables, int format, std::string 
buf);
+  std::string _read_spi (int optional_header, int enables, int format, int 
len);
+
+  tune_result tune(int chan, db_base_sptr db, double target_freq);
+};
+
+
+// ================================================================
+//                     concrete sources
+// ================================================================
+
+GR_SWIG_BLOCK_MAGIC(usrp1,source_c)
+
+usrp1_source_c_sptr
+usrp1_make_source_c (int which=0,
+                    unsigned int decim_rate=64,
+                    int nchan=1,
+                    int mux=0x32103210,
+                    int mode=0,
+                    int fusb_block_size=0,
+                    int fusb_nblocks=0,
+                    const std::string fpga_filename="",
+                    const std::string firmware_filename=""
+                    ) throw (std::runtime_error);
+
+class usrp1_source_c : public usrp1_source_base {
+ protected:
+  usrp1_source_c (int which, unsigned int decim_rate,
+                 int nchan, int mux, int mode, int fusb_block_size, int 
fusb_nblocks,
+                 const std::string fpga_filename, const std::string 
fgpa_filename);
+
+
+ public:
+  ~usrp1_source_c ();
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(usrp1,source_s)
+
+usrp1_source_s_sptr
+usrp1_make_source_s (int which=0,
+                    unsigned int decim_rate=64,
+                    int nchan=1,
+                    int mux=0x32103210,
+                    int mode=0,
+                    int fusb_block_size=0,
+                    int fusb_nblocks=0,
+                    const std::string fpga_filename="",
+                    const std::string firmware_filename=""
+                    ) throw (std::runtime_error);
+
+
+class usrp1_source_s : public usrp1_source_base {
+ protected:
+  usrp1_source_s (int which, unsigned int decim_rate,
+                 int nchan, int mux, int mode, int fusb_block_size, int 
fusb_nblocks,
+                 const std::string fpga_filename, const std::string 
firmware_filename);
+
+ public:
+  ~usrp1_source_s ();
+};
+
+std::vector<int> pick_rx_subdevice(usrp1_source_c_sptr u);
+std::vector<int> pick_rx_subdevice(usrp1_source_s_sptr u);

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_base.cc
 (from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.cc)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_base.cc
                         (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_base.cc
 2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,531 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <usrp1_source_base.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <assert.h>
+
+static const int OUTPUT_MULTIPLE_BYTES = 4 * 1024;
+
+usrp1_source_base::usrp1_source_base (const std::string &name,
+                                     gr_io_signature_sptr output_signature,
+                                     int which,
+                                     unsigned int decim_rate,
+                                     int nchan,
+                                     int mux,
+                                     int mode,
+                                     int fusb_block_size,
+                                     int fusb_nblocks,
+                                     const std::string fpga_filename,
+                                     const std::string firmware_filename
+                                     ) throw (std::runtime_error)
+  : usrp1_base(name, gr_make_io_signature (0, 0, 0), output_signature),
+    d_noverruns (0), 
+    d_usrp(usrp_standard_rx::make (which, decim_rate,nchan, mux, mode,
+                                  fusb_block_size, fusb_nblocks,
+                                  fpga_filename, firmware_filename))
+{
+  if (!d_usrp.get())
+    throw std::runtime_error ("can't open usrp1");
+
+  db = d_usrp->db();
+  
+  // All calls to d_usrp->read must be multiples of 512 bytes.
+  // We jack this up to 4k to reduce overhead.
+
+  set_output_multiple (OUTPUT_MULTIPLE_BYTES / 
output_signature->sizeof_stream_item (0));
+}
+
+usrp1_source_base::~usrp1_source_base ()
+{
+}
+
+unsigned int
+usrp1_source_base::determine_rx_mux_value(const std::vector<int> &subdev_spec)
+{
+  /*
+    Determine appropriate Rx mux value as a function of the subdevice choosen 
and the
+    characteristics of the respective daughterboard.
+    
+    @param u:           instance of USRP source
+    @param subdev_spec: return value from subdev option parser.  
+    @type  subdev_spec: (side, subdev), where side is 0 or 1 and subdev is 0 
or 1
+    @returns:           the Rx mux value
+  
+    Figure out which A/D's to connect to the DDC.
+    
+    Each daughterboard consists of 1 or 2 subdevices.  (At this time,
+    all but the Basic Rx have a single subdevice.  The Basic Rx
+    has two independent channels, treated as separate subdevices).
+    subdevice 0 of a daughterboard may use 1 or 2 A/D's.  We determine this
+    by checking the is_quadrature() method.  If subdevice 0 uses only a single
+    A/D, it's possible that the daughterboard has a second subdevice, 
subdevice 1,
+    and it uses the second A/D.
+    
+    If the card uses only a single A/D, we wire a zero into the DDC Q input.
+    
+    (side, 0) says connect only the A/D's used by subdevice 0 to the DDC.
+    (side, 1) says connect only the A/D's used by subdevice 1 to the DDC.
+  */
+
+  int side = subdev_spec[0];  // side A = 0, side B = 1
+  int spec = subdev_spec[1];
+
+  if(!((side == 0 || side == 1))) {
+    throw std::runtime_error("Invalid subdev_spec\n");
+  }
+
+  // This is a tuple of length 1 or 2 containing the subdevice
+  // classes for the selected side.
+  std::vector<db_base_sptr> db = d_usrp->db(side);
+  
+  unsigned int subdev0_uses, subdev1_uses, uses;
+
+  // compute bitmasks of used A/D's
+  
+  if(db[0]->is_quadrature()) {
+    subdev0_uses = 0x3;               // uses A/D 0 and 1
+  }
+  else {
+    subdev0_uses = 0x1;               // uses A/D 0 only
+  }
+
+  if(db.size() > 1) {                // test if we have 2 daughterboards
+    subdev1_uses = 0x2;               // uses A/D 1 only
+  }
+  else {
+    subdev1_uses = 0x0;              // uses no A/D (doesn't exist)
+  }
+  
+  if(spec == 0) {
+    uses = subdev0_uses;
+  }
+  else if(spec == 1) {
+    uses = subdev1_uses;
+  }
+  else {
+    throw std::runtime_error("Invalid subdev_spec");
+  }
+
+  if(uses == 0) {
+    throw std::runtime_error("Daughterboard doesn't have a subdevice 1");
+  }
+  
+  bool swap_iq = db[0]->i_and_q_swapped();
+  
+  truth_table_element_t truth_table[8] = {
+    // (side, uses, swap_iq) : mux_val
+    truth_table_element_t(0, 0x1, false, 0xf0f0f0f0),
+    truth_table_element_t(0, 0x2, false, 0xf0f0f0f1),
+    truth_table_element_t(0, 0x3, false, 0x00000010),
+    truth_table_element_t(0, 0x3, true,  0x00000001),
+    truth_table_element_t(1, 0x1, false, 0xf0f0f0f2),
+    truth_table_element_t(1, 0x2, false, 0xf0f0f0f3),
+    truth_table_element_t(1, 0x3, false, 0x00000032),
+    truth_table_element_t(1, 0x3, true,  0x00000023)
+  };
+  
+  truth_table_element_t match(side, uses, swap_iq, 0);
+  
+  int i=0;
+  while((i < 8) && (truth_table[i] != match))
+    i++;
+
+  return truth_table[i].mux_val();
+}
+
+db_base_sptr
+usrp1_source_base::selected_subdev(const std::vector<int> &subdev_spec)
+{
+  /*
+    Return the user specified daughterboard subdevice.
+    
+    @param subdev_spec: return value from subdev option parser.
+    @type  subdev_spec: (side, subdev), where side is 0 or 1 and subdev is 0 
or 1
+    @returns: an weakref to an instance derived from db_base
+  */
+
+  std::vector<db_base_sptr> db1 = d_usrp->db(subdev_spec[0]);
+  return db1[subdev_spec[1]];
+}
+
+
+unsigned int
+usrp1_source_base::sizeof_basic_sample() const
+{
+  return usrp_standard_rx::format_width(d_usrp->format()) / 8;
+}
+
+bool
+usrp1_source_base::start()
+{
+  return d_usrp->start();
+}
+
+bool
+usrp1_source_base::stop()
+{
+  return d_usrp->stop();
+}
+
+int
+usrp1_source_base::work (int noutput_items,
+                        gr_vector_const_void_star &input_items,
+                        gr_vector_void_star &output_items)
+{
+  static const int BUFSIZE = 4 * OUTPUT_MULTIPLE_BYTES;
+  unsigned char buf[BUFSIZE];
+  int output_index = 0;
+  int output_items_produced;
+  int bytes_read;
+  bool overrun;
+
+  while (output_index < noutput_items){
+    int nbytes = ninput_bytes_reqd_for_noutput_items (noutput_items - 
output_index);
+    nbytes = std::min (nbytes, BUFSIZE);
+
+    int result_nbytes = d_usrp->read (buf, nbytes, &overrun);
+    if (overrun){
+      // fprintf (stderr, "usrp1_source: overrun\n");
+      fputs ("uO", stderr);
+      d_noverruns++;
+    }
+
+    if (result_nbytes < 0)     // We've got a problem.  Usually board 
unplugged or powered down.
+      return -1;               // Indicate we're done.
+
+    if (result_nbytes != nbytes){      // not really an error, but unexpected
+      fprintf (stderr, "usrp1_source: short read.  Expected %d, got %d\n",
+              nbytes, result_nbytes);
+    }
+
+    copy_from_usrp_buffer (output_items,
+                          output_index,
+                          noutput_items - output_index,   // 
output_items_available
+                          output_items_produced,          // [out]
+                          buf,                            // usrp_buffer
+                          result_nbytes,                  // usrp_buffer_length
+                          bytes_read);                    // [out]
+
+    assert (output_index + output_items_produced <= noutput_items);
+    assert (bytes_read == result_nbytes);
+
+    output_index += output_items_produced;
+  }
+
+  return noutput_items;
+}
+
+
+bool
+usrp1_source_base::set_decim_rate (unsigned int rate)
+{
+  return d_usrp->set_decim_rate (rate);
+}
+
+bool
+usrp1_source_base::set_nchannels (unsigned int nchan)
+{
+  return d_usrp->set_nchannels (nchan);
+}
+
+bool
+usrp1_source_base::set_mux (unsigned int mux)
+{
+  return d_usrp->set_mux (mux);
+}
+
+bool
+usrp1_source_base::set_rx_freq (int channel, double freq)
+{
+  return d_usrp->set_rx_freq (channel, freq);
+}
+
+long
+usrp1_source_base::fpga_master_clock_freq() const
+{
+  return d_usrp->fpga_master_clock_freq();
+}
+
+long
+usrp1_source_base::converter_rate() const
+{
+  return d_usrp->converter_rate();
+}
+
+unsigned int
+usrp1_source_base::decim_rate () const
+{
+  return d_usrp->decim_rate ();
+}
+
+int
+usrp1_source_base::nchannels () const
+{
+  return d_usrp->nchannels ();
+}
+
+int
+usrp1_source_base::mux () const
+{
+  return d_usrp->mux ();
+}
+
+double
+usrp1_source_base::rx_freq (int channel) const
+{
+  return d_usrp->rx_freq (channel);
+}
+
+bool
+usrp1_source_base::set_fpga_mode (int mode)
+{
+  return d_usrp->set_fpga_mode (mode);
+}
+
+bool
+usrp1_source_base::set_ddc_phase (int channel, int phase)
+{
+  return d_usrp->set_ddc_phase(channel, phase);
+}
+
+bool
+usrp1_source_base::set_dc_offset_cl_enable(int bits, int mask)
+{
+  return d_usrp->set_dc_offset_cl_enable(bits, mask);
+}
+
+void
+usrp1_source_base::set_verbose (bool verbose)
+{  
+  d_usrp->set_verbose (verbose);
+}
+
+bool
+usrp1_source_base::write_aux_dac (int which_dboard, int which_dac, int value)
+{
+  return d_usrp->write_aux_dac (which_dboard, which_dac, value);
+}
+
+int
+usrp1_source_base::read_aux_adc (int which_dboard, int which_adc)
+{
+  return d_usrp->read_aux_adc (which_dboard, which_adc);
+}
+
+bool
+usrp1_source_base::write_eeprom (int i2c_addr, int eeprom_offset, const 
std::string buf)
+{
+  return d_usrp->write_eeprom (i2c_addr, eeprom_offset, buf);
+}
+
+std::string
+usrp1_source_base::read_eeprom (int i2c_addr, int eeprom_offset, int len)
+{
+  return d_usrp->read_eeprom (i2c_addr, eeprom_offset, len);
+}
+
+bool
+usrp1_source_base::write_i2c (int i2c_addr, const std::string buf)
+{
+  return d_usrp->write_i2c (i2c_addr, buf);
+}
+
+std::string
+usrp1_source_base::read_i2c (int i2c_addr, int len)
+{
+  return d_usrp->read_i2c (i2c_addr, len);
+}
+
+bool
+usrp1_source_base::set_pga (int which, double gain)
+{
+  return d_usrp->set_pga (which, gain);
+}
+
+double
+usrp1_source_base::pga (int which) const
+{
+  return d_usrp->pga (which);
+}
+
+double
+usrp1_source_base::pga_min () const
+{
+  return d_usrp->pga_min ();
+}
+
+double
+usrp1_source_base::pga_max () const
+{
+  return d_usrp->pga_max ();
+}
+
+double
+usrp1_source_base::pga_db_per_step () const
+{
+  return d_usrp->pga_db_per_step ();
+}
+
+int
+usrp1_source_base::daughterboard_id (int which) const
+{
+  return d_usrp->daughterboard_id (which);
+}
+
+
+bool
+usrp1_source_base::set_adc_offset (int which, int offset)
+{
+  return d_usrp->set_adc_offset (which, offset);
+}
+
+bool
+usrp1_source_base::set_dac_offset (int which, int offset, int offset_pin)
+{
+  return d_usrp->set_dac_offset (which, offset, offset_pin);
+}
+
+bool
+usrp1_source_base::set_adc_buffer_bypass (int which, bool bypass)
+{
+  return d_usrp->set_adc_buffer_bypass (which, bypass);
+}
+
+std::string
+usrp1_source_base::serial_number()
+{
+  return d_usrp->serial_number();
+}
+
+bool
+usrp1_source_base::_write_oe (int which_dboard, int value, int mask)
+{
+  return d_usrp->_write_oe (which_dboard, value, mask);
+}
+
+bool
+usrp1_source_base::write_io (int which_dboard, int value, int mask)
+{
+  return d_usrp->write_io (which_dboard, value, mask);
+}
+
+int
+usrp1_source_base::read_io (int which_dboard)
+{
+  return d_usrp->read_io (which_dboard);
+}
+
+
+
+
+// internal routines...
+
+bool
+usrp1_source_base::_write_fpga_reg (int regno, int value)
+{
+  return d_usrp->_write_fpga_reg (regno, value);
+}
+
+bool
+usrp1_source_base::_write_fpga_reg_masked (int regno, int value, int mask)
+{
+  return d_usrp->_write_fpga_reg_masked (regno, value, mask);
+}
+
+int
+usrp1_source_base::_read_fpga_reg (int regno)
+{
+  return d_usrp->_read_fpga_reg (regno);
+}
+
+bool
+usrp1_source_base::_write_9862 (int which_codec, int regno, unsigned char 
value)
+{
+  return d_usrp->_write_9862 (which_codec, regno, value);
+}
+
+int
+usrp1_source_base::_read_9862 (int which_codec, int regno) const
+{
+  return d_usrp->_read_9862 (which_codec, regno);
+}
+
+bool
+usrp1_source_base::_write_spi (int optional_header, int enables,
+                              int format, std::string buf)
+{
+  return d_usrp->_write_spi (optional_header, enables, format, buf);
+}
+
+std::string
+usrp1_source_base::_read_spi (int optional_header, int enables, int format, 
int len)
+{
+  return d_usrp->_read_spi (optional_header, enables, format, len);
+}
+
+bool
+usrp1_source_base::set_format(unsigned int format)
+{
+  return d_usrp->set_format(format);
+}
+
+unsigned int
+usrp1_source_base::format() const
+{
+  return d_usrp->format();
+}
+
+unsigned int
+usrp1_source_base::make_format(int width, int shift, bool want_q, bool 
bypass_halfband)
+{
+  return usrp_standard_rx::make_format(width, shift, want_q, bypass_halfband);
+}
+
+int
+usrp1_source_base::format_width(unsigned int format)
+{
+  return usrp_standard_rx::format_width(format);
+}
+
+int
+usrp1_source_base::format_shift(unsigned int format)
+{
+  return usrp_standard_rx::format_shift(format);
+}
+
+bool
+usrp1_source_base::format_want_q(unsigned int format)
+{
+  return usrp_standard_rx::format_want_q(format);
+}
+
+bool
+usrp1_source_base::format_bypass_halfband(unsigned int format)
+{
+  return usrp_standard_rx::format_bypass_halfband(format);
+}

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_base.h
 (from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.h)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_base.h
                          (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_base.h
  2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,467 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_USRP1_SOURCE_BASE_H
+#define INCLUDED_USRP1_SOURCE_BASE_H
+
+#include <usrp1_base.h>
+#include <stdexcept>
+#include <memory>
+
+class usrp_standard_rx;
+
+/*!
+ * \brief abstract interface to Universal Software Radio Peripheral Rx path 
(Rev 1)
+ */
+class usrp1_source_base : public usrp1_base
+{
+ protected:
+  usrp1_source_base (const std::string &name,
+                    gr_io_signature_sptr output_signature,
+                    int which,
+                    unsigned int decim_rate,
+                    int nchan,
+                    int mux,
+                    int mode,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error);
+
+
+  int d_noverruns;
+  std::auto_ptr<usrp_standard_rx> d_usrp;
+
+  /*!
+   * \brief return number of usrp input bytes required to produce noutput 
items.
+   */
+  virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items) = 0;
+
+  /*!
+   * \brief number of bytes in a low-level sample
+   */
+  unsigned int sizeof_basic_sample() const;
+
+  /*!
+   * \brief convert between native usrp format and output item format
+   *
+   * \param output_items[out]          stream(s) of output items
+   * \param output_index[in]           starting index in output_items
+   * \param output_items_available[in] number of empty items available at 
item[index]
+   * \param output_items_produced[out] number of items produced by copy
+   * \param usrp_buffer[in]            source buffer
+   * \param usrp_buffer_length[in]     number of bytes available in \p 
usrp_buffer
+   * \param bytes_read[out]            number of bytes read from \p usrp_buffer
+   *
+   * The copy must consume all bytes available.  That is, \p bytes_read must 
equal
+   * \p usrp_buffer_length.
+   */
+  virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items,
+                                     int output_index,
+                                     int output_items_available,
+                                     int &output_items_produced,
+                                     const void *usrp_buffer,
+                                     int usrp_buffer_length,
+                                     int &bytes_read) = 0;
+
+ public:
+  //! magic value used on alternate register read interfaces
+  static const int READ_FAILED = -99999;
+
+  ~usrp1_source_base ();
+
+  // These must be included in here and not usrp1_base because of
+  // usrp_standard_common used in that class
+  std::vector<db_base_sptr> dboard(int which) { return d_usrp->db(which); }  
+  db_base_sptr selected_subdev(const std::vector<int> &subdev_spec);
+  unsigned int determine_rx_mux_value(const std::vector<int> &subdev_spec);
+  usrp_standard_rx * usrp() { return d_usrp.get(); }
+
+  // Wrapper function to call tune from USRP source class
+  tune_result tune(int chan, db_base_sptr db, double target_freq)
+  { return db->tune(chan, target_freq); }
+  int work (int noutput_items,
+           gr_vector_const_void_star &input_items,
+           gr_vector_void_star &output_items);
+
+  bool start();
+  bool stop();
+
+  /*!
+   * \brief Set decimator rate.  \p rate must be EVEN and in [8, 256].
+   *
+   * The final complex sample rate across the USB is
+   *   adc_freq () / decim_rate ()
+   */
+  bool set_decim_rate (unsigned int rate);
+  bool set_nchannels (unsigned int nchan);
+  bool set_mux (unsigned int mux);
+
+  /*!
+   * \brief set the center frequency of the digital down converter.
+   *
+   * \p channel must be 0.  \p freq is the center frequency in Hz.
+   * It must be in the range [-FIXME, FIXME].  The frequency specified is
+   * quantized.  Use rx_freq to retrieve the actual value used.
+   */
+  bool set_rx_freq (int channel, double freq);
+
+  /*!
+   * \brief set fpga special modes
+   */
+  bool set_fpga_mode (int mode);
+
+  void set_verbose (bool verbose);
+
+  /*!
+   * \brief Set the digital down converter phase register.
+   *
+   * \param channel    which ddc channel [0, 3]
+   * \param phase      32-bit integer phase value.
+   */
+  bool set_ddc_phase(int channel, int phase);
+
+  /*!
+   * \brief Set Programmable Gain Amplifier (PGA)
+   *
+   * \param which      which A/D [0,3]
+   * \param gain_in_db gain value (linear in dB)
+   *
+   * gain is rounded to closest setting supported by hardware.
+   *
+   * \returns true iff sucessful.
+   *
+   * \sa pga_min(), pga_max(), pga_db_per_step()
+   */
+  bool set_pga (int which, double gain_in_db);
+
+  /*!
+   * \brief Return programmable gain amplifier gain setting in dB.
+   *
+   * \param which      which A/D [0,3]
+   */
+  double pga (int which) const;
+
+  /*!
+   * \brief Return minimum legal PGA setting in dB.
+   */
+  double pga_min () const;
+
+  /*!
+   * \brief Return maximum legal PGA setting in dB.
+   */
+  double pga_max () const;
+
+  /*!
+   * \brief Return hardware step size of PGA (linear in dB).
+   */
+  double pga_db_per_step () const;
+
+  // ACCESSORS
+
+  long fpga_master_clock_freq() const;
+  long converter_rate() const;
+  long adc_rate() const { return converter_rate(); }   // alias
+  long adc_freq() const { return converter_rate(); }   // deprecated alias
+
+  unsigned int decim_rate () const;
+  int nchannels () const;
+  int mux () const;
+  double rx_freq (int channel) const;
+  int noverruns () const { return d_noverruns; }
+
+  /*!
+   * \brief Return daughterboard ID for given Rx daughterboard slot [0,1].
+   *
+   * \return daughterboard id >= 0 if successful
+   * \return -1 if no daugherboard
+   * \return -2 if invalid EEPROM on daughterboard
+   */
+  int daughterboard_id (int which_dboard) const;
+
+  /*!
+   * \brief Write auxiliary digital to analog converter.
+   *
+   * \param which_dboard       [0,1] which d'board
+   *                           N.B., SLOT_TX_A and SLOT_RX_A share the same 
AUX DAC's.
+   *                           SLOT_TX_B and SLOT_RX_B share the same AUX 
DAC's.
+   * \param which_dac          [2,3] TX slots must use only 2 and 3.
+   * \param value              [0,4095]
+   * \returns true iff successful
+   */
+  bool write_aux_dac (int which_board, int which_dac, int value);
+
+  /*!
+   * \brief Read auxiliary analog to digital converter.
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param which_adc          [0,1]
+   * \returns value in the range [0,4095] if successful, else READ_FAILED.
+   */
+  int read_aux_adc (int which_dboard, int which_adc);
+
+  /*!
+   * \brief Write EEPROM on motherboard or any daughterboard.
+   * \param i2c_addr           I2C bus address of EEPROM
+   * \param eeprom_offset      byte offset in EEPROM to begin writing
+   * \param buf                        the data to write
+   * \returns true iff sucessful
+   */
+  bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf);
+
+  /*!
+   * \brief Write EEPROM on motherboard or any daughterboard.
+   * \param i2c_addr           I2C bus address of EEPROM
+   * \param eeprom_offset      byte offset in EEPROM to begin reading
+   * \param len                        number of bytes to read
+   * \returns the data read if successful, else a zero length string.
+   */
+  std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
+
+  /*!
+   * \brief Write to I2C peripheral
+   * \param i2c_addr           I2C bus address (7-bits)
+   * \param buf                        the data to write
+   * \returns true iff successful
+   * Writes are limited to a maximum of of 64 bytes.
+   */
+  bool write_i2c (int i2c_addr, const std::string buf);
+
+  /*!
+   * \brief Read from I2C peripheral
+   * \param i2c_addr           I2C bus address (7-bits)
+   * \param len                        number of bytes to read
+   * \returns the data read if successful, else a zero length string.
+   * Reads are limited to a maximum of of 64 bytes.
+   */
+  std::string read_i2c (int i2c_addr, int len);
+
+  /*!
+   * \brief Set ADC offset correction
+   * \param which      which ADC[0,3]: 0 = RX_A I, 1 = RX_A Q...
+   * \param offset     16-bit value to subtract from raw ADC input.
+   */
+  bool set_adc_offset (int which, int offset);
+
+  /*!
+   * \brief Set DAC offset correction
+   * \param which      which DAC[0,3]: 0 = TX_A I, 1 = TX_A Q...
+   * \param offset     10-bit offset value (ambiguous format:  See AD9862 
datasheet).
+   * \param offset_pin 1-bit value.  If 0 offset applied to -ve differential 
pin;
+   *                                  If 1 offset applied to +ve differential 
pin.
+   */
+  bool set_dac_offset (int which, int offset, int offset_pin);
+
+  /*!
+   * \brief Control ADC input buffer
+   * \param which      which ADC[0,3]
+   * \param bypass     if non-zero, bypass input buffer and connect input
+   *                   directly to switched cap SHA input of RxPGA.
+   */
+  bool set_adc_buffer_bypass (int which, bool bypass);
+
+  /*!
+   * \brief return the usrp's serial number.
+   *
+   * \returns non-zero length string iff successful.
+   */
+  std::string serial_number();
+
+  /*!
+   * \brief Write direction register (output enables) for pins that go to 
daughterboard.
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param value              value to write into register
+   * \param mask               which bits of value to write into reg
+   *
+   * Each d'board has 16-bits of general purpose i/o.
+   * Setting the bit makes it an output from the FPGA to the d'board.
+   *
+   * This register is initialized based on a value stored in the
+   * d'board EEPROM.  In general, you shouldn't be using this routine
+   * without a very good reason.  Using this method incorrectly will
+   * kill your USRP motherboard and/or daughterboard.
+   */
+  bool _write_oe (int which_dboard, int value, int mask);
+
+  /*!
+   * \brief Write daughterboard i/o pin value
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param value              value to write into register
+   * \param mask               which bits of value to write into reg
+   */
+  bool write_io (int which_dboard, int value, int mask);
+
+  /*!
+   * \brief Read daughterboard i/o pin value
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \returns register value if successful, else READ_FAILED
+   */
+  int read_io (int which_dboard);
+
+  /*!
+   * \brief Enable/disable automatic DC offset removal control loop in FPGA
+   *
+   * \param bits  which control loops to enable
+   * \param mask  which \p bits to pay attention to
+   *
+   * If the corresponding bit is set, enable the automatic DC
+   * offset correction control loop.
+   *
+   * <pre>
+   * The 4 low bits are significant:
+   *
+   *   ADC0 = (1 << 0)
+   *   ADC1 = (1 << 1)
+   *   ADC2 = (1 << 2)
+   *   ADC3 = (1 << 3)
+   * </pre>
+   *
+   * By default the control loop is enabled on all ADC's.
+   */
+  bool set_dc_offset_cl_enable(int bits, int mask);
+
+  /*!
+   * \brief Specify Rx data format.
+   *
+   * \param format     format specifier
+   *
+   * Rx data format control register
+   *
+   *     3                   2                   1                       
+   *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+   *  +-----------------------------------------+-+-+---------+-------+
+   *  |          Reserved (Must be zero)        |B|Q|  WIDTH  | SHIFT |
+   *  +-----------------------------------------+-+-+---------+-------+
+   *
+   *  SHIFT specifies arithmetic right shift [0, 15]
+   *  WIDTH specifies bit-width of I & Q samples across the USB [1, 16] (not 
all valid)
+   *  Q     if set deliver both I & Q, else just I
+   *  B     if set bypass half-band filter.
+   *
+   * Right now the acceptable values are:
+   *
+   *   B  Q  WIDTH  SHIFT
+   *   0  1    16     0
+   *   0  1     8     8
+   *
+   * More valid combos to come.
+   *
+   * Default value is 0x00000300  16-bits, 0 shift, deliver both I & Q.
+   */
+  bool set_format(unsigned int format);
+
+  /*!
+   * \brief return current format
+   */
+  unsigned int format () const;
+
+  static unsigned int make_format(int width=16, int shift=0,
+                                 bool want_q=true, bool bypass_halfband=false);
+  static int format_width(unsigned int format);
+  static int format_shift(unsigned int format);
+  static bool format_want_q(unsigned int format);
+  static bool format_bypass_halfband(unsigned int format);
+
+  // ----------------------------------------------------------------
+  // internal routines...  
+  // You probably shouldn't be using these...
+  // ----------------------------------------------------------------
+
+  /*!
+   * \brief Write FPGA register.
+   * \param regno      7-bit register number
+   * \param value      32-bit value
+   * \returns true iff successful
+   */
+  bool _write_fpga_reg (int regno, int value); //< 7-bit regno, 32-bit value
+
+  /*!
+   * \brief Write FPGA register masked.
+   * \param regno      7-bit register number
+   * \param value      16-bit value
+   * \param mask               16-bit mask
+   * \returns true iff successful
+   */
+  bool _write_fpga_reg_masked (int regno, int value, int mask);        //< 
7-bit regno, 16-bit value, 16-bit mask
+
+  /*!
+   * \brief Read FPGA register.
+   * \param regno      7-bit register number
+   * \returns register value if successful, else READ_FAILED
+   */
+  int  _read_fpga_reg (int regno);
+
+  /*!
+   * \brief Write AD9862 register.
+   * \param which_codec 0 or 1
+   * \param regno      6-bit register number
+   * \param value      8-bit value
+   * \returns true iff successful
+   */
+  bool _write_9862 (int which_codec, int regno, unsigned char value);
+
+  /*!
+   * \brief Read AD9862 register.
+   * \param which_codec 0 or 1
+   * \param regno      6-bit register number
+   * \returns register value if successful, else READ_FAILED
+   */
+  int  _read_9862 (int which_codec, int regno) const;
+
+  /*!
+   * \brief Write data to SPI bus peripheral.
+   *
+   * \param optional_header    0,1 or 2 bytes to write before buf.
+   * \param enables            bitmask of peripherals to write. See 
usrp_spi_defs.h
+   * \param format             transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+   * \param buf                        the data to write
+   * \returns true iff successful
+   * Writes are limited to a maximum of 64 bytes.
+   *
+   * If \p format specifies that optional_header bytes are present, they are
+   * written to the peripheral immediately prior to writing \p buf.
+   */
+  bool _write_spi (int optional_header, int enables, int format, std::string 
buf);
+
+  /*
+   * \brief Read data from SPI bus peripheral.
+   *
+   * \param optional_header    0,1 or 2 bytes to write before buf.
+   * \param enables            bitmask of peripheral to read. See 
usrp_spi_defs.h
+   * \param format             transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+   * \param len                        number of bytes to read.  Must be in 
[0,64].
+   * \returns the data read if sucessful, else a zero length string.
+   *
+   * Reads are limited to a maximum of 64 bytes.
+   *
+   * If \p format specifies that optional_header bytes are present, they
+   * are written to the peripheral first.  Then \p len bytes are read from
+   * the peripheral and returned.
+   */
+  std::string _read_spi (int optional_header, int enables, int format, int 
len);
+};
+
+#endif /* INCLUDED_USRP1_SOURCE_BASE_H */

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_c.cc
 (from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.cc)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_c.cc
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_c.cc
    2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,140 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <usrp1_source_c.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <usrp_bytesex.h>
+
+static const int NBASIC_SAMPLES_PER_ITEM = 2;  // I & Q
+
+usrp1_source_c_sptr
+usrp1_make_source_c (int which_board,
+                    unsigned int decim_rate,
+                    int nchan,
+                    int mux,
+                    int mode,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error)
+{
+  return usrp1_source_c_sptr (new usrp1_source_c (which_board,
+                                                 decim_rate,
+                                                 nchan,
+                                                 mux,
+                                                 mode,
+                                                 fusb_block_size,
+                                                 fusb_nblocks,
+                                                 fpga_filename,
+                                                 firmware_filename
+                                                 ));
+}
+
+
+usrp1_source_c::usrp1_source_c (int which_board,
+                               unsigned int decim_rate,
+                               int nchan,
+                               int mux,
+                               int mode,
+                               int fusb_block_size,
+                               int fusb_nblocks,
+                               const std::string fpga_filename,
+                               const std::string firmware_filename
+                               ) throw (std::runtime_error)
+  : usrp1_source_base ("usrp1_source_c",
+                      gr_make_io_signature (1, 1, sizeof (gr_complex)),
+                      which_board, decim_rate, nchan, mux, mode,
+                      fusb_block_size, fusb_nblocks,
+                      fpga_filename, firmware_filename)
+{
+  _ensure_rev2(which_board);
+}
+
+usrp1_source_c::~usrp1_source_c ()
+{
+  // NOP
+}
+
+int
+usrp1_source_c::ninput_bytes_reqd_for_noutput_items (int noutput_items)
+{
+  return noutput_items * NBASIC_SAMPLES_PER_ITEM * sizeof_basic_sample();
+}
+
+/*
+ * Convert interleaved 8 or 16-bit I & Q from usrp buffer into a single
+ * complex output stream.
+ */
+void
+usrp1_source_c::copy_from_usrp_buffer (gr_vector_void_star &output_items,
+                                      int output_index,
+                                      int output_items_available,
+                                      int &output_items_produced,
+                                      const void *usrp_buffer,
+                                      int usrp_buffer_length,
+                                      int &bytes_read)
+{
+  gr_complex *out = &((gr_complex *) output_items[0])[output_index];
+  unsigned sbs = sizeof_basic_sample();
+  unsigned nusrp_bytes_per_item = NBASIC_SAMPLES_PER_ITEM * sbs;
+
+  int nitems = std::min (output_items_available,
+                        (int)(usrp_buffer_length / nusrp_bytes_per_item));
+
+  signed char *s8 = (signed char *) usrp_buffer;
+  short *s16 = (short *) usrp_buffer;
+
+  switch (sbs){
+  case 1:
+    for (int i = 0; i < nitems; i++){
+      out[i] = gr_complex ((float)(s8[2*i+0] << 8), (float)(s8[2*i+1] << 8));
+    }
+    break;
+
+  case 2:
+    for (int i = 0; i < nitems; i++){
+      out[i] = gr_complex ((float) usrp_to_host_short(s16[2*i+0]),
+                          (float) usrp_to_host_short(s16[2*i+1]));
+    }
+    break;
+
+  default:
+    assert(0);
+  }
+
+  output_items_produced = nitems;
+  bytes_read = nitems * nusrp_bytes_per_item;
+}
+
+/******************************************************************************/
+
+std::vector<int>
+pick_rx_subdevice(usrp1_source_c_sptr u)
+{
+  return pick_rx_subdevice(u->usrp());
+}

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_c.h 
(from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.h)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_c.h 
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_c.h 
    2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,96 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_USRP1_SOURCE_C_H
+#define INCLUDED_USRP1_SOURCE_C_H
+
+#include <usrp1_source_base.h>
+#include <db_boards.h>
+#include <stdexcept>
+
+
+class usrp1_source_c;
+typedef boost::shared_ptr<usrp1_source_c> usrp1_source_c_sptr;
+
+
+usrp1_source_c_sptr
+usrp1_make_source_c (int which_board=0,
+                    unsigned int decim_rate=64,
+                    int nchan=1,
+                    int mux=0x32103210,
+                    int mode=0,
+                    int fusb_block_size=0,
+                    int fusb_nblocks=0,
+                    const std::string fpga_filename="",
+                    const std::string firmware_filename=""
+                    ) throw (std::runtime_error);
+
+// public shared_ptr constructor
+
+/*!
+ * \brief interface to Universal Software Radio Peripheral Rx path (Rev 1)
+ */
+class usrp1_source_c : public usrp1_source_base {
+ private:
+  friend usrp1_source_c_sptr
+  usrp1_make_source_c (int which_board,
+                      unsigned int decim_rate,
+                      int nchan,
+                      int mux,
+                      int mode,
+                      int fusb_block_size,
+                      int fusb_nblocks,
+                      const std::string fpga_filename,
+                      const std::string firmware_filename
+                      ) throw (std::runtime_error);
+
+ protected:
+  usrp1_source_c (int which_board,
+                 unsigned int decim_rate,
+                 int nchan,
+                 int mux,
+                 int mode,
+                 int fusb_block_size,
+                 int fusb_nblocks,
+                 const std::string fpga_filename,
+                 const std::string firmware_filename
+                 ) throw (std::runtime_error);
+
+  virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items);
+
+  virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items,
+                                     int output_index,
+                                     int output_items_available,
+                                     int &output_items_produced,
+                                     const void *usrp_buffer,
+                                     int usrp_buffer_length,
+                                     int &bytes_read);
+
+ public:
+  ~usrp1_source_c ();
+};
+
+
+std::vector<int> pick_rx_subdevice(usrp1_source_c_sptr u);
+
+
+#endif /* INCLUDED_USRP1_SOURCE_C_H */

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_s.cc
 (from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.cc)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_s.cc
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_s.cc
    2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,141 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <usrp1_source_s.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <usrp_bytesex.h>
+
+static const int NBASIC_SAMPLES_PER_ITEM = 1;
+
+usrp1_source_s_sptr
+usrp1_make_source_s (int which_board, 
+                    unsigned int decim_rate,
+                    int nchan,
+                    int mux,
+                    int mode,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error)
+{
+  return usrp1_source_s_sptr (new usrp1_source_s (which_board,
+                                                 decim_rate, 
+                                                 nchan,
+                                                 mux,
+                                                 mode,
+                                                 fusb_block_size,
+                                                 fusb_nblocks,
+                                                 fpga_filename,
+                                                 firmware_filename
+                                                 ));
+}
+
+
+usrp1_source_s::usrp1_source_s (int which_board,
+                               unsigned int decim_rate,
+                               int nchan,
+                               int mux,
+                               int mode,
+                               int fusb_block_size,
+                               int fusb_nblocks,
+                               const std::string fpga_filename,
+                               const std::string firmware_filename
+                               ) throw (std::runtime_error)
+  : usrp1_source_base ("usrp1_source_s",
+                      gr_make_io_signature (1, 1, sizeof (short)),
+                      which_board, decim_rate, nchan, mux, mode,
+                      fusb_block_size,
+                      fusb_nblocks,
+                      fpga_filename, firmware_filename)
+{
+  _ensure_rev2(which_board);
+}
+
+usrp1_source_s::~usrp1_source_s ()
+{
+  // NOP
+}
+
+int
+usrp1_source_s::ninput_bytes_reqd_for_noutput_items (int noutput_items)
+{
+  return noutput_items * NBASIC_SAMPLES_PER_ITEM * sizeof_basic_sample();
+}
+
+/*
+ * Convert interleaved 8 or 16-bit I & Q from usrp buffer into a single
+ * short output stream.
+ */
+void
+usrp1_source_s::copy_from_usrp_buffer (gr_vector_void_star &output_items,
+                                      int output_index,
+                                      int output_items_available,
+                                      int &output_items_produced,
+                                      const void *usrp_buffer,
+                                      int usrp_buffer_length,
+                                      int &bytes_read)
+{
+  short *out = &((short *) output_items[0])[output_index];
+  unsigned sbs = sizeof_basic_sample();
+  unsigned nusrp_bytes_per_item = NBASIC_SAMPLES_PER_ITEM * sbs;
+
+  int nitems = std::min (output_items_available,
+                        (int)(usrp_buffer_length / nusrp_bytes_per_item));
+
+  signed char *s8 = (signed char *) usrp_buffer;
+  short *s16 = (short *) usrp_buffer;
+
+  switch(sbs){
+  case 1:
+    for (int i = 0; i < nitems; i++){
+      out[i] = s8[i] << 8;
+    }
+    break;
+
+  case 2:
+    for (int i = 0; i < nitems; i++){
+      out[i] = usrp_to_host_short(s16[i]);
+    }
+    break;
+    
+  default:
+    assert(0);
+  }
+
+  output_items_produced = nitems;
+  bytes_read = nitems * nusrp_bytes_per_item;
+}
+
+
+/******************************************************************************/
+
+std::vector<int>
+pick_rx_subdevice(usrp1_source_s_sptr u)
+{
+  return pick_rx_subdevice(u->usrp());
+}

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_s.h 
(from rev 9904, 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.h)
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_s.h 
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/not-sure/usrp1_source_s.h 
    2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,98 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_USRP1_SOURCE_S_H
+#define INCLUDED_USRP1_SOURCE_S_H
+
+#include <usrp1_source_base.h>
+#include <stdexcept>
+
+class usrp_standard_rx;
+
+
+class usrp1_source_s;
+typedef boost::shared_ptr<usrp1_source_s> usrp1_source_s_sptr;
+
+
+// public shared_ptr constructor
+
+usrp1_source_s_sptr
+usrp1_make_source_s (int which_board=0,
+                    unsigned int decim_rate=64,
+                    int nchan=1,
+                    int mux=0x32103210,
+                    int mode=0,
+                    int fusb_block_size=0,
+                    int fusb_nblocks=0,
+                    const std::string fpga_filename="",
+                    const std::string firmware_filename=""
+                    ) throw (std::runtime_error);
+
+/*!
+ * \brief interface to Universal Software Radio Peripheral Rx path (Rev 1)
+ *
+ * output: 1 stream of short
+ */
+class usrp1_source_s : public usrp1_source_base {
+ private:
+  friend usrp1_source_s_sptr
+  usrp1_make_source_s (int which_board, 
+                      unsigned int decim_rate,
+                      int nchan,
+                      int mux,
+                      int mode,
+                      int fusb_block_size,
+                      int fusb_nblocks,
+                      const std::string fpga_filename,
+                      const std::string firmware_filename
+                      ) throw (std::runtime_error);
+
+ protected:
+  usrp1_source_s (int which_board, 
+                 unsigned int decim_rate,
+                 int nchan,
+                 int mux,
+                 int mode,
+                 int fusb_block_size,
+                 int fusb_nblocks,
+                 const std::string fpga_filename,
+                 const std::string firmware_filename
+                 ) throw (std::runtime_error);
+
+  virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items);
+
+  virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items,
+                                     int output_index,
+                                     int output_items_available,
+                                     int &output_items_produced,
+                                     const void *usrp_buffer,
+                                     int usrp_buffer_length,
+                                     int &bytes_read);
+ public:
+  ~usrp1_source_s ();
+};
+
+
+std::vector<int> pick_rx_subdevice(usrp1_source_s_sptr u);
+
+
+#endif /* INCLUDED_USRP1_SOURCE_S_H */

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1.i

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_base.cc

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_base.h

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_base.i

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink.i

Deleted: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.cc

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.cc (from 
rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_sink_base.cc)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.cc    
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.cc    
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,359 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <usrp1_sink_base.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <assert.h>
+
+static const int OUTPUT_MULTIPLE_SAMPLES = 128;                // DON'T CHANGE 
THIS VALUE!
+
+usrp1_sink_base::usrp1_sink_base (const std::string &name,
+                                 gr_io_signature_sptr input_signature,
+                                 int which_board,
+                                 unsigned int interp_rate,
+                                 int nchan,
+                                 int mux,
+                                 int fusb_block_size,
+                                 int fusb_nblocks,
+                                 const std::string fpga_filename,
+                                 const std::string firmware_filename
+                                 ) throw (std::runtime_error)
+  : gr_sync_block (name,
+                  input_signature,
+                  gr_make_io_signature (0, 0, 0)),
+    d_nunderruns (0)
+{
+  d_usrp = usrp_standard_tx::make (which_board,
+                                  interp_rate,
+                                  nchan, mux,
+                                  fusb_block_size,
+                                  fusb_nblocks,
+                                  fpga_filename,
+                                  firmware_filename
+                                  );
+  if (d_usrp == 0)
+    throw std::runtime_error ("can't open usrp1");
+
+  // All calls to d_usrp->write must be multiples of 512 bytes.
+
+  set_output_multiple (OUTPUT_MULTIPLE_SAMPLES);
+}
+
+usrp1_sink_base::~usrp1_sink_base ()
+{
+  delete d_usrp;
+}
+
+bool 
+usrp1_sink_base::start()
+{
+  return d_usrp->start();
+}
+
+bool 
+usrp1_sink_base::stop()
+{
+  return d_usrp->stop();
+}
+
+int
+usrp1_sink_base::work (int noutput_items,
+                      gr_vector_const_void_star &input_items,
+                      gr_vector_void_star &output_items)
+{
+  static const int BUFSIZE = 16 * (1L << 10);  // 16kB
+  unsigned char outbuf[BUFSIZE];
+  int          obi = 0;
+  int          input_index = 0;
+  int          input_items_consumed;
+  int          bytes_written;
+  bool         underrun;
+  
+
+  while (input_index < noutput_items){
+  
+    copy_to_usrp_buffer (input_items,
+                        input_index,
+                        noutput_items - input_index,   // input_items_available
+                        input_items_consumed,          // [out]
+                        &outbuf[obi],                  // [out] usrp_buffer
+                        BUFSIZE - obi,                 // usrp_buffer_length
+                        bytes_written);                // [out]
+
+    assert (input_index + input_items_consumed <= noutput_items);
+    assert (obi + bytes_written <= BUFSIZE);
+    
+    input_index += input_items_consumed;
+    obi += bytes_written;
+
+    if (obi >= BUFSIZE){       // flush
+      if (d_usrp->write (outbuf, obi, &underrun) != obi)
+       return -1;              // indicate we're done
+
+      if (underrun){
+       d_nunderruns++;
+       // fprintf (stderr, "usrp1_sink: underrun\n");
+       fputs ("uU", stderr);
+      }
+      obi = 0;
+    }
+  }
+
+  if (obi != 0){
+    assert (obi % 512 == 0);
+    if (d_usrp->write (outbuf, obi, &underrun) != obi)
+      return -1;       // indicate we're done
+
+    if (underrun){
+      d_nunderruns++;
+      // fprintf (stderr, "usrp1_sink: underrun\n");
+      fputs ("uU", stderr);
+    }
+  }
+
+  return noutput_items;
+}
+
+bool
+usrp1_sink_base::set_interp_rate (unsigned int rate)
+{
+  return d_usrp->set_interp_rate (rate);
+}
+
+bool
+usrp1_sink_base::set_nchannels (int nchan)
+{
+  return d_usrp->set_nchannels (nchan);
+}
+
+bool
+usrp1_sink_base::set_mux (int mux)
+{
+  return d_usrp->set_mux (mux);
+}
+
+bool
+usrp1_sink_base::set_tx_freq (int channel, double freq)
+{
+  return d_usrp->set_tx_freq (channel, freq);
+}
+
+long
+usrp1_sink_base::fpga_master_clock_freq() const
+{
+  return d_usrp->fpga_master_clock_freq();
+}
+
+long
+usrp1_sink_base::converter_rate () const
+{
+  return d_usrp->converter_rate ();
+}
+
+unsigned int
+usrp1_sink_base::interp_rate () const
+{
+  return d_usrp->interp_rate ();
+}
+
+int
+usrp1_sink_base::nchannels () const
+{
+  return d_usrp->nchannels ();
+}
+
+int
+usrp1_sink_base::mux () const
+{
+  return d_usrp->mux ();
+}
+
+
+double
+usrp1_sink_base::tx_freq (int channel) const
+{
+  return d_usrp->tx_freq (channel);
+}
+
+void
+usrp1_sink_base::set_verbose (bool verbose)
+{  
+  d_usrp->set_verbose (verbose);
+}
+
+bool
+usrp1_sink_base::write_aux_dac (int which_dboard, int which_dac, int value)
+{
+  return d_usrp->write_aux_dac (which_dboard, which_dac, value);
+}
+
+int
+usrp1_sink_base::read_aux_adc (int which_dboard, int which_adc)
+{
+  return d_usrp->read_aux_adc (which_dboard, which_adc);
+}
+
+bool
+usrp1_sink_base::write_eeprom (int i2c_addr, int eeprom_offset, const 
std::string buf)
+{
+  return d_usrp->write_eeprom (i2c_addr, eeprom_offset, buf);
+}
+
+std::string
+usrp1_sink_base::read_eeprom (int i2c_addr, int eeprom_offset, int len)
+{
+  return d_usrp->read_eeprom (i2c_addr, eeprom_offset, len);
+}
+
+bool
+usrp1_sink_base::write_i2c (int i2c_addr, const std::string buf)
+{
+  return d_usrp->write_i2c (i2c_addr, buf);
+}
+
+std::string
+usrp1_sink_base::read_i2c (int i2c_addr, int len)
+{
+  return d_usrp->read_i2c (i2c_addr, len);
+}
+
+bool
+usrp1_sink_base::set_pga (int which, double gain)
+{
+  return d_usrp->set_pga (which, gain);
+}
+
+double
+usrp1_sink_base::pga (int which) const
+{
+  return d_usrp->pga (which);
+}
+
+double
+usrp1_sink_base::pga_min () const
+{
+  return d_usrp->pga_min ();
+}
+
+double
+usrp1_sink_base::pga_max () const
+{
+  return d_usrp->pga_max ();
+}
+
+double
+usrp1_sink_base::pga_db_per_step () const
+{
+  return d_usrp->pga_db_per_step ();
+}
+
+int
+usrp1_sink_base::daughterboard_id (int which) const
+{
+  return d_usrp->daughterboard_id (which);
+}
+
+bool
+usrp1_sink_base::set_adc_offset (int which, int offset)
+{
+  return d_usrp->set_adc_offset (which, offset);
+}
+
+bool
+usrp1_sink_base::set_dac_offset (int which, int offset, int offset_pin)
+{
+  return d_usrp->set_dac_offset (which, offset, offset_pin);
+}
+
+bool
+usrp1_sink_base::set_adc_buffer_bypass (int which, bool bypass)
+{
+  return d_usrp->set_adc_buffer_bypass (which, bypass);
+}
+
+std::string
+usrp1_sink_base::serial_number()
+{
+  return d_usrp->serial_number();
+}
+
+bool
+usrp1_sink_base::_write_oe (int which_dboard, int value, int mask)
+{
+  return d_usrp->_write_oe (which_dboard, value, mask);
+}
+
+bool
+usrp1_sink_base::write_io (int which_dboard, int value, int mask)
+{
+  return d_usrp->write_io (which_dboard, value, mask);
+}
+
+int
+usrp1_sink_base::read_io (int which_dboard)
+{
+  return d_usrp->read_io (which_dboard);
+}
+
+// internal routines...
+
+bool
+usrp1_sink_base::_write_fpga_reg (int regno, int value)
+{
+  return d_usrp->_write_fpga_reg (regno, value);
+}
+
+int
+usrp1_sink_base::_read_fpga_reg (int regno)
+{
+  return d_usrp->_read_fpga_reg (regno);
+}
+
+bool
+usrp1_sink_base::_write_9862 (int which_codec, int regno, unsigned char value)
+{
+  return d_usrp->_write_9862 (which_codec, regno, value);
+}
+
+int
+usrp1_sink_base::_read_9862 (int which_codec, int regno) const
+{
+  return d_usrp->_read_9862 (which_codec, regno);
+}
+
+bool
+usrp1_sink_base::_write_spi (int optional_header, int enables,
+                            int format, std::string buf)
+{
+  return d_usrp->_write_spi (optional_header, enables, format, buf);
+}
+
+std::string
+usrp1_sink_base::_read_spi (int optional_header, int enables, int format, int 
len)
+{
+  return d_usrp->_read_spi (optional_header, enables, format, len);
+}

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.h

Copied: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.h 
(from rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_sink_base.h)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.h     
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_base.h     
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,359 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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_USRP1_SINK_BASE_H
+#define INCLUDED_USRP1_SINK_BASE_H
+
+#include <gr_sync_block.h>
+#include <stdexcept>
+
+class usrp_standard_tx;
+
+
+/*!
+ * \brief abstract interface to Universal Software Radio Peripheral Tx path 
(Rev 1)
+ */
+class usrp1_sink_base : public gr_sync_block {
+ private:
+  usrp_standard_tx     *d_usrp;
+  int                   d_nunderruns;
+  
+ protected:
+  usrp1_sink_base (const std::string &name,
+                  gr_io_signature_sptr input_signature,
+                  int which_board,
+                  unsigned int interp_rate,
+                  int nchan,
+                  int mux,
+                  int fusb_block_size,
+                  int fusb_nblocks,
+                  const std::string fpga_filename,
+                  const std::string firmware_filename
+                  ) throw (std::runtime_error);
+
+  /*!
+   * \brief convert between input item format and usrp native format
+   *
+   * \param input_items[in]            stream(s) of input items
+   * \param input_index[in]            starting index in input_items
+   * \param input_items_available[in]  number of items available starting at 
item[index]
+   * \param input_items_consumed[out]          number of input items consumed 
by copy
+   * \param usrp_buffer[out]           destination buffer
+   * \param usrp_buffer_length[in]     \p usrp_buffer length in bytes
+   * \param bytes_written[out]         number of bytes written into \p 
usrp_buffer
+   */
+  virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
+                                   int  input_index,
+                                   int  input_items_available,
+                                   int  &input_items_consumed,
+                                   void *usrp_buffer,
+                                   int  usrp_buffer_length,
+                                   int  &bytes_written) = 0;
+
+ public:
+  //! magic value used on alternate register read interfaces
+  static const int READ_FAILED = -99999;
+
+
+  ~usrp1_sink_base ();
+
+  int work (int noutput_items,
+           gr_vector_const_void_star &input_items,
+           gr_vector_void_star &output_items);
+
+  bool start();
+  bool stop();
+
+  /*!
+   * \brief Set interpolator rate.  \p rate must be in [4, 1024] and a 
multiple of 4.
+   *
+   * The final complex sample rate across the USB is
+   *   dac_freq () / interp_rate () * nchannels ()
+   */
+  bool set_interp_rate (unsigned int rate);
+  bool set_nchannels (int nchan);
+  bool set_mux (int mux);
+
+  /*!
+   * \brief set the frequency of the digital up converter.
+   *
+   * \p channel must be 0.  \p freq is the center frequency in Hz.
+   * It must be in the range [-44M, 44M].  The frequency specified is
+   * quantized.  Use tx_freq to retrieve the actual value used.
+   */
+  bool set_tx_freq (int channel, double freq);
+
+  void set_verbose (bool verbose);
+
+  /*!
+   * \brief Set Programmable Gain Amplifier (PGA)
+   *
+   * \param which      which D/A [0,3]
+   * \param gain_in_db gain value (linear in dB)
+   *
+   * gain is rounded to closest setting supported by hardware.
+   * Note that DAC 0 and DAC 1 share a gain setting as do DAC 2 and DAC 3.
+   * Setting DAC 0 affects DAC 1 and vice versa.  Same with DAC 2 and DAC 3.
+   *
+   * \returns true iff sucessful.
+   *
+   * \sa pga_min(), pga_max(), pga_db_per_step()
+   */
+  bool set_pga (int which, double gain_in_db);
+
+  /*!
+   * \brief Return programmable gain amplifier gain in dB.
+   *
+   * \param which      which D/A [0,3]
+   */
+  double pga (int which) const;
+
+  /*!
+   * \brief Return minimum legal PGA gain in dB.
+   */
+  double pga_min () const;
+
+  /*!
+   * \brief Return maximum legal PGA gain in dB.
+   */
+  double pga_max () const;
+
+  /*!
+   * \brief Return hardware step size of PGA (linear in dB).
+   */
+  double pga_db_per_step () const;
+
+
+  // ACCESSORS
+
+  long fpga_master_clock_freq() const;
+  long converter_rate() const;
+  long dac_rate() const { return converter_rate(); }   // alias
+  long dac_freq() const { return converter_rate(); }   // deprecated alias
+
+  unsigned int interp_rate () const;
+  int nchannels () const;
+  int mux () const;
+  double tx_freq (int channel) const;
+  int nunderruns () const { return d_nunderruns; }
+
+  /*!
+   * \brief Return daughterboard ID for given Rx daughterboard slot [0,1].
+   *
+   * \return daughterboard id >= 0 if successful
+   * \return -1 if no daugherboard
+   * \return -2 if invalid EEPROM on daughterboard
+   */
+  int daughterboard_id (int which_dboard) const;
+
+  /*!
+   * \brief Write auxiliary digital to analog converter.
+   *
+   * \param which_dboard       [0,1] which d'board
+   *                           N.B., SLOT_TX_A and SLOT_RX_A share the same 
AUX DAC's.
+   *                           SLOT_TX_B and SLOT_RX_B share the same AUX 
DAC's.
+   * \param which_dac          [2,3] TX slots must use only 2 and 3.
+   * \param value              [0,4095]
+   * \returns true iff successful
+   */
+  bool write_aux_dac (int which_board, int which_dac, int value);
+
+  /*!
+   * \brief Read auxiliary analog to digital converter.
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param which_adc          [0,1]
+   * \returns value in the range [0,4095] if successful, else READ_FAILED.
+   */
+  int read_aux_adc (int which_dboard, int which_adc);
+
+  /*!
+   * \brief Write EEPROM on motherboard or any daughterboard.
+   * \param i2c_addr           I2C bus address of EEPROM
+   * \param eeprom_offset      byte offset in EEPROM to begin writing
+   * \param buf                        the data to write
+   * \returns true iff sucessful
+   */
+  bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf);
+
+  /*!
+   * \brief Write EEPROM on motherboard or any daughterboard.
+   * \param i2c_addr           I2C bus address of EEPROM
+   * \param eeprom_offset      byte offset in EEPROM to begin reading
+   * \param len                        number of bytes to read
+   * \returns the data read if successful, else a zero length string.
+   */
+  std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
+
+  /*!
+   * \brief Write to I2C peripheral
+   * \param i2c_addr           I2C bus address (7-bits)
+   * \param buf                        the data to write
+   * \returns true iff successful
+   * Writes are limited to a maximum of of 64 bytes.
+   */
+  bool write_i2c (int i2c_addr, const std::string buf);
+
+  /*!
+   * \brief Read from I2C peripheral
+   * \param i2c_addr           I2C bus address (7-bits)
+   * \param len                        number of bytes to read
+   * \returns the data read if successful, else a zero length string.
+   * Reads are limited to a maximum of of 64 bytes.
+   */
+  std::string read_i2c (int i2c_addr, int len);
+
+  /*!
+   * \brief Set ADC offset correction
+   * \param which      which ADC[0,3]: 0 = RX_A I, 1 = RX_A Q...
+   * \param offset     16-bit value to subtract from raw ADC input.
+   */
+  bool set_adc_offset (int which, int offset);
+
+  /*!
+   * \brief Set DAC offset correction
+   * \param which      which DAC[0,3]: 0 = TX_A I, 1 = TX_A Q...
+   * \param offset     10-bit offset value (ambiguous format:  See AD9862 
datasheet).
+   * \param offset_pin 1-bit value.  If 0 offset applied to -ve differential 
pin;
+   *                                  If 1 offset applied to +ve differential 
pin.
+   */
+  bool set_dac_offset (int which, int offset, int offset_pin);
+
+  /*!
+   * \brief Control ADC input buffer
+   * \param which      which ADC[0,3]
+   * \param bypass     if non-zero, bypass input buffer and connect input
+   *                   directly to switched cap SHA input of RxPGA.
+   */
+  bool set_adc_buffer_bypass (int which, bool bypass);
+
+  /*!
+   * \brief return the usrp's serial number.
+   *
+   * \returns non-zero length string iff successful.
+   */
+  std::string serial_number();
+
+  /*!
+   * \brief Write direction register (output enables) for pins that go to 
daughterboard.
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param value              value to write into register
+   * \param mask               which bits of value to write into reg
+   *
+   * Each d'board has 16-bits of general purpose i/o.
+   * Setting the bit makes it an output from the FPGA to the d'board.
+   *
+   * This register is initialized based on a value stored in the
+   * d'board EEPROM.  In general, you shouldn't be using this routine
+   * without a very good reason.  Using this method incorrectly will
+   * kill your USRP motherboard and/or daughterboard.
+   */
+  bool _write_oe (int which_dboard, int value, int mask);
+
+  /*!
+   * \brief Write daughterboard i/o pin value
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param value              value to write into register
+   * \param mask               which bits of value to write into reg
+   */
+  bool write_io (int which_dboard, int value, int mask);
+
+  /*!
+   * \brief Read daughterboard i/o pin value
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \returns register value if successful, else READ_FAILED
+   */
+  int read_io (int which_dboard);
+
+  //
+  // internal routines...
+  // You probably shouldn't be using these...
+  //
+  /*!
+   * \brief Write FPGA register.
+   * \param regno      7-bit register number
+   * \param value      32-bit value
+   * \returns true iff successful
+   */
+  bool _write_fpga_reg (int regno, int value); //< 7-bit regno, 32-bit value
+
+  /*!
+   * \brief Read FPGA register.
+   * \param regno      7-bit register number
+   * \returns register value if successful, else READ_FAILED
+   */
+  int  _read_fpga_reg (int regno);
+
+  /*!
+   * \brief Write AD9862 register.
+   * \param which_codec 0 or 1
+   * \param regno      6-bit register number
+   * \param value      8-bit value
+   * \returns true iff successful
+   */
+  bool _write_9862 (int which_codec, int regno, unsigned char value);
+
+  /*!
+   * \brief Read AD9862 register.
+   * \param which_codec 0 or 1
+   * \param regno      6-bit register number
+   * \returns register value if successful, else READ_FAILED
+   */
+  int  _read_9862 (int which_codec, int regno) const;
+
+  /*!
+   * \brief Write data to SPI bus peripheral.
+   *
+   * \param optional_header    0,1 or 2 bytes to write before buf.
+   * \param enables            bitmask of peripherals to write. See 
usrp_spi_defs.h
+   * \param format             transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+   * \param buf                        the data to write
+   * \returns true iff successful
+   * Writes are limited to a maximum of 64 bytes.
+   *
+   * If \p format specifies that optional_header bytes are present, they are
+   * written to the peripheral immediately prior to writing \p buf.
+   */
+  bool _write_spi (int optional_header, int enables, int format, std::string 
buf);
+
+  /*
+   * \brief Read data from SPI bus peripheral.
+   *
+   * \param optional_header    0,1 or 2 bytes to write before buf.
+   * \param enables            bitmask of peripheral to read. See 
usrp_spi_defs.h
+   * \param format             transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+   * \param len                        number of bytes to read.  Must be in 
[0,64].
+   * \returns the data read if sucessful, else a zero length string.
+   *
+   * Reads are limited to a maximum of 64 bytes.
+   *
+   * If \p format specifies that optional_header bytes are present, they
+   * are written to the peripheral first.  Then \p len bytes are read from
+   * the peripheral and returned.
+   */
+  std::string _read_spi (int optional_header, int enables, int format, int 
len);
+};
+
+#endif /* INCLUDED_USRP1_SINK_BASE_H */

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.cc

Copied: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.cc 
(from rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_sink_c.cc)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.cc       
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.cc       
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,106 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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 <usrp1_sink_c.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <usrp_bytesex.h>
+
+usrp1_sink_c_sptr
+usrp1_make_sink_c (int which_board,
+                  unsigned int interp_rate,
+                  int nchan,
+                  int mux,
+                  int fusb_block_size,
+                  int fusb_nblocks,
+                  const std::string fpga_filename,
+                  const std::string firmware_filename
+                  ) throw (std::runtime_error)
+{
+  return usrp1_sink_c_sptr (new usrp1_sink_c (which_board,
+                                             interp_rate,
+                                             nchan,
+                                             mux,
+                                             fusb_block_size,
+                                             fusb_nblocks,
+                                             fpga_filename,
+                                             firmware_filename
+                                             ));
+}
+
+
+usrp1_sink_c::usrp1_sink_c (int which_board,
+                           unsigned int interp_rate,
+                           int nchan,
+                           int mux,
+                           int fusb_block_size,
+                           int fusb_nblocks,
+                           const std::string fpga_filename,
+                           const std::string firmware_filename
+                           ) throw (std::runtime_error)
+  : usrp1_sink_base ("usrp1_sink_c",
+                    gr_make_io_signature (1, 1, sizeof (gr_complex)),
+                    which_board, interp_rate, nchan, mux,
+                    fusb_block_size, fusb_nblocks,
+                    fpga_filename, firmware_filename)
+{
+}
+
+usrp1_sink_c::~usrp1_sink_c ()
+{
+  // NOP
+}
+
+/*
+ * Take one complex input stream and format it into interleaved short I & Q
+ * for the usrp.
+ */
+void
+usrp1_sink_c::copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
+                                  int  input_index,
+                                  int  input_items_available,
+                                  int  &input_items_consumed,  // out
+                                  void *usrp_buffer,
+                                  int  usrp_buffer_length,
+                                  int  &bytes_written)         // out
+{
+  gr_complex *in = &((gr_complex *) input_items[0])[input_index];
+  short *dst = (short *) usrp_buffer;
+
+  static const int usrp_bytes_per_input_item = 2 * sizeof (short); // I & Q
+
+  int nitems = std::min (input_items_available,
+                        usrp_buffer_length / usrp_bytes_per_input_item);
+
+  for (int i = 0; i < nitems; i++){
+    dst[2*i + 0] = host_to_usrp_short((short) real(in[i]));    // FIXME 
saturate?
+    dst[2*i + 1] = host_to_usrp_short((short) imag(in[i]));    // FIXME 
saturate?
+  }
+
+  input_items_consumed = nitems;
+  bytes_written = nitems * usrp_bytes_per_input_item;
+}
+

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.h

Copied: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.h 
(from rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_sink_c.h)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.h        
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_c.h        
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,87 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_USRP1_SINK_C_H
+#define INCLUDED_USRP1_SINK_C_H
+
+#include <usrp1_sink_base.h>
+
+class usrp1_sink_c;
+typedef boost::shared_ptr<usrp1_sink_c> usrp1_sink_c_sptr;
+
+
+// public shared_ptr constructor
+
+usrp1_sink_c_sptr
+usrp1_make_sink_c (int which_board,
+                  unsigned int interp_rate,
+                  int nchan,
+                  int mux,
+                  int fusb_block_size,
+                  int fusb_nblocks,
+                  const std::string fpga_filename,
+                  const std::string firmware_filename
+                  ) throw (std::runtime_error);
+
+
+/*!
+ * \brief interface to Universal Software Radio Peripheral Tx path (Rev 1)
+ *
+ * input: gr_complex
+ */
+class usrp1_sink_c : public usrp1_sink_base {
+ private:
+
+  friend usrp1_sink_c_sptr
+  usrp1_make_sink_c (int which_board,
+                    unsigned int interp_rate,
+                    int nchan,
+                    int mux,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error);
+
+ protected:
+  usrp1_sink_c (int which_board,
+               unsigned int interp_rate,
+               int nchan,
+               int mux,
+               int fusb_block_size,
+               int fusb_nblocks,
+               const std::string fpga_filename,
+               const std::string firmware_filename
+               ) throw (std::runtime_error);
+
+  virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
+                                   int  input_index,
+                                   int  input_items_available,
+                                   int  &input_items_consumed,
+                                   void *usrp_buffer,
+                                   int  usrp_buffer_length,
+                                   int  &bytes_written);
+ public:
+  ~usrp1_sink_c ();
+};
+
+#endif /* INCLUDED_USRP1_SINK_C_H */

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.cc

Copied: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.cc 
(from rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_sink_s.cc)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.cc       
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.cc       
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,106 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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 <usrp1_sink_s.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <usrp_bytesex.h>
+
+usrp1_sink_s_sptr
+usrp1_make_sink_s (int which_board,
+                  unsigned int interp_rate,
+                  int nchan,
+                  int mux,
+                  int fusb_block_size,
+                  int fusb_nblocks,
+                  const std::string fpga_filename,
+                  const std::string firmware_filename
+                  ) throw (std::runtime_error)
+{
+  return usrp1_sink_s_sptr (new usrp1_sink_s (which_board,
+                                             interp_rate,
+                                             nchan,
+                                             mux,
+                                             fusb_block_size,
+                                             fusb_nblocks,
+                                             fpga_filename,
+                                             firmware_filename
+                                             ));
+}
+
+
+usrp1_sink_s::usrp1_sink_s (int which_board,
+                           unsigned int interp_rate,
+                           int nchan,
+                           int mux,
+                           int fusb_block_size,
+                           int fusb_nblocks,
+                           const std::string fpga_filename,
+                           const std::string firmware_filename
+                           ) throw (std::runtime_error)
+  : usrp1_sink_base ("usrp1_sink_s",
+                    gr_make_io_signature (1, 1, sizeof (short)),
+                    which_board, interp_rate, nchan, mux,
+                    fusb_block_size, fusb_nblocks,
+                    fpga_filename, firmware_filename)
+{
+  set_output_multiple (512 / sizeof(short));   // don't change
+}
+
+usrp1_sink_s::~usrp1_sink_s ()
+{
+  // NOP
+}
+
+/*
+ * Take one short input stream and format it into interleaved short I & Q
+ * for the usrp.
+ */
+void
+usrp1_sink_s::copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
+                                  int  input_index,
+                                  int  input_items_available,
+                                  int  &input_items_consumed,  // out
+                                  void *usrp_buffer,
+                                  int  usrp_buffer_length,
+                                  int  &bytes_written)         // out
+{
+  short *in = &((short *) input_items[0])[input_index];
+  short *dst = (short *) usrp_buffer;
+
+  static const int usrp_bytes_per_input_item = sizeof (short);
+
+  int nitems = std::min (input_items_available,
+                        usrp_buffer_length / usrp_bytes_per_input_item);
+
+  for (int i = 0; i < nitems; i++){    // FIXME unroll
+    dst[i] = host_to_usrp_short(in[i]);
+  }
+
+  input_items_consumed = nitems;
+  bytes_written = nitems * usrp_bytes_per_input_item;
+}
+

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.h

Copied: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.h 
(from rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_sink_s.h)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.h        
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_sink_s.h        
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,86 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_USRP1_SINK_S_H
+#define INCLUDED_USRP1_SINK_S_H
+
+#include <usrp1_sink_base.h>
+
+class usrp1_sink_s;
+typedef boost::shared_ptr<usrp1_sink_s> usrp1_sink_s_sptr;
+
+
+// public shared_ptr constructor
+
+usrp1_sink_s_sptr
+usrp1_make_sink_s (int which_board,
+                  unsigned int interp_rate,
+                  int nchan,
+                  int mux,
+                  int fusb_block_size,
+                  int fusb_nblocks,
+                  const std::string fpga_filename,
+                  const std::string firmware_filename
+                  ) throw (std::runtime_error);
+
+/*!
+ * \brief interface to Universal Software Radio Peripheral Tx path (Rev 1)
+ *
+ * input: short
+ */
+class usrp1_sink_s : public usrp1_sink_base {
+ private:
+
+  friend usrp1_sink_s_sptr
+  usrp1_make_sink_s (int which_board,
+                    unsigned int interp_rate,
+                    int nchan,
+                    int mux,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error);
+
+ protected:
+  usrp1_sink_s (int which_board,
+               unsigned int interp_rate,
+               int nchan,
+               int mux,
+               int fusb_block_size,
+               int fusb_nblocks,
+               const std::string fpga_filename,
+               const std::string firmware_filename
+               ) throw (std::runtime_error);
+
+  virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
+                                   int  input_index,
+                                   int  input_items_available,
+                                   int  &input_items_consumed,
+                                   void *usrp_buffer,
+                                   int  usrp_buffer_length,
+                                   int  &bytes_written);
+ public:
+  ~usrp1_sink_s ();
+};
+
+#endif /* INCLUDED_USRP1_SINK_S_H */

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source.i

Deleted: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.cc

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.cc 
(from rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_source_base.cc)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.cc  
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.cc  
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,425 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <usrp1_source_base.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <assert.h>
+
+static const int OUTPUT_MULTIPLE_BYTES = 4 * 1024;
+
+usrp1_source_base::usrp1_source_base (const std::string &name,
+                                     gr_io_signature_sptr output_signature,
+                                     int which_board,
+                                     unsigned int decim_rate,
+                                     int nchan,
+                                     int mux,
+                                     int mode,
+                                     int fusb_block_size,
+                                     int fusb_nblocks,
+                                     const std::string fpga_filename,
+                                     const std::string firmware_filename
+                                     ) throw (std::runtime_error)
+  : gr_sync_block (name,
+                  gr_make_io_signature (0, 0, 0),
+                  output_signature),
+    d_noverruns (0)
+{
+  d_usrp = usrp_standard_rx::make (which_board, decim_rate,
+                                  nchan, mux, mode,
+                                  fusb_block_size,
+                                  fusb_nblocks,
+                                  fpga_filename,
+                                  firmware_filename);
+  if (d_usrp == 0)
+    throw std::runtime_error ("can't open usrp1");
+
+  // All calls to d_usrp->read must be multiples of 512 bytes.
+  // We jack this up to 4k to reduce overhead.
+
+  set_output_multiple (OUTPUT_MULTIPLE_BYTES / 
output_signature->sizeof_stream_item (0));
+}
+
+usrp1_source_base::~usrp1_source_base ()
+{
+  delete d_usrp;
+}
+
+unsigned int
+usrp1_source_base::sizeof_basic_sample() const
+{
+  return usrp_standard_rx::format_width(d_usrp->format()) / 8;
+}
+
+bool
+usrp1_source_base::start()
+{
+  return d_usrp->start();
+}
+
+bool
+usrp1_source_base::stop()
+{
+  return d_usrp->stop();
+}
+
+int
+usrp1_source_base::work (int noutput_items,
+                        gr_vector_const_void_star &input_items,
+                        gr_vector_void_star &output_items)
+{
+  static const int BUFSIZE = 4 * OUTPUT_MULTIPLE_BYTES;
+  unsigned char buf[BUFSIZE];
+  int output_index = 0;
+  int output_items_produced;
+  int bytes_read;
+  bool overrun;
+
+  while (output_index < noutput_items){
+    int nbytes = ninput_bytes_reqd_for_noutput_items (noutput_items - 
output_index);
+    nbytes = std::min (nbytes, BUFSIZE);
+
+    int result_nbytes = d_usrp->read (buf, nbytes, &overrun);
+    if (overrun){
+      // fprintf (stderr, "usrp1_source: overrun\n");
+      fputs ("uO", stderr);
+      d_noverruns++;
+    }
+
+    if (result_nbytes < 0)     // We've got a problem.  Usually board 
unplugged or powered down.
+      return -1;               // Indicate we're done.
+
+    if (result_nbytes != nbytes){      // not really an error, but unexpected
+      fprintf (stderr, "usrp1_source: short read.  Expected %d, got %d\n",
+              nbytes, result_nbytes);
+    }
+
+    copy_from_usrp_buffer (output_items,
+                          output_index,
+                          noutput_items - output_index,   // 
output_items_available
+                          output_items_produced,          // [out]
+                          buf,                            // usrp_buffer
+                          result_nbytes,                  // usrp_buffer_length
+                          bytes_read);                    // [out]
+
+    assert (output_index + output_items_produced <= noutput_items);
+    assert (bytes_read == result_nbytes);
+
+    output_index += output_items_produced;
+  }
+
+  return noutput_items;
+}
+
+
+bool
+usrp1_source_base::set_decim_rate (unsigned int rate)
+{
+  return d_usrp->set_decim_rate (rate);
+}
+
+bool
+usrp1_source_base::set_nchannels (int nchan)
+{
+  return d_usrp->set_nchannels (nchan);
+}
+
+bool
+usrp1_source_base::set_mux (int mux)
+{
+  return d_usrp->set_mux (mux);
+}
+
+bool
+usrp1_source_base::set_rx_freq (int channel, double freq)
+{
+  return d_usrp->set_rx_freq (channel, freq);
+}
+
+long
+usrp1_source_base::fpga_master_clock_freq() const
+{
+  return d_usrp->fpga_master_clock_freq();
+}
+
+long
+usrp1_source_base::converter_rate() const
+{
+  return d_usrp->converter_rate();
+}
+
+unsigned int
+usrp1_source_base::decim_rate () const
+{
+  return d_usrp->decim_rate ();
+}
+
+int
+usrp1_source_base::nchannels () const
+{
+  return d_usrp->nchannels ();
+}
+
+int
+usrp1_source_base::mux () const
+{
+  return d_usrp->mux ();
+}
+
+double
+usrp1_source_base::rx_freq (int channel) const
+{
+  return d_usrp->rx_freq (channel);
+}
+
+bool
+usrp1_source_base::set_fpga_mode (int mode)
+{
+  return d_usrp->set_fpga_mode (mode);
+}
+
+bool
+usrp1_source_base::set_ddc_phase (int channel, int phase)
+{
+  return d_usrp->set_ddc_phase(channel, phase);
+}
+
+bool
+usrp1_source_base::set_dc_offset_cl_enable(int bits, int mask)
+{
+  return d_usrp->set_dc_offset_cl_enable(bits, mask);
+}
+
+void
+usrp1_source_base::set_verbose (bool verbose)
+{  
+  d_usrp->set_verbose (verbose);
+}
+
+bool
+usrp1_source_base::write_aux_dac (int which_dboard, int which_dac, int value)
+{
+  return d_usrp->write_aux_dac (which_dboard, which_dac, value);
+}
+
+int
+usrp1_source_base::read_aux_adc (int which_dboard, int which_adc)
+{
+  return d_usrp->read_aux_adc (which_dboard, which_adc);
+}
+
+bool
+usrp1_source_base::write_eeprom (int i2c_addr, int eeprom_offset, const 
std::string buf)
+{
+  return d_usrp->write_eeprom (i2c_addr, eeprom_offset, buf);
+}
+
+std::string
+usrp1_source_base::read_eeprom (int i2c_addr, int eeprom_offset, int len)
+{
+  return d_usrp->read_eeprom (i2c_addr, eeprom_offset, len);
+}
+
+bool
+usrp1_source_base::write_i2c (int i2c_addr, const std::string buf)
+{
+  return d_usrp->write_i2c (i2c_addr, buf);
+}
+
+std::string
+usrp1_source_base::read_i2c (int i2c_addr, int len)
+{
+  return d_usrp->read_i2c (i2c_addr, len);
+}
+
+bool
+usrp1_source_base::set_pga (int which, double gain)
+{
+  return d_usrp->set_pga (which, gain);
+}
+
+double
+usrp1_source_base::pga (int which) const
+{
+  return d_usrp->pga (which);
+}
+
+double
+usrp1_source_base::pga_min () const
+{
+  return d_usrp->pga_min ();
+}
+
+double
+usrp1_source_base::pga_max () const
+{
+  return d_usrp->pga_max ();
+}
+
+double
+usrp1_source_base::pga_db_per_step () const
+{
+  return d_usrp->pga_db_per_step ();
+}
+
+int
+usrp1_source_base::daughterboard_id (int which) const
+{
+  return d_usrp->daughterboard_id (which);
+}
+
+
+bool
+usrp1_source_base::set_adc_offset (int which, int offset)
+{
+  return d_usrp->set_adc_offset (which, offset);
+}
+
+bool
+usrp1_source_base::set_dac_offset (int which, int offset, int offset_pin)
+{
+  return d_usrp->set_dac_offset (which, offset, offset_pin);
+}
+
+bool
+usrp1_source_base::set_adc_buffer_bypass (int which, bool bypass)
+{
+  return d_usrp->set_adc_buffer_bypass (which, bypass);
+}
+
+std::string
+usrp1_source_base::serial_number()
+{
+  return d_usrp->serial_number();
+}
+
+bool
+usrp1_source_base::_write_oe (int which_dboard, int value, int mask)
+{
+  return d_usrp->_write_oe (which_dboard, value, mask);
+}
+
+bool
+usrp1_source_base::write_io (int which_dboard, int value, int mask)
+{
+  return d_usrp->write_io (which_dboard, value, mask);
+}
+
+int
+usrp1_source_base::read_io (int which_dboard)
+{
+  return d_usrp->read_io (which_dboard);
+}
+
+
+
+
+// internal routines...
+
+bool
+usrp1_source_base::_write_fpga_reg (int regno, int value)
+{
+  return d_usrp->_write_fpga_reg (regno, value);
+}
+
+bool
+usrp1_source_base::_write_fpga_reg_masked (int regno, int value, int mask)
+{
+  return d_usrp->_write_fpga_reg_masked (regno, value, mask);
+}
+
+int
+usrp1_source_base::_read_fpga_reg (int regno)
+{
+  return d_usrp->_read_fpga_reg (regno);
+}
+
+bool
+usrp1_source_base::_write_9862 (int which_codec, int regno, unsigned char 
value)
+{
+  return d_usrp->_write_9862 (which_codec, regno, value);
+}
+
+int
+usrp1_source_base::_read_9862 (int which_codec, int regno) const
+{
+  return d_usrp->_read_9862 (which_codec, regno);
+}
+
+bool
+usrp1_source_base::_write_spi (int optional_header, int enables,
+                              int format, std::string buf)
+{
+  return d_usrp->_write_spi (optional_header, enables, format, buf);
+}
+
+std::string
+usrp1_source_base::_read_spi (int optional_header, int enables, int format, 
int len)
+{
+  return d_usrp->_read_spi (optional_header, enables, format, len);
+}
+
+bool
+usrp1_source_base::set_format(unsigned int format)
+{
+  return d_usrp->set_format(format);
+}
+
+unsigned int
+usrp1_source_base::format() const
+{
+  return d_usrp->format();
+}
+
+unsigned int
+usrp1_source_base::make_format(int width, int shift, bool want_q, bool 
bypass_halfband)
+{
+  return usrp_standard_rx::make_format(width, shift, want_q, bypass_halfband);
+}
+
+int
+usrp1_source_base::format_width(unsigned int format)
+{
+  return usrp_standard_rx::format_width(format);
+}
+
+int
+usrp1_source_base::format_shift(unsigned int format)
+{
+  return usrp_standard_rx::format_shift(format);
+}
+
+bool
+usrp1_source_base::format_want_q(unsigned int format)
+{
+  return usrp_standard_rx::format_want_q(format);
+}
+
+bool
+usrp1_source_base::format_bypass_halfband(unsigned int format)
+{
+  return usrp_standard_rx::format_bypass_halfband(format);
+}

Deleted: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.h

Copied: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.h (from 
rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_source_base.h)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.h   
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_base.h   
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,455 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_USRP1_SOURCE_BASE_H
+#define INCLUDED_USRP1_SOURCE_BASE_H
+
+#include <gr_sync_block.h>
+#include <stdexcept>
+
+class usrp_standard_rx;
+
+/*!
+ * \brief abstract interface to Universal Software Radio Peripheral Rx path 
(Rev 1)
+ */
+class usrp1_source_base : public gr_sync_block {
+ private:
+  usrp_standard_rx     *d_usrp;
+  int                   d_noverruns;
+  
+ protected:
+  usrp1_source_base (const std::string &name,
+                    gr_io_signature_sptr output_signature,
+                    int which_board,
+                    unsigned int decim_rate,
+                    int nchan,
+                    int mux,
+                    int mode,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error);
+
+  /*!
+   * \brief return number of usrp input bytes required to produce noutput 
items.
+   */
+  virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items) = 0;
+
+  /*!
+   * \brief number of bytes in a low-level sample
+   */
+  unsigned int sizeof_basic_sample() const;
+
+  /*!
+   * \brief convert between native usrp format and output item format
+   *
+   * \param output_items[out]          stream(s) of output items
+   * \param output_index[in]           starting index in output_items
+   * \param output_items_available[in] number of empty items available at 
item[index]
+   * \param output_items_produced[out] number of items produced by copy
+   * \param usrp_buffer[in]            source buffer
+   * \param usrp_buffer_length[in]     number of bytes available in \p 
usrp_buffer
+   * \param bytes_read[out]            number of bytes read from \p usrp_buffer
+   *
+   * The copy must consume all bytes available.  That is, \p bytes_read must 
equal
+   * \p usrp_buffer_length.
+   */
+  virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items,
+                                     int output_index,
+                                     int output_items_available,
+                                     int &output_items_produced,
+                                     const void *usrp_buffer,
+                                     int usrp_buffer_length,
+                                     int &bytes_read) = 0;
+
+ public:
+  //! magic value used on alternate register read interfaces
+  static const int READ_FAILED = -99999;
+
+  ~usrp1_source_base ();
+
+  int work (int noutput_items,
+           gr_vector_const_void_star &input_items,
+           gr_vector_void_star &output_items);
+
+  bool start();
+  bool stop();
+
+  /*!
+   * \brief Set decimator rate.  \p rate must be EVEN and in [8, 256].
+   *
+   * The final complex sample rate across the USB is
+   *   adc_freq () / decim_rate ()
+   */
+  bool set_decim_rate (unsigned int rate);
+  bool set_nchannels (int nchan);
+  bool set_mux (int mux);
+
+  /*!
+   * \brief set the center frequency of the digital down converter.
+   *
+   * \p channel must be 0.  \p freq is the center frequency in Hz.
+   * It must be in the range [-FIXME, FIXME].  The frequency specified is
+   * quantized.  Use rx_freq to retrieve the actual value used.
+   */
+  bool set_rx_freq (int channel, double freq);
+
+  /*!
+   * \brief set fpga special modes
+   */
+  bool set_fpga_mode (int mode);
+
+  void set_verbose (bool verbose);
+
+  /*!
+   * \brief Set the digital down converter phase register.
+   *
+   * \param channel    which ddc channel [0, 3]
+   * \param phase      32-bit integer phase value.
+   */
+  bool set_ddc_phase(int channel, int phase);
+
+  /*!
+   * \brief Set Programmable Gain Amplifier (PGA)
+   *
+   * \param which      which A/D [0,3]
+   * \param gain_in_db gain value (linear in dB)
+   *
+   * gain is rounded to closest setting supported by hardware.
+   *
+   * \returns true iff sucessful.
+   *
+   * \sa pga_min(), pga_max(), pga_db_per_step()
+   */
+  bool set_pga (int which, double gain_in_db);
+
+  /*!
+   * \brief Return programmable gain amplifier gain setting in dB.
+   *
+   * \param which      which A/D [0,3]
+   */
+  double pga (int which) const;
+
+  /*!
+   * \brief Return minimum legal PGA setting in dB.
+   */
+  double pga_min () const;
+
+  /*!
+   * \brief Return maximum legal PGA setting in dB.
+   */
+  double pga_max () const;
+
+  /*!
+   * \brief Return hardware step size of PGA (linear in dB).
+   */
+  double pga_db_per_step () const;
+
+  // ACCESSORS
+
+  long fpga_master_clock_freq() const;
+  long converter_rate() const;
+  long adc_rate() const { return converter_rate(); }   // alias
+  long adc_freq() const { return converter_rate(); }   // deprecated alias
+
+  unsigned int decim_rate () const;
+  int nchannels () const;
+  int mux () const;
+  double rx_freq (int channel) const;
+  int noverruns () const { return d_noverruns; }
+
+  /*!
+   * \brief Return daughterboard ID for given Rx daughterboard slot [0,1].
+   *
+   * \return daughterboard id >= 0 if successful
+   * \return -1 if no daugherboard
+   * \return -2 if invalid EEPROM on daughterboard
+   */
+  int daughterboard_id (int which_dboard) const;
+
+  /*!
+   * \brief Write auxiliary digital to analog converter.
+   *
+   * \param which_dboard       [0,1] which d'board
+   *                           N.B., SLOT_TX_A and SLOT_RX_A share the same 
AUX DAC's.
+   *                           SLOT_TX_B and SLOT_RX_B share the same AUX 
DAC's.
+   * \param which_dac          [2,3] TX slots must use only 2 and 3.
+   * \param value              [0,4095]
+   * \returns true iff successful
+   */
+  bool write_aux_dac (int which_board, int which_dac, int value);
+
+  /*!
+   * \brief Read auxiliary analog to digital converter.
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param which_adc          [0,1]
+   * \returns value in the range [0,4095] if successful, else READ_FAILED.
+   */
+  int read_aux_adc (int which_dboard, int which_adc);
+
+  /*!
+   * \brief Write EEPROM on motherboard or any daughterboard.
+   * \param i2c_addr           I2C bus address of EEPROM
+   * \param eeprom_offset      byte offset in EEPROM to begin writing
+   * \param buf                        the data to write
+   * \returns true iff sucessful
+   */
+  bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf);
+
+  /*!
+   * \brief Write EEPROM on motherboard or any daughterboard.
+   * \param i2c_addr           I2C bus address of EEPROM
+   * \param eeprom_offset      byte offset in EEPROM to begin reading
+   * \param len                        number of bytes to read
+   * \returns the data read if successful, else a zero length string.
+   */
+  std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
+
+  /*!
+   * \brief Write to I2C peripheral
+   * \param i2c_addr           I2C bus address (7-bits)
+   * \param buf                        the data to write
+   * \returns true iff successful
+   * Writes are limited to a maximum of of 64 bytes.
+   */
+  bool write_i2c (int i2c_addr, const std::string buf);
+
+  /*!
+   * \brief Read from I2C peripheral
+   * \param i2c_addr           I2C bus address (7-bits)
+   * \param len                        number of bytes to read
+   * \returns the data read if successful, else a zero length string.
+   * Reads are limited to a maximum of of 64 bytes.
+   */
+  std::string read_i2c (int i2c_addr, int len);
+
+  /*!
+   * \brief Set ADC offset correction
+   * \param which      which ADC[0,3]: 0 = RX_A I, 1 = RX_A Q...
+   * \param offset     16-bit value to subtract from raw ADC input.
+   */
+  bool set_adc_offset (int which, int offset);
+
+  /*!
+   * \brief Set DAC offset correction
+   * \param which      which DAC[0,3]: 0 = TX_A I, 1 = TX_A Q...
+   * \param offset     10-bit offset value (ambiguous format:  See AD9862 
datasheet).
+   * \param offset_pin 1-bit value.  If 0 offset applied to -ve differential 
pin;
+   *                                  If 1 offset applied to +ve differential 
pin.
+   */
+  bool set_dac_offset (int which, int offset, int offset_pin);
+
+  /*!
+   * \brief Control ADC input buffer
+   * \param which      which ADC[0,3]
+   * \param bypass     if non-zero, bypass input buffer and connect input
+   *                   directly to switched cap SHA input of RxPGA.
+   */
+  bool set_adc_buffer_bypass (int which, bool bypass);
+
+  /*!
+   * \brief return the usrp's serial number.
+   *
+   * \returns non-zero length string iff successful.
+   */
+  std::string serial_number();
+
+  /*!
+   * \brief Write direction register (output enables) for pins that go to 
daughterboard.
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param value              value to write into register
+   * \param mask               which bits of value to write into reg
+   *
+   * Each d'board has 16-bits of general purpose i/o.
+   * Setting the bit makes it an output from the FPGA to the d'board.
+   *
+   * This register is initialized based on a value stored in the
+   * d'board EEPROM.  In general, you shouldn't be using this routine
+   * without a very good reason.  Using this method incorrectly will
+   * kill your USRP motherboard and/or daughterboard.
+   */
+  bool _write_oe (int which_dboard, int value, int mask);
+
+  /*!
+   * \brief Write daughterboard i/o pin value
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \param value              value to write into register
+   * \param mask               which bits of value to write into reg
+   */
+  bool write_io (int which_dboard, int value, int mask);
+
+  /*!
+   * \brief Read daughterboard i/o pin value
+   *
+   * \param which_dboard       [0,1] which d'board
+   * \returns register value if successful, else READ_FAILED
+   */
+  int read_io (int which_dboard);
+
+  /*!
+   * \brief Enable/disable automatic DC offset removal control loop in FPGA
+   *
+   * \param bits  which control loops to enable
+   * \param mask  which \p bits to pay attention to
+   *
+   * If the corresponding bit is set, enable the automatic DC
+   * offset correction control loop.
+   *
+   * <pre>
+   * The 4 low bits are significant:
+   *
+   *   ADC0 = (1 << 0)
+   *   ADC1 = (1 << 1)
+   *   ADC2 = (1 << 2)
+   *   ADC3 = (1 << 3)
+   * </pre>
+   *
+   * By default the control loop is enabled on all ADC's.
+   */
+  bool set_dc_offset_cl_enable(int bits, int mask);
+
+  /*!
+   * \brief Specify Rx data format.
+   *
+   * \param format     format specifier
+   *
+   * Rx data format control register
+   *
+   *     3                   2                   1                       
+   *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+   *  +-----------------------------------------+-+-+---------+-------+
+   *  |          Reserved (Must be zero)        |B|Q|  WIDTH  | SHIFT |
+   *  +-----------------------------------------+-+-+---------+-------+
+   *
+   *  SHIFT specifies arithmetic right shift [0, 15]
+   *  WIDTH specifies bit-width of I & Q samples across the USB [1, 16] (not 
all valid)
+   *  Q     if set deliver both I & Q, else just I
+   *  B     if set bypass half-band filter.
+   *
+   * Right now the acceptable values are:
+   *
+   *   B  Q  WIDTH  SHIFT
+   *   0  1    16     0
+   *   0  1     8     8
+   *
+   * More valid combos to come.
+   *
+   * Default value is 0x00000300  16-bits, 0 shift, deliver both I & Q.
+   */
+  bool set_format(unsigned int format);
+
+  /*!
+   * \brief return current format
+   */
+  unsigned int format () const;
+
+  static unsigned int make_format(int width=16, int shift=0,
+                                 bool want_q=true, bool bypass_halfband=false);
+  static int format_width(unsigned int format);
+  static int format_shift(unsigned int format);
+  static bool format_want_q(unsigned int format);
+  static bool format_bypass_halfband(unsigned int format);
+
+  // ----------------------------------------------------------------
+  // internal routines...  
+  // You probably shouldn't be using these...
+  // ----------------------------------------------------------------
+
+  /*!
+   * \brief Write FPGA register.
+   * \param regno      7-bit register number
+   * \param value      32-bit value
+   * \returns true iff successful
+   */
+  bool _write_fpga_reg (int regno, int value); //< 7-bit regno, 32-bit value
+
+  /*!
+   * \brief Write FPGA register masked.
+   * \param regno      7-bit register number
+   * \param value      16-bit value
+   * \param mask               16-bit mask
+   * \returns true iff successful
+   */
+  bool _write_fpga_reg_masked (int regno, int value, int mask);        //< 
7-bit regno, 16-bit value, 16-bit mask
+
+  /*!
+   * \brief Read FPGA register.
+   * \param regno      7-bit register number
+   * \returns register value if successful, else READ_FAILED
+   */
+  int  _read_fpga_reg (int regno);
+
+  /*!
+   * \brief Write AD9862 register.
+   * \param which_codec 0 or 1
+   * \param regno      6-bit register number
+   * \param value      8-bit value
+   * \returns true iff successful
+   */
+  bool _write_9862 (int which_codec, int regno, unsigned char value);
+
+  /*!
+   * \brief Read AD9862 register.
+   * \param which_codec 0 or 1
+   * \param regno      6-bit register number
+   * \returns register value if successful, else READ_FAILED
+   */
+  int  _read_9862 (int which_codec, int regno) const;
+
+  /*!
+   * \brief Write data to SPI bus peripheral.
+   *
+   * \param optional_header    0,1 or 2 bytes to write before buf.
+   * \param enables            bitmask of peripherals to write. See 
usrp_spi_defs.h
+   * \param format             transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+   * \param buf                        the data to write
+   * \returns true iff successful
+   * Writes are limited to a maximum of 64 bytes.
+   *
+   * If \p format specifies that optional_header bytes are present, they are
+   * written to the peripheral immediately prior to writing \p buf.
+   */
+  bool _write_spi (int optional_header, int enables, int format, std::string 
buf);
+
+  /*
+   * \brief Read data from SPI bus peripheral.
+   *
+   * \param optional_header    0,1 or 2 bytes to write before buf.
+   * \param enables            bitmask of peripheral to read. See 
usrp_spi_defs.h
+   * \param format             transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+   * \param len                        number of bytes to read.  Must be in 
[0,64].
+   * \returns the data read if sucessful, else a zero length string.
+   *
+   * Reads are limited to a maximum of 64 bytes.
+   *
+   * If \p format specifies that optional_header bytes are present, they
+   * are written to the peripheral first.  Then \p len bytes are read from
+   * the peripheral and returned.
+   */
+  std::string _read_spi (int optional_header, int enables, int format, int 
len);
+};
+
+#endif /* INCLUDED_USRP1_SOURCE_BASE_H */

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.cc

Copied: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.cc 
(from rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_source_c.cc)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.cc     
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.cc     
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,131 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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 <usrp1_source_c.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <usrp_bytesex.h>
+
+static const int NBASIC_SAMPLES_PER_ITEM = 2;  // I & Q
+
+usrp1_source_c_sptr
+usrp1_make_source_c (int which_board,
+                    unsigned int decim_rate,
+                    int nchan,
+                    int mux,
+                    int mode,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error)
+{
+  return usrp1_source_c_sptr (new usrp1_source_c (which_board,
+                                                 decim_rate,
+                                                 nchan,
+                                                 mux,
+                                                 mode,
+                                                 fusb_block_size,
+                                                 fusb_nblocks,
+                                                 fpga_filename,
+                                                 firmware_filename
+                                                 ));
+}
+
+
+usrp1_source_c::usrp1_source_c (int which_board,
+                               unsigned int decim_rate,
+                               int nchan,
+                               int mux,
+                               int mode,
+                               int fusb_block_size,
+                               int fusb_nblocks,
+                               const std::string fpga_filename,
+                               const std::string firmware_filename
+                               ) throw (std::runtime_error)
+  : usrp1_source_base ("usrp1_source_c",
+                      gr_make_io_signature (1, 1, sizeof (gr_complex)),
+                      which_board, decim_rate, nchan, mux, mode,
+                      fusb_block_size, fusb_nblocks,
+                      fpga_filename, firmware_filename)
+{
+}
+
+usrp1_source_c::~usrp1_source_c ()
+{
+  // NOP
+}
+
+int
+usrp1_source_c::ninput_bytes_reqd_for_noutput_items (int noutput_items)
+{
+  return noutput_items * NBASIC_SAMPLES_PER_ITEM * sizeof_basic_sample();
+}
+
+/*
+ * Convert interleaved 8 or 16-bit I & Q from usrp buffer into a single
+ * complex output stream.
+ */
+void
+usrp1_source_c::copy_from_usrp_buffer (gr_vector_void_star &output_items,
+                                      int output_index,
+                                      int output_items_available,
+                                      int &output_items_produced,
+                                      const void *usrp_buffer,
+                                      int usrp_buffer_length,
+                                      int &bytes_read)
+{
+  gr_complex *out = &((gr_complex *) output_items[0])[output_index];
+  unsigned sbs = sizeof_basic_sample();
+  unsigned nusrp_bytes_per_item = NBASIC_SAMPLES_PER_ITEM * sbs;
+
+  int nitems = std::min (output_items_available,
+                        (int)(usrp_buffer_length / nusrp_bytes_per_item));
+
+  signed char *s8 = (signed char *) usrp_buffer;
+  short *s16 = (short *) usrp_buffer;
+
+  switch (sbs){
+  case 1:
+    for (int i = 0; i < nitems; i++){
+      out[i] = gr_complex ((float)(s8[2*i+0] << 8), (float)(s8[2*i+1] << 8));
+    }
+    break;
+
+  case 2:
+    for (int i = 0; i < nitems; i++){
+      out[i] = gr_complex ((float) usrp_to_host_short(s16[2*i+0]),
+                          (float) usrp_to_host_short(s16[2*i+1]));
+    }
+    break;
+
+  default:
+    assert(0);
+  }
+
+  output_items_produced = nitems;
+  bytes_read = nitems * nusrp_bytes_per_item;
+}

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.h

Copied: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.h 
(from rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_source_c.h)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.h      
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_c.h      
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,93 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_USRP1_SOURCE_C_H
+#define INCLUDED_USRP1_SOURCE_C_H
+
+#include <usrp1_source_base.h>
+#include <stdexcept>
+
+class usrp_standard_rx;
+
+
+class usrp1_source_c;
+typedef boost::shared_ptr<usrp1_source_c> usrp1_source_c_sptr;
+
+
+// public shared_ptr constructor
+
+usrp1_source_c_sptr
+usrp1_make_source_c (int which_board,
+                    unsigned int decim_rate,
+                    int nchan,
+                    int mux,
+                    int mode,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error);
+
+/*!
+ * \brief interface to Universal Software Radio Peripheral Rx path (Rev 1)
+ */
+class usrp1_source_c : public usrp1_source_base {
+ private:
+  friend usrp1_source_c_sptr
+  usrp1_make_source_c (int which_board,
+                      unsigned int decim_rate,
+                      int nchan,
+                      int mux,
+                      int mode,
+                      int fusb_block_size,
+                      int fusb_nblocks,
+                      const std::string fpga_filename,
+                      const std::string firmware_filename
+                      ) throw (std::runtime_error);
+
+ protected:
+  usrp1_source_c (int which_board,
+                 unsigned int decim_rate,
+                 int nchan,
+                 int mux,
+                 int mode,
+                 int fusb_block_size,
+                 int fusb_nblocks,
+                 const std::string fpga_filename,
+                 const std::string firmware_filename
+                 ) throw (std::runtime_error);
+
+  virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items);
+
+  virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items,
+                                     int output_index,
+                                     int output_items_available,
+                                     int &output_items_produced,
+                                     const void *usrp_buffer,
+                                     int usrp_buffer_length,
+                                     int &bytes_read);
+
+ public:
+  ~usrp1_source_c ();
+};
+
+#endif /* INCLUDED_USRP1_SOURCE_C_H */

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.cc

Copied: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.cc 
(from rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_source_s.cc)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.cc     
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.cc     
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,131 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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 <usrp1_source_s.h>
+#include <gr_io_signature.h>
+#include <usrp_standard.h>
+#include <usrp_bytesex.h>
+
+static const int NBASIC_SAMPLES_PER_ITEM = 1;
+
+usrp1_source_s_sptr
+usrp1_make_source_s (int which_board, 
+                    unsigned int decim_rate,
+                    int nchan,
+                    int mux,
+                    int mode,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error)
+{
+  return usrp1_source_s_sptr (new usrp1_source_s (which_board,
+                                                 decim_rate, 
+                                                 nchan,
+                                                 mux,
+                                                 mode,
+                                                 fusb_block_size,
+                                                 fusb_nblocks,
+                                                 fpga_filename,
+                                                 firmware_filename
+                                                 ));
+}
+
+
+usrp1_source_s::usrp1_source_s (int which_board,
+                               unsigned int decim_rate,
+                               int nchan,
+                               int mux,
+                               int mode,
+                               int fusb_block_size,
+                               int fusb_nblocks,
+                               const std::string fpga_filename,
+                               const std::string firmware_filename
+                               ) throw (std::runtime_error)
+  : usrp1_source_base ("usrp1_source_s",
+                      gr_make_io_signature (1, 1, sizeof (short)),
+                      which_board, decim_rate, nchan, mux, mode,
+                      fusb_block_size,
+                      fusb_nblocks,
+                      fpga_filename, firmware_filename)
+{
+}
+
+usrp1_source_s::~usrp1_source_s ()
+{
+  // NOP
+}
+
+int
+usrp1_source_s::ninput_bytes_reqd_for_noutput_items (int noutput_items)
+{
+  return noutput_items * NBASIC_SAMPLES_PER_ITEM * sizeof_basic_sample();
+}
+
+/*
+ * Convert interleaved 8 or 16-bit I & Q from usrp buffer into a single
+ * short output stream.
+ */
+void
+usrp1_source_s::copy_from_usrp_buffer (gr_vector_void_star &output_items,
+                                      int output_index,
+                                      int output_items_available,
+                                      int &output_items_produced,
+                                      const void *usrp_buffer,
+                                      int usrp_buffer_length,
+                                      int &bytes_read)
+{
+  short *out = &((short *) output_items[0])[output_index];
+  unsigned sbs = sizeof_basic_sample();
+  unsigned nusrp_bytes_per_item = NBASIC_SAMPLES_PER_ITEM * sbs;
+
+  int nitems = std::min (output_items_available,
+                        (int)(usrp_buffer_length / nusrp_bytes_per_item));
+
+  signed char *s8 = (signed char *) usrp_buffer;
+  short *s16 = (short *) usrp_buffer;
+
+  switch(sbs){
+  case 1:
+    for (int i = 0; i < nitems; i++){
+      out[i] = s8[i] << 8;
+    }
+    break;
+
+  case 2:
+    for (int i = 0; i < nitems; i++){
+      out[i] = usrp_to_host_short(s16[i]);
+    }
+    break;
+    
+  default:
+    assert(0);
+  }
+
+  output_items_produced = nitems;
+  bytes_read = nitems * nusrp_bytes_per_item;
+}

Deleted: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.h

Copied: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.h 
(from rev 9904, gnuradio/trunk/gr-usrp/src/usrp1_source_s.h)
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.h      
                        (rev 0)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp1_source_s.h      
2008-11-02 22:42:57 UTC (rev 9905)
@@ -0,0 +1,94 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_USRP1_SOURCE_S_H
+#define INCLUDED_USRP1_SOURCE_S_H
+
+#include <usrp1_source_base.h>
+#include <stdexcept>
+
+class usrp_standard_rx;
+
+
+class usrp1_source_s;
+typedef boost::shared_ptr<usrp1_source_s> usrp1_source_s_sptr;
+
+
+// public shared_ptr constructor
+
+usrp1_source_s_sptr
+usrp1_make_source_s (int which_board, 
+                    unsigned int decim_rate,
+                    int nchan,
+                    int mux,
+                    int mode,
+                    int fusb_block_size,
+                    int fusb_nblocks,
+                    const std::string fpga_filename,
+                    const std::string firmware_filename
+                    ) throw (std::runtime_error);
+
+/*!
+ * \brief interface to Universal Software Radio Peripheral Rx path (Rev 1)
+ *
+ * output: 1 stream of short
+ */
+class usrp1_source_s : public usrp1_source_base {
+ private:
+  friend usrp1_source_s_sptr
+  usrp1_make_source_s (int which_board, 
+                      unsigned int decim_rate,
+                      int nchan,
+                      int mux,
+                      int mode,
+                      int fusb_block_size,
+                      int fusb_nblocks,
+                      const std::string fpga_filename,
+                      const std::string firmware_filename
+                      ) throw (std::runtime_error);
+
+ protected:
+  usrp1_source_s (int which_board, 
+                 unsigned int decim_rate,
+                 int nchan,
+                 int mux,
+                 int mode,
+                 int fusb_block_size,
+                 int fusb_nblocks,
+                 const std::string fpga_filename,
+                 const std::string firmware_filename
+                 ) throw (std::runtime_error);
+
+  virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items);
+
+  virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items,
+                                     int output_index,
+                                     int output_items_available,
+                                     int &output_items_produced,
+                                     const void *usrp_buffer,
+                                     int usrp_buffer_length,
+                                     int &bytes_read);
+ public:
+  ~usrp1_source_s ();
+};
+
+#endif /* INCLUDED_USRP1_SOURCE_S_H */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]