commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10967 - gnuradio/branches/developers/eb/t371/usrp/hos


From: eb
Subject: [Commit-gnuradio] r10967 - gnuradio/branches/developers/eb/t371/usrp/host/lib/legacy
Date: Tue, 5 May 2009 16:40:00 -0600 (MDT)

Author: eb
Date: 2009-05-05 16:39:59 -0600 (Tue, 05 May 2009)
New Revision: 10967

Modified:
   gnuradio/branches/developers/eb/t371/usrp/host/lib/legacy/db_xcvr2450.cc
   gnuradio/branches/developers/eb/t371/usrp/host/lib/legacy/db_xcvr2450.h
Log:
Works in tx only and rx only cases.  Need to test with both tx and rx open.


Modified: 
gnuradio/branches/developers/eb/t371/usrp/host/lib/legacy/db_xcvr2450.cc
===================================================================
--- gnuradio/branches/developers/eb/t371/usrp/host/lib/legacy/db_xcvr2450.cc    
2009-05-05 22:37:03 UTC (rev 10966)
+++ gnuradio/branches/developers/eb/t371/usrp/host/lib/legacy/db_xcvr2450.cc    
2009-05-05 22:39:59 UTC (rev 10967)
@@ -77,9 +77,10 @@
 class xcvr2450
 {
 private:
-  boost::weak_ptr<usrp_basic> d_weak_usrp;
+  usrp_basic *d_raw_usrp;
   int d_which;
 
+  bool d_is_shutdown;
   int d_spi_format, d_spi_enable;
   
   int d_mimo, d_int_div, d_frac_div, d_highband, d_five_gig;
@@ -102,13 +103,14 @@
   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
+  usrp_basic *usrp(){
+    return d_raw_usrp;
   }
 
 public:
   xcvr2450(usrp_basic_sptr usrp, int which);
   ~xcvr2450();
+  void shutdown();
 
   void set_reg_standby();
   
@@ -158,7 +160,7 @@
 
 
 xcvr2450::xcvr2450(usrp_basic_sptr _usrp, int which)
-  : d_weak_usrp(_usrp), d_which(which)
+  : d_raw_usrp(_usrp.get()), d_which(which), d_is_shutdown(false)
 {
   // Handler for Tv Rx daughterboards.
   // 
@@ -237,13 +239,23 @@
 xcvr2450::~xcvr2450()
 {
   //printf("xcvr2450::destructor\n");
-  usrp()->common_write_atr_txval(C_TX, d_which, TX_SAFE_IO);
-  usrp()->common_write_atr_rxval(C_TX, d_which, TX_SAFE_IO);
-  usrp()->common_write_atr_txval(C_RX, d_which, RX_SAFE_IO);
-  usrp()->common_write_atr_rxval(C_RX, d_which, RX_SAFE_IO);
+  shutdown();
 }
 
 void
+xcvr2450::shutdown()
+{
+  if (!d_is_shutdown){
+    d_is_shutdown = true;
+    usrp()->common_write_atr_txval(C_TX, d_which, TX_SAFE_IO);
+    usrp()->common_write_atr_rxval(C_TX, d_which, TX_SAFE_IO);
+    usrp()->common_write_atr_txval(C_RX, d_which, RX_SAFE_IO);
+    usrp()->common_write_atr_rxval(C_RX, d_which, RX_SAFE_IO);
+  }
+}
+
+
+void
 xcvr2450::set_reg_standby()
 {
   d_reg_standby = ((d_mimo<<17) | 
@@ -578,7 +590,6 @@
       p = s_table.erase(p);    // erase it
     else {
       if (key == p->key){      // found it
-       std::cerr << "found xcvr2450\n";
        return xcvr2450_sptr(p->value);
       }
       else                     
@@ -593,8 +604,6 @@
   xcvr2450_table_entry t(key, r);
   s_table.push_back(t);
 
-  std::cerr << "make new xcvr2450\n";
-
   return r;
 }
 
@@ -622,6 +631,18 @@
 {
 }
 
+void
+db_xcvr2450_base::shutdown_common()
+{
+  std::cerr << "db_xcvr2450_base::shutdown_common: d_xcvr.use_count = "
+           << d_xcvr.use_count() << std::endl;
+
+  // If we're the last user of d_xcvr, shut it down
+  if (d_xcvr.use_count() == 1){
+    d_xcvr->shutdown();
+  }
+}
+
 struct freq_result_t
 db_xcvr2450_base::set_freq(double target_freq)
 {
@@ -669,8 +690,18 @@
 
 db_xcvr2450_tx::~db_xcvr2450_tx()
 {
+  shutdown();
 }
 
+void
+db_xcvr2450_tx::shutdown()
+{
+  if (!d_is_shutdown){
+    d_is_shutdown = true;
+    shutdown_common();
+  }
+}
+
 float
 db_xcvr2450_tx::gain_min()
 {
@@ -718,8 +749,18 @@
 
 db_xcvr2450_rx::~db_xcvr2450_rx()
 {
+  shutdown();
 }
 
+void
+db_xcvr2450_rx::shutdown()
+{
+  if (!d_is_shutdown){
+    d_is_shutdown = true;
+    shutdown_common();
+  }
+}
+
 float
 db_xcvr2450_rx::gain_min()
 {

Modified: 
gnuradio/branches/developers/eb/t371/usrp/host/lib/legacy/db_xcvr2450.h
===================================================================
--- gnuradio/branches/developers/eb/t371/usrp/host/lib/legacy/db_xcvr2450.h     
2009-05-05 22:37:03 UTC (rev 10966)
+++ gnuradio/branches/developers/eb/t371/usrp/host/lib/legacy/db_xcvr2450.h     
2009-05-05 22:39:59 UTC (rev 10967)
@@ -49,6 +49,7 @@
 
 protected:
   xcvr2450_sptr d_xcvr;
+  void shutdown_common();
 };
 
 
@@ -57,6 +58,9 @@
 
 class db_xcvr2450_tx : public db_xcvr2450_base
 {
+protected:
+  void shutdown();
+
 public:
   db_xcvr2450_tx(usrp_basic_sptr usrp, int which);
   ~db_xcvr2450_tx();
@@ -70,6 +74,9 @@
 
 class db_xcvr2450_rx : public db_xcvr2450_base
 {
+protected:
+  void shutdown();
+
 public:
   db_xcvr2450_rx(usrp_basic_sptr usrp, int which);
   ~db_xcvr2450_rx();





reply via email to

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