diff options
author | trondeau | 2009-06-17 22:48:03 +0000 |
---|---|---|
committer | trondeau | 2009-06-17 22:48:03 +0000 |
commit | 4ae36c7b4cee668a68a6f149c874e01fa2484f1c (patch) | |
tree | e164989def69e81853bc7e570e20e2821e08e7d0 /gnuradio-examples | |
parent | 5f6f09b79e7b54b7130a26ff4ab6c5db6c4ab70e (diff) | |
download | gnuradio-4ae36c7b4cee668a68a6f149c874e01fa2484f1c.tar.gz gnuradio-4ae36c7b4cee668a68a6f149c874e01fa2484f1c.tar.bz2 gnuradio-4ae36c7b4cee668a68a6f149c874e01fa2484f1c.zip |
Fixing digital benchmarks: adding usrp_options class to reciever.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11224 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-examples')
-rwxr-xr-x | gnuradio-examples/python/digital/benchmark_rx.py | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/gnuradio-examples/python/digital/benchmark_rx.py b/gnuradio-examples/python/digital/benchmark_rx.py index 736110da4..0e82d9ba9 100755 --- a/gnuradio-examples/python/digital/benchmark_rx.py +++ b/gnuradio-examples/python/digital/benchmark_rx.py @@ -32,6 +32,8 @@ import sys # from current dir from receive_path import receive_path +from pick_bitrate import pick_rx_bitrate +import usrp_options #import os #print os.getpid() @@ -43,43 +45,43 @@ class my_top_block(gr.top_block): self._rx_freq = options.rx_freq # receiver's center frequency self._rx_gain = options.rx_gain # receiver's gain - self._rx_subdev_spec = options.rx_subdev_spec # daughterboard to use self._decim = options.decim # Decimating rate for the USRP (prelim) + self._bitrate = options.bitrate + self._samples_per_symbol = options.samples_per_symbol + self._demod_class = demodulator if self._rx_freq is None: sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n") raise SystemExit # Set up USRP source - self._setup_usrp_source() + self._setup_usrp_source(options) ok = self.set_freq(self._rx_freq) if not ok: print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(self._rx_freq)) raise ValueError, eng_notation.num_to_str(self._rx_freq) - g = self.subdev.gain_range() - if options.show_rx_gain_range: - print "Rx Gain Range: minimum = %g, maximum = %g, step size = %g" \ - % (g[0], g[1], g[2]) + self.set_gain(options.rx_gain) - self.set_auto_tr(True) # enable Auto Transmit/Receive switching + #self.set_auto_tr(True) # enable Auto Transmit/Receive switching # Set up receive path self.rxpath = receive_path(demodulator, rx_callback, options) self.connect(self.u, self.rxpath) - def _setup_usrp_source(self): - self.u = usrp.source_c () + def _setup_usrp_source(self, options): + self.u = usrp_options.create_usrp_source(options) adc_rate = self.u.adc_rate() - self.u.set_decim_rate(self._decim) + self.u.set_decim(self._decim) + + (self._bitrate, self._samples_per_symbol, self._decim) = \ + pick_rx_bitrate(self._bitrate, self._demod_class.bits_per_symbol(), \ + self._samples_per_symbol, self._decim, adc_rate, \ + self.u.get_decim_rates()) - # determine the daughterboard subdevice we're using - if self._rx_subdev_spec is None: - self._rx_subdev_spec = usrp.pick_rx_subdevice(self.u) - self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec) + self.u.set_decim(self._decim) - self.u.set_mux(usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec)) def set_freq(self, target_freq): """ @@ -93,21 +95,17 @@ class my_top_block(gr.top_block): the result of that operation and our target_frequency to determine the value for the digital up converter. """ - r = self.u.tune(0, self.subdev, target_freq) - if r: - return True - - return False + return self.u.set_center_freq(target_freq) def set_gain(self, gain): """ Sets the analog gain in the USRP """ if gain is None: - r = self.subdev.gain_range() + r = self.u.gain_range() gain = (r[0] + r[1])/2 # set gain to midpoint self.gain = gain - return self.subdev.set_gain(gain) + return self.u.set_gain(gain) def set_auto_tr(self, enable): return self.subdev.set_auto_tr(enable) @@ -120,20 +118,10 @@ class my_top_block(gr.top_block): Adds usrp-specific options to the Options Parser """ add_freq_option(normal) - normal.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, - help="select USRP Rx side A or B") - normal.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") - normal.add_option("", "--show-rx-gain-range", action="store_true", default=False, - help="print min and max Rx gain available on selected daughterboard") normal.add_option("-v", "--verbose", action="store_true", default=False) expert.add_option("", "--rx-freq", type="eng_float", default=None, help="set Rx frequency to FREQ [default=%default]", metavar="FREQ") - expert.add_option("-d", "--decim", type="intx", default=128, - help="set fpga decimation rate to DECIM [default=%default]") - expert.add_option("", "--snr", type="eng_float", default=30, - help="set the SNR of the channel in dB [default=%default]") # Make a static method to call before instantiation @@ -191,6 +179,7 @@ def main(): my_top_block.add_options(parser, expert_grp) receive_path.add_options(parser, expert_grp) + usrp_options.add_rx_options(parser) for mod in demods.values(): mod.add_options(expert_grp) |