commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9979 - gnuradio/branches/features/cppdb/gnuradio-exam


From: trondeau
Subject: [Commit-gnuradio] r9979 - gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test
Date: Wed, 12 Nov 2008 17:20:31 -0700 (MST)

Author: trondeau
Date: 2008-11-12 17:20:30 -0700 (Wed, 12 Nov 2008)
New Revision: 9979

Added:
   
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.cc
   
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.h
Removed:
   gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/main.cc
   gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test.cc
   gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test.h
Modified:
   gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/Makefile.am
Log:
changing usrp example project name

Modified: 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/Makefile.am
===================================================================
--- 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/Makefile.am    
    2008-11-13 00:11:07 UTC (rev 9978)
+++ 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/Makefile.am    
    2008-11-13 00:20:30 UTC (rev 9979)
@@ -36,16 +36,15 @@
 # For compiling outside the tree, these will get fished out by pkgconfig
 
 noinst_PROGRAMS = \
-       usrp_test
+       usrp_test_rx
 
 noinst_HEADERS =       \
-       usrp_test.h
+       usrp_test_rx.h
 
-usrp_test_SOURCES =    \
-    usrp_test.cc       \
-    main.cc
+usrp_test_rx_SOURCES =         \
+    usrp_test_rx.cc
 
-usrp_test_LDADD = \
+usrp_test_rx_LDADD = \
        $(GR_USRP_LA)
 #      $(GNURADIO_CORE_LA)
 

Deleted: 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/main.cc

Deleted: 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test.cc

Deleted: 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test.h

Copied: 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.cc
 (from rev 9977, 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test.cc)
===================================================================
--- 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.cc
                            (rev 0)
+++ 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.cc
    2008-11-13 00:20:30 UTC (rev 9979)
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <usrp_test_rx.h>
+#include <gr_io_signature.h>
+#include <usrp_source_c.h>
+#include <gr_head.h>
+
+// Shared pointer constructor
+usrp_test_sptr make_usrp_test()
+{
+  return gnuradio::get_initial_sptr(new usrp_test());
+}
+
+// Hierarchical block constructor, with no inputs or outputs
+usrp_test::usrp_test() : 
+    gr_top_block("usrp_test")
+{
+  int decim = 64;
+  usrp_source_c_sptr usrp = usrp_make_source_c(0, decim);
+
+  usrp_subdev_spec spec(0,0);
+  db_base_sptr subdev = usrp->selected_subdev(spec);
+  printf("Subdevice name is %s\n", subdev->name().c_str());
+  printf("Subdevice freq range: (%g, %g)\n", subdev->freq_min(), 
subdev->freq_max());
+
+  unsigned int mux = usrp->determine_rx_mux_value(spec);
+  printf("mux: %x\n",  mux);
+  usrp->set_mux(mux);
+
+  float input_rate = usrp->adc_freq() / usrp->decim_rate();
+  printf("baseband rate: %g\n",  input_rate);
+
+  float gain_min = subdev->gain_min();
+  float gain_max = subdev->gain_max();
+  printf("gain: (%g, %g)\n",  gain_min, gain_max);
+  
+  subdev->set_gain((gain_min + gain_max)/2.0);
+  
+  usrp_tune_result r;
+  double target_freq = 101.3e6;
+  bool ok = usrp->tune(0, subdev, target_freq, &r);
+  
+  printf("target_freq:     %f\n", target_freq);
+  printf("ok:              %s\n", ok ? "true" : "false");
+  printf("r.baseband_freq: %f\n", r.baseband_freq);
+  printf("r.dxc_freq:      %f\n", r.dxc_freq);
+  printf("r.residual_freq: %f\n", r.residual_freq);
+  printf("r.inverted:      %d\n", r.inverted);
+
+  /* The rest */
+  gr_block_sptr head = gr_make_head(sizeof(gr_complex), 1024);
+  sink = gr_make_vector_sink_c();
+
+  connect(usrp, 0, head, 0);
+  connect(head, 0, sink, 0);
+}
+
+int main()
+{
+  usrp_test_sptr top_block = make_usrp_test();
+  top_block->run();
+  
+  std::vector<gr_complex> data = top_block->sink->data();
+  
+  printf("data size: %zu\n", data.size());
+  for(size_t i=0; i < data.size(); i++) {
+    printf("%f + %fj\n", data[i].real(), data[i].imag());
+  }
+  printf("\n");
+  
+  return 0;
+}

Copied: 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.h 
(from rev 9977, 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test.h)
===================================================================
--- 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.h 
                            (rev 0)
+++ 
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.h 
    2008-11-13 00:20:30 UTC (rev 9979)
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <gr_top_block.h>
+#include <gr_vector_sink_c.h>
+
+class usrp_test;
+typedef boost::shared_ptr<usrp_test> usrp_test_sptr;
+usrp_test_sptr make_usrp_test();
+
+class usrp_test : public gr_top_block
+{
+private:
+    usrp_test();
+    friend usrp_test_sptr make_usrp_test();
+
+ public:
+    gr_vector_sink_c_sptr sink;
+};





reply via email to

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