[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10022 - in gnuradio/branches/features/cppdb: gr-usrp/
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r10022 - in gnuradio/branches/features/cppdb: gr-usrp/src usrp/host/lib/legacy |
Date: |
Wed, 19 Nov 2008 20:23:55 -0700 (MST) |
Author: jcorgan
Date: 2008-11-19 20:23:54 -0700 (Wed, 19 Nov 2008)
New Revision: 10022
Modified:
gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.cc
gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.cc
gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.h
gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_dbs_rx.cc
gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_dbs_rx.h
gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_flexrf.cc
gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_flexrf.h
gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_wbx.cc
gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_wbx.h
gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_basic.cc
gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_basic.h
Log:
Fixed weak ptr reference error on shutdown. It was caused by having the
USRP go out of scope, then the daughterboard destuctors trying to issue
calls the the now dead USRP pointers. It is not possible to control the
destructor invocation order, so any daughterboard destructor activity
has been moved out of that place and put into a new function that must
be called prior to destruction.
A new libusrp API call, shutdown(), has now been created, and the user must
call this function as the last API call to ensure the daughterboards are
properly shutdown. This only affects libusrp users; the code for C++ and
Python users of gr-usrp will take care of this for them.
Note: The implementation for the XCVR2450 has not yet been done.
Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.cc
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.cc 2008-11-19
20:41:53 UTC (rev 10021)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.cc 2008-11-20
03:23:54 UTC (rev 10022)
@@ -44,6 +44,7 @@
usrp_base::~usrp_base()
{
+ d_usrp_basic->shutdown();
}
void
Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.cc
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.cc
2008-11-19 20:41:53 UTC (rev 10021)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.cc
2008-11-20 03:23:54 UTC (rev 10022)
@@ -42,6 +42,10 @@
{
}
+void
+db_base::shutdown()
+{
+}
db_base::~db_base()
{
Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.h
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.h
2008-11-19 20:41:53 UTC (rev 10021)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.h
2008-11-20 03:23:54 UTC (rev 10022)
@@ -91,7 +91,7 @@
virtual bool set_enable(bool on);
virtual bool set_auto_tr(bool on);
virtual bool select_rx_antenna(int which_antenna);
-
+ virtual void shutdown();
};
Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_dbs_rx.cc
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_dbs_rx.cc
2008-11-19 20:41:53 UTC (rev 10021)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_dbs_rx.cc
2008-11-20 03:23:54 UTC (rev 10022)
@@ -64,11 +64,14 @@
bypass_adc_buffers(true);
}
+void
+db_dbs_rx::shutdown()
+{
+ _enable_refclk(false);
+}
+
db_dbs_rx::~db_dbs_rx()
{
- if(usrp()) {
- _enable_refclk(false);
- }
}
void
Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_dbs_rx.h
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_dbs_rx.h
2008-11-19 20:41:53 UTC (rev 10021)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_dbs_rx.h
2008-11-20 03:23:54 UTC (rev 10022)
@@ -74,6 +74,7 @@
struct freq_result_t set_freq(double freq);
bool set_gain(float gain);
bool is_quadrature();
+ void shutdown();
};
#endif
Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_flexrf.cc
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_flexrf.cc
2008-11-19 20:41:53 UTC (rev 10021)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_flexrf.cc
2008-11-20 03:23:54 UTC (rev 10022)
@@ -273,7 +273,8 @@
set_gain((gain_min() + gain_max()) / 2.0); // initialize gain
}
-flexrf_base_tx::~flexrf_base_tx()
+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));
@@ -286,6 +287,10 @@
set_auto_tr(false);
}
+flexrf_base_tx::~flexrf_base_tx()
+{
+}
+
bool
flexrf_base_tx::set_auto_tr(bool on)
{
@@ -382,8 +387,11 @@
set_lo_offset(-4e6);
}
-flexrf_base_rx::~flexrf_base_rx()
+void
+flexrf_base_rx::shutdown()
{
+ fprintf(stderr, "flexrf_base_rx::shutdown()\n");
+
// Power down
usrp()->common_write_io(C_RX, d_which, power_off(), (POWER_UP|ENABLE));
@@ -395,6 +403,9 @@
set_auto_tr(false);
}
+flexrf_base_rx::~flexrf_base_rx()
+{
+}
bool
flexrf_base_rx::set_auto_tr(bool on)
Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_flexrf.h
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_flexrf.h
2008-11-19 20:41:53 UTC (rev 10021)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_flexrf.h
2008-11-20 03:23:54 UTC (rev 10022)
@@ -86,6 +86,8 @@
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
@@ -98,6 +100,8 @@
bool select_rx_antenna(int which_antenna);
bool select_rx_antenna(const std::string &which_antenna);
bool set_gain(float gain);
+
+ void shutdown();
};
// ----------------------------------------------------------------
Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_wbx.cc
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_wbx.cc
2008-11-19 20:41:53 UTC (rev 10021)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_wbx.cc
2008-11-20 03:23:54 UTC (rev 10022)
@@ -80,11 +80,16 @@
}
+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
+}
+
wbx_base::~wbx_base()
{
- //d_usrp->write_io(d_which, d_power_off, POWER_UP) // turn off power to
board
- //d_usrp->_write_oe(d_which, 0, 0xffff) // turn off all outputs
- set_auto_tr(false);
}
bool
Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_wbx.h
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_wbx.h
2008-11-19 20:41:53 UTC (rev 10021)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_wbx.h
2008-11-20 03:23:54 UTC (rev 10022)
@@ -55,6 +55,8 @@
bool set_gain(float gain);
bool is_quadrature();
+ void shutdown();
+
protected:
virtual bool _lock_detect();
Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_basic.cc
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_basic.cc
2008-11-19 20:41:53 UTC (rev 10021)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_basic.cc
2008-11-20 03:23:54 UTC (rev 10022)
@@ -156,9 +156,20 @@
_write_fpga_reg (FR_DEBUG_EN, 0); // disable debug outputs
}
+void
+usrp_basic::shutdown()
+{
+ // 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++)
+ d_db[i][j]->shutdown();
+}
+
usrp_basic::~usrp_basic ()
{
- d_db.resize(0); // nuke d'boards before we close down USB
+ d_db.resize(0); // forget db weak ptrs
if (d_udh)
usb_close (d_udh);
Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_basic.h
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_basic.h
2008-11-19 20:41:53 UTC (rev 10021)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_basic.h
2008-11-20 03:23:54 UTC (rev 10022)
@@ -1,3 +1,4 @@
+
/* -*- c++ -*- */
/*
* Copyright 2003,2004,2008 Free Software Foundation, Inc.
@@ -148,6 +149,13 @@
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. Regular gr-usrp users will have
this
+ * done for them.
+ */
+ 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] r10022 - in gnuradio/branches/features/cppdb: gr-usrp/src usrp/host/lib/legacy,
jcorgan <=