commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8425 - in usrp2/branches/developers/jcorgan/u2/host:


From: jcorgan
Subject: [Commit-gnuradio] r8425 - in usrp2/branches/developers/jcorgan/u2/host: apps gr-usrp2 lib
Date: Wed, 14 May 2008 11:49:04 -0600 (MDT)

Author: jcorgan
Date: 2008-05-14 11:48:59 -0600 (Wed, 14 May 2008)
New Revision: 8425

Added:
   usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_tune_result.h
Modified:
   usrp2/branches/developers/jcorgan/u2/host/apps/rx_streaming_samples.cc
   usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2.i
   usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.cc
   usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.h
   usrp2/branches/developers/jcorgan/u2/host/lib/Makefile.am
   usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc
   usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h
Log:
Add receiver config to usrp2.source_c

Modified: usrp2/branches/developers/jcorgan/u2/host/apps/rx_streaming_samples.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/apps/rx_streaming_samples.cc      
2008-05-14 13:50:43 UTC (rev 8424)
+++ usrp2/branches/developers/jcorgan/u2/host/apps/rx_streaming_samples.cc      
2008-05-14 17:48:59 UTC (rev 8425)
@@ -334,7 +334,7 @@
   class file_writer *writer = new file_writer(ofd, rb);
   writer->start_undetached();
 
-  usrp2_tune_result tune_result;
+  usrp2_tune_result_sptr tune_result;
   
   if (gain != GAIN_NOT_SET){
     if (!u2->set_rx_gain(gain)){
@@ -343,9 +343,9 @@
     }
   }
 
-  if (!u2->set_rx_freq(freq, &tune_result)){
+  if (!(tune_result = u2->set_rx_freq(freq))){
     std::cerr << "set_rx_freq failed\n";
-    return 1;
+    //return 1;
   }
 
   if (!u2->set_rx_decim(decim)){

Modified: usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2.i
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2.i  2008-05-14 
13:50:43 UTC (rev 8424)
+++ usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2.i  2008-05-14 
17:48:59 UTC (rev 8425)
@@ -31,6 +31,9 @@
 #include "usrp2_source_c.h"
 %}
 
+%include "../lib/usrp2_tune_result.h"
+%template(usrp2_tune_result_sptr) boost::shared_ptr<usrp2_tune_result>;
+
 // ----------------------------------------------------------------
 
 class usrp2_source_base : public gr_sync_block {
@@ -60,6 +63,10 @@
 public:
   ~usrp2_source_c();
 
+  bool set_gain(double gain);
+  usrp2_tune_result_sptr set_freq(double frequency);
+  bool set_decim(int decimation_factor);
+  bool set_scale_iq(int scale_i, int scale_q);
 };
 
 // ----------------------------------------------------------------

Modified: 
usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.cc     
2008-05-14 13:50:43 UTC (rev 8424)
+++ usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.cc     
2008-05-14 17:48:59 UTC (rev 8425)
@@ -66,6 +66,30 @@
 }
 
 bool
+usrp2_source_base::set_gain(double gain)
+{
+  return d_u2->set_rx_gain(gain);
+}
+
+usrp2_tune_result_sptr
+usrp2_source_base::set_freq(double frequency) 
+{
+  return d_u2->set_rx_freq(frequency);
+}
+
+bool
+usrp2_source_base::set_decim(int decimation_factor)
+{
+  return d_u2->set_rx_decim(decimation_factor);
+}
+
+bool
+usrp2_source_base::set_scale_iq(int scale_i, int scale_q)
+{
+  return d_u2->set_rx_scale_iq(scale_i, scale_q);
+}
+
+bool
 usrp2_source_base::start()
 {
   if (USRP2_SOURCE_BASE_DEBUG)

Modified: usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.h
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.h      
2008-05-14 13:50:43 UTC (rev 8424)
+++ usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_source_base.h      
2008-05-14 17:48:59 UTC (rev 8425)
@@ -44,6 +44,11 @@
   virtual bool start();
   virtual bool stop();
 
+  bool set_gain(double gain);
+  usrp2_tune_result_sptr set_freq(double frequency);
+  bool set_decim(int decimation_factor);
+  bool set_scale_iq(int scale_i, int scale_q);
+
   int work(int noutput_items,
           gr_vector_const_void_star &input_items,
           gr_vector_void_star &output_items);

Modified: usrp2/branches/developers/jcorgan/u2/host/lib/Makefile.am
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/Makefile.am   2008-05-14 
13:50:43 UTC (rev 8424)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/Makefile.am   2008-05-14 
17:48:59 UTC (rev 8425)
@@ -47,5 +47,6 @@
        gri_if_stats.h \
        gri_pktfilter.h \
        strtod_si.h \
+       usrp2_tune_result.h \
        usrp2_basic.h
 

Modified: usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc        
2008-05-14 13:50:43 UTC (rev 8424)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc        
2008-05-14 17:48:59 UTC (rev 8425)
@@ -54,6 +54,10 @@
 #define MAX_PKTLEN 1512          // biggest thing USRP2 can swallow
                           //   (14-byte ethernet hdr + 1500 byte payload)
 
+usrp2_tune_result::~usrp2_tune_result()
+{
+}
+
 usrp2_basic_sptr 
 usrp2_make_basic(const std::string &ifc, const u2_mac_addr_t &addr)
 {
@@ -262,9 +266,10 @@
   return true;
 }
 
-bool
-usrp2_basic::set_rx_freq(double freq, usrp2_tune_result *result)
+usrp2_tune_result_sptr
+usrp2_basic::set_rx_freq(double freq)
 {
+  usrp2_tune_result_sptr result(new usrp2_tune_result());
   uint8_t      pktbuf[MAX_PKTLEN];
   memset(pktbuf, 0, sizeof(pktbuf));
 
@@ -290,15 +295,11 @@
   c->eop.len = sizeof(op_eop_t);
 
   int len = std::max((size_t) MIN_PKTLEN, sizeof(command));
-  if (d_ethernet->write_packet(c, len) != len)
-    return false;
+  if (d_ethernet->write_packet(c, len) == len) {
+    // FIXME: wait for corresponding reply, set tune result members
+  }
 
-  // FIXME wait for corresponding reply, etc.
-
-  if (result)
-    memset(result, 0, sizeof(*result));
-
-  return true;
+  return result;
 }
 
 bool

Modified: usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h 2008-05-14 
13:50:43 UTC (rev 8424)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h 2008-05-14 
17:48:59 UTC (rev 8425)
@@ -23,6 +23,7 @@
 #include <boost/shared_ptr.hpp>
 #include <vector>
 #include "usrp2_eth_packet.h"
+#include "usrp2_tune_result.h"
 
 class gri_ethernet;
 class gri_ethernet_pfring;
@@ -30,26 +31,6 @@
 
 #define GRI_ETHERNET gri_ethernet
 
-//! Provides detailed result of tuning request
-
-struct usrp2_tune_result
-{
-  // RF frequency that corresponds to DC in the IF
-  double baseband_freq;
-
-  // frequency programmed into the DDC/DUC
-  double dxc_freq;
-
-  // residual frequency (typically < 0.01 Hz)
-  double residual_freq;
-
-  // is the spectrum inverted?
-  bool  spectrum_inverted;
-
-  usrp2_tune_result()
-    : baseband_freq(0), dxc_freq(0), residual_freq(0), 
spectrum_inverted(false) {}
-};
-
 class usrp2_basic;
 typedef boost::shared_ptr<usrp2_basic> usrp2_basic_sptr;
 
@@ -130,7 +111,7 @@
    * Rx configuration and control
    */
   bool set_rx_gain(double gain);
-  bool set_rx_freq(double frequency, usrp2_tune_result *result);
+  usrp2_tune_result_sptr set_rx_freq(double frequency);
   bool set_rx_decim(int decimation_factor);
   bool set_rx_scale_iq(int scale_i, int scale_q);
 

Added: usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_tune_result.h
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_tune_result.h           
                (rev 0)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_tune_result.h   
2008-05-14 17:48:59 UTC (rev 8425)
@@ -0,0 +1,46 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef INCLUDED_USRP2_TUNE_RESULT_H
+#define INCLUDED_USRP2_TUNE_RESULT_H
+
+#include <boost/shared_ptr.hpp>
+
+class usrp2_tune_result
+{
+public:
+  // RF frequency that corresponds to DC in the IF
+  double baseband_freq;
+
+  // frequency programmed into the DDC/DUC
+  double dxc_freq;
+
+  // residual frequency (typically < 0.01 Hz)
+  double residual_freq;
+
+  // is the spectrum inverted?
+  bool  spectrum_inverted;
+
+  usrp2_tune_result()
+    : baseband_freq(0), dxc_freq(0), residual_freq(0), 
spectrum_inverted(false) {}
+  ~usrp2_tune_result();
+};
+
+typedef boost::shared_ptr<usrp2_tune_result> usrp2_tune_result_sptr;
+
+#endif /* INCLUDED_USRP2_TUNE_RESULT_H */





reply via email to

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