commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10045 - gnuradio/branches/features/cppdb/gr-usrp/src


From: jcorgan
Subject: [Commit-gnuradio] r10045 - gnuradio/branches/features/cppdb/gr-usrp/src
Date: Mon, 24 Nov 2008 13:18:30 -0700 (MST)

Author: jcorgan
Date: 2008-11-24 13:18:30 -0700 (Mon, 24 Nov 2008)
New Revision: 10045

Modified:
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp.i
   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-usrp/src/usrp_sink_base.cc
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.h
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.i
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.cc
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.h
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.i
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_standard.i
Log:
Adds pick_* methods to C++ and Python APIs

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp.i 2008-11-24 18:06:10 UTC 
(rev 10044)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp.i 2008-11-24 20:18:30 UTC 
(rev 10045)
@@ -60,6 +60,21 @@
     ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1])
     return self._real_determine_rx_mux_value(ss)
 
+# Allow subdev_spec to be tuple
+def __pick_subdev(self, candidates=[]):
+    ss = self._real_pick_subdev(candidates)
+    return (ss.side, ss.subdev)
+
+# Allow subdev_spec to be tuple
+def __pick_tx_subdev(self):
+    ss = self._real_pick_tx_subdev()
+    return (ss.side, ss.subdev)
+
+# Allow subdev_spec to be tuple
+def __pick_rx_subdev(self):
+    ss = self._real_pick_rx_subdev()
+    return (ss.side, ss.subdev)
+
 # Make return tune_result or None on failure
 def __tune(self, chan, db, target_freq):
     tr = usrp_tune_result()
@@ -81,6 +96,18 @@
 def selected_subdev(u, subdev_spec):
     return u.selected_subdev(subdev_spec)
 
+# Allow to be called as free function
+def pick_subdev(u, candidates=[]):
+    return u.pick_subdev(candidates);
+
+# Allow to be called as free function
+def pick_tx_subdev(u):
+    return u.pick_tx_subdev();
+
+# Allow to be called as free function
+def pick_rx_subdev(u):
+    return u.pick_rx_subdev();
+
 # Jam into Python objects
 usrp_sink_c_sptr.determine_tx_mux_value   = __determine_tx_mux_value
 usrp_sink_s_sptr.determine_tx_mux_value   = __determine_tx_mux_value
@@ -98,4 +125,14 @@
 usrp_source_c_sptr.tune                   = __tune
 usrp_source_s_sptr.tune                   = __tune
 
+usrp_sink_c_sptr.pick_subdev              = __pick_subdev
+usrp_sink_s_sptr.pick_subdev              = __pick_subdev
+usrp_source_c_sptr.pick_subdev            = __pick_subdev
+usrp_source_s_sptr.pick_subdev            = __pick_subdev
+
+usrp_sink_c_sptr.pick_tx_subdev           = __pick_tx_subdev
+usrp_sink_s_sptr.pick_tx_subdev           = __pick_tx_subdev
+usrp_source_c_sptr.pick_rx_subdev         = __pick_rx_subdev
+usrp_source_s_sptr.pick_rx_subdev         = __pick_rx_subdev
+
 %}

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.cc
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.cc   2008-11-24 
18:06:10 UTC (rev 10044)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.cc   2008-11-24 
20:18:30 UTC (rev 10045)
@@ -293,3 +293,25 @@
 {
   return d_usrp_basic->_read_spi (optional_header, enables, format, len);
 }
+
+usrp_subdev_spec
+usrp_base::pick_subdev(std::vector<int> candidates)
+{
+  int dbid0 = db(0, 0)->dbid();
+  int dbid1 = db(1, 0)->dbid();
+
+  for (int i = 0; i < candidates.size(); i++) {
+    int dbid = candidates[i];
+    if (dbid0 == dbid)
+      return usrp_subdev_spec(0, 0);
+    if (dbid1 == dbid)
+      return usrp_subdev_spec(1, 0);
+  }
+
+  if (dbid0 >= 0)
+    return usrp_subdev_spec(0, 0);
+  if (dbid1 >= 0)
+    return usrp_subdev_spec(1, 0);
+
+  throw std::runtime_error("No suitable daughterboard found!");
+}

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.h
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.h    2008-11-24 
18:06:10 UTC (rev 10044)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.h    2008-11-24 
20:18:30 UTC (rev 10045)
@@ -428,6 +428,16 @@
    * the peripheral and returned.
    */
   std::string _read_spi (int optional_header, int enables, int format, int 
len);
+
+  /*!
+   * Return an existing daughterboard from list of candidate dbids, or the 
first found
+   * on side A or side B.
+   *
+   * \param candidates          Vector of candidate dbids
+   * 
+   * Throws std::runtime_error if not found
+   */
+  usrp_subdev_spec pick_subdev(std::vector<int> 
candidates=std::vector<int>(0));
 };
 
 #endif /* INCLUDED_USRP_BASE_H */

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.i    2008-11-24 
18:06:10 UTC (rev 10044)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.i    2008-11-24 
20:18:30 UTC (rev 10045)
@@ -77,4 +77,7 @@
   int  _read_9862 (int which_codec, int regno) const;
   bool _write_spi (int optional_header, int enables, int format, std::string 
buf);
   std::string _read_spi (int optional_header, int enables, int format, int 
len);
+  %rename(_real_pick_subdev) pick_subdev;
+  usrp_subdev_spec pick_subdev(std::vector<int> candidates=std::vector<int>(0))
+    throw (std::runtime_error);
 };

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.cc
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.cc      
2008-11-24 18:06:10 UTC (rev 10044)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.cc      
2008-11-24 20:18:30 UTC (rev 10045)
@@ -224,3 +224,18 @@
 {
   return d_usrp->tune(chan, db, target_freq, result);
 }
+
+usrp_subdev_spec
+usrp_sink_base::pick_tx_subdev()
+{
+  int dbids[] = {
+    USRP_DBID_FLEX_400_TX,
+    USRP_DBID_FLEX_900_TX,
+    USRP_DBID_FLEX_1200_TX,
+    USRP_DBID_FLEX_2400_TX,
+    USRP_DBID_BASIC_TX
+  };
+
+  std::vector<int> candidates(dbids, dbids+(sizeof(dbids)/sizeof(int)));
+  return pick_subdev(candidates);
+}

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.h
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.h       
2008-11-24 18:06:10 UTC (rev 10044)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.h       
2008-11-24 20:18:30 UTC (rev 10045)
@@ -1,3 +1,4 @@
+
 /* -*- c++ -*- */
 /*
  * Copyright 2004,2006,2008 Free Software Foundation, Inc.
@@ -26,6 +27,7 @@
 #include <usrp_base.h>
 #include <stdexcept>
 #include <usrp_tune_result.h>
+#include <usrp_dbid.h>
 
 class usrp_standard_tx;
 
@@ -139,6 +141,11 @@
    * \returns true iff everything was successful.
    */
   bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result 
*result);
+
+  /*!
+   * \brief Select suitable Tx daughterboard
+   */
+  usrp_subdev_spec pick_tx_subdev();
 };
 
 #endif /* INCLUDED_USRP_SINK_BASE_H */

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.i       
2008-11-24 18:06:10 UTC (rev 10044)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.i       
2008-11-24 20:18:30 UTC (rev 10045)
@@ -49,4 +49,6 @@
   int nducs();
   %rename(_real_tune) tune;
   bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result 
*result);
+  %rename(_real_pick_tx_subdev) pick_tx_subdev();
+  usrp_subdev_spec pick_tx_subdev();
 };

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.cc
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.cc    
2008-11-24 18:06:10 UTC (rev 10044)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.cc    
2008-11-24 20:18:30 UTC (rev 10045)
@@ -274,3 +274,22 @@
 {
   return d_usrp->tune(chan, db, target_freq, result);
 }
+
+usrp_subdev_spec
+usrp_source_base::pick_rx_subdev()
+{
+  int dbids[] = {
+    USRP_DBID_FLEX_400_RX,
+    USRP_DBID_FLEX_900_RX,
+    USRP_DBID_FLEX_1200_RX,
+    USRP_DBID_FLEX_2400_RX,
+    USRP_DBID_TV_RX,
+    USRP_DBID_TV_RX_REV_2,
+    USRP_DBID_DBS_RX,
+    USRP_DBID_DBS_RX_REV_2_1,
+    USRP_DBID_BASIC_RX
+  };
+
+  std::vector<int> candidates(dbids, dbids+(sizeof(dbids)/sizeof(int)));
+  return pick_subdev(candidates);
+}

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.h
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.h     
2008-11-24 18:06:10 UTC (rev 10044)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.h     
2008-11-24 20:18:30 UTC (rev 10045)
@@ -26,6 +26,7 @@
 #include <usrp_base.h>
 #include <stdexcept>
 #include <usrp_tune_result.h>
+#include <usrp_dbid.h>
 
 class usrp_standard_rx;
 
@@ -208,6 +209,11 @@
    * \returns true iff everything was successful.
    */
   bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result 
*result);
+
+  /*!
+   * \brief Select suitable Rx daughterboard
+   */
+  usrp_subdev_spec pick_rx_subdev();
 };
 
 #endif /* INCLUDED_USRP_SOURCE_BASE_H */

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.i     
2008-11-24 18:06:10 UTC (rev 10044)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.i     
2008-11-24 20:18:30 UTC (rev 10045)
@@ -58,4 +58,6 @@
   static bool format_bypass_halfband(unsigned int format);
   %rename(_real_tune) tune;
   bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result 
*result);
+  %rename(_real_pick_rx_subdev) pick_rx_subdev();
+  usrp_subdev_spec pick_rx_subdev();
 };

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_standard.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_standard.i        
2008-11-24 18:06:10 UTC (rev 10044)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_standard.i        
2008-11-24 20:18:30 UTC (rev 10045)
@@ -25,9 +25,11 @@
 %{
 #include <usrp_standard.h>
 #include <usrp_spi_defs.h>
+#include <usrp_dbid.h>
 %}
 
 %include <usrp_spi_defs.h>
+%include <usrp_dbid.h>
 
 %constant int FPGA_MODE_NORMAL   = usrp_standard_rx::FPGA_MODE_NORMAL;
 %constant int FPGA_MODE_LOOPBACK = usrp_standard_rx::FPGA_MODE_LOOPBACK;





reply via email to

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