commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9259 - gnuradio/branches/developers/trondeau/dbs/gr-u


From: trondeau
Subject: [Commit-gnuradio] r9259 - gnuradio/branches/developers/trondeau/dbs/gr-usrp/src
Date: Tue, 12 Aug 2008 15:09:18 -0600 (MDT)

Author: trondeau
Date: 2008-08-12 15:09:18 -0600 (Tue, 12 Aug 2008)
New Revision: 9259

Modified:
   gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1.i
   gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.cc
   gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.h
   gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.i
   gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_sink_base.cc
   gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_sink_base.h
   gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_source_base.cc
   gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_source_base.h
Log:
wip: more cleanup and using auto_ptr for d_usrp objects.

Modified: gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1.i
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1.i       
2008-08-12 21:08:52 UTC (rev 9258)
+++ gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1.i       
2008-08-12 21:09:18 UTC (rev 9259)
@@ -34,6 +34,7 @@
 #include "usrp1_sink_c.h"
 #include "usrp_standard.h"
 #include "usrp_spi_defs.h"
+#include <db_base.h>
 #include <stdexcept>
 %}
 
@@ -41,8 +42,9 @@
 %include <usrp1_base.i>
 %include <usrp1_source.i>
 %include <usrp1_sink.i>
-//%include <db1_base.i>
 
+%include <db_base.i>
+
 %constant int FPGA_MODE_NORMAL   = usrp_standard_rx::FPGA_MODE_NORMAL;
 %constant int FPGA_MODE_LOOPBACK = usrp_standard_rx::FPGA_MODE_LOOPBACK;
 %constant int FPGA_MODE_COUNTING = usrp_standard_rx::FPGA_MODE_COUNTING;

Modified: gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.cc
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.cc 
2008-08-12 21:08:52 UTC (rev 9258)
+++ gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.cc 
2008-08-12 21:09:18 UTC (rev 9259)
@@ -152,7 +152,6 @@
 
   // compute bitmasks of used A/D's
   
-  printf("db[0].is_quadrature(): %d\n", db[0]->is_quadrature());
   if(db[0]->is_quadrature()) {
     subdev0_uses = 0x3;               // uses A/D 0 and 1
   }
@@ -253,9 +252,7 @@
     @returns: an weakref to an instance derived from db_base
   */
 
-  // FIXME: make sure we don't leave this in memory
-  return &d_usrp->db(subdev_spec[0])[subdev_spec[1]];
-  //return d_db;
+  return d_usrp->db(subdev_spec[0])[subdev_spec[1]];
 }
 #endif
 

Modified: gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.h
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.h  
2008-08-12 21:08:52 UTC (rev 9258)
+++ gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.h  
2008-08-12 21:09:18 UTC (rev 9259)
@@ -202,7 +202,7 @@
    * \returns true iff successful
    * Writes are limited to a maximum of of 64 bytes.
    */
-  virtual bool write_i2c (int i2c_addr, const std::string buf) { 
printf("usrp1_base::i2c\n"); return false;}
+  virtual bool write_i2c (int i2c_addr, const std::string buf) { return false;}
 
   /*!
    * \brief Read from I2C peripheral

Modified: gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.i
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.i  
2008-08-12 21:08:52 UTC (rev 9258)
+++ gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_base.i  
2008-08-12 21:09:18 UTC (rev 9259)
@@ -27,8 +27,10 @@
 // ================================================================
 //                        abstract classes
 // ================================================================
+namespace std {
+  %template() vector<db_base_sptr>; 
+}
 
-
 class usrp1_base : public gr_sync_block
 {
  private:
@@ -44,6 +46,8 @@
 
   virtual ~usrp1_base ();
 
+  std::vector<db_base_sptr> db(int which);
+
   int determine_tx_mux_value(const std::vector<int> &subdev_spec);
   int determine_rx_mux_value(const std::vector<int> &subdev_spec);
   db_base_sptr selected_subdev(const std::vector<int> &subdev_spec);

Modified: 
gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_sink_base.cc
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_sink_base.cc    
2008-08-12 21:08:52 UTC (rev 9258)
+++ gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_sink_base.cc    
2008-08-12 21:09:18 UTC (rev 9259)
@@ -43,17 +43,13 @@
                                  const std::string firmware_filename
                                  ) throw (std::runtime_error)
   : usrp1_base(name, input_signature, gr_make_io_signature (0, 0, 0)),
-    d_nunderruns (0)
+    d_nunderruns (0), 
+    d_usrp(usrp_standard_tx::make (which_board, interp_rate,
+                                  nchan, mux, fusb_block_size,
+                                  fusb_nblocks, fpga_filename,
+                                  firmware_filename))
 {
-  d_usrp = usrp_standard_tx::make (which_board,
-                                  interp_rate,
-                                  nchan, mux,
-                                  fusb_block_size,
-                                  fusb_nblocks,
-                                  fpga_filename,
-                                  firmware_filename
-                                  );
-  if (d_usrp == 0)
+  if (!d_usrp.get())
     throw std::runtime_error ("can't open usrp1");
 
   // All calls to d_usrp->write must be multiples of 512 bytes.
@@ -63,7 +59,6 @@
 
 usrp1_sink_base::~usrp1_sink_base ()
 {
-  delete d_usrp;
 }
 
 bool 

Modified: 
gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_sink_base.h
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_sink_base.h     
2008-08-12 21:08:52 UTC (rev 9258)
+++ gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_sink_base.h     
2008-08-12 21:09:18 UTC (rev 9259)
@@ -25,6 +25,7 @@
 
 #include <usrp1_base.h>
 #include <stdexcept>
+#include <memory>
 
 class usrp_standard_tx;
 
@@ -47,8 +48,8 @@
                   const std::string firmware_filename
                   ) throw (std::runtime_error);
 
-  usrp_standard_tx     *d_usrp;
-  int                   d_nunderruns;
+  int d_nunderruns;
+  std::auto_ptr<usrp_standard_tx> d_usrp;
 
   /*!
    * \brief convert between input item format and usrp native format

Modified: 
gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_source_base.cc
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_source_base.cc  
2008-08-12 21:08:52 UTC (rev 9258)
+++ gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_source_base.cc  
2008-08-12 21:09:18 UTC (rev 9259)
@@ -44,18 +44,16 @@
                                      const std::string firmware_filename
                                      ) throw (std::runtime_error)
   : usrp1_base(name, gr_make_io_signature (0, 0, 0), output_signature),
-    d_noverruns (0)
+    d_noverruns (0), 
+    d_usrp(usrp_standard_rx::make (which_board, decim_rate,nchan, mux, mode,
+                                  fusb_block_size, fusb_nblocks,
+                                  fpga_filename, firmware_filename))
 {
-  d_usrp = usrp_standard_rx::make (which_board, decim_rate,
-                                  nchan, mux, mode,
-                                  fusb_block_size,
-                                  fusb_nblocks,
-                                  fpga_filename,
-                                  firmware_filename);
-
-  if (d_usrp == 0)
+  if (!d_usrp.get())
     throw std::runtime_error ("can't open usrp1");
 
+  std::vector<db_base_sptr> dbtmp = d_usrp->db(0);
+  
   // All calls to d_usrp->read must be multiples of 512 bytes.
   // We jack this up to 4k to reduce overhead.
 
@@ -64,17 +62,9 @@
 
 usrp1_source_base::~usrp1_source_base ()
 {
-
-  delete d_usrp;
+  //delete d_usrp;
 }
 
-std::vector<db_base_sptr>
-usrp1_source_base::db(int which)
-{
-  return d_usrp->db(which);
-}
-
-
 int
 usrp1_source_base::determine_rx_mux_value(const std::vector<int> &subdev_spec)
 {
@@ -119,7 +109,6 @@
 
   // compute bitmasks of used A/D's
   
-  printf("db[0].is_quadrature(): %d\n", db[0]->is_quadrature());
   if(db[0]->is_quadrature()) {
     subdev0_uses = 0x3;               // uses A/D 0 and 1
   }
@@ -184,7 +173,8 @@
     @returns: an weakref to an instance derived from db_base
   */
 
-  return d_usrp->db(subdev_spec[0])[subdev_spec[1]];
+  std::vector<db_base_sptr> db1 = d_usrp->db(subdev_spec[0]);
+  return db1[subdev_spec[1]];
 }
 
 

Modified: 
gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_source_base.h
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_source_base.h   
2008-08-12 21:08:52 UTC (rev 9258)
+++ gnuradio/branches/developers/trondeau/dbs/gr-usrp/src/usrp1_source_base.h   
2008-08-12 21:09:18 UTC (rev 9259)
@@ -25,6 +25,7 @@
 
 #include <usrp1_base.h>
 #include <stdexcept>
+#include <memory>
 
 class usrp_standard_rx;
 
@@ -48,8 +49,8 @@
                     ) throw (std::runtime_error);
 
 
-  usrp_standard_rx     *d_usrp;
-  int                   d_noverruns;
+  int d_noverruns;
+  std::auto_ptr<usrp_standard_rx> d_usrp;
 
   /*!
    * \brief return number of usrp input bytes required to produce noutput 
items.
@@ -89,7 +90,7 @@
 
   ~usrp1_source_base ();
 
-  std::vector<db_base_sptr> db(int which);
+  //std::vector<db_base_sptr> db(int which);
   int determine_rx_mux_value(const std::vector<int> &subdev_spec);
   db_base_sptr selected_subdev(const std::vector<int> &subdev_spec);
 





reply via email to

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