commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10031 - in gnuradio/branches/features/cppdb: gr-usrp/


From: jcorgan
Subject: [Commit-gnuradio] r10031 - in gnuradio/branches/features/cppdb: gr-usrp/src gr-utils/src/python usrp/host/lib/legacy
Date: Fri, 21 Nov 2008 20:39:30 -0700 (MST)

Author: jcorgan
Date: 2008-11-21 20:39:26 -0700 (Fri, 21 Nov 2008)
New Revision: 10031

Removed:
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_shim.py
Modified:
   gnuradio/branches/features/cppdb/gr-usrp/src/Makefile.am
   gnuradio/branches/features/cppdb/gr-usrp/src/__init__.py
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp.i
   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.h
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.i
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_c.i
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_s.i
   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_source_c.i
   gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_s.i
   gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_siggen.py
   gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.i
   gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_standard.cc
Log:
wip, Python API mostly complete, lacks 'pick subdev' utilities and keyword 
argument passing

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/Makefile.am
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/Makefile.am    2008-11-22 
01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/Makefile.am    2008-11-22 
03:39:26 UTC (rev 10031)
@@ -94,7 +94,6 @@
 
 ourlib_PYTHON = \
        __init__.py \
-       usrp_shim.py \
        usrp_swig.py
 
 _usrp_swig_la_SOURCES =        \

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/__init__.py
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/__init__.py    2008-11-22 
01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/__init__.py    2008-11-22 
03:39:26 UTC (rev 10031)
@@ -25,4 +25,4 @@
 from usrp_swig import *
 
 # Add other content from pure-Python modules here
-from usrp_shim import *
+

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp.i 2008-11-22 01:31:35 UTC 
(rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp.i 2008-11-22 03:39:26 UTC 
(rev 10031)
@@ -31,6 +31,7 @@
 %}
 
 %include <usrp_subdev_spec.h>
+%include <db_base.i>
 %include "usrp_standard.i"
 %include "usrp_base.i"
 %include "usrp_source_base.i"
@@ -39,3 +40,61 @@
 %include "usrp_sink_base.i"
 %include "usrp_sink_c.i"
 %include "usrp_sink_s.i"
+
+//---Allow a more Pythonic interface
+%pythoncode %{
+
+# Allow subdev_spec to be tuple
+def __selected_subdev(self, subdev_spec):
+  ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1])
+  return self._real_selected_subdev(ss)
+
+# Allow subdev_spec to be tuple
+def __determine_tx_mux_value(self, subdev_spec):
+    ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1])
+    return self._real_determine_tx_mux_value(ss)
+
+# Allow subdev_spec to be tuple
+def __determine_rx_mux_value(self, subdev_spec):
+    ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1])
+    return self._real_determine_rx_mux_value(ss)
+
+# Make return tune_result or None on failure
+def __tune(self, chan, db, target_freq):
+    tr = usrp_tune_result()
+    r = self._real_tune(chan, db, target_freq, tr)
+    if r:
+        return tr
+    else:
+        return None
+
+# Allow to be called as free function
+def determine_tx_mux_value(u, subdev_spec):
+    return u.determine_tx_mux_value(subdev_spec)
+
+# Allow to be called as free function
+def determine_rx_mux_value(u, subdev_spec):
+    return u.determine_rx_mux_value(subdev_spec)
+
+# Allow to be called as free function
+def selected_subdev(u, subdev_spec):
+    return u.selected_subdev(subdev_spec)
+
+# 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
+
+usrp_source_c_sptr.determine_rx_mux_value = __determine_rx_mux_value
+usrp_source_s_sptr.determine_rx_mux_value = __determine_rx_mux_value
+
+usrp_sink_c_sptr.selected_subdev          = __selected_subdev
+usrp_sink_s_sptr.selected_subdev          = __selected_subdev
+usrp_source_c_sptr.selected_subdev        = __selected_subdev
+usrp_source_s_sptr.selected_subdev        = __selected_subdev
+
+usrp_sink_c_sptr.tune                     = __tune
+usrp_sink_s_sptr.tune                     = __tune
+usrp_source_c_sptr.tune                   = __tune
+usrp_source_s_sptr.tune                   = __tune
+
+%}

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.h
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.h    2008-11-22 
01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.h    2008-11-22 
03:39:26 UTC (rev 10031)
@@ -26,7 +26,6 @@
 #include <boost/shared_ptr.hpp>
 #include <db_base.h>
 #include <usrp_subdev_spec.h>
-#include <usrp_tune_result.h>
 
 class usrp_basic;
 

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.i    2008-11-22 
01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_base.i    2008-11-22 
03:39:26 UTC (rev 10031)
@@ -34,6 +34,7 @@
     
 public:
   std::vector<db_base_sptr> db(int which_side);
+  %rename (_real_selected_subdev) selected_subdev;
   db_base_sptr selected_subdev(usrp_subdev_spec ss);
   long  fpga_master_clock_freq() const;
   void set_verbose (bool on);

Deleted: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_shim.py

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-22 01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.h       
2008-11-22 03:39:26 UTC (rev 10031)
@@ -25,6 +25,7 @@
 
 #include <usrp_base.h>
 #include <stdexcept>
+#include <usrp_tune_result.h>
 
 class usrp_standard_tx;
 

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-22 01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_base.i       
2008-11-22 03:39:26 UTC (rev 10031)
@@ -47,13 +47,6 @@
   bool has_tx_halfband();
   int nddcs();
   int nducs();
+  %rename(_real_tune) tune;
   bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result 
*result);
 };
-
-//--- Allow Python subdev_spec to be tuple
-
-%pythoncode %{
-def __determine_tx_mux_value(self, subdev_spec):
-    ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1])
-    return self._real_determine_tx_mux_value(ss)
-%}

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_c.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_c.i  2008-11-22 
01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_c.i  2008-11-22 
03:39:26 UTC (rev 10031)
@@ -45,10 +45,3 @@
 private:
   usrp_sink_c() throw (std::runtime_error);
 };
-
-//--- Allow Python subdev_spec to be tuple
-%pythoncode %{
-
-usrp_sink_c_sptr.determine_tx_mux_value = __determine_tx_mux_value
-
-%}

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_s.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_s.i  2008-11-22 
01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_sink_s.i  2008-11-22 
03:39:26 UTC (rev 10031)
@@ -45,10 +45,3 @@
 private:
   usrp_sink_s() throw (std::runtime_error);
 };
-
-//--- Allow Python subdev_spec to be tuple
-%pythoncode %{
-
-usrp_sink_s_sptr.determine_tx_mux_value = __determine_tx_mux_value
-
-%}

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-22 01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.h     
2008-11-22 03:39:26 UTC (rev 10031)
@@ -25,6 +25,7 @@
 
 #include <usrp_base.h>
 #include <stdexcept>
+#include <usrp_tune_result.h>
 
 class usrp_standard_rx;
 

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-22 01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_base.i     
2008-11-22 03:39:26 UTC (rev 10031)
@@ -56,13 +56,6 @@
   static int format_shift(unsigned int format);
   static bool format_want_q(unsigned int format);
   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);
 };
-
-//--- Allow Python subdev_spec to be tuple
-
-%pythoncode %{
-def __determine_rx_mux_value(self, subdev_spec):
-    ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1])
-    return self._real_determine_rx_mux_value(ss)
-%}

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_c.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_c.i        
2008-11-22 01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_c.i        
2008-11-22 03:39:26 UTC (rev 10031)
@@ -46,10 +46,3 @@
 private:
   usrp_source_c() throw (std::runtime_error);
 };
-
-//--- Allow Python subdev_spec to be tuple
-%pythoncode %{
-
-usrp_source_c_sptr.determine_rx_mux_value = __determine_rx_mux_value
-
-%}

Modified: gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_s.i
===================================================================
--- gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_s.i        
2008-11-22 01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-usrp/src/usrp_source_s.i        
2008-11-22 03:39:26 UTC (rev 10031)
@@ -46,10 +46,3 @@
 private:
   usrp_source_s() throw (std::runtime_error);
 };
-
-//--- Allow Python subdev_spec to be tuple
-%pythoncode %{
-
-usrp_source_s_sptr.determine_rx_mux_value = __determine_rx_mux_value
-
-%}

Modified: gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_siggen.py
===================================================================
--- gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_siggen.py 
2008-11-22 01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/gr-utils/src/python/usrp_siggen.py 
2008-11-22 03:39:26 UTC (rev 10031)
@@ -118,7 +118,7 @@
         the result of that operation and our target_frequency to
         determine the value for the digital up converter.
         """
-        r = self.u.tune(self.subdev._which, self.subdev, target_freq)
+        r = self.u.tune(self.subdev.which(), self.subdev, target_freq)
         if r:
             #print "r.baseband_freq =", 
eng_notation.num_to_str(r.baseband_freq)
             #print "r.dxc_freq      =", eng_notation.num_to_str(r.dxc_freq)
@@ -200,5 +200,6 @@
     except KeyboardInterrupt:
         pass
 
+
 if __name__ == '__main__':
     main ()

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-22 01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/db_base.i     
2008-11-22 03:39:26 UTC (rev 10031)
@@ -27,14 +27,13 @@
 
 %include <shared_ptr.i>
 
-class tune_result
+class usrp_tune_result
 {
 public:  
-  tune_result(double baseband=0, double dxc=0, 
-             double residual=0, bool inv=0);
-  ~tune_result();
+  usrp_tune_result(double baseband=0, double dxc=0, 
+                  double residual=0, bool inv=0);
+  ~usrp_tune_result();
 
-  bool  ok;
   double baseband_freq;
   double dxc_freq;
   double residual_freq;
@@ -49,33 +48,40 @@
 
 class db_base
 {
+ private:
+  db_base(boost::shared_ptr<usrp_basic> usrp, int which);
+
  public:
-  db_base(usrp_basic *usrp, int which, bool tx=true);
-  ~db_base();
+  virtual ~db_base();
 
   int dbid();
   std::string name();
   std::string side_and_name();
+  int which() { return d_which; }
 
-  float gain_min();
-  float gain_max();
-  float gain_db_per_step();
-  double freq_min();
-  double freq_max();
-  struct freq_result_t set_freq(double target_freq);
-  bool set_gain(float gain);
-  bool is_quadrature();
-  bool i_and_q_swapped();
-  bool spectrum_inverted();
-  void set_enable(bool on);
-  void set_auto_tr(bool on);
-  void set_lo_offset(double offset);
-  double lo_offset();
-  void select_rx_antenna(int which_antenna);
+  bool bypass_adc_buffers(bool bypass);
+  bool set_atr_mask(int v);
+  bool set_atr_txval(int v);
+  bool set_atr_rxval(int v);
+  bool set_atr_tx_delay(int v);
+  bool set_atr_rx_delay(int v);
+  bool set_lo_offset(double offset);
+  double lo_offset() { return d_lo_offset; }
 
-  tune_result tune(int chan, double target_freq);
-
-  int _which;
+  virtual float gain_min() = 0;
+  virtual float gain_max() = 0;
+  virtual float gain_db_per_step() = 0;
+  virtual double freq_min() = 0;
+  virtual double freq_max() = 0;
+  virtual struct freq_result_t set_freq(double target_freq) = 0;
+  virtual bool set_gain(float gain) = 0;
+  virtual bool is_quadrature() = 0;
+  virtual bool i_and_q_swapped();
+  virtual bool spectrum_inverted();
+  virtual bool set_enable(bool on);
+  virtual bool set_auto_tr(bool on);
+  virtual bool select_rx_antenna(int which_antenna);
+  virtual void shutdown();
 };
 
 typedef boost::shared_ptr<db_base> db_base_sptr;
@@ -88,6 +94,7 @@
   db_base_sptr.__repr__ = lambda self: "<db_base::%s>" % (self.name(),)
   db_base_sptr.freq_range = lambda self: (self.freq_min(), self.freq_max(), 1)
   db_base_sptr.gain_range = lambda self: (self.gain_min(), self.gain_max(), 
self.gain_db_per_step())
+
   def tune(u, chan, subdev, target_freq):
-      return subdev.tune(chan, target_freq)
+      return u.tune(chan, subdev, target_freq)
 %}

Modified: gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_standard.cc
===================================================================
--- gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_standard.cc      
2008-11-22 01:31:35 UTC (rev 10030)
+++ gnuradio/branches/features/cppdb/usrp/host/lib/legacy/usrp_standard.cc      
2008-11-22 03:39:26 UTC (rev 10031)
@@ -60,12 +60,12 @@
       Nyquist zone.
   */
 
-  if (1){
+#if 0
     printf("calc_dxc_freq:\n");
     printf("  target   = %f\n", target_freq);
     printf("  baseband = %f\n", baseband_freq);
     printf("  fs       = %f\n", fs);
-  }
+#endif
 
   double delta = target_freq - baseband_freq;
     





reply via email to

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