summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r--gnuradio-core/src/lib/filter/Makefile.am7
-rw-r--r--gnuradio-core/src/lib/filter/filter.i2
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc1
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h4
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc1
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h4
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc258
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h106
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i49
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc1
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h2
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc1
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h2
-rw-r--r--gnuradio-core/src/lib/general/gr_constants.cc.in12
-rw-r--r--gnuradio-core/src/lib/general/gr_constants.h10
-rw-r--r--gnuradio-core/src/lib/general/gr_constants.i4
-rw-r--r--gnuradio-core/src/lib/gnuradio-config-info.cc8
-rw-r--r--gnuradio-core/src/python/gnuradio/Makefile.am1
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am1
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/generic_usrp.py244
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py4
-rw-r--r--gnuradio-core/src/python/gnuradio/eng_option.py22
-rw-r--r--gnuradio-core/src/python/gnuradio/usrp_options.py123
23 files changed, 803 insertions, 64 deletions
diff --git a/gnuradio-core/src/lib/filter/Makefile.am b/gnuradio-core/src/lib/filter/Makefile.am
index 838f69b92..d5afd571b 100644
--- a/gnuradio-core/src/lib/filter/Makefile.am
+++ b/gnuradio-core/src/lib/filter/Makefile.am
@@ -205,7 +205,8 @@ libfilter_la_common_SOURCES = \
gr_pfb_channelizer_ccf.cc \
gr_pfb_decimator_ccf.cc \
gr_pfb_interpolator_ccf.cc \
- gr_pfb_arb_resampler_ccf.cc
+ gr_pfb_arb_resampler_ccf.cc \
+ gr_pfb_clock_sync_ccf.cc
libfilter_qa_la_common_SOURCES = \
qa_filter.cc \
@@ -284,7 +285,8 @@ grinclude_HEADERS = \
gr_pfb_channelizer_ccf.h \
gr_pfb_decimator_ccf.h \
gr_pfb_interpolator_ccf.h \
- gr_pfb_arb_resampler_ccf.h
+ gr_pfb_arb_resampler_ccf.h \
+ gr_pfb_clock_sync_ccf.h
noinst_HEADERS = \
assembly.h \
@@ -339,6 +341,7 @@ swiginclude_HEADERS = \
gr_pfb_decimator_ccf.i \
gr_pfb_interpolator_ccf.i \
gr_pfb_arb_resampler_ccf.i \
+ gr_pfb_clock_sync_ccf.i \
$(GENERATED_I)
endif
diff --git a/gnuradio-core/src/lib/filter/filter.i b/gnuradio-core/src/lib/filter/filter.i
index 16b8005be..91f55c514 100644
--- a/gnuradio-core/src/lib/filter/filter.i
+++ b/gnuradio-core/src/lib/filter/filter.i
@@ -36,6 +36,7 @@
#include <gr_pfb_decimator_ccf.h>
#include <gr_pfb_interpolator_ccf.h>
#include <gr_pfb_arb_resampler_ccf.h>
+#include <gr_pfb_clock_sync_ccf.h>
%}
%include "gr_iir_filter_ffd.i"
@@ -56,5 +57,6 @@
%include "gr_pfb_decimator_ccf.i"
%include "gr_pfb_interpolator_ccf.i"
%include "gr_pfb_arb_resampler_ccf.i"
+%include "gr_pfb_clock_sync_ccf.i"
%include "filter_generated.i"
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc
index bfc4c0467..8971d3d39 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc
+++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc
@@ -28,6 +28,7 @@
#include <gr_fir_ccf.h>
#include <gr_fir_util.h>
#include <gr_io_signature.h>
+#include <cstdio>
gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate,
const std::vector<float> &taps,
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h
index b79a89fe9..d4c886ec3 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h
+++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h
@@ -91,8 +91,8 @@ class gr_fir_ccf;
* The theory behind this block can be found in Chapter 7.5 of
* the following book.
*
- * <B><EM>f. harris, Multirate Signal Processing for Communication
- * Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B>
+ * <B><EM>f. harris, "Multirate Signal Processing for Communication
+ * Systems", Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B>
*/
class gr_pfb_arb_resampler_ccf : public gr_block
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
index 7be611e23..a7e8de62a 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
+++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
@@ -29,6 +29,7 @@
#include <gr_fir_util.h>
#include <gri_fft.h>
#include <gr_io_signature.h>
+#include <cstdio>
gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans,
const std::vector<float> &taps)
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h
index 7d0a31c59..b2e67e817 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h
+++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h
@@ -91,8 +91,8 @@ class gri_fft_complex;
* The theory behind this block can be found in Chapter 6 of
* the following book.
*
- * <B><EM>f. harris, Multirate Signal Processing for Communication
- * Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.
+ * <B><EM>f. harris, "Multirate Signal Processing for Communication
+ * Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B>
*
*/
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc
new file mode 100644
index 000000000..91cbf74c6
--- /dev/null
+++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc
@@ -0,0 +1,258 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <cstdio>
+#include <cmath>
+
+#include <gr_pfb_clock_sync_ccf.h>
+#include <gr_fir_ccf.h>
+#include <gr_fir_util.h>
+#include <gr_io_signature.h>
+#include <gr_math.h>
+
+gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+ const std::vector<float> &taps,
+ unsigned int filter_size,
+ float init_phase)
+{
+ return gr_pfb_clock_sync_ccf_sptr (new gr_pfb_clock_sync_ccf (sps, gain, taps,
+ filter_size,
+ init_phase));
+}
+
+
+gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (float sps, float gain,
+ const std::vector<float> &taps,
+ unsigned int filter_size,
+ float init_phase)
+ : gr_block ("pfb_clock_sync_ccf",
+ gr_make_io_signature (1, 1, sizeof(gr_complex)),
+ gr_make_io_signature2 (2, 2, sizeof(gr_complex), sizeof(float))),
+ d_updated (false), d_sps(sps), d_alpha(gain)
+{
+ d_nfilters = filter_size;
+
+ // Store the last filter between calls to work
+ // The accumulator keeps track of overflow to increment the stride correctly.
+ // set it here to the fractional difference based on the initial phaes
+ // assert(init_phase <= 2*M_PI);
+ float x = init_phase / (2*M_PI); //normalize initial phase
+ d_acc = x*(d_nfilters-1);
+ d_last_filter = (int)floor(d_acc);
+ d_acc = fmodf(d_acc, 1);
+ d_start_count = 0;
+
+
+ d_filters = std::vector<gr_fir_ccf*>(d_nfilters);
+ d_diff_filters = std::vector<gr_fir_ccf*>(d_nfilters);
+
+ // Create an FIR filter for each channel and zero out the taps
+ std::vector<float> vtaps(0, d_nfilters);
+ for(unsigned int i = 0; i < d_nfilters; i++) {
+ d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps);
+ d_diff_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps);
+ }
+
+ // Now, actually set the filters' taps
+ std::vector<float> dtaps;
+ create_diff_taps(taps, dtaps);
+ set_taps(taps, d_taps, d_filters);
+ set_taps(dtaps, d_dtaps, d_diff_filters);
+}
+
+gr_pfb_clock_sync_ccf::~gr_pfb_clock_sync_ccf ()
+{
+ for(unsigned int i = 0; i < d_nfilters; i++) {
+ delete d_filters[i];
+ }
+}
+
+void
+gr_pfb_clock_sync_ccf::set_taps (const std::vector<float> &newtaps,
+ std::vector< std::vector<float> > &ourtaps,
+ std::vector<gr_fir_ccf*> &ourfilter)
+{
+ unsigned int i,j;
+
+ unsigned int ntaps = newtaps.size();
+ d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters);
+
+ // Create d_numchan vectors to store each channel's taps
+ ourtaps.resize(d_nfilters);
+
+ // Make a vector of the taps plus fill it out with 0's to fill
+ // each polyphase filter with exactly d_taps_per_filter
+ std::vector<float> tmp_taps;
+ tmp_taps = newtaps;
+ while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) {
+ tmp_taps.push_back(0.0);
+ }
+
+ // Partition the filter
+ for(i = 0; i < d_nfilters; i++) {
+ // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out
+ ourtaps[i] = std::vector<float>(d_taps_per_filter, 0);
+ for(j = 0; j < d_taps_per_filter; j++) {
+ ourtaps[i][j] = tmp_taps[i + j*d_nfilters]; // add taps to channels in reverse order
+ }
+
+ // Build a filter for each channel and add it's taps to it
+ ourfilter[i]->set_taps(ourtaps[i]);
+ }
+
+ // Set the history to ensure enough input items for each filter
+ set_history (d_taps_per_filter + d_sps);
+
+ d_updated = true;
+}
+
+void
+gr_pfb_clock_sync_ccf::create_diff_taps(const std::vector<float> &newtaps,
+ std::vector<float> &difftaps)
+{
+ difftaps.clear();
+ difftaps.push_back(0); //newtaps[0]);
+ for(unsigned int i = 1; i < newtaps.size()-1; i++) {
+ difftaps.push_back(newtaps[i+1] - newtaps[i-1]);
+ }
+ difftaps.push_back(0);//-newtaps[newtaps.size()-1]);
+}
+
+void
+gr_pfb_clock_sync_ccf::print_taps()
+{
+ unsigned int i, j;
+ for(i = 0; i < d_nfilters; i++) {
+ printf("filter[%d]: [%.4e, ", i, d_taps[i][0]);
+ for(j = 1; j < d_taps_per_filter-1; j++) {
+ printf("%.4e,", d_taps[i][j]);
+ }
+ printf("%.4e]\n", d_taps[i][j]);
+ }
+}
+
+void
+gr_pfb_clock_sync_ccf::print_diff_taps()
+{
+ unsigned int i, j;
+ for(i = 0; i < d_nfilters; i++) {
+ printf("filter[%d]: [%.4e, ", i, d_dtaps[i][0]);
+ for(j = 1; j < d_taps_per_filter-1; j++) {
+ printf("%.4e,", d_dtaps[i][j]);
+ }
+ printf("%.4e]\n", d_dtaps[i][j]);
+ }
+}
+
+
+std::vector<float>
+gr_pfb_clock_sync_ccf::channel_taps(int channel)
+{
+ std::vector<float> taps;
+ unsigned int i;
+ for(i = 0; i < d_taps_per_filter; i++) {
+ taps.push_back(d_taps[channel][i]);
+ }
+ return taps;
+}
+
+std::vector<float>
+gr_pfb_clock_sync_ccf::diff_channel_taps(int channel)
+{
+ std::vector<float> taps;
+ unsigned int i;
+ for(i = 0; i < d_taps_per_filter; i++) {
+ taps.push_back(d_dtaps[channel][i]);
+ }
+ return taps;
+}
+
+
+int
+gr_pfb_clock_sync_ccf::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ gr_complex *in = (gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+ float *err = (float *) output_items[1];
+
+ if (d_updated) {
+ d_updated = false;
+ return 0; // history requirements may have changed.
+ }
+
+ // We need this many to process one output
+ int nrequired = ninput_items[0] - d_taps_per_filter;
+
+ int i = 0, count = d_start_count;
+ float error = 0;
+
+ // produce output as long as we can and there are enough input samples
+ while((i < noutput_items) && (count < nrequired)) {
+ out[i] = d_filters[d_last_filter]->filter(&in[count]);
+ error = (out[i] * d_diff_filters[d_last_filter]->filter(&in[count])).real();
+ err[i] = error;
+
+ d_acc += d_alpha*error;
+ gr_branchless_clip(d_acc, 1);
+
+ int newfilter;
+ newfilter = (int)((float)d_last_filter + d_acc);
+ if(newfilter != (int)d_last_filter)
+ d_acc = 0.5;
+
+ if(newfilter >= (int)d_nfilters) {
+ d_last_filter = newfilter - d_nfilters;
+ count++;
+ }
+ else if(newfilter < 0) {
+ d_last_filter = d_nfilters + newfilter;
+ count--;
+ }
+ else {
+ d_last_filter = newfilter;
+ }
+
+ i++;
+ count += d_sps;
+ }
+
+ // Set the start index at the next entrance to the work function
+ // if we stop because we run out of input items, jump ahead in the
+ // next call to work. Otherwise, we can start at zero.
+ if(count > nrequired) {
+ d_start_count = count - (nrequired);
+ consume_each(ninput_items[0]-d_taps_per_filter);
+ }
+ else {
+ d_start_count = 0;
+ consume_each(count);
+ }
+
+ return i;
+}
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h
new file mode 100644
index 000000000..1a04e55c7
--- /dev/null
+++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h
@@ -0,0 +1,106 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 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.
+ */
+
+
+#ifndef INCLUDED_GR_PFB_CLOCK_SYNC_CCF_H
+#define INCLUDED_GR_PFB_CLOCK_SYNC_CCF_H
+
+#include <gr_block.h>
+
+class gr_pfb_clock_sync_ccf;
+typedef boost::shared_ptr<gr_pfb_clock_sync_ccf> gr_pfb_clock_sync_ccf_sptr;
+gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+ const std::vector<float> &taps,
+ unsigned int filter_size=32,
+ float init_phase=0);
+
+class gr_fir_ccf;
+
+/*!
+ * \class gr_pfb_clock_sync_ccf
+ *
+ * \brief Timing synchronizer using polyphase filterbanks
+ *
+ * \ingroup filter_blk
+ *
+ */
+
+class gr_pfb_clock_sync_ccf : public gr_block
+{
+ private:
+ /*!
+ * Build the polyphase filterbank timing synchronizer.
+ */
+ friend gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+ const std::vector<float> &taps,
+ unsigned int filter_size,
+ float init_phase);
+
+ bool d_updated;
+ unsigned int d_sps;
+ float d_alpha;
+ unsigned int d_nfilters;
+ std::vector<gr_fir_ccf*> d_filters;
+ std::vector<gr_fir_ccf*> d_diff_filters;
+ std::vector< std::vector<float> > d_taps;
+ std::vector< std::vector<float> > d_dtaps;
+ float d_acc;
+ unsigned int d_last_filter;
+ unsigned int d_start_count;
+ unsigned int d_taps_per_filter;
+
+ /*!
+ * Build the polyphase filterbank timing synchronizer.
+ */
+ gr_pfb_clock_sync_ccf (float sps, float gain,
+ const std::vector<float> &taps,
+ unsigned int filter_size,
+ float init_phase);
+
+ void create_diff_taps(const std::vector<float> &newtaps,
+ std::vector<float> &difftaps);
+
+public:
+ ~gr_pfb_clock_sync_ccf ();
+
+ /*!
+ * Resets the filterbank's filter taps with the new prototype filter
+ */
+ void set_taps (const std::vector<float> &taps,
+ std::vector< std::vector<float> > &ourtaps,
+ std::vector<gr_fir_ccf*> &ourfilter);
+ std::vector<float> channel_taps(int channel);
+ std::vector<float> diff_channel_taps(int channel);
+
+ /*!
+ * Print all of the filterbank taps to screen.
+ */
+ void print_taps();
+ void print_diff_taps();
+
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i
new file mode 100644
index 000000000..729d4a1aa
--- /dev/null
+++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i
@@ -0,0 +1,49 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,pfb_clock_sync_ccf);
+
+gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
+ const std::vector<float> &taps,
+ unsigned int filter_size=32,
+ float init_phase=0);
+
+class gr_pfb_clock_sync_ccf : public gr_block
+{
+ private:
+ gr_pfb_clock_sync_ccf (float sps, float gain,
+ const std::vector<float> &taps,
+ unsigned int filter_size,
+ float init_phase);
+
+ public:
+ ~gr_pfb_clock_sync_ccf ();
+
+ void set_taps (const std::vector<float> &taps,
+ std::vector< std::vector<float> > &ourtaps,
+ std::vector<gr_fir_ccf*> &ourfilter);
+
+ std::vector<float> channel_taps(int channel);
+ std::vector<float> diff_channel_taps(int channel);
+ void print_taps();
+ void print_diff_taps();
+};
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc
index b334f5878..e05e18ff2 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc
+++ b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc
@@ -30,6 +30,7 @@
#include <gri_fft.h>
#include <gr_io_signature.h>
#include <gr_expj.h>
+#include <cstdio>
gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim,
const std::vector<float> &taps,
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h
index 83997c0c9..200adee3d 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h
+++ b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h
@@ -88,7 +88,7 @@ class gri_fft_complex;
* The theory behind this block can be found in Chapter 6 of
* the following book.
*
- * <B><EM>f. harris, Multirate Signal Processing for Communication
+ * <B><EM>f. harris, "Multirate Signal Processing for Communication
* Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B>
*/
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc
index d5eba885c..6a9598f34 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc
+++ b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc
@@ -28,6 +28,7 @@
#include <gr_fir_ccf.h>
#include <gr_fir_util.h>
#include <gr_io_signature.h>
+#include <cstdio>
gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp,
const std::vector<float> &taps)
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h
index 50849d510..d2efc591a 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h
+++ b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h
@@ -74,7 +74,7 @@ class gr_fir_ccf;
* The theory behind this block can be found in Chapter 7.1 of the
* following book.
*
- * <B><EM>f. harris, <EM>Multirate Signal Processing for Communication
+ * <B><EM>f. harris, "Multirate Signal Processing for Communication
* Systems</EM>," Upper Saddle River, NJ: Prentice Hall,
* Inc. 2004.</EM></B>
*/
diff --git a/gnuradio-core/src/lib/general/gr_constants.cc.in b/gnuradio-core/src/lib/general/gr_constants.cc.in
index efb0f1c77..71a47eb51 100644
--- a/gnuradio-core/src/lib/general/gr_constants.cc.in
+++ b/gnuradio-core/src/lib/general/gr_constants.cc.in
@@ -51,18 +51,6 @@ gr_build_date()
}
const std::string
-gr_svn_date()
-{
- return "@SVNDATE@";
-}
-
-const std::string
-gr_svn_version()
-{
- return "@SVNVERSION@";
-}
-
-const std::string
gr_version()
{
return "@VERSION@";
diff --git a/gnuradio-core/src/lib/general/gr_constants.h b/gnuradio-core/src/lib/general/gr_constants.h
index e44890be0..449d41c17 100644
--- a/gnuradio-core/src/lib/general/gr_constants.h
+++ b/gnuradio-core/src/lib/general/gr_constants.h
@@ -45,16 +45,6 @@ const std::string gr_prefsdir();
const std::string gr_build_date();
/*!
- * \brief return repository date as set when 'bootstrap' is run
- */
-const std::string gr_svn_date();
-
-/*!
- * \brief return repository version as set when 'bootstrap' is run
- */
-const std::string gr_svn_version();
-
-/*!
* \brief return version string defined in configure.ac
*/
const std::string gr_version();
diff --git a/gnuradio-core/src/lib/general/gr_constants.i b/gnuradio-core/src/lib/general/gr_constants.i
index 156af4a36..a5aef1492 100644
--- a/gnuradio-core/src/lib/general/gr_constants.i
+++ b/gnuradio-core/src/lib/general/gr_constants.i
@@ -4,14 +4,10 @@
%rename(sysconfdir) gr_sysconfdir;
%rename(prefsdir) gr_prefsdir;
%rename(build_date) gr_build_date;
-%rename(svn_date) gr_svn_date;
-%rename(svn_version) gr_svn_version;
%rename(version) gr_version;
const std::string gr_prefix();
const std::string gr_sysconfdir();
const std::string gr_prefsdir();
const std::string gr_build_date();
-const std::string gr_svn_date();
-const std::string gr_svn_version();
const std::string gr_version();
diff --git a/gnuradio-core/src/lib/gnuradio-config-info.cc b/gnuradio-core/src/lib/gnuradio-config-info.cc
index df78ea2dd..6fa53b877 100644
--- a/gnuradio-core/src/lib/gnuradio-config-info.cc
+++ b/gnuradio-core/src/lib/gnuradio-config-info.cc
@@ -43,8 +43,6 @@ main(int argc, char **argv)
("prefsdir", "print gnuradio preferences directory")
("builddate", "print gnuradio build date (RFC2822 format)")
("version,v", "print gnuradio version")
- ("svnversion", "print SVN repository version (SVN format)")
- ("svndate", "print SVN repository date")
;
po::store(po::parse_command_line(argc, argv, desc), vm);
@@ -70,11 +68,5 @@ main(int argc, char **argv)
if (vm.count("version"))
std::cout << gr_version() << std::endl;
- if (vm.count("svnversion"))
- std::cout << gr_svn_version() << std::endl;
-
- if (vm.count("svndate"))
- std::cout << gr_svn_date() << std::endl;
-
return 0;
}
diff --git a/gnuradio-core/src/python/gnuradio/Makefile.am b/gnuradio-core/src/python/gnuradio/Makefile.am
index ed36bbae7..dcc0017b3 100644
--- a/gnuradio-core/src/python/gnuradio/Makefile.am
+++ b/gnuradio-core/src/python/gnuradio/Makefile.am
@@ -34,5 +34,6 @@ grpython_PYTHON = \
packet_utils.py \
gr_unittest.py \
optfir.py \
+ usrp_options.py \
window.py
endif
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am
index 17be09cc7..f0825b151 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am
@@ -36,6 +36,7 @@ grblkspython_PYTHON = \
filterbank.py \
fm_demod.py \
fm_emph.py \
+ generic_usrp.py \
gmsk.py \
cpm.py \
logpwrfft.py \
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/generic_usrp.py b/gnuradio-core/src/python/gnuradio/blks2impl/generic_usrp.py
new file mode 100644
index 000000000..5abbaf9eb
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/generic_usrp.py
@@ -0,0 +1,244 @@
+#
+# Copyright 2009 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.
+#
+
+USRP1_TYPE = 'usrp1'
+USRP2_TYPE = 'usrp2'
+DUMMY_TYPE = 'dummy'
+#usrp2 rates common for decim and interp
+_USRP2_RATES = range(4, 128+1, 1) + range(130, 256+1, 2) + range(260, 512+1, 4)
+#dummy common rates
+_DUMMY_XRATES = range(4, 512, 2)
+_DUMMY_CONVERTER_RATE = 100e6
+#dummy freq result
+class _dummy_freq_result(object):
+ def __init__(self, target_freq):
+ self.baseband_freq = target_freq
+ self.dxc_freq = 0
+ self.residual_freq = 0
+from gnuradio import gr
+
+########################################################################
+# generic usrp common stuff
+########################################################################
+class _generic_usrp_base(object):
+
+ def __init__(self, which=0, subdev_spec=None, interface="", mac_addr="",
+ fusb_block_size=0, fusb_nblocks=0, usrpx=None, lo_offset=None, gain=None):
+ self._lo_offset = lo_offset
+ #usrp options
+ self._which = which
+ self._subdev_spec = subdev_spec
+ #usrp2 options
+ self._interface = interface
+ self._mac_addr = mac_addr
+ #fusb options
+ self._fusb_block_size = fusb_block_size
+ self._fusb_nblocks = fusb_nblocks
+ #pick which usrp model
+ if usrpx == '0': self._setup_usrpx(DUMMY_TYPE)
+ elif usrpx == '1' or self._subdev_spec: self._setup_usrpx(USRP1_TYPE)
+ elif usrpx == '2' or self._mac_addr: self._setup_usrpx(USRP2_TYPE)
+ else: #automatic
+ try: self._setup_usrpx(USRP2_TYPE)
+ except:
+ try: self._setup_usrpx(USRP1_TYPE)
+ except: raise Exception, 'Failed to automatically setup a usrp device.'
+ #post usrp setup
+ if self._lo_offset is not None:
+ self.set_lo_offset(self._lo_offset)
+ self.set_gain(gain)
+ self.set_auto_tr(True)
+
+ def _setup_usrpx(self, type):
+ """
+ Call the appropriate setup method.
+ @param type the usrp type constant
+ """
+ self._type = type
+ if self._type == USRP1_TYPE: self._setup_usrp1()
+ elif self._type == USRP2_TYPE: self._setup_usrp2()
+ elif self._type == DUMMY_TYPE: self._setup_dummy()
+
+ def __str__(self):
+ if self._type == USRP1_TYPE: return self._subdev.side_and_name()
+ elif self._type == USRP2_TYPE:
+ return 'Interface: %s MAC Address: %s D-Board ID: 0x%.2x'%(
+ self._u.interface_name(), self._u.mac_addr(), self._u.daughterboard_id())
+ elif self._type == DUMMY_TYPE: return 'Dummy USRP Device'
+
+ def gain(self): return self._gain
+
+ def set_gain(self, gain=None):
+ #automatic gain calculation
+ r = self.gain_range()
+ if gain is None: gain = (r[0] + r[1])/2 # set gain to midpoint
+ #set gain for usrp
+ self._gain = gain
+ if self._type == USRP1_TYPE: return self._subdev.set_gain(gain)
+ elif self._type == USRP2_TYPE: return self._u.set_gain(gain)
+ elif self._type == DUMMY_TYPE: return True
+
+ def gain_range(self):
+ if self._type == USRP1_TYPE: return self._subdev.gain_range()
+ elif self._type == USRP2_TYPE: return self._u.gain_range()
+ elif self._type == DUMMY_TYPE: return (0, 0, 0)
+
+ def set_center_freq(self, target_freq):
+ if self._type == USRP1_TYPE:
+ return self._u.tune(self._dxc, self._subdev, target_freq)
+ elif self._type == USRP2_TYPE:
+ return self._u.set_center_freq(target_freq)
+ elif self._type == DUMMY_TYPE: return _dummy_freq_result(target_freq)
+
+ def freq_range(self):
+ if self._type == USRP1_TYPE: return self._subdev.freq_range()
+ elif self._type == USRP2_TYPE: return self._u.freq_range()
+ elif self._type == DUMMY_TYPE: return (-10e9, 10e9, 100e3)
+
+ def set_lo_offset(self, lo_offset):
+ if self._type == USRP1_TYPE: return self._subdev.set_lo_offset(lo_offset)
+ elif self._type == USRP2_TYPE: return self._u.set_lo_offset(lo_offset)
+ elif self._type == DUMMY_TYPE: return True
+
+ def set_auto_tr(self, enable):
+ if self._type == USRP1_TYPE: return self._subdev.set_auto_tr(enable)
+
+ def __del__(self):
+ try: # Avoid weak reference error
+ del self._u
+ del self._subdev
+ except: pass
+
+########################################################################
+# generic usrp source
+########################################################################
+class generic_usrp_source_c(_generic_usrp_base, gr.hier_block2):
+ """
+ Create a generic usrp source that represents usrp and usrp2.
+ Take usrp and usrp2 constructor arguments and try to figure out usrp or usrp2.
+ Provide generic access methods so the API looks the same for both.
+ """
+
+ def __init__(self, **kwargs):
+ gr.hier_block2.__init__(self, "generic_usrp_source",
+ gr.io_signature(0, 0, 0), # Input signature
+ gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
+ _generic_usrp_base.__init__(self, **kwargs)
+ self.connect(self._u, self)
+
+ ####################################################################
+ # generic access methods
+ ####################################################################
+ def set_decim(self, decim):
+ if decim not in self.get_decim_rates(): return False
+ if self._type == USRP1_TYPE: return self._u.set_decim_rate(decim)
+ elif self._type == USRP2_TYPE: return self._u.set_decim(decim)
+ elif self._type == DUMMY_TYPE: return True
+
+ def get_decim_rates(self):
+ if self._type == USRP1_TYPE: return range(8, 256+1, 2) #default firmware w/ hb filters
+ if self._type == USRP2_TYPE: return _USRP2_RATES
+ elif self._type == DUMMY_TYPE: return _DUMMY_XRATES
+
+ def adc_rate(self):
+ if self._type == USRP1_TYPE: return self._u.adc_rate()
+ if self._type == USRP2_TYPE: return self._u.adc_rate()
+ elif self._type == DUMMY_TYPE: return _DUMMY_CONVERTER_RATE
+
+ ####################################################################
+ # setup usrp methods
+ ####################################################################
+ def _setup_usrp1(self):
+ from gnuradio import usrp
+ self._u = usrp.source_c (self._which,
+ fusb_block_size=self._fusb_block_size,
+ fusb_nblocks=self._fusb_nblocks)
+ # determine the daughterboard subdevice we're using
+ if self._subdev_spec is None:
+ self._subdev_spec = usrp.pick_rx_subdevice(self._u)
+ self._subdev = usrp.selected_subdev(self._u, self._subdev_spec)
+ self._u.set_mux(usrp.determine_rx_mux_value(self._u, self._subdev_spec))
+ self._dxc = 0
+
+ def _setup_usrp2(self):
+ from gnuradio import usrp2
+ self._u = usrp2.source_32fc(self._interface, self._mac_addr)
+
+ def _setup_dummy(self): self._u = gr.null_source(gr.sizeof_gr_complex)
+
+########################################################################
+# generic usrp sink
+########################################################################
+class generic_usrp_sink_c(_generic_usrp_base, gr.hier_block2):
+ """
+ Create a generic usrp sink that represents usrp and usrp2.
+ Take usrp and usrp2 constructor arguments and try to figure out usrp or usrp2.
+ Provide generic access methods so the API looks the same for both.
+ """
+
+ def __init__(self, **kwargs):
+ gr.hier_block2.__init__(self, "generic_usrp_sink",
+ gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
+ gr.io_signature(0, 0, 0)) # Output signature
+ _generic_usrp_base.__init__(self, **kwargs)
+ if self._type == USRP1_TYPE: #scale 0.0 to 1.0 input for usrp1
+ self.connect(self, gr.multiply_const_cc((2**15)-1), self._u)
+ else: self.connect(self, self._u)
+
+ ####################################################################
+ # generic access methods
+ ####################################################################
+ def set_interp(self, interp):
+ if interp not in self.get_interp_rates(): return False
+ if self._type == USRP1_TYPE: return self._u.set_interp_rate(interp)
+ elif self._type == USRP2_TYPE: return self._u.set_interp(interp)
+ elif self._type == DUMMY_TYPE: return True
+
+ def get_interp_rates(self):
+ if self._type == USRP1_TYPE: return range(16, 512+1, 4)
+ if self._type == USRP2_TYPE: return _USRP2_RATES
+ elif self._type == DUMMY_TYPE: return _DUMMY_XRATES
+
+ def dac_rate(self):
+ if self._type == USRP1_TYPE: return self._u.dac_rate()
+ if self._type == USRP2_TYPE: return self._u.dac_rate()
+ elif self._type == DUMMY_TYPE: return _DUMMY_CONVERTER_RATE
+
+ ####################################################################
+ # setup usrp methods
+ ####################################################################
+ def _setup_usrp1(self):
+ from gnuradio import usrp
+ self._u = usrp.sink_c (self._which,
+ fusb_block_size=self._fusb_block_size,
+ fusb_nblocks=self._fusb_nblocks)
+ # determine the daughterboard subdevice we're using
+ if self._subdev_spec is None:
+ self._subdev_spec = usrp.pick_tx_subdevice(self._u)
+ self._subdev = usrp.selected_subdev(self._u, self._subdev_spec)
+ self._u.set_mux(usrp.determine_tx_mux_value(self._u, self._subdev_spec))
+ self._dxc = self._subdev.which()
+
+ def _setup_usrp2(self):
+ from gnuradio import usrp2
+ self._u = usrp2.sink_32fc(self._interface, self._mac_addr)
+
+ def _setup_dummy(self): self._u = gr.null_sink(gr.sizeof_gr_complex)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py
index cf8eb1be7..7ef40be40 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py
@@ -55,9 +55,9 @@ class _logpwrfft_base(gr.hier_block2):
c2mag = gr.complex_to_mag(fft_size)
self._avg = gr.single_pole_iir_filter_ff(1.0, fft_size)
self._log = gr.nlog10_ff(20, fft_size,
- -10*math.log10(fft_size) # Adjust for number of bins
+ -20*math.log10(fft_size) # Adjust for number of bins
-10*math.log10(window_power/fft_size) # Adjust for windowing loss
- -20*math.log10(ref_scale/2)) # Adjust for reference scale
+ -20*math.log10(ref_scale/2)+3.0) # Adjust for reference scale
self.connect(self, self._sd, fft, c2mag, self._avg, self._log, self)
self._average = average
diff --git a/gnuradio-core/src/python/gnuradio/eng_option.py b/gnuradio-core/src/python/gnuradio/eng_option.py
index 09c3e1d87..e10235f14 100644
--- a/gnuradio-core/src/python/gnuradio/eng_option.py
+++ b/gnuradio-core/src/python/gnuradio/eng_option.py
@@ -23,29 +23,11 @@
from copy import copy
from optparse import Option, OptionValueError
-
-scale_factor = {}
-scale_factor['E'] = 1e18
-scale_factor['P'] = 1e15
-scale_factor['T'] = 1e12
-scale_factor['G'] = 1e9
-scale_factor['M'] = 1e6
-scale_factor['k'] = 1e3
-scale_factor['m'] = 1e-3
-scale_factor['u'] = 1e-6
-scale_factor['n'] = 1e-9
-scale_factor['p'] = 1e-12
-scale_factor['f'] = 1e-15
-scale_factor['a'] = 1e-18
-
+import eng_notation
def check_eng_float (option, opt, value):
try:
- scale = 1.0
- suffix = value[-1]
- if scale_factor.has_key (suffix):
- return float (value[0:-1]) * scale_factor[suffix]
- return float (value)
+ return eng_notation.str_to_num(value)
except:
raise OptionValueError (
"option %s: invalid engineering notation value: %r" % (opt, value))
diff --git a/gnuradio-core/src/python/gnuradio/usrp_options.py b/gnuradio-core/src/python/gnuradio/usrp_options.py
new file mode 100644
index 000000000..86dba2f9a
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/usrp_options.py
@@ -0,0 +1,123 @@
+#
+# Copyright 2009 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.
+#
+
+_parser_to_groups_dict = dict()
+class _parser_groups(object):
+ def __init__(self, parser):
+ self.usrpx_grp = parser.add_option_group("General USRP Options")
+ self.usrp1_grp = parser.add_option_group("USRP1 Specific Options")
+ self.usrp1exp_grp = parser.add_option_group("USRP1 Expert Options")
+ self.usrp2_grp = parser.add_option_group("USRP2 Specific Options")
+
+from gnuradio import blks2
+
+def _add_options(parser):
+ """
+ Add options to manually choose between usrp or usrp2.
+ Add options for usb. Add options common to source and sink.
+ @param parser: instance of OptionParser
+ @return the parser group
+ """
+ #cache groups so they dont get added twice on tranceiver apps
+ if not _parser_to_groups_dict.has_key(parser): _parser_to_groups_dict[parser] = _parser_groups(parser)
+ pg = _parser_to_groups_dict[parser]
+ #pick usrp or usrp2
+ pg.usrpx_grp.add_option("-u", "--usrpx", type="string", default=None,
+ help="specify which usrp model: 1 for USRP, 2 for USRP2 [default=auto]")
+ #fast usb options
+ pg.usrp1exp_grp.add_option("-B", "--fusb-block-size", type="int", default=0,
+ help="specify fast usb block size [default=%default]")
+ pg.usrp1exp_grp.add_option("-N", "--fusb-nblocks", type="int", default=0,
+ help="specify number of fast usb blocks [default=%default]")
+ #lo offset
+ pg.usrpx_grp.add_option("--lo-offset", type="eng_float", default=None,
+ help="set LO Offset in Hz [default=automatic].")
+ #usrp options
+ pg.usrp1_grp.add_option("-w", "--which", type="int", default=0,
+ help="select USRP board [default=%default]")
+ #usrp2 options
+ pg.usrp2_grp.add_option("-e", "--interface", type="string", default="eth0",
+ help="Use USRP2 at specified Ethernet interface [default=%default]")
+ pg.usrp2_grp.add_option("-a", "--mac-addr", type="string", default="",
+ help="Use USRP2 at specified MAC address [default=None]")
+ return pg
+
+def add_rx_options(parser):
+ """
+ Add receive specific usrp options.
+ @param parser: instance of OptionParser
+ """
+ pg = _add_options(parser)
+ pg.usrp1_grp.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
+ help="select USRP Rx side A or B")
+ pg.usrpx_grp.add_option("--rx-gain", type="eng_float", default=None, metavar="GAIN",
+ help="set receiver gain in dB [default=midpoint]. See also --show-rx-gain-range")
+ pg.usrpx_grp.add_option("--show-rx-gain-range", action="store_true", default=False,
+ help="print min and max Rx gain available on selected daughterboard")
+ pg.usrpx_grp.add_option("-d", "--decim", type="intx", default=None,
+ help="set fpga decimation rate to DECIM [default=%default]")
+
+def create_usrp_source(options):
+ u = blks2.generic_usrp_source_c(
+ usrpx=options.usrpx,
+ which=options.which,
+ subdev_spec=options.rx_subdev_spec,
+ interface=options.interface,
+ mac_addr=options.mac_addr,
+ fusb_block_size=options.fusb_block_size,
+ fusb_nblocks=options.fusb_nblocks,
+ lo_offset=options.lo_offset,
+ gain=options.rx_gain,
+ )
+ if options.show_rx_gain_range:
+ print "Rx Gain Range: minimum = %g, maximum = %g, step size = %g"%tuple(u.gain_range())
+ return u
+
+def add_tx_options(parser):
+ """
+ Add transmit specific usrp options.
+ @param parser: instance of OptionParser
+ """
+ pg = _add_options(parser)
+ pg.usrp1_grp.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
+ help="select USRP Rx side A or B")
+ pg.usrpx_grp.add_option("--tx-gain", type="eng_float", default=None, metavar="GAIN",
+ help="set transmitter gain in dB [default=midpoint]. See also --show-tx-gain-range")
+ pg.usrpx_grp.add_option("--show-tx-gain-range", action="store_true", default=False,
+ help="print min and max Tx gain available on selected daughterboard")
+ pg.usrpx_grp.add_option("-i", "--interp", type="intx", default=None,
+ help="set fpga interpolation rate to INTERP [default=%default]")
+
+def create_usrp_sink(options):
+ u = blks2.generic_usrp_sink_c(
+ usrpx=options.usrpx,
+ which=options.which,
+ subdev_spec=options.tx_subdev_spec,
+ interface=options.interface,
+ mac_addr=options.mac_addr,
+ fusb_block_size=options.fusb_block_size,
+ fusb_nblocks=options.fusb_nblocks,
+ lo_offset=options.lo_offset,
+ gain=options.tx_gain,
+ )
+ if options.show_tx_gain_range:
+ print "Tx Gain Range: minimum = %g, maximum = %g, step size = %g"%tuple(u.gain_range())
+ return u