diff options
Diffstat (limited to 'gnuradio-examples/python/hier/sounder')
-rw-r--r-- | gnuradio-examples/python/hier/sounder/Makefile.am | 30 | ||||
-rw-r--r-- | gnuradio-examples/python/hier/sounder/sounder_rx.py | 53 | ||||
-rw-r--r-- | gnuradio-examples/python/hier/sounder/sounder_tx.py | 45 | ||||
-rw-r--r-- | gnuradio-examples/python/hier/sounder/usrp_sink.py | 117 | ||||
-rwxr-xr-x | gnuradio-examples/python/hier/sounder/usrp_sounder_rx.py | 95 | ||||
-rwxr-xr-x | gnuradio-examples/python/hier/sounder/usrp_sounder_tx.py | 110 | ||||
-rw-r--r-- | gnuradio-examples/python/hier/sounder/usrp_source.py | 126 |
7 files changed, 0 insertions, 576 deletions
diff --git a/gnuradio-examples/python/hier/sounder/Makefile.am b/gnuradio-examples/python/hier/sounder/Makefile.am deleted file mode 100644 index 9814d80ef8..0000000000 --- a/gnuradio-examples/python/hier/sounder/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright 2007 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. -# - -EXTRA_DIST = \ - usrp_sounder_rx.py \ - usrp_sounder_tx.py \ - usrp_source.py \ - usrp_sink.py \ - sounder_rx.py \ - sounder_tx.py - -MOSTLYCLEANFILES = *.pyc *~ *.dat diff --git a/gnuradio-examples/python/hier/sounder/sounder_rx.py b/gnuradio-examples/python/hier/sounder/sounder_rx.py deleted file mode 100644 index d24eb8efa9..0000000000 --- a/gnuradio-examples/python/hier/sounder/sounder_rx.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 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. -# - -from gnuradio import gr, usrp, eng_notation -from usrp_source import usrp_source_c -import math - -n2s = eng_notation.num_to_str - -class sounder_rx(gr.hier_block2): - """ - Creates a channel sounder receiver block with the given parameters. - """ - - def __init__(self, chip_rate, degree, verbose): - - # Call hierarchical block constructor - # Top-level blocks have no inputs or outputs - gr.hier_block2.__init__(self, - "sounder_rx", # Block typename - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._degree = degree - self._chip_rate = chip_rate - self._verbose = verbose - self._length = 2**self._degree-1 - self._rep_rate = self._chip_rate/float(self._length) - - if self._verbose: - print "Using PN sequence of degree", self._degree, "length", self._length - print "Sequence repetition rate is", n2s(self._rep_rate), "per sec" - - self.connect(self, gr.pn_correlator_cc(self._degree), self) diff --git a/gnuradio-examples/python/hier/sounder/sounder_tx.py b/gnuradio-examples/python/hier/sounder/sounder_tx.py deleted file mode 100644 index dcdd9fc5ce..0000000000 --- a/gnuradio-examples/python/hier/sounder/sounder_tx.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 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. -# - -from gnuradio import gr, usrp, eng_notation -import math - -n2s = eng_notation.num_to_str - -class sounder_tx(gr.hier_block2): - """ - Creates a channel sounder generator with the given parameters. - """ - - def __init__(self, degree, chip_rate, verbose): - gr.hier_block2.__init__(self, - "sounder_tx", # Block typename - gr.io_signature(0,0,0), # Input signature - gr.io_signature(1, 1, gr.sizeof_float)) # Output signature - - self._degree = degree - self._chip_rate = chip_rate - self._verbose = verbose - self._length = 2**degree-1 - - # Connect PN source to block output - self.connect(gr.glfsr_source_f(degree), self) diff --git a/gnuradio-examples/python/hier/sounder/usrp_sink.py b/gnuradio-examples/python/hier/sounder/usrp_sink.py deleted file mode 100644 index 34b6107048..0000000000 --- a/gnuradio-examples/python/hier/sounder/usrp_sink.py +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 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. -# - -from gnuradio import gr, usrp, eng_notation -n2s = eng_notation.num_to_str - -# Hierarchical block implementing a USRP sink for complex floats, -# with convenience functions for tuning, interpolation, etc. -# -class usrp_sink_c(gr.hier_block2): - """ - Create a USRP sink object accepting complex floats. - """ - def __init__(self, which=0, subdev_spec=None, if_rate=None, - freq=0.0, calibration=0.0, verbose=False): - # Call hierarchical block constructor - gr.hier_block2.__init__(self, - "usrp_sink_c", # Block typename - gr.io_signature(1,1,gr.sizeof_gr_complex), # Input signature - gr.io_signature(0,0,0)) # Output signature - - self._verbose = verbose - self._u = usrp.sink_c(which) - if self._verbose: - print 'DAC sample rate is', n2s(self._u.dac_rate()), "sps" - self.set_subdev(subdev_spec) - self.set_if_rate(if_rate) - self.set_calibration(calibration) - self.tune(freq) - self.connect(self, self._u) - - def set_subdev(self, subdev_spec): - if subdev_spec is None: - subdev_spec = self.pick_subdevice() - self._subdev = usrp.selected_subdev(self._u, subdev_spec) - self._u.set_mux(usrp.determine_tx_mux_value(self._u, subdev_spec)) - if self._verbose: - print 'TX using', self._subdev.name(), 'daughterboard' - - def pick_subdevice(self): - """ - The user didn't specify a subdevice. - If there's a daughterboard on A, select A. - If there's a daughterboard on B, select B. - Otherwise, select A. - """ - if self._u.db[0][0].dbid() >= 0: # dbid is < 0 if there's no d'board or a problem - return (0, 0) - if self._u.db[1][0].dbid() >= 0: - return (1, 0) - return (0, 0) - - def set_if_rate(self, if_rate): - # If no IF rate specified, set to maximum interpolation - if if_rate is None: - self._interp = 512 - else: - self._interp = 4*int(self._u.dac_rate()/(4.0*if_rate)+0.5) - - - self._if_rate = self._u.dac_rate()/self._interp - self._u.set_interp_rate(self._interp) - - if self._verbose: - print "USRP interpolation rate is", self._interp - print "USRP IF rate is", n2s(self._if_rate), "sps" - - def set_calibration(self, calibration): - self._cal = calibration - if self._verbose: - print "Using frequency calibration offset of", n2s(calibration), "Hz" - - def tune(self, freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @type: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital down converter. - """ - self._tune_result = self._u.tune(self._subdev._which, self._subdev, freq+self._cal) - if self._tune_result: - if self._verbose: - print "Baseband frequency is", n2s(self._tune_result.baseband_freq), "Hz" - print "DXC frequency is", n2s(self._tune_result.dxc_freq), "Hz" - print "Center frequency is", n2s(freq), "Hz" - print "Residual frequency is", n2s(self._tune_result.residual_freq), "Hz" - return True - - return False - -if __name__ == '__main__': - sink = usrp_sink_c(verbose=True) - diff --git a/gnuradio-examples/python/hier/sounder/usrp_sounder_rx.py b/gnuradio-examples/python/hier/sounder/usrp_sounder_rx.py deleted file mode 100755 index 6b85281ad7..0000000000 --- a/gnuradio-examples/python/hier/sounder/usrp_sounder_rx.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 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. -# - -from gnuradio import gr, eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser -from usrp_source import usrp_source_c -from sounder_rx import sounder_rx - -n2s = eng_notation.num_to_str - -class usrp_sounder_rx(gr.top_block): - def __init__(self, options): - gr.top_block.__init__(self, "usrp_sounder_rx") - self._options = options - self._u = usrp_source_c(0, - self._options.rx_subdev_spec, - self._options.gain, - self._options.chip_rate, - self._options.freq, - self._options.cal, - self._options.verbose) - self._options.chip_rate = self._u._if_rate - self._length = 2**self._options.degree-1 - self._receiver = sounder_rx(self._options.chip_rate, - self._options.degree, - self._options.verbose) - - samples = 100 * self._length**2 - - head = gr.head(gr.sizeof_gr_complex, samples) - c2m = gr.complex_to_mag() - s2v = gr.stream_to_vector(gr.sizeof_float, self._length) - lpf = gr.single_pole_iir_filter_ff(self._options.alpha, self._length) - v2s = gr.vector_to_stream(gr.sizeof_float, self._length) - sink = gr.file_sink(gr.sizeof_float, "impulse.dat") - - self.connect(self._u, head, self._receiver, c2m, s2v, lpf, v2s, sink) - - if self._options.verbose: - print "Chip rate is", n2s(self._options.chip_rate), "chips/sec" - print "Resolution is", n2s(1.0/self._options.chip_rate), "sec" - print "Using PN code of degree", self._options.degree - -def main(): - parser = OptionParser(option_class=eng_option) - parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, - help="select USRP Rx side A or B (default=first found)") - parser.add_option("-f", "--freq", type="eng_float", default=0.0, - help="set center frequency (default=%default)") - parser.add_option("-c", "--cal", type="eng_float", default=0.0, - help="set frequency calibration offset (default=%default)") - parser.add_option("-v", "--verbose", action="store_true", default=False, - help="print extra debugging info") - parser.add_option("-d", "--degree", type="int", default=10, - help="set PN code degree (length=2**degree-1, default=%default)") - parser.add_option("-r", "--chip-rate", type="eng_float", default=8e6, - help="set sounder chip rate (default=%default)") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set receiver gain (default=%default)") - parser.add_option("", "--alpha", type="eng_float", default=1.0, - help="set smoothing constant (default=%default)") - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - top_block = usrp_sounder_rx(options) - - try: - top_block.run() - except KeyboardInterrupt: - pass - -if __name__ == '__main__': - main () diff --git a/gnuradio-examples/python/hier/sounder/usrp_sounder_tx.py b/gnuradio-examples/python/hier/sounder/usrp_sounder_tx.py deleted file mode 100755 index ae531d5100..0000000000 --- a/gnuradio-examples/python/hier/sounder/usrp_sounder_tx.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 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. -# - -from gnuradio import gr, eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser -from usrp_sink import usrp_sink_c -from sounder_tx import sounder_tx - -n2s = eng_notation.num_to_str - -class usrp_sounder_tx(gr.top_block): - def __init__(self, subdev_spec, freq, cal, verbose, degree, chip_rate, amplitude): - - # Call hierarchical block constructor - # Top-level blocks have no inputs or outputs - gr.top_block.__init__(self, "usrp_sounder_tx") - self._freq = freq - self._cal = cal - self._verbose = verbose - self._degree = degree - self._length = 2**degree-1 - self._amplitude = amplitude - - self._u = usrp_sink_c(0, subdev_spec, chip_rate, self._freq, self._cal, self._verbose) - self._chip_rate = self._u._if_rate - self._max_time = float(self._length)/self._chip_rate - self._pn = sounder_tx(self._degree, self._chip_rate, self._verbose) - self._gain = gr.multiply_const_ff(amplitude) - self._f2c = gr.float_to_complex() - self.connect(self._pn, self._gain, self._f2c, self._u) - - if self._verbose: - print "Chip rate is", n2s(self._chip_rate), "chips/sec" - print "Resolution is", n2s(1.0/self._chip_rate), "sec" - print "Using PN code of degree", self._degree, "length", 2**self._degree-1 - print "Maximum measurable impulse response is", n2s(self._max_time), "sec" - print "Output amplitude is", amplitude - - -def main(): - parser = OptionParser(option_class=eng_option) - - # Transmit path options - parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None, - help="select USRP Rx side A or B (default=first found)") - parser.add_option("-f", "--freq", type="eng_float", default=0.0, - help="set center frequency (default=%default)") - parser.add_option("-c", "--cal", type="eng_float", default=0.0, - help="set frequency calibration offset (default=%default)") - parser.add_option("-v", "--verbose", action="store_true", default=False, - help="print extra debugging info") - parser.add_option("-d", "--degree", type="int", default=10, - help="set PN code degree (length=2**degree-1, default=%default)") - parser.add_option("-r", "--chip-rate", type="eng_float", default=8e6, - help="set sounder chip rate (default=%default)") - parser.add_option("-g", "--amplitude", type="eng_float", default=8000.0, - help="set output amplitude (default=%default)") - parser.add_option("", "--real-time", action="store_true", default=False, - help="Attempt to enable real-time scheduling") - (options, args) = parser.parse_args() - - if len(args) != 0: - parser.print_help() - sys.exit(1) - - if not options.real_time: - realtime = False - else: - # Attempt to enable realtime scheduling - r = gr.enable_realtime_scheduling() - if r == gr.RT_OK: - realtime = True - else: - realtime = False - print "Note: failed to enable realtime scheduling" - - # Create an instance of a hierarchical block - top_block = usrp_sounder_tx(options.tx_subdev_spec, options.freq, options.cal, - options.verbose, options.degree, options.chip_rate, - options.amplitude) - - try: - # Run forever - top_block.run() - except KeyboardInterrupt: - # Ctrl-C exits - pass - -if __name__ == '__main__': - main () diff --git a/gnuradio-examples/python/hier/sounder/usrp_source.py b/gnuradio-examples/python/hier/sounder/usrp_source.py deleted file mode 100644 index 63eb3ce2bf..0000000000 --- a/gnuradio-examples/python/hier/sounder/usrp_source.py +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 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. -# - -from gnuradio import gr, usrp, eng_notation -n2s = eng_notation.num_to_str - -# Hierarchical block implementing a USRP source for complex floats, -# with convenience functions for gain, tune, decimation, etc. -# -class usrp_source_c(gr.hier_block2): - """ - Create a USRP source object supplying complex floats. - """ - def __init__(self, which=0, subdev_spec=None, gain=None, if_rate=None, - freq=0.0, calibration=0.0, verbose=False): - # Call hierarchical block constructor - gr.hier_block2.__init__(self, - "usrp_source_c", # Block typename - gr.io_signature(0,0,0), # Input signature - gr.io_signature(1,1,gr.sizeof_gr_complex)) # Output signature - - self._verbose = verbose - self._u = usrp.source_c(which) - if self._verbose: - print 'ADC sample rate is', n2s(self._u.adc_rate()), "sps" - self.set_subdev(subdev_spec) - self.set_if_rate(if_rate) - self.set_gain(gain) - self.set_calibration(calibration) - self.tune(freq) - self.connect(self._u, self) - - def set_subdev(self, subdev_spec): - if subdev_spec is None: - subdev_spec = self.pick_subdevice() - self._subdev = usrp.selected_subdev(self._u, subdev_spec) - self._u.set_mux(usrp.determine_rx_mux_value(self._u, subdev_spec)) - if self._verbose: - print 'RX using', self._subdev.name(), 'daughterboard' - - def pick_subdevice(self): - """ - The user didn't specify a subdevice. - If there's a daughterboard on A, select A. - If there's a daughterboard on B, select B. - Otherwise, select A. - """ - if self._u.db[0][0].dbid() >= 0: # dbid is < 0 if there's no d'board or a problem - return (0, 0) - if self._u.db[1][0].dbid() >= 0: - return (1, 0) - return (0, 0) - - def set_if_rate(self, if_rate): - # If no IF rate specified, set to maximum decimation - if if_rate is None: - self._decim = 256 - else: - self._decim = int(self._u.adc_rate()/if_rate) - - self._u.set_decim_rate(self._decim) - self._if_rate = self._u.adc_rate()/self._decim - - if self._verbose: - print "USRP decimation rate is", self._decim - print "USRP IF rate is", n2s(self._if_rate), "sps" - - def set_gain(self, gain): - # If no gain specified, set to midrange - if gain is None: - g = self._subdev.gain_range() - gain = (g[0]+g[1])/2.0 - self._gain = gain - self._subdev.set_gain(self._gain) - if self._verbose: - print "USRP gain set to", self._gain - - def set_calibration(self, calibration): - self._cal = calibration - if self._verbose: - print "Using frequency calibration offset of", n2s(calibration), "Hz" - - def tune(self, freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @type: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital down converter. - """ - self._tune_result = usrp.tune(self._u, 0, self._subdev, freq+self._cal) - if self._tune_result: - if self._verbose: - print "Baseband frequency is", n2s(self._tune_result.baseband_freq), "Hz" - print "DXC frequency is", n2s(self._tune_result.dxc_freq), "Hz" - print "Center frequency is", n2s(freq), "Hz" - print "Residual frequency is", n2s(self._tune_result.residual_freq), "Hz" - return True - - return False - -if __name__ == '__main__': - src = usrp_source_c(verbose=True) |