commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9950 - in gnuradio/branches/developers/eb/cppdb-wip:


From: eb
Subject: [Commit-gnuradio] r9950 - in gnuradio/branches/developers/eb/cppdb-wip: gnuradio-examples/c++/usrp_test gr-usrp/src usrp/host/apps usrp/host/lib/legacy
Date: Thu, 6 Nov 2008 23:23:25 -0700 (MST)

Author: eb
Date: 2008-11-06 23:23:24 -0700 (Thu, 06 Nov 2008)
New Revision: 9950

Modified:
   
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/c++/usrp_test/usrp_test.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_base.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.h
   
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/test_usrp_standard_rx.cc
   
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/test_usrp_standard_tx.cc
   
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/usrp_cal_dc_offset.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.h
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_basic.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_basic.h
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_boards.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_boards.h
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.h
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt754.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt754.h
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt768.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt768.h
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf.h
   
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf_mimo.cc
   
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf_mimo.h
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_tv_rx.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_tv_rx.h
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_wbx.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_wbx.h
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_xcvr2450.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_xcvr2450.h
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc
   gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h
   
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.cc
   
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.h
Log:
Switching to usrp_standard_sptr's, part 2 of 2.  Work in progress.


Modified: 
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/c++/usrp_test/usrp_test.cc
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/c++/usrp_test/usrp_test.cc
      2008-11-07 06:22:20 UTC (rev 9949)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/c++/usrp_test/usrp_test.cc
      2008-11-07 06:23:24 UTC (rev 9950)
@@ -21,7 +21,7 @@
 
 #include <usrp_test.h>
 #include <gr_io_signature.h>
-#include <usrp1_source_c.h>
+#include <usrp_source_c.h>
 #include <gr_head.h>
 
 // Shared pointer constructor
@@ -35,7 +35,7 @@
     gr_top_block("usrp_test")
 {
   int decim = 64;
-  usrp1_source_c_sptr usrp = usrp1_make_source_c(0, decim);
+  usrp_source_c_sptr usrp = usrp_make_source_c(0, decim);
 
   std::vector<int> spec(2,0);
   db_base_sptr subdev = usrp->selected_subdev(spec);

Modified: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_base.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_base.cc  
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_base.cc  
2008-11-07 06:23:24 UTC (rev 9950)
@@ -44,22 +44,44 @@
 
 usrp_base::~usrp_base()
 {
-  // NOP
 }
 
 void
-usrp_base::set_usrp_basic(usrp_basic *u)
+usrp_base::set_usrp_basic(boost::shared_ptr<usrp_basic> u)
 {
-  d_usrp_basic = boost::shared_ptr<usrp_basic>(u);
+  d_usrp_basic = u;
 }
 
 
-std::vector<db_base_wptr> 
+std::vector<db_base_sptr> 
 usrp_base::db(int which_side)
 {
   return d_usrp_basic->db(which_side);
 }
 
+db_base_sptr
+usrp_base::selected_subdev(const std::vector<int> &subdev_spec)
+{
+  size_t sss = subdev_spec.size();
+  if (!(1 <= sss && sss <= 2))
+    throw std::invalid_argument("invalid subdev_spec");
+
+  unsigned int side = subdev_spec[0];
+  unsigned int subdev = 0;
+  if (sss == 2)
+    subdev = subdev_spec[1];
+
+  std::vector<db_base_sptr> v = db(side);
+
+  assert(v.size() >= 1);
+
+  if (!(subdev <= 0 && subdev < v.size()))
+    throw std::invalid_argument("invalid subdev_spec");
+
+  return v[subdev];
+}
+
+
 long
 usrp_base::fpga_master_clock_freq() const
 {

Modified: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_base.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_base.h   
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_base.h   
2008-11-07 06:23:24 UTC (rev 9950)
@@ -24,17 +24,10 @@
 #include <gr_sync_block.h>
 #include <stdexcept>
 #include <boost/shared_ptr.hpp>
-#include <boost/weak_ptr.hpp>
+#include <db_base.h>
 
 class usrp_basic;
 
-class db_base;
-typedef boost::weak_ptr<db_base> db_base_wptr;
-typedef boost::shared_ptr<db_base> db_base_sptr;
-
-typedef std::vector<int> subdev_spec_t;
-
-
 /*!
  * \brief base class for GNU Radio interface to the USRP
  */
@@ -49,7 +42,7 @@
     : gr_sync_block(name, input_signature, output_signature) {}
     
 
-  void set_usrp_basic(usrp_basic *u);
+  void set_usrp_basic(boost::shared_ptr<usrp_basic> u);
 
 public:
   virtual ~usrp_base();
@@ -66,9 +59,19 @@
    * pointers after this usrp object has been destroyed, everything
    * will work out fine.
    */
-  std::vector<db_base_wptr> db(int which_side);
+  std::vector<db_base_sptr> db(int which_side);
 
   /*!
+   * \brief returns a weak_ptr to an instance derived from db_base.
+   *
+   * \param subdev_spec is an array of length 1 or 2.  The first integer
+   * specifies the side (0 -> A, 1 -> B).  The optional second integer (0 or 1)
+   * selects the subdevice for those devices such as the Basic Rx and LF Rx
+   * that have multiple subdevices.
+   */
+  db_base_sptr selected_subdev(const std::vector<int> &subdev_spec);
+
+  /*!
    * \brief return frequency of master oscillator on USRP
    */
   long  fpga_master_clock_freq() const;

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc     
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc     
2008-11-07 06:23:24 UTC (rev 9950)
@@ -67,7 +67,6 @@
 
 usrp_sink_base::~usrp_sink_base ()
 {
-  // delete d_usrp;    // The base class deletes this via its d_usrp_basic 
instance var
 }
 
 int

Modified: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h      
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h      
2008-11-07 06:23:24 UTC (rev 9950)
@@ -34,7 +34,7 @@
  */
 class usrp_sink_base : public usrp_base {
  private:
-  usrp_standard_tx     *d_usrp;
+  boost::shared_ptr<usrp_standard_tx>  d_usrp;
   int                   d_nunderruns;
   
  protected:

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc   
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc   
2008-11-07 06:23:24 UTC (rev 9950)
@@ -67,7 +67,6 @@
 
 usrp_source_base::~usrp_source_base ()
 {
-  // delete d_usrp;    // The base class deletes this via its d_usrp_basic 
instance var
 }
 
 unsigned int

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.h    
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.h    
2008-11-07 06:23:24 UTC (rev 9950)
@@ -33,7 +33,7 @@
  */
 class usrp_source_base : public usrp_base {
  private:
-  usrp_standard_rx     *d_usrp;
+  boost::shared_ptr<usrp_standard_rx>  d_usrp;
   int                   d_noverruns;
   
  protected:

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/test_usrp_standard_rx.cc
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/test_usrp_standard_rx.cc
   2008-11-07 06:22:20 UTC (rev 9949)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/test_usrp_standard_rx.cc
   2008-11-07 06:23:24 UTC (rev 9950)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2003,2006 Free Software Foundation, Inc.
+ * Copyright 2003,2006,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -44,7 +44,7 @@
 
 char *prog_name;
 
-static bool test_input  (usrp_standard_rx *urx, int max_bytes, FILE *fp);
+static bool test_input  (usrp_standard_rx_sptr urx, int max_bytes, FILE *fp);
 
 static void
 set_progname (char *path)
@@ -189,7 +189,7 @@
     mode |= usrp_standard_rx::FPGA_MODE_COUNTING;
 
 
-  usrp_standard_rx *urx = 
+  usrp_standard_rx_sptr urx = 
     usrp_standard_rx::make (which_board, decim, 1, -1, mode,
                            fusb_block_size, fusb_nblocks);
 
@@ -214,14 +214,12 @@
   if (fp)
     fclose (fp);
 
-  delete urx;
-
   return 0;
 }
 
 
 static bool
-test_input  (usrp_standard_rx *urx, int max_bytes, FILE *fp)
+test_input  (usrp_standard_rx_sptr urx, int max_bytes, FILE *fp)
 {
   int             fd = -1;
   static const int BUFSIZE = urx->block_size();

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/test_usrp_standard_tx.cc
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/test_usrp_standard_tx.cc
   2008-11-07 06:22:20 UTC (rev 9949)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/test_usrp_standard_tx.cc
   2008-11-07 06:23:24 UTC (rev 9950)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2003,2004 Free Software Foundation, Inc.
+ * Copyright 2003,2004,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -42,7 +42,7 @@
 
 char *prog_name;
 
-static bool test_output (usrp_standard_tx *utx, int max_bytes, double ampl,
+static bool test_output (usrp_standard_tx_sptr utx, int max_bytes, double ampl,
                         bool dc_p, bool counting_p);
 
 static void
@@ -210,7 +210,7 @@
   }
 #endif
 
-  usrp_standard_tx *utx;
+  usrp_standard_tx_sptr utx;
 
   utx = usrp_standard_tx::make (which_board,
                                interp,
@@ -226,7 +226,7 @@
     die ("utx->set_tx_freq");
     
   if (dump_regs_p)
-    do_dump_codec_regs (utx);
+    do_dump_codec_regs (utx.get());
   
   
   fflush (stdout);
@@ -236,14 +236,12 @@
 
   test_output (utx, max_bytes, ampl, dc_p, counting_p);
 
-  delete utx;
-
   return 0;
 }
 
 
 static bool
-test_output (usrp_standard_tx *utx, int max_bytes, double ampl,
+test_output (usrp_standard_tx_sptr utx, int max_bytes, double ampl,
             bool dc_p, bool counting_p)
 {
   static const int BUFSIZE = utx->block_size();

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/usrp_cal_dc_offset.cc
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/usrp_cal_dc_offset.cc  
    2008-11-07 06:22:20 UTC (rev 9949)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/apps/usrp_cal_dc_offset.cc  
    2008-11-07 06:23:24 UTC (rev 9950)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2005 Free Software Foundation, Inc.
+ * Copyright 2005,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -43,7 +43,7 @@
 
 
 static void 
-run_cal(usrp_standard_rx *u, int which_side, int decim, bool verbose_p)
+run_cal(usrp_standard_rx_sptr u, int which_side, int decim, bool verbose_p)
 {
   static const int BUFSIZE = u->block_size();
   static const int N = BUFSIZE/sizeof (short);
@@ -213,11 +213,11 @@
   usrp_local_sighandler sigquit (SIGQUIT, usrp_local_sighandler::throw_signal);
 #endif
 
-  usrp_standard_rx *urx =
+  usrp_standard_rx_sptr urx =
     usrp_standard_rx::make(which_board, decim,
                           nchannels, mux, mode,
                           fusb_block_size, fusb_nblocks);
-  if (urx == 0)
+  if (!urx)
     die("usrp_standard_rx::make");
 
   try {
@@ -236,7 +236,5 @@
   catch(...){
     fprintf (stderr, "usrp_cal_dc_offset: caught something\n");
   }
-
-  delete urx;
 }
 

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.cc   
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.cc   
2008-11-07 06:23:24 UTC (rev 9950)
@@ -22,6 +22,7 @@
 #include <db_base.h>
 #include <db_base_impl.h>
 
+#if 0
 tune_result::tune_result(double baseband, double dxc, double residual, bool 
inv)
   : ok(false), baseband_freq(baseband), dxc_freq(dxc), 
     residual_freq(residual), inverted(inv)
@@ -31,13 +32,13 @@
 tune_result::~tune_result()
 { 
 }
+#endif
 
 
 /*****************************************************************************/
 
-
-db_base::db_base(usrp_basic *usrp, int which)
-  : d_usrp(usrp), d_which(which), d_lo_offset(0.0)
+db_base::db_base(usrp_basic_sptr usrp, int which)
+  : d_weak_usrp(usrp), d_which(which), d_lo_offset(0.0)
 {
 }
 
@@ -47,19 +48,19 @@
 }
 
 int 
-db_base::dbid() const
+db_base::dbid()
 {
-  return d_usrp->daughterboard_id(d_which);
+  return usrp()->daughterboard_id(d_which);
 }
 
 std::string 
-db_base::name() const
+db_base::name()
 {
   return usrp_dbid_to_string(dbid());
 }
 
 std::string 
-db_base::side_and_name() const
+db_base::side_and_name()
 {
   if(d_which == 0)
     return "A: " + name();
@@ -79,12 +80,12 @@
 
   bool ok = true;
   if(d_which==0) {
-    ok &= d_usrp->set_adc_buffer_bypass(0, bypass);
-    ok &= d_usrp->set_adc_buffer_bypass(1, bypass);
+    ok &= usrp()->set_adc_buffer_bypass(0, bypass);
+    ok &= usrp()->set_adc_buffer_bypass(1, bypass);
   }
   else {
-    ok &= d_usrp->set_adc_buffer_bypass(2, bypass);
-    ok &= d_usrp->set_adc_buffer_bypass(3, bypass);
+    ok &= usrp()->set_adc_buffer_bypass(2, bypass);
+    ok &= usrp()->set_adc_buffer_bypass(3, bypass);
   }
   return ok;
 }
@@ -93,21 +94,21 @@
 db_base::set_atr_mask(int v)
 {
   // Set Auto T/R mask.
-  return d_usrp->write_atr_mask(d_which, v);
+  return usrp()->write_atr_mask(d_which, v);
 }
 
 bool 
 db_base::set_atr_txval(int v)
 {
   // Set Auto T/R register value to be used when transmitting.
-  return d_usrp->write_atr_txval(d_which, v);
+  return usrp()->write_atr_txval(d_which, v);
 }
   
 bool 
 db_base::set_atr_rxval(int v)
 {
   // Set Auto T/R register value to be used when receiving.
-  return d_usrp->write_atr_rxval(d_which, v);
+  return usrp()->write_atr_rxval(d_which, v);
 }
   
 bool 
@@ -115,7 +116,7 @@
 {
   // Set Auto T/R delay (in clock ticks) from when Tx fifo gets data to 
   // when T/R switches.
-  return d_usrp->write_atr_tx_delay(v);
+  return usrp()->write_atr_tx_delay(v);
 }
 
 bool 
@@ -123,7 +124,7 @@
 {
   // Set Auto T/R delay (in clock ticks) from when Tx fifo goes empty to 
   // when T/R switches.
-  return d_usrp->write_atr_rx_delay(v);
+  return usrp()->write_atr_rx_delay(v);
 }
 
 bool
@@ -192,7 +193,7 @@
 double
 db_base::_refclk_freq() 
 {
-  return d_usrp->fpga_master_clock_freq() / _refclk_divisor();
+  return usrp()->fpga_master_clock_freq() / _refclk_divisor();
 }
 
 void 
@@ -203,11 +204,11 @@
   int REFCLK_DIVISOR_MASK = 0x7f;
 
   if(enable) {
-    d_usrp->_write_oe(d_which, CLOCK_OUT, CLOCK_OUT); // output enable
-    d_usrp->write_refclk(d_which, (_refclk_divisor() & REFCLK_DIVISOR_MASK) | 
REFCLK_ENABLE);
+    usrp()->_write_oe(d_which, CLOCK_OUT, CLOCK_OUT); // output enable
+    usrp()->write_refclk(d_which, (_refclk_divisor() & REFCLK_DIVISOR_MASK) | 
REFCLK_ENABLE);
   }
   else {
-    d_usrp->write_refclk(d_which, 0);
+    usrp()->write_refclk(d_which, 0);
   }
 }
 
@@ -219,7 +220,7 @@
 }
 
 
-std::ostream &operator<<(std::ostream &os, const db_base &x)
+std::ostream &operator<<(std::ostream &os, db_base &x)
 {
   os << x.side_and_name();
   return os;
@@ -256,7 +257,7 @@
   baseband_freq = freq.baseband_freq;
 
   struct dxc_freq_t dxc_freq = calc_dxc_freq(target_freq, baseband_freq,
-                                            d_usrp->converter_rate());
+                                            usrp()->converter_rate());
 
   // If the spectrum is inverted, and the daughterboard doesn't do
   // quadrature downconversion, we can fix the inversion by flipping the
@@ -272,12 +273,12 @@
   }
   
   if (!d_tx) {
-    ok = ok && ((usrp_standard_rx*)d_usrp)->set_rx_freq(chan,
+    ok = ok && ((usrp_standard_rx*)usrp())->set_rx_freq(chan,
                                                        dxc_freq.ddc_freq);
   }
   else {
     dxc_freq.ddc_freq = -dxc_freq.ddc_freq;
-    ok = ok && ((usrp_standard_tx*)d_usrp)->set_tx_freq(chan,
+    ok = ok && ((usrp_standard_tx*)usrp())->set_tx_freq(chan,
                                                        dxc_freq.ddc_freq);
   }
   
@@ -288,11 +289,11 @@
   // residual_freq is the offset left over because of dxc tuning step size
   double residual_freq;
   if(!d_tx) {
-    residual_freq = dxc_freq.ddc_freq - 
((usrp_standard_rx*)d_usrp)->rx_freq(chan);
+    residual_freq = dxc_freq.ddc_freq - 
((usrp_standard_rx*)usrp())->rx_freq(chan);
   }
   else {
     // FIXME 50-50 chance this has the wrong sign...
-    residual_freq = dxc_freq.ddc_freq - 
((usrp_standard_tx*)d_usrp)->tx_freq(chan);
+    residual_freq = dxc_freq.ddc_freq - 
((usrp_standard_tx*)usrp())->tx_freq(chan);
   }
 
   tune_result res = tune_result(baseband_freq, dxc_freq.ddc_freq, 

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.h    
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.h    
2008-11-07 06:23:24 UTC (rev 9950)
@@ -24,11 +24,17 @@
 #define INCLUDED_DB_BASE_H
 
 #include <string>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
 #include <iosfwd>
 
+class db_base;
+typedef boost::shared_ptr<db_base> db_base_sptr;
+
 class usrp_basic;
+typedef boost::shared_ptr<usrp_basic> usrp_basic_sptr;
 
-
+#if 0
 class tune_result
 {
 public:  
@@ -42,6 +48,7 @@
   double residual_freq;
   bool  inverted;
 };
+#endif
 
 struct freq_result_t
 {
@@ -53,13 +60,26 @@
 
 class db_base
 {
+ protected:
+  boost::weak_ptr<usrp_basic>  d_weak_usrp;
+  int                          d_which;
+  double                       d_lo_offset;
+
+  void _enable_refclk(bool enable);
+  virtual double _refclk_freq();
+  virtual int _refclk_divisor();
+
+  usrp_basic_sptr usrp(){
+    return usrp_basic_sptr(d_weak_usrp);    // throws bad_weak_ptr if 
d_usrp.use_count() == 0
+  }
+
  public:
-  db_base(usrp_basic *usrp, int which);
+  db_base(boost::shared_ptr<usrp_basic> usrp, int which);
   virtual ~db_base();
 
-  int dbid() const;
-  std::string name() const;
-  std::string side_and_name() const;
+  int dbid();
+  std::string name();
+  std::string side_and_name();
 
   bool bypass_adc_buffers(bool bypass);
   bool set_atr_mask(int v);
@@ -92,17 +112,9 @@
 
   int which() { return d_which; }
 
- protected:
-  void _enable_refclk(bool enable);
-  virtual double _refclk_freq();
-  virtual int _refclk_divisor();
-
-  usrp_basic   *d_usrp;
-  int          d_which;
-  double       d_lo_offset;
 };
 
 
-std::ostream & operator<<(std::ostream &os, const db_base &x);
+std::ostream & operator<<(std::ostream &os, db_base &x);
 
 #endif /* INCLUDED_DB_BASE_H */

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_basic.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_basic.cc  
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_basic.cc  
2008-11-07 06:23:24 UTC (rev 9950)
@@ -22,9 +22,7 @@
 #include <db_base_impl.h>
 
 
-/******************************************************************************/
-
-db_basic_tx::db_basic_tx(usrp_basic *usrp, int which)
+db_basic_tx::db_basic_tx(boost::shared_ptr<usrp_basic> usrp, int which)
   : db_base(usrp, which)
 {
   // Handler for Basic Tx daughterboards.
@@ -72,19 +70,19 @@
 float
 db_basic_tx::gain_min()
 {
-  return d_usrp->pga_min();
+  return usrp()->pga_min();
 }
 
 float
 db_basic_tx::gain_max()
 {
-  return d_usrp->pga_max();
+  return usrp()->pga_max();
 }
 
 float
 db_basic_tx::gain_db_per_step()
 {
-  return d_usrp->pga_db_per_step();
+  return usrp()->pga_db_per_step();
 }
 
 bool 
@@ -95,8 +93,8 @@
   // @param gain:  gain in decibels
   // @returns True/False
 
-  bool ok = d_usrp->set_pga(d_which * 2 + 0, gain);
-  ok = ok && d_usrp->set_pga(d_which * 2 + 1, gain);
+  bool ok = usrp()->set_pga(d_which * 2 + 0, gain);
+  ok = ok && usrp()->set_pga(d_which * 2 + 1, gain);
   return ok;
 }
 
@@ -112,7 +110,7 @@
 
/******************************************************************************/
 
 
-db_basic_rx::db_basic_rx(usrp_basic *usrp, int which, int subdev)
+db_basic_rx::db_basic_rx(usrp_basic_sptr usrp, int which, int subdev)
   : db_base(usrp, which)
 {
   // Handler for Basic Rx daughterboards.
@@ -166,19 +164,19 @@
 float
 db_basic_rx::gain_min()
 {
-  return d_usrp->pga_min();
+  return usrp()->pga_min();
 }
 
 float
 db_basic_rx::gain_max()
 {
-  return d_usrp->pga_max();
+  return usrp()->pga_max();
 }
 
 float
 db_basic_rx::gain_db_per_step()
 {
-  return d_usrp->pga_db_per_step();
+  return usrp()->pga_db_per_step();
 }
 
 bool 
@@ -189,7 +187,7 @@
   // @param gain:  gain in decibels
   // @returns True/False
   
-  return d_usrp->set_pga(d_which * 2 + d_subdev, gain);
+  return usrp()->set_pga(d_which * 2 + d_subdev, gain);
 }
 
 bool 
@@ -207,7 +205,7 @@
 
/******************************************************************************/
 
 
-db_lf_tx::db_lf_tx(usrp_basic *usrp, int which)
+db_lf_tx::db_lf_tx(usrp_basic_sptr usrp, int which)
   : db_basic_tx(usrp, which)
 {
   // Handler for Low Freq Tx daughterboards.
@@ -235,7 +233,7 @@
 
/******************************************************************************/
 
 
-db_lf_rx::db_lf_rx(usrp_basic *usrp, int which, int subdev)
+db_lf_rx::db_lf_rx(usrp_basic_sptr usrp, int which, int subdev)
   : db_basic_rx(usrp, which, subdev)
 {
   // Handler for Low Freq Rx daughterboards.

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_basic.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_basic.h   
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_basic.h   
2008-11-07 06:23:24 UTC (rev 9950)
@@ -31,7 +31,7 @@
 class db_basic_tx : public db_base
 {
 public:
-  db_basic_tx(usrp_basic *usrp, int which);
+  db_basic_tx(usrp_basic_sptr usrp, int which);
   ~db_basic_tx();
   
   float gain_min();
@@ -51,7 +51,7 @@
 class db_basic_rx : public db_base
 {
  public:
-  db_basic_rx(usrp_basic *usrp, int which, int subdev);
+  db_basic_rx(usrp_basic_sptr usrp, int which, int subdev);
   ~db_basic_rx();
   
   float gain_min();
@@ -74,7 +74,7 @@
 class db_lf_rx : public db_basic_rx
 {
  public:
-  db_lf_rx(usrp_basic *usrp, int which, int subdev);
+  db_lf_rx(usrp_basic_sptr usrp, int which, int subdev);
   ~db_lf_rx();
   
   double freq_min();
@@ -88,7 +88,7 @@
 class db_lf_tx : public db_basic_tx
 { 
  public:
-  db_lf_tx(usrp_basic *usrp, int which);
+  db_lf_tx(usrp_basic_sptr usrp, int which);
   ~db_lf_tx();
   
   double freq_min();

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_boards.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_boards.cc 
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_boards.cc 
2008-11-07 06:23:24 UTC (rev 9950)
@@ -33,7 +33,7 @@
 #include <db_dtt768.h>
 
 std::vector<db_base_sptr>
-instantiate_dbs(int dbid, usrp_basic *usrp, int which_side)
+instantiate_dbs(int dbid, usrp_basic_sptr usrp, int which_side)
 {
   std::vector<db_base_sptr> db;
 
@@ -186,7 +186,7 @@
     break;
 
   case(-1):
-    if (dynamic_cast<usrp_basic_tx*>(usrp)){
+    if (boost::dynamic_pointer_cast<usrp_basic_tx>(usrp)){
       db.push_back(db_base_sptr(new db_basic_tx(usrp, which_side)));
     }
     else {
@@ -197,7 +197,7 @@
   
   case(-2):
   default:
-    if (dynamic_cast<usrp_basic_tx*>(usrp)){
+    if (boost::dynamic_pointer_cast<usrp_basic_tx>(usrp)){
       fprintf(stderr, "\n\aWarning: Treating daughterboard with invalid EEPROM 
contents as if it were a \"Basic Tx.\"\n");
       fprintf(stderr, "Warning: This is almost certainly wrong...  Use 
appropriate burn-*-eeprom utility.\n\n");
       db.push_back(db_base_sptr(new db_basic_tx(usrp, which_side)));

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_boards.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_boards.h  
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_boards.h  
2008-11-07 06:23:24 UTC (rev 9950)
@@ -26,7 +26,7 @@
 #include <db_base.h>
 #include <usrp_basic.h>
 
-std::vector<db_base_sptr> instantiate_dbs(int dbid, usrp_basic *usrp, int 
which_side);
+std::vector<db_base_sptr> instantiate_dbs(int dbid, usrp_basic_sptr usrp, int 
which_side);
 
 #endif 
 

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.cc 
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.cc 
2008-11-07 06:23:24 UTC (rev 9950)
@@ -26,15 +26,15 @@
 /*****************************************************************************/
 
 
-db_dbs_rx::db_dbs_rx(usrp_basic *usrp, int which)
-  : db_base(usrp, which)
+db_dbs_rx::db_dbs_rx(usrp_basic_sptr _usrp, int which)
+  : db_base(_usrp, which)
 {
   // Control DBS receiver based USRP daughterboard.
   // 
   // @param usrp: instance of usrp.source_c
   // @param which: which side: 0, 1 corresponding to RX_A or RX_B respectively
 
-  d_usrp->_write_oe(d_which, 0x0001, 0x0001);
+  usrp()->_write_oe(d_which, 0x0001, 0x0001);
   if(which == 0) {
     d_i2c_addr = 0x67;
   }
@@ -66,7 +66,7 @@
 
 db_dbs_rx::~db_dbs_rx()
 {
-  if(d_usrp) {
+  if(usrp()) {
     _enable_refclk(false);
   }
 }
@@ -79,7 +79,7 @@
   std::vector<int> args(2);
   args[0] = regno;
   args[1] = v;
-  d_usrp->write_i2c (d_i2c_addr, int_seq_to_str (args));
+  usrp()->write_i2c (d_i2c_addr, int_seq_to_str (args));
 }
 
 void
@@ -92,14 +92,14 @@
   std::vector<int> args;
   args.push_back(starting_regno);
   args.insert(args.end(), vals.begin(), vals.end());
-  d_usrp->write_i2c (d_i2c_addr, int_seq_to_str (args));
+  usrp()->write_i2c (d_i2c_addr, int_seq_to_str (args));
 }
         
 std::vector<int>
 db_dbs_rx::_read_status ()
 {
   //If successful, return list of two ints: [status_info, filter_DAC]"""
-  std::string s = d_usrp->read_i2c (d_i2c_addr, 2);
+  std::string s = usrp()->read_i2c (d_i2c_addr, 2);
   if(s.size() != 2) {
     std::vector<int> ret(0);
     return ret;
@@ -202,7 +202,7 @@
 {
   assert(gc1>=0 && gc1<4096);
   d_gc1 = gc1;
-  d_usrp->write_aux_dac(d_which, 0, gc1);
+  usrp()->write_aux_dac(d_which, 0, gc1);
 }
 
 void
@@ -210,12 +210,12 @@
 {
   assert(pga_gain>=0 && pga_gain<=20);
   if(d_which == 0) {
-    d_usrp->set_pga (0, pga_gain);
-    d_usrp->set_pga (1, pga_gain);
+    usrp()->set_pga (0, pga_gain);
+    usrp()->set_pga (1, pga_gain);
   }
   else {
-    d_usrp->set_pga (2, pga_gain);
-    d_usrp->set_pga (3, pga_gain);
+    usrp()->set_pga (2, pga_gain);
+    usrp()->set_pga (3, pga_gain);
   }
 }
 

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.h  
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.h  
2008-11-07 06:23:24 UTC (rev 9950)
@@ -63,7 +63,7 @@
 
 
 public:
-  db_dbs_rx(usrp_basic *usrp, int which);
+  db_dbs_rx(usrp_basic_sptr usrp, int which);
   ~db_dbs_rx();
 
   float gain_min();

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt754.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt754.cc 
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt754.cc 
2008-11-07 06:23:24 UTC (rev 9950)
@@ -104,8 +104,8 @@
   return (CP<<6 | P5 << 4 | BS);
 }
 
-db_dtt754::db_dtt754(usrp_basic *usrp, int which)
-  : db_base(usrp, which)
+db_dtt754::db_dtt754(usrp_basic_sptr _usrp, int which)
+  : db_base(_usrp, which)
 {
   /*
    * Control custom DTT75403-based daughterboard.
@@ -233,7 +233,7 @@
   buf[3] = bandswitch_byte(actual_lo_freq, d_bw);
   buf[4] = control_byte_2();
 
-  bool ok = d_usrp->write_i2c(d_i2c_addr, int_seq_to_str (buf));
+  bool ok = usrp()->write_i2c(d_i2c_addr, int_seq_to_str (buf));
 
   d_freq = actual_lo_freq - d_IF;
         
@@ -294,7 +294,7 @@
   int dacword = (int)(4096*voltage/1.22/3.3);    // 1.22 = opamp gain
     
   assert(dacword>=0 && dacword<4096);
-  d_usrp->write_aux_dac(d_which, 1, dacword);
+  usrp()->write_aux_dac(d_which, 1, dacword);
 }
 
 void
@@ -305,7 +305,7 @@
   int dacword = (int)(4096*voltage/1.22/3.3);    // 1.22 = opamp gain
 
   assert(dacword>=0 && dacword<4096);
-  d_usrp->write_aux_dac(d_which, 0, dacword);
+  usrp()->write_aux_dac(d_which, 0, dacword);
 }
 
 void
@@ -313,9 +313,9 @@
 {
   assert(pga_gain >=0 && pga_gain <=20);
   if(d_which == 0) {
-    d_usrp->set_pga (0, pga_gain);
+    usrp()->set_pga (0, pga_gain);
   }
   else {
-    d_usrp->set_pga (2, pga_gain);
+    usrp()->set_pga (2, pga_gain);
   }
 }

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt754.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt754.h  
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt754.h  
2008-11-07 06:23:24 UTC (rev 9950)
@@ -28,7 +28,7 @@
 class db_dtt754 : public db_base
 {
 public:
-  db_dtt754(usrp_basic *usrp, int which);
+  db_dtt754(usrp_basic_sptr usrp, int which);
   ~db_dtt754();
   
   float gain_min();

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt768.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt768.cc 
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt768.cc 
2008-11-07 06:23:24 UTC (rev 9950)
@@ -79,8 +79,8 @@
   return (SAS << 7 | AGD << 5 | ADS << 4 | T);
 }
 
-db_dtt768::db_dtt768(usrp_basic *usrp, int which)
-  : db_base(usrp, which)
+db_dtt768::db_dtt768(usrp_basic_sptr _usrp, int which)
+  : db_base(_usrp, which)
 {
   /*
    * Control custom DTT76803-based daughterboard.
@@ -206,7 +206,7 @@
   buf[4] = control_byte_6();
   buf[5] = control_byte_7();
 
-  bool ok = d_usrp->write_i2c(d_i2c_addr, int_seq_to_str (buf));
+  bool ok = usrp()->write_i2c(d_i2c_addr, int_seq_to_str (buf));
 
   d_freq = actual_lo_freq - d_IF;
   
@@ -267,7 +267,7 @@
   int dacword = (int)(4096*voltage/1.22/3.3);    // 1.22 = opamp gain
     
   assert(dacword>=0 && dacword<4096);
-  d_usrp->write_aux_dac(d_which, 1, dacword);
+  usrp()->write_aux_dac(d_which, 1, dacword);
 }
 
 void
@@ -278,7 +278,7 @@
   int dacword = (int)(4096*voltage/1.22/3.3);    // 1.22 = opamp gain
 
   assert(dacword>=0 && dacword<4096);
-  d_usrp->write_aux_dac(d_which, 0, dacword);
+  usrp()->write_aux_dac(d_which, 0, dacword);
 }
 
 void
@@ -286,9 +286,9 @@
 {
   assert(pga_gain >=0 && pga_gain <=20);
   if(d_which == 0) {
-    d_usrp->set_pga (0, pga_gain);
+    usrp()->set_pga (0, pga_gain);
   }
   else {
-    d_usrp->set_pga (2, pga_gain);
+    usrp()->set_pga (2, pga_gain);
   }
 }

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt768.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt768.h  
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt768.h  
2008-11-07 06:23:24 UTC (rev 9950)
@@ -28,7 +28,7 @@
 class db_dtt768 : public db_base
 {
 public:
-  db_dtt768(usrp_basic *usrp, int which);
+  db_dtt768(usrp_basic_sptr usrp, int which);
   ~db_dtt768();
   
   float gain_min();

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf.cc 
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf.cc 
2008-11-07 06:23:24 UTC (rev 9950)
@@ -34,8 +34,8 @@
 #define AUX_SDO   (1 << 1)
 #define CLOCK_OUT (1 << 0)
 
-flexrf_base::flexrf_base(usrp_basic *usrp, int which, int _power_on)
-  : db_base(usrp, which), d_power_on(_power_on)
+flexrf_base::flexrf_base(usrp_basic_sptr _usrp, int which, int _power_on)
+  : db_base(_usrp, which), d_power_on(_power_on)
 {
   /*
     @param usrp: instance of usrp.source_c
@@ -46,7 +46,7 @@
   d_first = true;
   d_spi_format = SPI_FMT_MSB | SPI_FMT_HDR_0;
 
-  d_usrp->_write_oe(d_which, 0, 0xffff);   // turn off all outputs
+  usrp()->_write_oe(d_which, 0, 0xffff);   // turn off all outputs
   _enable_refclk(false);                // disable refclk
 
   set_auto_tr(false);
@@ -113,7 +113,7 @@
   s[1] = (char)((v >>  8) & 0xff);
   s[2] = (char)(v & 0xff);
   std::string str(s, 3);
-  d_usrp->_write_spi(0, d_spi_enable, d_spi_format, str);
+  usrp()->_write_spi(0, d_spi_enable, d_spi_format, str);
 }
         
 bool
@@ -123,7 +123,7 @@
     @returns: the value of the VCO/PLL lock detect bit.
     @rtype: 0 or 1
   */
-  if(d_usrp->read_io(d_which) & PLL_LOCK_DETECT) {
+  if(usrp()->read_io(d_which) & PLL_LOCK_DETECT) {
     return true;
   }
   else {      // Give it a second chance
@@ -133,7 +133,7 @@
     t.tv_nsec = 100000000;
     nanosleep(&t, NULL);
     
-    if(d_usrp->read_io(d_which) & PLL_LOCK_DETECT) {
+    if(usrp()->read_io(d_which) & PLL_LOCK_DETECT) {
       return true;
     }
     else {
@@ -215,12 +215,12 @@
 flexrf_base::_set_pga(float pga_gain)
 {
   if(d_which == 0) {
-    d_usrp->set_pga(0, pga_gain);
-    d_usrp->set_pga(1, pga_gain);
+    usrp()->set_pga(0, pga_gain);
+    usrp()->set_pga(1, pga_gain);
   }
   else {
-    d_usrp->set_pga(2, pga_gain);
-    d_usrp->set_pga(3, pga_gain);
+    usrp()->set_pga(2, pga_gain);
+    usrp()->set_pga(3, pga_gain);
   }
   return true;
 }
@@ -250,8 +250,8 @@
 
 // ----------------------------------------------------------------
 
-flexrf_base_tx::flexrf_base_tx(usrp_basic *usrp, int which, int _power_on)
-  : flexrf_base(usrp, which, _power_on)
+flexrf_base_tx::flexrf_base_tx(usrp_basic_sptr _usrp, int which, int _power_on)
+  : flexrf_base(_usrp, which, _power_on)
 {
   /*
     @param usrp: instance of usrp.sink_c
@@ -266,8 +266,8 @@
   }
   
   // power up the transmit side, but don't enable the mixer
-  d_usrp->_write_oe(d_which,(POWER_UP|RX_TXN|ENABLE), 0xffff);
-  d_usrp->write_io(d_which, (power_on()|RX_TXN), (POWER_UP|RX_TXN|ENABLE));
+  usrp()->_write_oe(d_which,(POWER_UP|RX_TXN|ENABLE), 0xffff);
+  usrp()->write_io(d_which, (power_on()|RX_TXN), (POWER_UP|RX_TXN|ENABLE));
   set_lo_offset(4e6);
 
   set_gain((gain_min() + gain_max()) / 2.0);  // initialize gain
@@ -276,7 +276,7 @@
 flexrf_base_tx::~flexrf_base_tx()
 {
   // Power down and leave the T/R switch in the R position
-  d_usrp->write_io(d_which, (power_off()|RX_TXN), (POWER_UP|RX_TXN|ENABLE));
+  usrp()->write_io(d_which, (power_off()|RX_TXN), (POWER_UP|RX_TXN|ENABLE));
 
   // Power down VCO/PLL
   d_PD = 3;
@@ -318,19 +318,19 @@
   else {
     v = RX_TXN;
   }
-  return d_usrp->write_io(d_which, v, mask);
+  return usrp()->write_io(d_which, v, mask);
 }
 
 float
 flexrf_base_tx::gain_min()
 {
-  return d_usrp->pga_max();
+  return usrp()->pga_max();
 }
 
 float
 flexrf_base_tx::gain_max()
 {
-  return d_usrp->pga_max();
+  return usrp()->pga_max();
 }
 
 float
@@ -348,15 +348,15 @@
     @param gain:  gain in decibels
     @returns True/False
   */
-  return _set_pga(d_usrp->pga_max());
+  return _set_pga(usrp()->pga_max());
 }
 
 
 /**************************************************************************/
 
 
-flexrf_base_rx::flexrf_base_rx(usrp_basic *usrp, int which, int _power_on)
-  : flexrf_base(usrp, which, _power_on)
+flexrf_base_rx::flexrf_base_rx(usrp_basic_sptr _usrp, int which, int _power_on)
+  : flexrf_base(_usrp, which, _power_on)
 {
   /*
     @param usrp: instance of usrp.source_c
@@ -370,8 +370,8 @@
     d_spi_enable = SPI_ENABLE_RX_B;
   }
 
-  d_usrp->_write_oe(d_which, (POWER_UP|RX2_RX1N|ENABLE), 0xffff);
-  d_usrp->write_io(d_which,  (power_on()|RX2_RX1N|ENABLE), 
+  usrp()->_write_oe(d_which, (POWER_UP|RX2_RX1N|ENABLE), 0xffff);
+  usrp()->write_io(d_which,  (power_on()|RX2_RX1N|ENABLE), 
                   (POWER_UP|RX2_RX1N|ENABLE));
   
   // set up for RX on TX/RX port
@@ -385,7 +385,7 @@
 flexrf_base_rx::~flexrf_base_rx()
 {
   // Power down
-  d_usrp->common_write_io(C_RX, d_which, power_off(), (POWER_UP|ENABLE));
+  usrp()->common_write_io(C_RX, d_which, power_off(), (POWER_UP|ENABLE));
 
   // Power down VCO/PLL
   d_PD = 3;
@@ -422,10 +422,10 @@
   */
 
   if(which_antenna == 0) {
-    d_usrp->write_io(d_which, 0,RX2_RX1N);
+    usrp()->write_io(d_which, 0,RX2_RX1N);
   }
   else if(which_antenna == 1) {
-    d_usrp->write_io(d_which, RX2_RX1N, RX2_RX1N);
+    usrp()->write_io(d_which, RX2_RX1N, RX2_RX1N);
   }
   else {
     return false;
@@ -443,10 +443,10 @@
   */
 
   if(which_antenna == "TX/RX") {
-    d_usrp->write_io(d_which, 0, RX2_RX1N);
+    usrp()->write_io(d_which, 0, RX2_RX1N);
   }
   else if(which_antenna == "RX2") {
-    d_usrp->write_io(d_which, RX2_RX1N, RX2_RX1N);
+    usrp()->write_io(d_which, RX2_RX1N, RX2_RX1N);
   }
   else {
     // throw std::invalid_argument("which_antenna must be either 'TX/RX' or 
'RX2'\n");
@@ -471,11 +471,11 @@
   float pga_gain, agc_gain;
   float V_maxgain, V_mingain, V_fullscale, dac_value;
 
-  float maxgain = gain_max() - d_usrp->pga_max();
+  float maxgain = gain_max() - usrp()->pga_max();
   float mingain = gain_min();
   if(gain > maxgain) {
     pga_gain = gain-maxgain;
-    assert(pga_gain <= d_usrp->pga_max());
+    assert(pga_gain <= usrp()->pga_max());
     agc_gain = maxgain;
   }
   else {
@@ -490,7 +490,7 @@
 
   assert(dac_value>=0 && dac_value<4096);
 
-  return (d_usrp->write_aux_dac(d_which, 0, int(dac_value))
+  return (usrp()->write_aux_dac(d_which, 0, int(dac_value))
          && _set_pga(int(pga_gain)));
 }
 
@@ -779,7 +779,7 @@
 
 //------------------------------------------------------------    
 
-db_flexrf_2400_tx::db_flexrf_2400_tx(usrp_basic *usrp, int which)
+db_flexrf_2400_tx::db_flexrf_2400_tx(usrp_basic_sptr usrp, int which)
   : flexrf_base_tx(usrp, which)
 {
   d_common = new _2400_common();
@@ -799,7 +799,7 @@
 
 
 
-db_flexrf_2400_rx::db_flexrf_2400_rx(usrp_basic *usrp, int which)
+db_flexrf_2400_rx::db_flexrf_2400_rx(usrp_basic_sptr usrp, int which)
   : flexrf_base_rx(usrp, which)
 {
   d_common = new _2400_common();
@@ -813,13 +813,13 @@
 float
 db_flexrf_2400_rx::gain_min()
 {
-  return d_usrp->pga_min();
+  return usrp()->pga_min();
 }
 
 float
 db_flexrf_2400_rx::gain_max()
 {
-  return d_usrp->pga_max()+70;
+  return usrp()->pga_max()+70;
 }
 
 float
@@ -846,7 +846,7 @@
 //------------------------------------------------------------    
 
 
-db_flexrf_1200_tx::db_flexrf_1200_tx(usrp_basic *usrp, int which)
+db_flexrf_1200_tx::db_flexrf_1200_tx(usrp_basic_sptr usrp, int which)
   : flexrf_base_tx(usrp, which)
 {
   d_common = new _1200_common();
@@ -867,7 +867,7 @@
 
 
 
-db_flexrf_1200_rx::db_flexrf_1200_rx(usrp_basic *usrp, int which)
+db_flexrf_1200_rx::db_flexrf_1200_rx(usrp_basic_sptr usrp, int which)
   : flexrf_base_rx(usrp, which)
 {
   d_common = new _1200_common();
@@ -881,13 +881,13 @@
 float
 db_flexrf_1200_rx::gain_min()
 {
-  return d_usrp->pga_min();
+  return usrp()->pga_min();
 }
 
 float
 db_flexrf_1200_rx::gain_max()
 {
-  return d_usrp->pga_max()+70;
+  return usrp()->pga_max()+70;
 }
 
 float
@@ -914,7 +914,7 @@
 //------------------------------------------------------------    
 
 
-db_flexrf_1800_tx::db_flexrf_1800_tx(usrp_basic *usrp, int which)
+db_flexrf_1800_tx::db_flexrf_1800_tx(usrp_basic_sptr usrp, int which)
   : flexrf_base_tx(usrp, which)
 {
   d_common = new _1800_common();
@@ -934,7 +934,7 @@
 
 
 
-db_flexrf_1800_rx::db_flexrf_1800_rx(usrp_basic *usrp, int which)
+db_flexrf_1800_rx::db_flexrf_1800_rx(usrp_basic_sptr usrp, int which)
   : flexrf_base_rx(usrp, which)
 {
   d_common = new _1800_common();
@@ -949,13 +949,13 @@
 float
 db_flexrf_1800_rx::gain_min()
 {
-  return d_usrp->pga_min();
+  return usrp()->pga_min();
 }
 
 float
 db_flexrf_1800_rx::gain_max()
 {
-  return d_usrp->pga_max()+70;
+  return usrp()->pga_max()+70;
 }
 
 float
@@ -982,7 +982,7 @@
 //------------------------------------------------------------    
 
 
-db_flexrf_900_tx::db_flexrf_900_tx(usrp_basic *usrp, int which)
+db_flexrf_900_tx::db_flexrf_900_tx(usrp_basic_sptr usrp, int which)
   : flexrf_base_tx(usrp, which)
 {
   d_common = new _900_common();
@@ -1001,7 +1001,7 @@
 }
 
 
-db_flexrf_900_rx::db_flexrf_900_rx(usrp_basic *usrp, int which)
+db_flexrf_900_rx::db_flexrf_900_rx(usrp_basic_sptr usrp, int which)
   : flexrf_base_rx(usrp, which)
 {
   d_common = new _900_common();
@@ -1015,13 +1015,13 @@
 float
 db_flexrf_900_rx::gain_min()
 {
-  return d_usrp->pga_min();
+  return usrp()->pga_min();
 }
 
 float
 db_flexrf_900_rx::gain_max()
 {
-  return d_usrp->pga_max()+70;
+  return usrp()->pga_max()+70;
 }
 
 float
@@ -1047,7 +1047,7 @@
 //------------------------------------------------------------    
 
 
-db_flexrf_400_tx::db_flexrf_400_tx(usrp_basic *usrp, int which)
+db_flexrf_400_tx::db_flexrf_400_tx(usrp_basic_sptr usrp, int which)
   : flexrf_base_tx(usrp, which, POWER_UP)
 {
   d_common = new _400_tx();
@@ -1067,7 +1067,7 @@
 
 
 
-db_flexrf_400_rx::db_flexrf_400_rx(usrp_basic *usrp, int which)
+db_flexrf_400_rx::db_flexrf_400_rx(usrp_basic_sptr usrp, int which)
   : flexrf_base_rx(usrp, which, POWER_UP)
 {
   d_common = new _400_rx();
@@ -1081,13 +1081,13 @@
 float
 db_flexrf_400_rx::gain_min()
 {
-  return d_usrp->pga_min();
+  return usrp()->pga_min();
 }
 
 float
 db_flexrf_400_rx::gain_max()
 {
-  return d_usrp->pga_max()+45;
+  return usrp()->pga_max()+45;
 }
 
 float

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf.h  
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf.h  
2008-11-07 06:23:24 UTC (rev 9950)
@@ -33,7 +33,7 @@
 class flexrf_base : public db_base
 {
 public:
-  flexrf_base(usrp_basic *usrp, int which, int _power_on=0);
+  flexrf_base(usrp_basic_sptr usrp, int which, int _power_on=0);
   ~flexrf_base();
 
   struct freq_result_t set_freq(double freq);
@@ -75,7 +75,7 @@
 class flexrf_base_tx : public flexrf_base
 {
 public:
-  flexrf_base_tx(usrp_basic *usrp, int which, int _power_on=0);
+  flexrf_base_tx(usrp_basic_sptr usrp, int which, int _power_on=0);
   ~flexrf_base_tx();
 
   // All RFX tx d'boards have fixed gain
@@ -91,7 +91,7 @@
 class flexrf_base_rx : public flexrf_base
 {
 public:
-  flexrf_base_rx(usrp_basic *usrp, int which, int _power_on=0);
+  flexrf_base_rx(usrp_basic_sptr usrp, int which, int _power_on=0);
   ~flexrf_base_rx();
     
   bool set_auto_tr(bool on);
@@ -209,7 +209,7 @@
 class db_flexrf_2400_tx : public flexrf_base_tx
 {
  public:
-  db_flexrf_2400_tx(usrp_basic *usrp, int which);
+  db_flexrf_2400_tx(usrp_basic_sptr usrp, int which);
   ~db_flexrf_2400_tx();
 
   // Wrapper calls to d_common functions
@@ -220,7 +220,7 @@
 class db_flexrf_2400_rx : public flexrf_base_rx
 {
 public:
-  db_flexrf_2400_rx(usrp_basic *usrp, int which);
+  db_flexrf_2400_rx(usrp_basic_sptr usrp, int which);
   ~db_flexrf_2400_rx();
   
   float gain_min();
@@ -237,7 +237,7 @@
 class db_flexrf_1200_tx : public flexrf_base_tx
 {
 public:
-  db_flexrf_1200_tx(usrp_basic *usrp, int which);
+  db_flexrf_1200_tx(usrp_basic_sptr usrp, int which);
   ~db_flexrf_1200_tx();
 
   // Wrapper calls to d_common functions
@@ -248,7 +248,7 @@
 class db_flexrf_1200_rx : public flexrf_base_rx
 {
 public:
-  db_flexrf_1200_rx(usrp_basic *usrp, int which);
+  db_flexrf_1200_rx(usrp_basic_sptr usrp, int which);
   ~db_flexrf_1200_rx();
   
   float gain_min();
@@ -265,7 +265,7 @@
 class db_flexrf_1800_tx : public flexrf_base_tx
 {
  public:
-  db_flexrf_1800_tx(usrp_basic *usrp, int which);
+  db_flexrf_1800_tx(usrp_basic_sptr usrp, int which);
   ~db_flexrf_1800_tx();
 
   // Wrapper calls to d_common functions
@@ -276,7 +276,7 @@
 class db_flexrf_1800_rx : public flexrf_base_rx
 {
 public:
-  db_flexrf_1800_rx(usrp_basic *usrp, int which);
+  db_flexrf_1800_rx(usrp_basic_sptr usrp, int which);
   ~db_flexrf_1800_rx();
   
   float gain_min();
@@ -293,7 +293,7 @@
 class db_flexrf_900_tx : public flexrf_base_tx
 {
  public:
-  db_flexrf_900_tx(usrp_basic *usrp, int which);
+  db_flexrf_900_tx(usrp_basic_sptr usrp, int which);
   ~db_flexrf_900_tx();
 
   // Wrapper calls to d_common functions
@@ -304,7 +304,7 @@
 class db_flexrf_900_rx : public flexrf_base_rx
 {
 public:
-  db_flexrf_900_rx(usrp_basic *usrp, int which);
+  db_flexrf_900_rx(usrp_basic_sptr usrp, int which);
   ~db_flexrf_900_rx();
   
   float gain_min();
@@ -322,7 +322,7 @@
 class db_flexrf_400_tx : public flexrf_base_tx
 {
  public:
-  db_flexrf_400_tx(usrp_basic *usrp, int which);
+  db_flexrf_400_tx(usrp_basic_sptr usrp, int which);
   ~db_flexrf_400_tx();
 
   // Wrapper calls to d_common functions
@@ -333,7 +333,7 @@
 class db_flexrf_400_rx : public flexrf_base_rx
 {
 public:
-  db_flexrf_400_rx(usrp_basic *usrp, int which);
+  db_flexrf_400_rx(usrp_basic_sptr usrp, int which);
   ~db_flexrf_400_rx();
 
   float gain_min();

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf_mimo.cc
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf_mimo.cc
    2008-11-07 06:22:20 UTC (rev 9949)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf_mimo.cc
    2008-11-07 06:23:24 UTC (rev 9950)
@@ -26,7 +26,7 @@
 #include <usrp_spi_defs.h>
 
 
-db_flexrf_2400_tx_mimo_a::db_flexrf_2400_tx_mimo_a(usrp_basic *usrp, int which)
+db_flexrf_2400_tx_mimo_a::db_flexrf_2400_tx_mimo_a(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_2400_tx(usrp, which)
 {
   _enable_refclk(true);
@@ -39,7 +39,7 @@
   return 16;
 }
 
-db_flexrf_2400_rx_mimo_a::db_flexrf_2400_rx_mimo_a(usrp_basic *usrp, int which)
+db_flexrf_2400_rx_mimo_a::db_flexrf_2400_rx_mimo_a(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_2400_rx(usrp, which)
 {
   _enable_refclk(true);
@@ -52,7 +52,7 @@
   return 16;
 }
       
-db_flexrf_2400_tx_mimo_b::db_flexrf_2400_tx_mimo_b(usrp_basic *usrp, int which)
+db_flexrf_2400_tx_mimo_b::db_flexrf_2400_tx_mimo_b(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_2400_tx(usrp, which)
 {
   d_common->R_DIV(16);
@@ -64,7 +64,7 @@
   return 1;
 }
 
-db_flexrf_2400_rx_mimo_b::db_flexrf_2400_rx_mimo_b(usrp_basic *usrp, int which)
+db_flexrf_2400_rx_mimo_b::db_flexrf_2400_rx_mimo_b(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_2400_rx(usrp, which)
 {
   d_common->R_DIV(16);
@@ -76,7 +76,7 @@
   return 1;
 }
 
-db_flexrf_1800_tx_mimo_a::db_flexrf_1800_tx_mimo_a(usrp_basic *usrp, int which)
+db_flexrf_1800_tx_mimo_a::db_flexrf_1800_tx_mimo_a(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_1800_tx(usrp, which)
 {
   _enable_refclk(true);
@@ -89,7 +89,7 @@
   return 16;
 }
 
-db_flexrf_1800_rx_mimo_a::db_flexrf_1800_rx_mimo_a(usrp_basic *usrp, int which)
+db_flexrf_1800_rx_mimo_a::db_flexrf_1800_rx_mimo_a(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_1800_rx(usrp, which)
 {
   _enable_refclk(true);
@@ -102,7 +102,7 @@
   return 16;
 }
     
-db_flexrf_1800_tx_mimo_b::db_flexrf_1800_tx_mimo_b(usrp_basic *usrp, int which)
+db_flexrf_1800_tx_mimo_b::db_flexrf_1800_tx_mimo_b(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_1800_tx(usrp, which)
 {
   d_common->R_DIV(1);
@@ -114,7 +114,7 @@
   return 1;
 }
 
-db_flexrf_1800_rx_mimo_b::db_flexrf_1800_rx_mimo_b(usrp_basic *usrp, int which)
+db_flexrf_1800_rx_mimo_b::db_flexrf_1800_rx_mimo_b(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_1800_rx(usrp, which)
 {
   d_common->R_DIV(16);
@@ -126,7 +126,7 @@
   return 1;
 }
 
-db_flexrf_1200_tx_mimo_a::db_flexrf_1200_tx_mimo_a(usrp_basic *usrp, int which)
+db_flexrf_1200_tx_mimo_a::db_flexrf_1200_tx_mimo_a(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_1200_tx(usrp, which)
 {
   _enable_refclk(true);
@@ -139,7 +139,7 @@
   return 16;
 }
 
-db_flexrf_1200_rx_mimo_a::db_flexrf_1200_rx_mimo_a(usrp_basic *usrp, int which)
+db_flexrf_1200_rx_mimo_a::db_flexrf_1200_rx_mimo_a(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_1200_rx(usrp, which)
 {
   _enable_refclk(true);
@@ -152,7 +152,7 @@
   return 16;
 }
     
-db_flexrf_1200_tx_mimo_b::db_flexrf_1200_tx_mimo_b(usrp_basic *usrp, int which)
+db_flexrf_1200_tx_mimo_b::db_flexrf_1200_tx_mimo_b(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_1200_tx(usrp, which)
 {
   d_common->R_DIV(16);
@@ -164,7 +164,7 @@
   return 1;
 }
 
-db_flexrf_1200_rx_mimo_b::db_flexrf_1200_rx_mimo_b(usrp_basic *usrp, int which)
+db_flexrf_1200_rx_mimo_b::db_flexrf_1200_rx_mimo_b(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_1200_rx(usrp, which)
 {
   d_common->R_DIV(16);
@@ -176,7 +176,7 @@
   return 1;
 }
 
-db_flexrf_900_tx_mimo_a::db_flexrf_900_tx_mimo_a(usrp_basic *usrp, int which)
+db_flexrf_900_tx_mimo_a::db_flexrf_900_tx_mimo_a(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_900_tx(usrp, which)
 {
   _enable_refclk(true);
@@ -189,7 +189,7 @@
   return 16;
 }
 
-db_flexrf_900_rx_mimo_a::db_flexrf_900_rx_mimo_a(usrp_basic *usrp, int which)
+db_flexrf_900_rx_mimo_a::db_flexrf_900_rx_mimo_a(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_900_rx(usrp, which)
 {
   _enable_refclk(true);
@@ -202,7 +202,7 @@
   return 16;
 }
     
-db_flexrf_900_tx_mimo_b::db_flexrf_900_tx_mimo_b(usrp_basic *usrp, int which)
+db_flexrf_900_tx_mimo_b::db_flexrf_900_tx_mimo_b(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_900_tx(usrp, which)
 {
   d_common->R_DIV(16);
@@ -214,7 +214,7 @@
   return 1;
 }
 
-db_flexrf_900_rx_mimo_b::db_flexrf_900_rx_mimo_b(usrp_basic *usrp, int which)
+db_flexrf_900_rx_mimo_b::db_flexrf_900_rx_mimo_b(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_900_rx(usrp, which)
 {
   d_common->R_DIV(16);
@@ -225,7 +225,7 @@
   return 1;
 }
 
-db_flexrf_400_tx_mimo_a::db_flexrf_400_tx_mimo_a(usrp_basic *usrp, int which)
+db_flexrf_400_tx_mimo_a::db_flexrf_400_tx_mimo_a(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_400_tx(usrp, which)
 {
   _enable_refclk(true);
@@ -238,7 +238,7 @@
   return 16;
 }
     
-db_flexrf_400_rx_mimo_a::db_flexrf_400_rx_mimo_a(usrp_basic *usrp, int which)
+db_flexrf_400_rx_mimo_a::db_flexrf_400_rx_mimo_a(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_400_rx(usrp, which)
 {
   _enable_refclk(true);
@@ -251,7 +251,7 @@
   return 16;
 }
     
-db_flexrf_400_tx_mimo_b::db_flexrf_400_tx_mimo_b(usrp_basic *usrp, int which)
+db_flexrf_400_tx_mimo_b::db_flexrf_400_tx_mimo_b(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_400_tx(usrp, which)
 {
   d_common->R_DIV(16);
@@ -263,7 +263,7 @@
   return 1;
 }
     
-db_flexrf_400_rx_mimo_b::db_flexrf_400_rx_mimo_b(usrp_basic *usrp, int which)
+db_flexrf_400_rx_mimo_b::db_flexrf_400_rx_mimo_b(usrp_basic_sptr usrp, int 
which)
   : db_flexrf_400_rx(usrp, which)
 {
   d_common->R_DIV(16);

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf_mimo.h
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf_mimo.h 
    2008-11-07 06:22:20 UTC (rev 9949)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf_mimo.h 
    2008-11-07 06:23:24 UTC (rev 9950)
@@ -24,28 +24,28 @@
 class db_flexrf_2400_tx_mimo_a : public db_flexrf_2400_tx
 {
  public:
-  db_flexrf_2400_tx_mimo_a(usrp_basic *usrp, int which);
+  db_flexrf_2400_tx_mimo_a(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_2400_rx_mimo_a : public db_flexrf_2400_rx
 {
  public:
-  db_flexrf_2400_rx_mimo_a(usrp_basic *usrp, int which);
+  db_flexrf_2400_rx_mimo_a(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
       
 class db_flexrf_2400_tx_mimo_b : public db_flexrf_2400_tx
 {
  public:
-  db_flexrf_2400_tx_mimo_b(usrp_basic *usrp, int which);
+  db_flexrf_2400_tx_mimo_b(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_2400_rx_mimo_b : public db_flexrf_2400_rx
 {
  public:
-  db_flexrf_2400_rx_mimo_b(usrp_basic *usrp, int which);
+  db_flexrf_2400_rx_mimo_b(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
@@ -53,111 +53,111 @@
 class db_flexrf_1800_tx_mimo_a : public db_flexrf_1800_tx
 {
  public:
-  db_flexrf_1800_tx_mimo_a(usrp_basic *usrp, int which);
+  db_flexrf_1800_tx_mimo_a(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_1800_rx_mimo_a : public db_flexrf_1800_rx
 {
  public:
-  db_flexrf_1800_rx_mimo_a(usrp_basic *usrp, int which);
+  db_flexrf_1800_rx_mimo_a(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_1800_tx_mimo_b : public db_flexrf_1800_tx
 {
  public:
-  db_flexrf_1800_tx_mimo_b(usrp_basic *usrp, int which);
+  db_flexrf_1800_tx_mimo_b(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_1800_rx_mimo_b : public db_flexrf_1800_rx
 {
  public:
-  db_flexrf_1800_rx_mimo_b(usrp_basic *usrp, int which);
+  db_flexrf_1800_rx_mimo_b(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_1200_tx_mimo_a : public db_flexrf_1200_tx
 {
  public:
-  db_flexrf_1200_tx_mimo_a(usrp_basic *usrp, int which);
+  db_flexrf_1200_tx_mimo_a(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_1200_rx_mimo_a : public db_flexrf_1200_rx
 {
  public:
-  db_flexrf_1200_rx_mimo_a(usrp_basic *usrp, int which);
+  db_flexrf_1200_rx_mimo_a(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_1200_tx_mimo_b : public db_flexrf_1200_tx
 {
  public:
-  db_flexrf_1200_tx_mimo_b(usrp_basic *usrp, int which);
+  db_flexrf_1200_tx_mimo_b(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_1200_rx_mimo_b : public db_flexrf_1200_rx
 {
  public:
-  db_flexrf_1200_rx_mimo_b(usrp_basic *usrp, int which);
+  db_flexrf_1200_rx_mimo_b(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_900_tx_mimo_a : public db_flexrf_900_tx
 {
  public:
-  db_flexrf_900_tx_mimo_a(usrp_basic *usrp, int which);
+  db_flexrf_900_tx_mimo_a(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_900_rx_mimo_a : public db_flexrf_900_rx
 {
  public:
-  db_flexrf_900_rx_mimo_a(usrp_basic *usrp, int which);
+  db_flexrf_900_rx_mimo_a(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_900_tx_mimo_b : public db_flexrf_900_tx
 {
  public:
-  db_flexrf_900_tx_mimo_b(usrp_basic *usrp, int which);
+  db_flexrf_900_tx_mimo_b(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_900_rx_mimo_b : public db_flexrf_900_rx
 {
  public:
-  db_flexrf_900_rx_mimo_b(usrp_basic *usrp, int which);
+  db_flexrf_900_rx_mimo_b(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_400_tx_mimo_a : public db_flexrf_400_tx
 {
  public:
-  db_flexrf_400_tx_mimo_a(usrp_basic *usrp, int which);
+  db_flexrf_400_tx_mimo_a(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_400_rx_mimo_a : public db_flexrf_400_rx
 {
  public:
-  db_flexrf_400_rx_mimo_a(usrp_basic *usrp, int which);
+  db_flexrf_400_rx_mimo_a(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_400_tx_mimo_b : public db_flexrf_400_tx
 {
  public:
-  db_flexrf_400_tx_mimo_b(usrp_basic *usrp, int which);
+  db_flexrf_400_tx_mimo_b(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };
 
 class db_flexrf_400_rx_mimo_b : public db_flexrf_400_rx
 {
  public:
-  db_flexrf_400_rx_mimo_b(usrp_basic *usrp, int which);
+  db_flexrf_400_rx_mimo_b(usrp_basic_sptr usrp, int which);
   int _refclk_divisor();
 };

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_tv_rx.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_tv_rx.cc  
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_tv_rx.cc  
2008-11-07 06:23:24 UTC (rev 9950)
@@ -72,7 +72,7 @@
 /*****************************************************************************/
 
 
-db_tv_rx::db_tv_rx(usrp_basic *usrp, int which,
+db_tv_rx::db_tv_rx(usrp_basic_sptr usrp, int which,
                   double first_IF, double second_IF)
   : db_base(usrp, which)
 {
@@ -121,7 +121,7 @@
   int dacword = int(4096*voltage/1.22/3.3);    // 1.22 = opamp gain
 
   assert(dacword>=0 && dacword<4096);
-  d_usrp->write_aux_dac(d_which, 1, dacword);
+  usrp()->write_aux_dac(d_which, 1, dacword);
 }
 
 void
@@ -134,7 +134,7 @@
   int dacword = int(4096*voltage/1.22/3.3);    // 1.22 = opamp gain
   
   assert(dacword>=0 && dacword<4096);
-  d_usrp->write_aux_dac(d_which, 0, dacword);
+  usrp()->write_aux_dac(d_which, 0, dacword);
 }
 
 void
@@ -142,10 +142,10 @@
 {
   assert(pga_gain >=0 && pga_gain <=20);
   if(d_which == 0) {
-    d_usrp->set_pga(0, pga_gain);
+    usrp()->set_pga(0, pga_gain);
   }
   else {
-    d_usrp->set_pga (2, pga_gain);
+    usrp()->set_pga (2, pga_gain);
   }
 }           
 
@@ -199,7 +199,7 @@
   buf[2] = control_byte_1(d_fast_tuning, d_reference_divisor);
   buf[3] = control_byte_2(actual_freq, true);
 
-  args.ok = d_usrp->write_i2c(d_i2c_addr, int_seq_to_str (buf));
+  args.ok = usrp()->write_i2c(d_i2c_addr, int_seq_to_str (buf));
   args.baseband_freq = actual_freq - d_second_IF;
   return args;
 }

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_tv_rx.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_tv_rx.h   
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_tv_rx.h   
2008-11-07 06:23:24 UTC (rev 9950)
@@ -38,7 +38,7 @@
   bool d_inverted;
 
 public:
-  db_tv_rx(usrp_basic *usrp, int which, 
+  db_tv_rx(usrp_basic_sptr usrp, int which, 
           double first_IF, double second_IF);
   ~db_tv_rx();
 

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_wbx.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_wbx.cc    
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_wbx.cc    
2008-11-07 06:23:24 UTC (rev 9950)
@@ -50,7 +50,7 @@
 #define AUX_SEN         (1 << 11) // ALT SPI SEN
 
 
-wbx_base::wbx_base(usrp_basic *usrp, int which)
+wbx_base::wbx_base(usrp_basic_sptr usrp, int which)
   : db_base(usrp, which)
 {
   /*
@@ -254,7 +254,7 @@
 /****************************************************************************/
 
 
-wbx_base_tx::wbx_base_tx(usrp_basic *usrp, int which)
+wbx_base_tx::wbx_base_tx(usrp_basic_sptr usrp, int which)
   : wbx_base(usrp, which)
 {        
   /*
@@ -336,7 +336,7 @@
 /****************************************************************************/
 
 
-wbx_base_rx::wbx_base_rx(usrp_basic *usrp, int which)
+wbx_base_rx::wbx_base_rx(usrp_basic_sptr usrp, int which)
   : wbx_base(usrp, which)
 {
   /*
@@ -797,7 +797,7 @@
 /****************************************************************************/
 
 
-db_wbx_lo_tx::db_wbx_lo_tx(usrp_basic *usrp, int which)
+db_wbx_lo_tx::db_wbx_lo_tx(usrp_basic_sptr usrp, int which)
   : _lo_common(),
     wbx_base_tx(usrp, which)
 {
@@ -888,7 +888,7 @@
 /****************************************************************************/
 
 
-db_wbx_lo_rx::db_wbx_lo_rx(usrp_basic *usrp, int which)
+db_wbx_lo_rx::db_wbx_lo_rx(usrp_basic_sptr usrp, int which)
   : _lo_common(),
     wbx_base_rx(usrp, which)    
 {

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_wbx.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_wbx.h     
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_wbx.h     
2008-11-07 06:23:24 UTC (rev 9950)
@@ -45,7 +45,7 @@
    */
 
 public:
-  wbx_base(usrp_basic *usrp, int which);
+  wbx_base(usrp_basic_sptr usrp, int which);
   ~wbx_base();
   
   struct freq_result_t set_freq(double freq);
@@ -84,7 +84,7 @@
 class wbx_base_tx : public wbx_base
 {
 public:
-  wbx_base_tx(usrp_basic *usrp, int which);
+  wbx_base_tx(usrp_basic_sptr usrp, int which);
   ~wbx_base_tx();
 
   bool set_auto_tr(bool on);
@@ -98,7 +98,7 @@
 class wbx_base_rx : public wbx_base
 {
 public:
-  wbx_base_rx(usrp_basic *usrp, int which);
+  wbx_base_rx(usrp_basic_sptr usrp, int which);
   ~wbx_base_rx();
   
   bool set_auto_tr(bool on);
@@ -176,7 +176,7 @@
 class db_wbx_lo_tx : public _lo_common, public wbx_base_tx
 {
 public:
-  db_wbx_lo_tx(usrp_basic *usrp, int which);
+  db_wbx_lo_tx(usrp_basic_sptr usrp, int which);
   ~db_wbx_lo_tx();
 
   float gain_min();
@@ -199,7 +199,7 @@
 class db_wbx_lo_rx : public _lo_common, public  wbx_base_rx
 {
 public:
-  db_wbx_lo_rx(usrp_basic *usrp, int which);
+  db_wbx_lo_rx(usrp_basic_sptr usrp, int which);
   ~db_wbx_lo_rx();
 
   float gain_min();

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_xcvr2450.cc
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_xcvr2450.cc   
    2008-11-07 06:22:20 UTC (rev 9949)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_xcvr2450.cc   
    2008-11-07 06:23:24 UTC (rev 9950)
@@ -39,16 +39,14 @@
 /*****************************************************************************/
 
 
-xcvr2450::xcvr2450(usrp_basic *usrp, int which)
+xcvr2450::xcvr2450(usrp_basic_sptr _usrp, int which)
+  : d_weak_usrp(_usrp), d_which(which)
 {
   // Handler for Tv Rx daughterboards.
   // 
   // @param usrp: instance of usrp.source_c
   // @param which: which side: 0, 1 corresponding to RX_A or RX_B respectively
 
-  d_usrp = (usrp_basic*)usrp;
-  d_which = which;
-
   // Use MSB with no header
   d_spi_format = SPI_FMT_MSB | SPI_FMT_HDR_0;
 
@@ -129,7 +127,7 @@
 bool
 xcvr2450::operator==(xcvr2450_key x)
 {
-  if((x.serial_no == d_usrp->serial_number()) && (x.which == d_which)) {
+  if((x.serial_no == usrp()->serial_number()) && (x.which == d_which)) {
     return true;
   }
   else {
@@ -255,7 +253,7 @@
   c[2] = (char)((v & 0xff));
   std::string s(c, 3);
   
-  d_usrp->_write_spi(0, d_spi_enable, d_spi_format, s);
+  usrp()->_write_spi(0, d_spi_enable, d_spi_format, s);
   //printf("xcvr2450: Setting reg %d to %06X\n", (v&15), v);
 }
 
@@ -267,8 +265,9 @@
 // The board operates in ATR mode, always.  Thus, when the board is first
 // initialized, it is in receive mode, until bits show up in the TX FIFO.
 //
-// FIXME: We can do this now in db_base
 
+// FIXME these should just call the similarly named common_* method on 
usrp_basic
+
 bool
 xcvr2450::tx_write_oe(int value, int mask)
 {
@@ -277,7 +276,7 @@
     reg = FR_OE_0;
   else
     reg = FR_OE_2;
-  return d_usrp->_write_fpga_reg(reg, (mask << 16) | value);
+  return usrp()->_write_fpga_reg(reg, (mask << 16) | value);
 }
    
 bool
@@ -288,7 +287,7 @@
     reg = FR_IO_0;
   else
     reg = FR_IO_2;
-  return d_usrp->_write_fpga_reg(reg, (mask << 16) | value);
+  return usrp()->_write_fpga_reg(reg, (mask << 16) | value);
 }
 
 int
@@ -299,7 +298,7 @@
     val = FR_RB_IO_RX_A_IO_TX_A;
   else
     val = FR_RB_IO_RX_B_IO_TX_B;
-  int t = d_usrp->_read_fpga_reg(val);
+  int t = usrp()->_read_fpga_reg(val);
   return t & 0xffff;
 }
 
@@ -311,7 +310,7 @@
     reg = FR_OE_1;
   else
     reg = FR_OE_3;
-  return d_usrp->_write_fpga_reg(reg, (mask << 16) | value);
+  return usrp()->_write_fpga_reg(reg, (mask << 16) | value);
 }
 
 bool
@@ -322,7 +321,7 @@
     reg = FR_IO_1;
   else
     reg = FR_IO_3;
-  return d_usrp->_write_fpga_reg(reg, (mask << 16) | value);
+  return usrp()->_write_fpga_reg(reg, (mask << 16) | value);
 }
 
 int
@@ -333,7 +332,7 @@
     val = FR_RB_IO_RX_A_IO_TX_A;
   else
     val = FR_RB_IO_RX_B_IO_TX_B;
-  int t = d_usrp->_read_fpga_reg(val);
+  int t = usrp()->_read_fpga_reg(val);
   return (t >> 16) & 0xffff;
 }
 
@@ -345,7 +344,7 @@
     reg = FR_ATR_MASK_0;
   else
     reg = FR_ATR_MASK_2;
-  return d_usrp->_write_fpga_reg(reg, v);
+  return usrp()->_write_fpga_reg(reg, v);
 }
 
 bool
@@ -356,7 +355,7 @@
     reg = FR_ATR_TXVAL_0;
   else
     reg = FR_ATR_TXVAL_2;
-  return d_usrp->_write_fpga_reg(reg, v);
+  return usrp()->_write_fpga_reg(reg, v);
 }
 
 bool
@@ -367,7 +366,7 @@
     reg = FR_ATR_RXVAL_0;
   else
     reg = FR_ATR_RXVAL_2;
-  return d_usrp->_write_fpga_reg(reg, v);
+  return usrp()->_write_fpga_reg(reg, v);
 }
 
 bool
@@ -378,7 +377,7 @@
     reg = FR_ATR_MASK_1;
   else
     reg = FR_ATR_MASK_3;
-  return d_usrp->_write_fpga_reg(reg, v);
+  return usrp()->_write_fpga_reg(reg, v);
 }
 
 bool
@@ -389,7 +388,7 @@
     reg = FR_ATR_TXVAL_1;
   else
     reg = FR_ATR_TXVAL_3;
-  return d_usrp->_write_fpga_reg(reg, v);
+  return usrp()->_write_fpga_reg(reg, v);
 }
 
 bool
@@ -400,9 +399,11 @@
     reg = FR_ATR_RXVAL_1;
   else
     reg = FR_ATR_RXVAL_3;
-  return d_usrp->_write_fpga_reg(reg, v);
+  return usrp()->_write_fpga_reg(reg, v);
 }
 
+// ----------------------------------------------------------------
+
 void
 xcvr2450::set_gpio()
 {
@@ -478,7 +479,7 @@
   }
 
   double vco_freq = target_freq*scaler;
-  //ref_clk = d_usrp->fpga_master_clock_freq();  // Assumes AD9515 is bypassed
+  //ref_clk = usrp()->fpga_master_clock_freq();  // Assumes AD9515 is bypassed
   double sys_clk = 64e6;
   //sys_clk = 75e6;
   double ref_clk = sys_clk / d_ad9515_div;
@@ -580,7 +581,7 @@
 std::vector<xcvr2450_sptr> _xcvr2450_inst;
 
 xcvr2450_sptr
-_get_or_make_xcvr2450(usrp_basic *usrp, int which)
+_get_or_make_xcvr2450(usrp_basic_sptr usrp, int which)
 {
   xcvr2450_sptr inst;
   xcvr2450_key key = {usrp->serial_number(), which};
@@ -608,7 +609,7 @@
 /*****************************************************************************/
 
 
-db_xcvr2450_base::db_xcvr2450_base(usrp_basic *usrp, int which)
+db_xcvr2450_base::db_xcvr2450_base(usrp_basic_sptr usrp, int which)
   : db_base(usrp, which)
 {
   /*
@@ -666,7 +667,7 @@
 
/******************************************************************************/
 
 
-db_xcvr2450_tx::db_xcvr2450_tx(usrp_basic *usrp, int which)
+db_xcvr2450_tx::db_xcvr2450_tx(usrp_basic_sptr usrp, int which)
   : db_xcvr2450_base(usrp, which)
 {
   printf("db_xcvr2450_tx::db_xcvr2450_tx\n");
@@ -710,7 +711,7 @@
 
/******************************************************************************/
 
 
-db_xcvr2450_rx::db_xcvr2450_rx(usrp_basic *usrp, int which)
+db_xcvr2450_rx::db_xcvr2450_rx(usrp_basic_sptr usrp, int which)
   : db_xcvr2450_base(usrp, which)
 {
   /*

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_xcvr2450.h
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_xcvr2450.h    
    2008-11-07 06:22:20 UTC (rev 9949)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_xcvr2450.h    
    2008-11-07 06:23:24 UTC (rev 9950)
@@ -62,11 +62,7 @@
 class xcvr2450
 {
 private:
-  void _set_rfagc(float gain);
-  void _set_ifagc(float gain);
-  void _set_pga(float pga_gain);
-
-  usrp_basic *d_usrp;
+  boost::weak_ptr<usrp_basic> d_weak_usrp;
   int d_which;
 
   int d_spi_format, d_spi_enable;
@@ -87,8 +83,16 @@
 
   int d_ad9515_div;
 
+  void _set_rfagc(float gain);
+  void _set_ifagc(float gain);
+  void _set_pga(float pga_gain);
+
+  usrp_basic_sptr usrp(){
+    return usrp_basic_sptr(d_weak_usrp);    // throws bad_weak_ptr if 
d_usrp.use_count() == 0
+  }
+
 public:
-  xcvr2450(usrp_basic *usrp, int which);
+  xcvr2450(usrp_basic_sptr usrp, int which);
   ~xcvr2450();
 
   bool operator==(xcvr2450_key x);
@@ -136,6 +140,9 @@
   // The board operates in ATR mode, always.  Thus, when the board is first
   // initialized, it is in receive mode, until bits show up in the TX FIFO.
   //
+
+  // FIXME these should just call the similarly named common_* method on 
usrp_basic
+
   bool tx_write_oe(int value, int mask);
   bool tx_write_io(int value, int mask);
   int  tx_read_io();
@@ -148,9 +155,9 @@
   bool rx_set_atr_mask(int v);
   bool rx_set_atr_txval(int v);
   bool rx_set_atr_rxval(int v);
+
   void set_gpio();
   bool lock_detect();
-  
   bool set_rx_gain(float gain);
   bool set_tx_gain(float gain);
 
@@ -169,7 +176,7 @@
    * Derive board specific subclasses from db_xcvr2450_base_{tx,rx}
    */
 public:
-  db_xcvr2450_base(usrp_basic *usrp, int which);
+  db_xcvr2450_base(usrp_basic_sptr usrp, int which);
   ~db_xcvr2450_base();
   struct freq_result_t set_freq(double target_freq);
   bool is_quadrature();
@@ -187,7 +194,7 @@
 class db_xcvr2450_tx : public db_xcvr2450_base
 {
 public:
-  db_xcvr2450_tx(usrp_basic *usrp, int which);
+  db_xcvr2450_tx(usrp_basic_sptr usrp, int which);
   ~db_xcvr2450_tx();
 
   float gain_min();
@@ -200,7 +207,7 @@
 class db_xcvr2450_rx : public db_xcvr2450_base
 {
 public:
-  db_xcvr2450_rx(usrp_basic *usrp, int which);
+  db_xcvr2450_rx(usrp_basic_sptr usrp, int which);
   ~db_xcvr2450_rx();
 
   float gain_min();

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc    
    2008-11-07 06:22:20 UTC (rev 9949)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc    
    2008-11-07 06:23:24 UTC (rev 9950)
@@ -164,25 +164,13 @@
     usb_close (d_udh);
 }
 
-/*
- * We return a vector of weak pointers.  d_db should be the only place
- * in the system that's holding them as shared pointers.
- */
-std::vector<db_base_wptr> 
+std::vector<db_base_sptr> 
 usrp_basic::db(int which_side)
 {
   which_side &= 0x1;   // clamp it to avoid any reporting any errors
-  std::vector<db_base_wptr> r;
-
-  assert(d_db.size() == 2);
-
-  for (unsigned i = 0; i < d_db[which_side].size(); i++)
-    r.push_back(db_base_wptr(d_db[which_side][i]));
-
-  return r;
+  return d_db[which_side];
 }
 
-
 bool
 usrp_basic::start ()
 {
@@ -763,8 +751,9 @@
   set_dc_offset_cl_enable(0xf, 0xf);   // enable DC offset removal control 
loops
 
   probe_rx_slots (false);
-  d_db[0] = instantiate_dbs(d_dbid[0], this, 0);
-  d_db[1] = instantiate_dbs(d_dbid[1], this, 1);
+  // FIXME
+  //d_db[0] = instantiate_dbs(d_dbid[0], this, 0);
+  //d_db[1] = instantiate_dbs(d_dbid[1], this, 1);
 
   // check fusb buffering parameters
 
@@ -1169,8 +1158,9 @@
   set_fpga_tx_sample_rate_divisor (4); // we're using interp x4
 
   probe_tx_slots (false);
-  d_db[0] = instantiate_dbs(d_dbid[0], this, 0);
-  d_db[1] = instantiate_dbs(d_dbid[1], this, 1);
+  // FIXME
+  //d_db[0] = instantiate_dbs(d_dbid[0], this, 0);
+  //d_db[1] = instantiate_dbs(d_dbid[1], this, 1);
 
   // check fusb buffering parameters
 

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h 
2008-11-07 06:22:20 UTC (rev 9949)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h 
2008-11-07 06:23:24 UTC (rev 9950)
@@ -39,11 +39,10 @@
 #ifndef INCLUDED_USRP_BASIC_H
 #define INCLUDED_USRP_BASIC_H
 
+#include <db_base.h>
 #include <usrp_slots.h>
 #include <string>
 #include <vector>
-#include <boost/shared_ptr.hpp>
-#include <boost/weak_ptr.hpp>
 #include <boost/utility.hpp>
 
 
@@ -56,11 +55,6 @@
   C_TX = 1
 };
 
-class db_base;
-typedef boost::shared_ptr<db_base> db_base_sptr;
-typedef boost::weak_ptr<db_base> db_base_wptr;
-
-
 /*!
  * \brief abstract base class for usrp operations
  */
@@ -149,7 +143,7 @@
    * pointers after this usrp object has been destroyed, everything
    * will work out fine.
    */
-  std::vector<db_base_wptr> db(int which_side);
+  std::vector<db_base_sptr> db(int which_side);
 
   /*!
    * \brief return frequency of master oscillator on USRP

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.cc
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.cc 
    2008-11-07 06:22:20 UTC (rev 9949)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.cc 
    2008-11-07 06:23:24 UTC (rev 9950)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -210,7 +210,7 @@
   return ok;
 }
 
-usrp_standard_rx *
+usrp_standard_rx_sptr
 usrp_standard_rx::make (int which_board,
                        unsigned int decim_rate,
                        int nchan, int mux, int mode,
@@ -219,21 +219,15 @@
                        const std::string firmware_filename
                        )
 {
-  usrp_standard_rx *u = 0;
-  
   try {
-    u = new usrp_standard_rx (which_board, decim_rate,
-                             nchan, mux, mode,
-                             fusb_block_size, fusb_nblocks,
-                             fpga_filename, firmware_filename);
-    return u;
+    return usrp_standard_rx_sptr(new usrp_standard_rx(which_board, decim_rate,
+                                                     nchan, mux, mode,
+                                                     fusb_block_size, 
fusb_nblocks,
+                                                     fpga_filename, 
firmware_filename));
   }
   catch (...){
-    delete u;
-    return 0;
+    return usrp_standard_rx_sptr();
   }
-
-  return u;
 }
 
 bool
@@ -589,7 +583,7 @@
   return ok;
 }
 
-usrp_standard_tx *
+usrp_standard_tx_sptr
 usrp_standard_tx::make (int which_board,
                        unsigned int interp_rate,
                        int nchan, int mux,
@@ -598,20 +592,14 @@
                        const std::string firmware_filename
                        )
 {
-  usrp_standard_tx *u = 0;
-  
   try {
-    u = new usrp_standard_tx (which_board, interp_rate, nchan, mux,
-                             fusb_block_size, fusb_nblocks,
-                             fpga_filename, firmware_filename);
-    return u;
+    return usrp_standard_tx_sptr(new usrp_standard_tx(which_board, 
interp_rate, nchan, mux,
+                                                     fusb_block_size, 
fusb_nblocks,
+                                                     fpga_filename, 
firmware_filename));
   }
   catch (...){
-    delete u;
-    return 0;
+    return usrp_standard_tx_sptr();
   }
-
-  return u;
 }
 
 bool

Modified: 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.h
===================================================================
--- 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.h  
    2008-11-07 06:22:20 UTC (rev 9949)
+++ 
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_standard.h  
    2008-11-07 06:23:24 UTC (rev 9950)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -24,7 +24,15 @@
 #define INCLUDED_USRP_STANDARD_H
 
 #include <usrp_basic.h>
+#include <boost/shared_ptr.hpp>
 
+class usrp_standard_tx;
+class usrp_standard_rx;
+
+typedef boost::shared_ptr<usrp_standard_tx> usrp_standard_tx_sptr;
+typedef boost::shared_ptr<usrp_standard_rx> usrp_standard_rx_sptr;
+
+
 class usrp_standard_common
 {
   int                  d_fpga_caps;            // capability register val
@@ -99,23 +107,23 @@
   ~usrp_standard_rx ();
 
   /*!
-   * \brief invokes constructor, returns instance or 0 if trouble
+   * \brief invokes constructor, returns shared_ptr or shared_ptr equivalent 
of 0 if trouble
    *
    * \param which_board             Which USRP board on usb (not particularly 
useful; use 0)
    * \param fusb_block_size  fast usb xfer block size.  Must be a multiple of 
512. 
    *                         Use zero for a reasonable default.
    * \param fusb_nblocks     number of fast usb URBs to allocate.  Use zero 
for a reasonable default. 
    */
-  static usrp_standard_rx *make (int which_board,
-                                unsigned int decim_rate,
-                                int nchan = 1,
-                                int mux = -1,
-                                int mode = 0,
-                                int fusb_block_size = 0,
-                                int fusb_nblocks = 0,
-                                const std::string fpga_filename = "",
-                                const std::string firmware_filename = ""
-                                );
+  static usrp_standard_rx_sptr make(int which_board,
+                                   unsigned int decim_rate,
+                                   int nchan = 1,
+                                   int mux = -1,
+                                   int mode = 0,
+                                   int fusb_block_size = 0,
+                                   int fusb_nblocks = 0,
+                                   const std::string fpga_filename = "",
+                                   const std::string firmware_filename = ""
+                                   );
   /*!
    * \brief Set decimator rate.  \p rate MUST BE EVEN and in [8, 256].
    *
@@ -274,22 +282,22 @@
   ~usrp_standard_tx ();
 
   /*!
-   * \brief invokes constructor, returns instance or 0 if trouble
+   * \brief invokes constructor, returns shared_ptr or shared_ptr equivalent 
of 0 if trouble
    *
    * \param which_board             Which USRP board on usb (not particularly 
useful; use 0)
    * \param fusb_block_size  fast usb xfer block size.  Must be a multiple of 
512. 
    *                         Use zero for a reasonable default.
    * \param fusb_nblocks     number of fast usb URBs to allocate.  Use zero 
for a reasonable default. 
    */
-  static usrp_standard_tx *make (int which_board,
-                                unsigned int interp_rate,
-                                int nchan = 1,
-                                int mux = -1,
-                                int fusb_block_size = 0,
-                                int fusb_nblocks = 0,
-                                const std::string fpga_filename = "",
-                                const std::string firmware_filename = ""
-                                );
+  static usrp_standard_tx_sptr make(int which_board,
+                                   unsigned int interp_rate,
+                                   int nchan = 1,
+                                   int mux = -1,
+                                   int fusb_block_size = 0,
+                                   int fusb_nblocks = 0,
+                                   const std::string fpga_filename = "",
+                                   const std::string firmware_filename = ""
+                                   );
 
   /*!
    * \brief Set interpolator rate.  \p rate must be in [4, 512] and a multiple 
of 4.





reply via email to

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