commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10042 - in gnuradio/branches/features/cppdb: gnuradio


From: jcorgan
Subject: [Commit-gnuradio] r10042 - in gnuradio/branches/features/cppdb: gnuradio-examples/python/apps/hf_explorer gnuradio-examples/python/dect gnuradio-examples/python/multi-antenna gnuradio-examples/python/multi_usrp gnuradio-examples/python/usrp gr-usrp/src gr-utils/src/python usrp/host/lib/legacy
Date: Mon, 24 Nov 2008 10:39:26 -0700 (MST)

Author: jcorgan
Date: 2008-11-24 10:39:25 -0700 (Mon, 24 Nov 2008)
New Revision: 10042

Modified:
   
gnuradio/branches/features/cppdb/gnuradio-examples/python/apps/hf_explorer/hfx2.py
   gnuradio/branches/features/cppdb/gnuradio-examples/python/dect/usrp_source.py
   
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_fft.py
   
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_file.py
   
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_scope.py
   
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi_usrp/multi_usrp_oscope.py
   
gnuradio/branches/features/cppdb/gnuradio-examples/python/usrp/fm_tx_2_daughterboards.py
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.cc
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.h
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.i
   gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_fft.py
   gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_oscope.py
   gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.i
   gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_basic.h
Log:
Extend C++ API db() call into Python.  This changes the Python API from 
referencing a db instance variable to calling a db instance function. Changes 
to gr-utils and gnuradio-examples are done.

Modified: 
gnuradio/branches/features/cppdb/gnuradio-examples/python/apps/hf_explorer/hfx2.py
===================================================================
--- 
gnuradio/branches/features/cppdb/gnuradio-examples/python/apps/hf_explorer/hfx2.py
  2008-11-23 22:22:15 UTC (rev 10041)
+++ 
gnuradio/branches/features/cppdb/gnuradio-examples/python/apps/hf_explorer/hfx2.py
  2008-11-24 17:39:25 UTC (rev 10042)
@@ -118,9 +118,9 @@
     If there's a daughterboard on B, select B.
     Otherwise, select A.
     """
-    if u.db[0][0].dbid() >= 0:       # dbid is < 0 if there's no d'board or a 
problem
+    if u.db(0, 0).dbid() >= 0:       # dbid is < 0 if there's no d'board or a 
problem
         return (0, 0)
-    if u.db[1][0].dbid() >= 0:
+    if u.db(1, 0).dbid() >= 0:
         return (1, 0)
     return (0, 0)
 

Modified: 
gnuradio/branches/features/cppdb/gnuradio-examples/python/dect/usrp_source.py
===================================================================
--- 
gnuradio/branches/features/cppdb/gnuradio-examples/python/dect/usrp_source.py   
    2008-11-23 22:22:15 UTC (rev 10041)
+++ 
gnuradio/branches/features/cppdb/gnuradio-examples/python/dect/usrp_source.py   
    2008-11-24 17:39:25 UTC (rev 10042)
@@ -64,9 +64,9 @@
         If there's a daughterboard on B, select B.
         Otherwise, select A.
         """
-        if self._u.db[0][0].dbid() >= 0:       # dbid is < 0 if there's no 
d'board or a problem
+        if self._u.db(0, 0).dbid() >= 0:       # dbid is < 0 if there's no 
d'board or a problem
             return (0, 0)
-        if self._u.db[1][0].dbid() >= 0:
+        if self._u.db(1, 0).dbid() >= 0:
             return (1, 0)
         return (0, 0)
 

Modified: 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_fft.py
===================================================================
--- 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_fft.py
        2008-11-23 22:22:15 UTC (rev 10041)
+++ 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_fft.py
        2008-11-24 17:39:25 UTC (rev 10042)
@@ -62,11 +62,11 @@
         print "USB data rate   = %s" % (eng_notation.num_to_str(input_rate),)
         print "Scope data rate = %s" % 
(eng_notation.num_to_str(input_rate/sw_decim),)
 
-        self.subdev = self.u.db[0] + self.u.db[1]
+        self.subdev = self.u.db(0) + self.u.db(1)
 
         if (len (self.subdev) != 4 or
-            self.u.db[0][0].dbid() != usrp_dbid.BASIC_RX or
-            self.u.db[1][0].dbid() != usrp_dbid.BASIC_RX):
+            self.u.db(0, 0).dbid() != usrp_dbid.BASIC_RX or
+            self.u.db(0, 0).dbid() != usrp_dbid.BASIC_RX):
             sys.stderr.write('This code requires a Basic Rx board on Sides A & 
B\n')
             sys.exit(1)
 

Modified: 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_file.py
===================================================================
--- 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_file.py
       2008-11-23 22:22:15 UTC (rev 10041)
+++ 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_file.py
       2008-11-24 17:39:25 UTC (rev 10042)
@@ -68,11 +68,11 @@
         sink_data_rate = input_rate/sw_decim
         print "Scope data rate = %s" % 
(eng_notation.num_to_str(sink_data_rate),)
 
-        self.subdev = self.u.db[0] + self.u.db[1]
+        self.subdev = self.u.db(0) + self.u.db(1)
 
         if (len(self.subdev) != 4 or
-            self.u.db[0][0].dbid() != usrp_dbid.BASIC_RX or
-            self.u.db[1][0].dbid() != usrp_dbid.BASIC_RX):
+            self.u.db(0, 0).dbid() != usrp_dbid.BASIC_RX or
+            self.u.db(1, 0).dbid() != usrp_dbid.BASIC_RX):
             sys.stderr.write('This code requires a Basic Rx board on Sides A & 
B\n')
             sys.exit(1)
 

Modified: 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_scope.py
===================================================================
--- 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_scope.py
      2008-11-23 22:22:15 UTC (rev 10041)
+++ 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi-antenna/multi_scope.py
      2008-11-24 17:39:25 UTC (rev 10042)
@@ -62,11 +62,11 @@
         print "USB data rate   = %s" % (eng_notation.num_to_str(input_rate),)
         print "Scope data rate = %s" % 
(eng_notation.num_to_str(input_rate/sw_decim),)
 
-        self.subdev = self.u.db[0] + self.u.db[1]
+        self.subdev = self.u.db(0) + self.u.db(1)
 
         if (len(self.subdev) != 4 or
-            self.u.db[0][0].dbid() != usrp_dbid.BASIC_RX or
-            self.u.db[1][0].dbid() != usrp_dbid.BASIC_RX):
+            self.u.db(0, 0).dbid() != usrp_dbid.BASIC_RX or
+            self.u.db(0, 0).dbid() != usrp_dbid.BASIC_RX):
             sys.stderr.write('This code requires a Basic Rx board on Sides A & 
B\n')
             sys.exit(1)
 

Modified: 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi_usrp/multi_usrp_oscope.py
===================================================================
--- 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi_usrp/multi_usrp_oscope.py
   2008-11-23 22:22:15 UTC (rev 10041)
+++ 
gnuradio/branches/features/cppdb/gnuradio-examples/python/multi_usrp/multi_usrp_oscope.py
   2008-11-24 17:39:25 UTC (rev 10042)
@@ -42,9 +42,9 @@
     If there's a daughterboard on B, select B.
     Otherwise, select A.
     """
-    if u.db[0][0].dbid() >= 0:       # dbid is < 0 if there's no d'board or a 
problem
+    if u.db(0, 0).dbid() >= 0:       # dbid is < 0 if there's no d'board or a 
problem
         return (0, 0)
-    if u.db[1][0].dbid() >= 0:
+    if u.db(0, 0).dbid() >= 0:
         return (1, 0)
     return (0, 0)
 

Modified: 
gnuradio/branches/features/cppdb/gnuradio-examples/python/usrp/fm_tx_2_daughterboards.py
===================================================================
--- 
gnuradio/branches/features/cppdb/gnuradio-examples/python/usrp/fm_tx_2_daughterboards.py
    2008-11-23 22:22:15 UTC (rev 10041)
+++ 
gnuradio/branches/features/cppdb/gnuradio-examples/python/usrp/fm_tx_2_daughterboards.py
    2008-11-24 17:39:25 UTC (rev 10042)
@@ -112,7 +112,7 @@
         self.usrp_rate = self.dac_rate / self.usrp_interp    # 320 kS/s
 
         # we're using both daughterboard slots, thus subdev is a 2-tuple
-        self.subdev = (self.u.db[0][0], self.u.db[1][0])
+        self.subdev = (self.u.db(0, 0), self.u.db(1, 0))
         print "Using TX d'board %s" % (self.subdev[0].side_and_name(),)
         print "Using TX d'board %s" % (self.subdev[1].side_and_name(),)
         

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.cc
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.cc   2008-11-23 
22:22:15 UTC (rev 10041)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.cc   2008-11-24 
17:39:25 UTC (rev 10042)
@@ -53,6 +53,11 @@
   d_usrp_basic = u;
 }
 
+std::vector<std::vector<db_base_sptr> >
+usrp_base::db()
+{
+  return d_usrp_basic->db();
+}
 
 std::vector<db_base_sptr> 
 usrp_base::db(int which_side)
@@ -61,6 +66,12 @@
 }
 
 db_base_sptr
+usrp_base::db(int which_side, int which_dev)
+{
+  return d_usrp_basic->selected_subdev(usrp_subdev_spec(which_side, 
which_dev));
+}
+
+db_base_sptr
 usrp_base::selected_subdev(usrp_subdev_spec ss)
 {
   return d_usrp_basic->selected_subdev(ss);

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.h
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.h    2008-11-23 
22:22:15 UTC (rev 10041)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.h    2008-11-24 
17:39:25 UTC (rev 10042)
@@ -48,6 +48,20 @@
 public:
   virtual ~usrp_base();
 
+  /* !
+   * Return a vector of vectors of daughterboard instances associated with
+   * the USRP source or sink.  The first dimension of the returned vector
+   * corresponds to the side of the USRP, the second dimension, the subdevice
+   * on the particular daughterboard.
+   *
+   * N.B. To ensure proper lifetime management, the caller should
+   * continue to hold these as weak pointers, not shared pointers.  
+   * As long as the caller does not attempt to directly use the weak
+   * pointers after this usrp object has been destroyed, everything
+   * will work out fine.
+   */
+   std::vector<std::vector<db_base_sptr> > db();
+
   /*!
    * Return a vector of size 1 or 2 that contains shared pointers
    * to the daughterboard instance(s) associated with the specified side.
@@ -63,6 +77,17 @@
   std::vector<db_base_sptr> db(int which_side);
 
   /*!
+   * Return the daughterboard instance corresponding to the selected
+   * side of the USRP and selected daughterboard subdevice.
+   * N.B. To ensure proper lifetime management, the caller should
+   * continue to hold these as weak pointers, not shared pointers.  
+   * As long as the caller does not attempt to directly use the weak
+   * pointers after this usrp object has been destroyed, everything
+   * will work out fine.
+   */
+  db_base_sptr db(int which_side, int which_dev);
+
+  /*!
    * \brief given a usrp_subdev_spec, return the corresponding daughterboard 
object.
    * \throws std::invalid_argument if ss is invalid.
    *

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.i    2008-11-23 
22:22:15 UTC (rev 10041)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.i    2008-11-24 
17:39:25 UTC (rev 10042)
@@ -33,7 +33,9 @@
     : gr_sync_block(name, input_signature, output_signature) {}
     
 public:
+  std::vector<std::vector<db_base_sptr> > db();
   std::vector<db_base_sptr> db(int which_side);
+  db_base_sptr db(int which_side, int chan);
   %rename (_real_selected_subdev) selected_subdev;
   db_base_sptr selected_subdev(usrp_subdev_spec ss);
   long  fpga_master_clock_freq() const;

Modified: gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_fft.py
===================================================================
--- gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_fft.py    
2008-11-23 22:22:15 UTC (rev 10041)
+++ gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_fft.py    
2008-11-24 17:39:25 UTC (rev 10042)
@@ -37,9 +37,9 @@
     If there's a daughterboard on B, select B.
     Otherwise, select A.
     """
-    if u.db[0][0].dbid() >= 0:       # dbid is < 0 if there's no d'board or a 
problem
+    if u.db(0, 0).dbid() >= 0:       # dbid is < 0 if there's no d'board or a 
problem
         return (0, 0)
-    if u.db[1][0].dbid() >= 0:
+    if u.db(0, 0).dbid() >= 0:
         return (1, 0)
     return (0, 0)
 

Modified: gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_oscope.py
===================================================================
--- gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_oscope.py 
2008-11-23 22:22:15 UTC (rev 10041)
+++ gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_oscope.py 
2008-11-24 17:39:25 UTC (rev 10042)
@@ -40,9 +40,10 @@
     If there's a daughterboard on B, select B.
     Otherwise, select A.
     """
-    if u.db[0][0].dbid() >= 0:       # dbid is < 0 if there's no d'board or a 
problem
+    db = u.db()
+    if db(0, 0).dbid() >= 0:       # dbid is < 0 if there's no d'board or a 
problem
         return (0, 0)
-    if u.db[1][0].dbid() >= 0:
+    if db(0, 0).dbid() >= 0:
         return (1, 0)
     return (0, 0)
 

Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.i
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.i     
2008-11-23 22:22:15 UTC (rev 10041)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.i     
2008-11-24 17:39:25 UTC (rev 10042)
@@ -84,10 +84,11 @@
   virtual void shutdown();
 };
 
+// Create templates for db's, vectors of db's, and vector of vectors of db's
 typedef boost::shared_ptr<db_base> db_base_sptr;
 %template(db_base_sptr) boost::shared_ptr<db_base>;
-
 %template(db_base_sptr_vector) std::vector<db_base_sptr>;
+%template(db_base_sptr_vector_vector) std::vector<std::vector<db_base_sptr> >;
 
 // Set better class name in Python
 // Enable freq_range and gain_range from public methods of class not 
implemented in C++

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-23 22:22:15 UTC (rev 10041)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_basic.h  
2008-11-24 17:39:25 UTC (rev 10042)
@@ -137,7 +137,17 @@
 public:
   virtual ~usrp_basic ();
 
+
   /*!
+   * Return a vector of vectors that contain shared pointers
+   * to the daughterboard instance(s) associated with the specified side.
+   *
+   * It is an error to use the returned objects after the usrp_basic
+   * object has been destroyed.
+   */
+  std::vector<std::vector<db_base_sptr> > db() const { return d_db; }
+
+  /*!
    * Return a vector of size >= 1 that contains shared pointers
    * to the daughterboard instance(s) associated with the specified side.
    *
@@ -147,11 +157,10 @@
    * object has been destroyed.
    */
   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.
+   * prior to the destructor being invoked.
    */
   void shutdown();
 





reply via email to

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