[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10160 - in gnuradio/branches/developers/eb/cppdb-wip:
From: |
eb |
Subject: |
[Commit-gnuradio] r10160 - in gnuradio/branches/developers/eb/cppdb-wip: gnuradio-examples/python/usrp gr-usrp/src usrp/host/lib/legacy |
Date: |
Tue, 23 Dec 2008 16:53:39 -0700 (MST) |
Author: eb
Date: 2008-12-23 16:53:38 -0700 (Tue, 23 Dec 2008)
New Revision: 10160
Modified:
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/python/usrp/fm_tx4.py
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_base.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_base.i
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_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_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/usrp_basic.cc
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h
Log:
Removed need for user code to call shutdown when closing out usrp.
Modified:
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/python/usrp/fm_tx4.py
===================================================================
---
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/python/usrp/fm_tx4.py
2008-12-23 08:13:43 UTC (rev 10159)
+++
gnuradio/branches/developers/eb/cppdb-wip/gnuradio-examples/python/usrp/fm_tx4.py
2008-12-23 23:53:38 UTC (rev 10160)
@@ -43,7 +43,7 @@
import sys
from gnuradio.wxgui import stdgui2, fftsink2
-from gnuradio import tx_debug_gui
+#from gnuradio import tx_debug_gui
import wx
@@ -84,8 +84,8 @@
help="set Tx frequency to FREQ [required]",
metavar="FREQ")
parser.add_option("-n", "--nchannels", type="int", default=4,
help="number of Tx channels [1,4]")
- parser.add_option("","--debug", action="store_true", default=False,
- help="Launch Tx debugger")
+ #parser.add_option("","--debug", action="store_true", default=False,
+ # help="Launch Tx debugger")
(options, args) = parser.parse_args ()
if len(args) != 0:
@@ -158,9 +158,9 @@
vbox.Add (post_mod.win, 1, wx.EXPAND)
- if options.debug:
- self.debugger = tx_debug_gui.tx_debug_gui(self.subdev)
- self.debugger.Show(True)
+ #if options.debug:
+ # self.debugger = tx_debug_gui.tx_debug_gui(self.subdev)
+ # self.debugger.Show(True)
def set_freq(self, target_freq):
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-12-23 08:13:43 UTC (rev 10159)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_base.cc
2008-12-23 23:53:38 UTC (rev 10160)
@@ -44,8 +44,6 @@
usrp_base::~usrp_base()
{
- if (d_usrp_basic)
- d_usrp_basic->shutdown();
}
void
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-12-23 08:13:43 UTC (rev 10159)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.cc
2008-12-23 23:53:38 UTC (rev 10160)
@@ -38,17 +38,22 @@
/*****************************************************************************/
db_base::db_base(usrp_basic_sptr usrp, int which)
- : d_weak_usrp(usrp), d_which(which), d_lo_offset(0.0)
+ : d_is_shutdown(false), d_weak_usrp(usrp), d_which(which), d_lo_offset(0.0)
{
}
-void
-db_base::shutdown()
+db_base::~db_base()
{
+ shutdown();
}
-db_base::~db_base()
+void
+db_base::shutdown()
{
+ if (!d_is_shutdown){
+ d_is_shutdown = true;
+ // do whatever there is to do to shutdown
+ }
}
int
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-12-23 08:13:43 UTC (rev 10159)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.h
2008-12-23 23:53:38 UTC (rev 10160)
@@ -45,6 +45,7 @@
class db_base
{
protected:
+ bool d_is_shutdown;
boost::weak_ptr<usrp_basic> d_weak_usrp;
int d_which;
double d_lo_offset;
@@ -75,9 +76,22 @@
bool set_lo_offset(double offset);
double lo_offset() { return d_lo_offset; }
+
////////////////////////////////////////////////////////
// derived classes should override the following methods
+protected:
+ friend class usrp_basic;
+
+ /*!
+ * Called to shutdown daughterboard. Called from dtor and usrp_basic dtor.
+ *
+ * N.B., any class that overrides shutdown MUST call shutdown in its
destructor.
+ */
+ virtual void shutdown();
+
+
+public:
virtual float gain_min() = 0;
virtual float gain_max() = 0;
virtual float gain_db_per_step() = 0;
@@ -92,7 +106,6 @@
virtual bool set_auto_tr(bool on);
virtual bool select_rx_antenna(int which_antenna);
virtual bool select_rx_antenna(const std::string &which_antenna);
- virtual void shutdown();
};
Modified:
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.i
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.i
2008-12-23 08:13:43 UTC (rev 10159)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.i
2008-12-23 23:53:38 UTC (rev 10160)
@@ -82,7 +82,6 @@
virtual bool set_auto_tr(bool on);
virtual bool select_rx_antenna(int which_antenna);
virtual bool select_rx_antenna(const std::string &antenna);
- virtual void shutdown();
};
// Create templates for db's, vectors of db's, and vector of vectors of db's
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-12-23 08:13:43 UTC (rev 10159)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.cc
2008-12-23 23:53:38 UTC (rev 10160)
@@ -64,14 +64,19 @@
bypass_adc_buffers(true);
}
-void
-db_dbs_rx::shutdown()
+db_dbs_rx::~db_dbs_rx()
{
- _enable_refclk(false);
+ shutdown();
}
-db_dbs_rx::~db_dbs_rx()
+void
+db_dbs_rx::shutdown()
{
+ if (!d_is_shutdown){
+ d_is_shutdown = true;
+ // do whatever there is to do to shutdown orderly
+ _enable_refclk(false);
+ }
}
void
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-12-23 08:13:43 UTC (rev 10159)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.h
2008-12-23 23:53:38 UTC (rev 10160)
@@ -61,6 +61,8 @@
int _refclk_divisor();
+protected:
+ void shutdown();
public:
db_dbs_rx(usrp_basic_sptr usrp, int which);
@@ -74,7 +76,6 @@
struct freq_result_t set_freq(double freq);
bool set_gain(float gain);
bool is_quadrature();
- void shutdown();
};
#endif
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-12-23 08:13:43 UTC (rev 10159)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf.cc
2008-12-23 23:53:38 UTC (rev 10160)
@@ -273,24 +273,31 @@
set_gain((gain_min() + gain_max()) / 2.0); // initialize gain
}
+flexrf_base_tx::~flexrf_base_tx()
+{
+ shutdown();
+}
+
+
void
flexrf_base_tx::shutdown()
{
- // Power down and leave the T/R switch in the R position
- usrp()->write_io(d_which, (power_off()|RX_TXN), (POWER_UP|RX_TXN|ENABLE));
+ if (!d_is_shutdown){
+ d_is_shutdown = true;
+ // do whatever there is to do to shutdown
- // Power down VCO/PLL
- d_PD = 3;
+ // Power down and leave the T/R switch in the R position
+ usrp()->write_io(d_which, (power_off()|RX_TXN), (POWER_UP|RX_TXN|ENABLE));
+
+ // Power down VCO/PLL
+ d_PD = 3;
- _write_control(_compute_control_reg());
- _enable_refclk(false); // turn off refclk
- set_auto_tr(false);
+ _write_control(_compute_control_reg());
+ _enable_refclk(false); // turn off refclk
+ set_auto_tr(false);
+ }
}
-flexrf_base_tx::~flexrf_base_tx()
-{
-}
-
bool
flexrf_base_tx::set_auto_tr(bool on)
{
@@ -387,24 +394,30 @@
set_lo_offset(-4e6);
}
+flexrf_base_rx::~flexrf_base_rx()
+{
+ shutdown();
+}
+
void
flexrf_base_rx::shutdown()
{
- // Power down
- usrp()->common_write_io(C_RX, d_which, power_off(), (POWER_UP|ENABLE));
+ if (!d_is_shutdown){
+ d_is_shutdown = true;
+ // do whatever there is to do to shutdown
- // Power down VCO/PLL
- d_PD = 3;
+ // Power down
+ usrp()->common_write_io(C_RX, d_which, power_off(), (POWER_UP|ENABLE));
+
+ // Power down VCO/PLL
+ d_PD = 3;
- _write_control(_compute_control_reg());
- _enable_refclk(false); // turn off refclk
- set_auto_tr(false);
+ _write_control(_compute_control_reg());
+ _enable_refclk(false); // turn off refclk
+ set_auto_tr(false);
+ }
}
-flexrf_base_rx::~flexrf_base_rx()
-{
-}
-
bool
flexrf_base_rx::set_auto_tr(bool on)
{
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-12-23 08:13:43 UTC (rev 10159)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf.h
2008-12-23 23:53:38 UTC (rev 10160)
@@ -74,6 +74,9 @@
class flexrf_base_tx : public flexrf_base
{
+protected:
+ void shutdown();
+
public:
flexrf_base_tx(usrp_basic_sptr usrp, int which, int _power_on=0);
~flexrf_base_tx();
@@ -86,12 +89,13 @@
bool set_auto_tr(bool on);
bool set_enable(bool on);
bool set_gain(float gain);
-
- void shutdown();
};
class flexrf_base_rx : public flexrf_base
{
+protected:
+ void shutdown();
+
public:
flexrf_base_rx(usrp_basic_sptr usrp, int which, int _power_on=0);
~flexrf_base_rx();
@@ -101,7 +105,6 @@
bool select_rx_antenna(const std::string &which_antenna);
bool set_gain(float gain);
- void shutdown();
};
// ----------------------------------------------------------------
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-12-23 08:13:43 UTC (rev 10159)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_wbx.cc
2008-12-23 23:53:38 UTC (rev 10160)
@@ -80,16 +80,23 @@
}
+wbx_base::~wbx_base()
+{
+ shutdown();
+}
+
+
void
wbx_base::shutdown()
{
- write_io(d_which, d_power_off, POWER_UP); // turn off power to board
- _write_oe(d_which, 0, 0xffff); // turn off all outputs
- set_auto_tr(false); // disable auto transmit
-}
+ if (!d_is_shutdown){
+ d_is_shutdown = true;
+ // do whatever there is to do to shutdown
-wbx_base::~wbx_base()
-{
+ write_io(d_which, d_power_off, POWER_UP); // turn off power to board
+ _write_oe(d_which, 0, 0xffff); // turn off all outputs
+ set_auto_tr(false); // disable auto transmit
+ }
}
bool
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-12-23 08:13:43 UTC (rev 10159)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_wbx.h
2008-12-23 23:53:38 UTC (rev 10160)
@@ -38,6 +38,9 @@
class wbx_base : public db_base
{
+protected:
+ void shutdown();
+
/*
* Abstract base class for all wbx boards.
*
@@ -55,7 +58,6 @@
bool set_gain(float gain);
bool is_quadrature();
- void shutdown();
protected:
virtual bool _lock_detect();
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-12-23 08:13:43 UTC (rev 10159)
+++
gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc
2008-12-23 23:53:38 UTC (rev 10160)
@@ -157,20 +157,22 @@
}
void
-usrp_basic::shutdown()
+usrp_basic::shutdown_daughterboards()
{
// nuke d'boards before we close down USB in ~usrp_basic
// shutdown() will do any board shutdown while the USRP can still
// be talked to
- for(int i = 0; i < d_db.size(); i++)
- for(int j = 0; j < d_db[i].size(); j++)
+ for(size_t i = 0; i < d_db.size(); i++)
+ for(size_t j = 0; j < d_db[i].size(); j++)
d_db[i][j]->shutdown();
}
usrp_basic::~usrp_basic ()
{
- d_db.resize(0); // forget db weak ptrs
+ shutdown_daughterboards();
+ d_db.resize(0); // forget db shared ptrs
+
if (d_udh)
usb_close (d_udh);
}
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-12-23 08:13:43 UTC (rev 10159)
+++ gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h
2008-12-23 23:53:38 UTC (rev 10160)
@@ -61,6 +61,9 @@
*/
class usrp_basic : boost::noncopyable
{
+private:
+ void shutdown_daughterboards();
+
protected:
struct usb_dev_handle *d_udh;
int d_usb_data_rate; // bytes/sec
@@ -159,12 +162,6 @@
std::vector<db_base_sptr> db(int which_side);
/*!
- * This *must* be called by the class user as the very last C++ API call
- * prior to the destructor being invoked.
- */
- void shutdown();
-
- /*!
* \brief is the subdev_spec valid?
*/
bool is_valid(const usrp_subdev_spec &ss);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10160 - in gnuradio/branches/developers/eb/cppdb-wip: gnuradio-examples/python/usrp gr-usrp/src usrp/host/lib/legacy,
eb <=