diff options
author | jcorgan | 2007-09-18 18:59:00 +0000 |
---|---|---|
committer | jcorgan | 2007-09-18 18:59:00 +0000 |
commit | e692e71305ecd71d3681fe37f3d76f350d67e276 (patch) | |
tree | dc320c9261303aa9a92f4d12bdba85f82720d1bf /gnuradio-examples/python/usrp | |
parent | 6ad04a094ced626e46c210b9847eae46a1ae8e67 (diff) | |
download | gnuradio-e692e71305ecd71d3681fe37f3d76f350d67e276.tar.gz gnuradio-e692e71305ecd71d3681fe37f3d76f350d67e276.tar.bz2 gnuradio-e692e71305ecd71d3681fe37f3d76f350d67e276.zip |
Merge r6461:6464 from jcorgan/t162-staging into trunk.
* Final gr.top_block and gr.hier_block2 implementation inside
gnuradio-core/src/lib/runtime
* Implementation of gr.hier_block2 versions of all the old-style blocks
in blks. These live in blks2.
* Addition of gr.hier_block2 based versions of gr-wxgui blocks
* Conversion of all the example code in gnuradio-examples to use this
new code
* Conversion of all the gr-utils scripts to use the new code
The OFDM examples and related hierarchical blocks have not yet been
converted. Code in the rest of the tree that is outside the core
and example components has also not yet been converted.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@6466 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-examples/python/usrp')
-rwxr-xr-x | gnuradio-examples/python/usrp/fm_tx4.py | 60 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/fm_tx_2_daughterboards.py | 57 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/max_power.py | 20 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_benchmark_usb.py | 8 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_nbfm_ptt.py | 64 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_nbfm_rcv.py | 65 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_spectrum_sense.py | 41 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_test_loop_lfsr.py | 16 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_tv_rcv.py | 30 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_tv_rcv_nogui.py | 26 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_wfm_rcv.py | 38 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_wfm_rcv2_nogui.py | 35 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_wfm_rcv_nogui.py | 32 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_wfm_rcv_pll.py | 56 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_wfm_rcv_sca.py | 25 | ||||
-rwxr-xr-x | gnuradio-examples/python/usrp/usrp_wxapt_rcv.py | 38 |
16 files changed, 421 insertions, 190 deletions
diff --git a/gnuradio-examples/python/usrp/fm_tx4.py b/gnuradio-examples/python/usrp/fm_tx4.py index 7e5023ddb..e97468d5e 100755 --- a/gnuradio-examples/python/usrp/fm_tx4.py +++ b/gnuradio-examples/python/usrp/fm_tx4.py @@ -1,4 +1,24 @@ #!/usr/bin/env python +# +# Copyright 2005,2006,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. +# """ Transmit N simultaneous narrow band FM signals. @@ -15,14 +35,14 @@ audio_to_file.py from gnuradio import gr, eng_notation from gnuradio import usrp from gnuradio import audio -from gnuradio import blks +from gnuradio import blks2 from gnuradio.eng_option import eng_option from optparse import OptionParser from usrpm import usrp_dbid import math import sys -from gnuradio.wxgui import stdgui, fftsink +from gnuradio.wxgui import stdgui2, fftsink2 from gnuradio import tx_debug_gui import wx @@ -30,12 +50,15 @@ import wx ######################################################## # instantiate one transmit chain for each call -class pipeline(gr.hier_block): - def __init__(self, fg, filename, lo_freq, audio_rate, if_rate): +class pipeline(gr.hier_block2): + def __init__(self, filename, lo_freq, audio_rate, if_rate): + + gr.hier_block2.__init__(self, "pipeline", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature src = gr.file_source (gr.sizeof_float, filename, True) - fmtx = blks.nbfm_tx (fg, audio_rate, if_rate, - max_dev=5e3, tau=75e-6) + fmtx = blks2.nbfm_tx (audio_rate, if_rate, max_dev=5e3, tau=75e-6) # Local oscillator lo = gr.sig_source_c (if_rate, # sample rate @@ -45,17 +68,14 @@ class pipeline(gr.hier_block): 0) # DC Offset mixer = gr.multiply_cc () - fg.connect (src, fmtx, (mixer, 0)) - fg.connect (lo, (mixer, 1)) - - gr.hier_block.__init__(self, fg, src, mixer) - + self.connect (src, fmtx, (mixer, 0)) + self.connect (lo, (mixer, 1)) -class fm_tx_graph (stdgui.gui_flow_graph): +class fm_tx_block(stdgui2.std_top_block): def __init__(self, frame, panel, vbox, argv): MAX_CHANNELS = 7 - stdgui.gui_flow_graph.__init__ (self, frame, panel, vbox, argv) + stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) parser = OptionParser (option_class=eng_option) parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None, @@ -119,9 +139,9 @@ class fm_tx_graph (stdgui.gui_flow_graph): step = 25e3 offset = (0 * step, 1 * step, -1 * step, 2 * step, -2 * step, 3 * step, -3 * step) for i in range (options.nchannels): - t = pipeline (self, "audio-%d.dat" % (i % 4), offset[i], - self.audio_rate, self.usrp_rate) - self.connect (t, (sum, i)) + t = pipeline("audio-%d.dat" % (i % 4), offset[i], + self.audio_rate, self.usrp_rate) + self.connect(t, (sum, i)) gain = gr.multiply_const_cc (4000.0 / options.nchannels) @@ -131,9 +151,9 @@ class fm_tx_graph (stdgui.gui_flow_graph): # plot an FFT to verify we are sending what we want if 1: - post_mod = fftsink.fft_sink_c(self, panel, title="Post Modulation", - fft_size=512, sample_rate=self.usrp_rate, - y_per_div=20, ref_level=40) + post_mod = fftsink2.fft_sink_c(panel, title="Post Modulation", + fft_size=512, sample_rate=self.usrp_rate, + y_per_div=20, ref_level=40) self.connect (sum, post_mod) vbox.Add (post_mod.win, 1, wx.EXPAND) @@ -170,7 +190,7 @@ class fm_tx_graph (stdgui.gui_flow_graph): return False def main (): - app = stdgui.stdapp (fm_tx_graph, "Multichannel FM Tx") + app = stdgui2.stdapp(fm_tx_block, "Multichannel FM Tx", nstatus=1) app.MainLoop () if __name__ == '__main__': diff --git a/gnuradio-examples/python/usrp/fm_tx_2_daughterboards.py b/gnuradio-examples/python/usrp/fm_tx_2_daughterboards.py index 66ee9f02d..499c7230b 100755 --- a/gnuradio-examples/python/usrp/fm_tx_2_daughterboards.py +++ b/gnuradio-examples/python/usrp/fm_tx_2_daughterboards.py @@ -1,4 +1,24 @@ #!/usr/bin/env python +# +# Copyright 2005,2006,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. +# """ Transmit 2 signals, one out each daughterboard. @@ -14,7 +34,7 @@ from gnuradio import gr from gnuradio.eng_notation import num_to_str, str_to_num from gnuradio import usrp from gnuradio import audio -from gnuradio import blks +from gnuradio import blks2 from gnuradio.eng_option import eng_option from optparse import OptionParser from usrpm import usrp_dbid @@ -22,11 +42,14 @@ import math import sys -class example_signal_0(gr.hier_block): +class example_signal_0(gr.hier_block2): """ Sinusoid at 600 Hz. """ - def __init__(self, fg, sample_rate): + def __init__(self, sample_rate): + gr.hier_block2.__init__(self, "example_signal_0", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature src = gr.sig_source_c (sample_rate, # sample rate gr.GR_SIN_WAVE, # waveform type @@ -34,14 +57,17 @@ class example_signal_0(gr.hier_block): 1.0, # amplitude 0) # DC Offset - gr.hier_block.__init__(self, fg, None, src) + self.connect(src, self) -class example_signal_1(gr.hier_block): +class example_signal_1(gr.hier_block2): """ North American dial tone (350 + 440 Hz). """ - def __init__(self, fg, sample_rate): + def __init__(self, sample_rate): + gr.hier_block2.__init__(self, "example_signal_1", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature src0 = gr.sig_source_c (sample_rate, # sample rate gr.GR_SIN_WAVE, # waveform type @@ -55,17 +81,14 @@ class example_signal_1(gr.hier_block): 1.0, # amplitude 0) # DC Offset sum = gr.add_cc() - fg.connect(src0, (sum, 0)) - fg.connect(src1, (sum, 1)) - - gr.hier_block.__init__(self, fg, None, sum) - - + self.connect(src0, (sum, 0)) + self.connect(src1, (sum, 1)) + self.connect(sum, self) -class my_graph(gr.flow_graph): +class my_top_block(gr.top_block): def __init__(self): - gr.flow_graph.__init__ (self) + gr.top_block.__init__(self) usage="%prog: [options] side-A-tx-freq side-B-tx-freq" parser = OptionParser (option_class=eng_option, usage=usage) @@ -108,8 +131,8 @@ class my_graph(gr.flow_graph): # ---------------------------------------------------------------- # build two signal sources, interleave them, amplify and connect them to usrp - sig0 = example_signal_0(self, self.usrp_rate) - sig1 = example_signal_1(self, self.usrp_rate) + sig0 = example_signal_0(self.usrp_rate) + sig1 = example_signal_1(self.usrp_rate) intl = gr.interleave(gr.sizeof_gr_complex) self.connect(sig0, (intl, 0)) @@ -155,6 +178,6 @@ class my_graph(gr.flow_graph): if __name__ == '__main__': try: - my_graph().run() + my_top_block().run() except KeyboardInterrupt: pass diff --git a/gnuradio-examples/python/usrp/max_power.py b/gnuradio-examples/python/usrp/max_power.py index 46df72542..91005e530 100755 --- a/gnuradio-examples/python/usrp/max_power.py +++ b/gnuradio-examples/python/usrp/max_power.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004 Free Software Foundation, Inc. +# Copyright 2004,2007 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -30,12 +30,12 @@ from gnuradio import usrp from gnuradio.eng_option import eng_option from optparse import OptionParser -def ramp_source (fg): +def ramp_source (): period = 2**16 src = gr.vector_source_s (range (-period/2, period/2, 1), True) return src -def build_graph (tx_enable, rx_enable): +def build_block (tx_enable, rx_enable): max_usb_rate = 8e6 # 8 MS/sec dac_freq = 128e6 adc_freq = 64e6 @@ -48,23 +48,23 @@ def build_graph (tx_enable, rx_enable): rx_mux = 0x00003210 rx_decim = int ((adc_freq * rx_nchan) / (max_usb_rate/2)) # 32 - fg = gr.flow_graph () + tb = gr.top_block () if tx_enable: tx_src0 = gr.sig_source_c (dac_freq/tx_interp, gr.GR_CONST_WAVE, 0, 16e3, 0) usrp_tx = usrp.sink_c (0, tx_interp, tx_nchan, tx_mux) usrp_tx.set_tx_freq (0, 10e6) usrp_tx.set_tx_freq (1, 9e6) - fg.connect (tx_src0, usrp_tx) + tb.connect (tx_src0, usrp_tx) if rx_enable: usrp_rx = usrp.source_c (0, rx_decim, rx_nchan, rx_mux) usrp_rx.set_rx_freq (0, 5.5e6) usrp_rx.set_rx_freq (1, 6.5e6) rx_dst0 = gr.null_sink (gr.sizeof_gr_complex) - fg.connect (usrp_rx, rx_dst0) + tb.connect (usrp_rx, rx_dst0) - return fg + return tb def main (): parser = OptionParser (option_class=eng_option) @@ -73,11 +73,11 @@ def main (): parser.add_option ("-r", action="store_true", dest="rx_enable", default=False, help="enable Rx path") (options, args) = parser.parse_args () - fg = build_graph (options.tx_enable, options.rx_enable) + tb = build_block (options.tx_enable, options.rx_enable) - fg.start () + tb.start () raw_input ('Press Enter to quit: ') - fg.stop () + tb.stop () if __name__ == '__main__': main () diff --git a/gnuradio-examples/python/usrp/usrp_benchmark_usb.py b/gnuradio-examples/python/usrp/usrp_benchmark_usb.py index fc01514a1..4ea84f764 100755 --- a/gnuradio-examples/python/usrp/usrp_benchmark_usb.py +++ b/gnuradio-examples/python/usrp/usrp_benchmark_usb.py @@ -55,21 +55,21 @@ def run_test (usb_throughput, verbose): # print "tx_interp =", tx_interp, "rx_decim =", rx_decim assert (tx_interp == 2 * rx_decim) - fg = gr.flow_graph () + tb = gr.top_block () # Build the Tx pipeline data_src = gr.lfsr_32k_source_s () src_head = gr.head (gr.sizeof_short, int (stream_length * 2)) usrp_tx = usrp.sink_s (0, tx_interp) - fg.connect (data_src, src_head, usrp_tx) + tb.connect (data_src, src_head, usrp_tx) # and the Rx pipeline usrp_rx = usrp.source_s (0, rx_decim, 1, 0x32103210, usrp.FPGA_MODE_LOOPBACK) head = gr.head (gr.sizeof_short, stream_length) check = gr.check_lfsr_32k_s () - fg.connect (usrp_rx, head, check) + tb.connect (usrp_rx, head, check) - fg.run () + tb.run () ntotal = check.ntotal () nright = check.nright () diff --git a/gnuradio-examples/python/usrp/usrp_nbfm_ptt.py b/gnuradio-examples/python/usrp/usrp_nbfm_ptt.py index 03333fa19..35f015215 100755 --- a/gnuradio-examples/python/usrp/usrp_nbfm_ptt.py +++ b/gnuradio-examples/python/usrp/usrp_nbfm_ptt.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005 Free Software Foundation, Inc. +# Copyright 2005,2007 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -28,9 +28,9 @@ from optparse import OptionParser from gnuradio import gr, gru, eng_notation from gnuradio import usrp from gnuradio import audio -from gnuradio import blks +from gnuradio import blks2 from gnuradio.eng_option import eng_option -from gnuradio.wxgui import stdgui, fftsink, scopesink, slider, form +from gnuradio.wxgui import stdgui2, fftsink2, scopesink2, slider, form from usrpm import usrp_dbid from numpy import convolve, array @@ -43,9 +43,9 @@ from numpy import convolve, array # Control Stuff # //////////////////////////////////////////////////////////////////////// -class ptt_graph(stdgui.gui_flow_graph): +class ptt_block(stdgui2.std_top_block): def __init__(self, frame, panel, vbox, argv): - stdgui.gui_flow_graph.__init__ (self, frame, panel, vbox, argv) + stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) self.frame = frame self.space_bar_pressed = False @@ -73,8 +73,11 @@ class ptt_graph(stdgui.gui_flow_graph): if options.freq < 1e6: options.freq *= 1e6 - self.txpath = transmit_path(self, options.tx_subdev_spec, options.audio_input) - self.rxpath = receive_path(self, options.rx_subdev_spec, options.rx_gain, options.audio_output) + self.txpath = transmit_path(options.tx_subdev_spec, options.audio_input) + self.rxpath = receive_path(options.rx_subdev_spec, options.rx_gain, options.audio_output) + self.connect(self.txpath) + self.connect(self.rxpath) + self._build_gui(frame, panel, vbox, argv, options.no_gui) self.set_transmit(False) @@ -142,29 +145,29 @@ class ptt_graph(stdgui.gui_flow_graph): panel.SetFocus() if 1 and not(no_gui): - rx_fft = fftsink.fft_sink_c (self, panel, title="Rx Input", fft_size=512, + rx_fft = fftsink2.fft_sink_c(panel, title="Rx Input", fft_size=512, sample_rate=self.rxpath.if_rate, ref_level=80, y_per_div=20) self.connect (self.rxpath.u, rx_fft) vbox.Add (rx_fft.win, 1, wx.EXPAND) if 1 and not(no_gui): - rx_fft = fftsink.fft_sink_c (self, panel, title="Post s/w DDC", + rx_fft = fftsink2.fft_sink_c(panel, title="Post s/w DDC", fft_size=512, sample_rate=self.rxpath.quad_rate, ref_level=80, y_per_div=20) self.connect (self.rxpath.ddc, rx_fft) vbox.Add (rx_fft.win, 1, wx.EXPAND) if 0 and not(no_gui): - foo = scopesink.scope_sink_f (self, panel, title="Squelch", - sample_rate=32000) + foo = scopesink2.scope_sink_f(panel, title="Squelch", + sample_rate=32000) self.connect (self.rxpath.fmrx.div, (foo,0)) self.connect (self.rxpath.fmrx.gate, (foo,1)) self.connect (self.rxpath.fmrx.squelch_lpf, (foo,2)) vbox.Add (foo.win, 1, wx.EXPAND) if 0 and not(no_gui): - tx_fft = fftsink.fft_sink_c (self, panel, title="Tx Output", + tx_fft = fftsink2.fft_sink_c(panel, title="Tx Output", fft_size=512, sample_rate=self.txpath.usrp_rate) self.connect (self.txpath.amp, tx_fft) vbox.Add (tx_fft.win, 1, wx.EXPAND) @@ -265,9 +268,12 @@ class ptt_graph(stdgui.gui_flow_graph): # Transmit Path # //////////////////////////////////////////////////////////////////////// -class transmit_path(gr.hier_block): - def __init__(self, fg, subdev_spec, audio_input): - +class transmit_path(gr.hier_block2): + def __init__(self, subdev_spec, audio_input): + gr.hier_block2.__init__(self, "transmit_path", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(0, 0, 0)) # Output signature + self.u = usrp.sink_c () dac_rate = self.u.dac_rate(); @@ -298,11 +304,11 @@ class transmit_path(gr.hier_block): audio_taps = convolve(array(lpf),array(hpf)) self.audio_filt = gr.fir_filter_fff(1,audio_taps) - self.pl = blks.ctcss_gen_f(fg, self.audio_rate,123.0) + self.pl = blks2.ctcss_gen_f(self.audio_rate,123.0) self.add_pl = gr.add_ff() - fg.connect(self.pl,(self.add_pl,1)) + self.connect(self.pl,(self.add_pl,1)) - self.fmtx = blks.nbfm_tx(fg, self.audio_rate, self.if_rate) + self.fmtx = blks2.nbfm_tx(self.audio_rate, self.if_rate) self.amp = gr.multiply_const_cc (self.normal_gain) # determine the daughterboard subdevice we're using @@ -312,10 +318,8 @@ class transmit_path(gr.hier_block): self.subdev = usrp.selected_subdev(self.u, subdev_spec) print "TX using", self.subdev.name() - fg.connect(self.audio, self.audio_amp, self.audio_filt, - (self.add_pl,0), self.fmtx, self.amp, self.u) - - gr.hier_block.__init__(self, fg, None, None) + self.connect(self.audio, self.audio_amp, self.audio_filt, + (self.add_pl,0), self.fmtx, self.amp, self.u) self.set_gain(self.subdev.gain_range()[1]) # set max Tx gain @@ -357,8 +361,11 @@ class transmit_path(gr.hier_block): # Receive Path # //////////////////////////////////////////////////////////////////////// -class receive_path(gr.hier_block): - def __init__(self, fg, subdev_spec, gain, audio_output): +class receive_path(gr.hier_block2): + def __init__(self, subdev_spec, gain, audio_output): + gr.hier_block2.__init__(self, "receive_path", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(0, 0, 0)) # Output signature self.u = usrp.source_c () adc_rate = self.u.adc_rate() @@ -395,10 +402,10 @@ class receive_path(gr.hier_block): self.if_rate) # input sample rate # instantiate the guts of the single channel receiver - self.fmrx = blks.nbfm_rx(fg, audio_rate, self.quad_rate) + self.fmrx = blks2.nbfm_rx(audio_rate, self.quad_rate) # standard squelch block - self.squelch = blks.standard_squelch(fg, audio_rate) + self.squelch = blks2.standard_squelch(audio_rate) # audio gain / mute block self._audio_gain = gr.multiply_const_ff(1.0) @@ -407,8 +414,7 @@ class receive_path(gr.hier_block): audio_sink = audio.sink (int(audio_rate), audio_output) # now wire it all together - fg.connect (self.u, self.ddc, self.fmrx, self.squelch, self._audio_gain, audio_sink) - gr.hier_block.__init__(self, fg, self.u, audio_sink) + self.connect (self.u, self.ddc, self.fmrx, self.squelch, self._audio_gain, audio_sink) if gain is None: # if no gain was specified, use the mid-point in dB @@ -484,7 +490,7 @@ class receive_path(gr.hier_block): # //////////////////////////////////////////////////////////////////////// def main(): - app = stdgui.stdapp(ptt_graph, "NBFM Push to Talk") + app = stdgui2.stdapp(ptt_block, "NBFM Push to Talk") app.MainLoop() if __name__ == '__main__': diff --git a/gnuradio-examples/python/usrp/usrp_nbfm_rcv.py b/gnuradio-examples/python/usrp/usrp_nbfm_rcv.py index 868dee5cc..c63bef0c4 100755 --- a/gnuradio-examples/python/usrp/usrp_nbfm_rcv.py +++ b/gnuradio-examples/python/usrp/usrp_nbfm_rcv.py @@ -1,12 +1,32 @@ #!/usr/bin/env python +# +# Copyright 2005,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, gru, eng_notation, optfir from gnuradio import audio from gnuradio import usrp -from gnuradio import blks +from gnuradio import blks2 from gnuradio.eng_option import eng_option from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui, fftsink, form +from gnuradio.wxgui import stdgui2, fftsink2, form from optparse import OptionParser from usrpm import usrp_dbid import sys @@ -18,9 +38,9 @@ import wx # Control Stuff #//////////////////////////////////////////////////////////////////////// -class my_graph (stdgui.gui_flow_graph): +class my_top_block (stdgui2.std_top_block): def __init__(self,frame,panel,vbox,argv): - stdgui.gui_flow_graph.__init__ (self,frame,panel,vbox,argv) + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) parser=OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, @@ -50,8 +70,9 @@ class my_graph (stdgui.gui_flow_graph): self.freq = 0 self.freq_step = 25e3 - self.rxpath = receive_path(self, options.rx_subdev_spec, options.gain, options.audio_output) - + self.rxpath = receive_path(options.rx_subdev_spec, options.gain, options.audio_output) + self.connect(self.rxpath) + self._build_gui(vbox, options.no_gui) # set initial values @@ -79,28 +100,27 @@ class my_graph (stdgui.gui_flow_graph): self.src_fft = None if 1 and not(no_gui): - self.src_fft = fftsink.fft_sink_c (self, self.panel, title="Data from USRP", + self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", fft_size=512, sample_rate=self.rxpath.if_rate, ref_level=80, y_per_div=20) self.connect (self.rxpath.u, self.src_fft) vbox.Add (self.src_fft.win, 4, wx.EXPAND) - if 1 and not(no_gui): - rx_fft = fftsink.fft_sink_c (self, self.panel, title="Post s/w DDC", + rx_fft = fftsink2.fft_sink_c(self.panel, title="Post s/w DDC", fft_size=512, sample_rate=self.rxpath.quad_rate, ref_level=80, y_per_div=20) self.connect (self.rxpath.ddc, rx_fft) vbox.Add (rx_fft.win, 4, wx.EXPAND) if 1 and not(no_gui): - post_deemph_fft = fftsink.fft_sink_f (self, self.panel, title="Post Deemph", + post_deemph_fft = fftsink2.fft_sink_f(self.panel, title="Post Deemph", fft_size=512, sample_rate=self.rxpath.audio_rate, y_per_div=10, ref_level=-40) self.connect (self.rxpath.fmrx.deemph, post_deemph_fft) vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) if 0: - post_filt_fft = fftsink.fft_sink_f (self, self.panel, title="Post Filter", + post_filt_fft = fftsink2.fft_sink_f(self.panel, title="Post Filter", fft_size=512, sample_rate=audio_rate, y_per_div=10, ref_level=-40) self.connect (self.guts.audio_filter, post_filt) @@ -225,8 +245,11 @@ class my_graph (stdgui.gui_flow_graph): USE_SIMPLE_SQUELCH = False -class receive_path(gr.hier_block): - def __init__(self, fg, subdev_spec, gain, audio_output): +class receive_path(gr.hier_block2): + def __init__(self, subdev_spec, gain, audio_output): + gr.hier_block2.__init__(self, "receive_path", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(0, 0, 0)) # Output signature self.u = usrp.source_c () adc_rate = self.u.adc_rate() @@ -266,10 +289,10 @@ class receive_path(gr.hier_block): if USE_SIMPLE_SQUELCH: self.squelch = gr.simple_squelch_cc(20) else: - self.squelch = blks.standard_squelch(fg, self.audio_rate) + self.squelch = blks2.standard_squelch(self.audio_rate) # instantiate the guts of the single channel receiver - self.fmrx = blks.nbfm_rx(fg, self.audio_rate, self.quad_rate) + self.fmrx = blks2.nbfm_rx(self.audio_rate, self.quad_rate) # audio gain / mute block self._audio_gain = gr.multiply_const_ff(1.0) @@ -279,13 +302,11 @@ class receive_path(gr.hier_block): # now wire it all together if USE_SIMPLE_SQUELCH: - fg.connect (self.u, self.ddc, self.squelch, self.fmrx, - self._audio_gain, audio_sink) + self.connect (self.u, self.ddc, self.squelch, self.fmrx, + self._audio_gain, audio_sink) else: - fg.connect (self.u, self.ddc, self.fmrx, self.squelch, - self._audio_gain, audio_sink) - - gr.hier_block.__init__(self, fg, self.u, audio_sink) + self.connect (self.u, self.ddc, self.fmrx, self.squelch, + self._audio_gain, audio_sink) if gain is None: # if no gain was specified, use the mid-point in dB @@ -358,5 +379,5 @@ class receive_path(gr.hier_block): # //////////////////////////////////////////////////////////////////////// if __name__ == '__main__': - app = stdgui.stdapp (my_graph, "USRP NBFM RX") + app = stdgui2.stdapp (my_top_block, "USRP NBFM RX") app.MainLoop () diff --git a/gnuradio-examples/python/usrp/usrp_spectrum_sense.py b/gnuradio-examples/python/usrp/usrp_spectrum_sense.py index 1d86e03cc..90adf1671 100755 --- a/gnuradio-examples/python/usrp/usrp_spectrum_sense.py +++ b/gnuradio-examples/python/usrp/usrp_spectrum_sense.py @@ -1,9 +1,28 @@ #!/usr/bin/env python +# +# Copyright 2005,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, gru, eng_notation, optfir, window from gnuradio import audio from gnuradio import usrp -from gnuradio import blks from gnuradio.eng_option import eng_option from optparse import OptionParser from usrpm import usrp_dbid @@ -16,9 +35,9 @@ class tune(gr.feval_dd): """ This class allows C++ code to callback into python. """ - def __init__(self, fg): + def __init__(self, tb): gr.feval_dd.__init__(self) - self.fg = fg + self.tb = tb def eval(self, ignore): """ @@ -36,7 +55,7 @@ class tune(gr.feval_dd): # # message on stderr. Not exactly helpful ;) - new_freq = self.fg.set_next_freq() + new_freq = self.tb.set_next_freq() return new_freq except Exception, e: @@ -55,10 +74,10 @@ class parse_msg(object): self.data = struct.unpack('%df' % (self.vlen,), t) -class my_graph(gr.flow_graph): +class my_top_block(gr.top_block): def __init__(self): - gr.flow_graph.__init__(self) + gr.top_block.__init__(self) usage = "usage: %prog [options] min_freq max_freq" parser = OptionParser(option_class=eng_option, usage=usage) @@ -213,12 +232,12 @@ class my_graph(gr.flow_graph): self.subdev.set_gain(gain) -def main_loop(fg): +def main_loop(tb): while 1: # Get the next message sent from the C++ code (blocking call). # It contains the center frequency and the mag squared of the fft - m = parse_msg(fg.msgq.delete_head()) + m = parse_msg(tb.msgq.delete_head()) # Print center freq so we know that something is happening... print m.center_freq @@ -233,10 +252,10 @@ def main_loop(fg): if __name__ == '__main__': - fg = my_graph() + tb = my_top_block() try: - fg.start() # start executing flow graph in another thread... - main_loop(fg) + tb.start() # start executing flow graph in another thread... + main_loop(tb) except KeyboardInterrupt: pass diff --git a/gnuradio-examples/python/usrp/usrp_test_loop_lfsr.py b/gnuradio-examples/python/usrp/usrp_test_loop_lfsr.py index 446ca30a1..696c1a24c 100755 --- a/gnuradio-examples/python/usrp/usrp_test_loop_lfsr.py +++ b/gnuradio-examples/python/usrp/usrp_test_loop_lfsr.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004 Free Software Foundation, Inc. +# Copyright 2004,2007 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -32,29 +32,29 @@ def build_graph (): tx_interp = 32 # tx should be twice rx rx_decim = 16 - fg = gr.flow_graph () + tb = gr.top_block () data_src = gr.lfsr_32k_source_s () # usrp_tx = usrp.sink_s (0, tx_interp, 1, 0x98) usrp_tx = usrp.sink_s (0, tx_interp) - fg.connect (data_src, usrp_tx) + tb.connect (data_src, usrp_tx) usrp_rx = usrp.source_s (0, rx_decim, 1, 0x32103210, usrp.FPGA_MODE_LOOPBACK) sink = gr.check_lfsr_32k_s () - fg.connect (usrp_rx, sink) + tb.connect (usrp_rx, sink) # file_sink = gr.file_sink (gr.sizeof_short, "loopback.dat") - # fg.connect (usrp_rx, file_sink) + # tb.connect (usrp_rx, file_sink) - return fg + return tb def main (): - fg = build_graph () + tb = build_graph () try: - fg.run() + tb.run() except KeyboardInterrupt: pass diff --git a/gnuradio-examples/python/usrp/usrp_tv_rcv.py b/gnuradio-examples/python/usrp/usrp_tv_rcv.py index 8fabc2b47..537e339be 100755 --- a/gnuradio-examples/python/usrp/usrp_tv_rcv.py +++ b/gnuradio-examples/python/usrp/usrp_tv_rcv.py @@ -1,4 +1,25 @@ #!/usr/bin/env python +# +# Copyright 2005,2006,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. +# + """ Realtime capture and display of analog Tv stations. Can also use a file as source or sink @@ -16,10 +37,9 @@ except: print "FYI: gr-video-sdl is not installed" print "realtime SDL video output window will not be available" from gnuradio import usrp -from gnuradio import blks from gnuradio.eng_option import eng_option from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui, fftsink, form +from gnuradio.wxgui import stdgui2, fftsink2, form from optparse import OptionParser from usrpm import usrp_dbid import sys @@ -45,9 +65,9 @@ def pick_subdevice(u): usrp_dbid.BASIC_RX)) -class tv_rx_graph (stdgui.gui_flow_graph): +class tv_rx_block (stdgui2.std_top_block): def __init__(self,frame,panel,vbox,argv): - stdgui.gui_flow_graph.__init__ (self,frame,panel,vbox,argv) + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) usage="%prog: [options] [input_filename]. \n If you don't specify an input filename the usrp will be used as source\n " \ "Make sure your input capture file containes interleaved shorts not complex floats" @@ -391,5 +411,5 @@ class tv_rx_graph (stdgui.gui_flow_graph): if __name__ == '__main__': - app = stdgui.stdapp (tv_rx_graph, "USRP TV RX black-and-white") + app = stdgui2.stdapp (tv_rx_block, "USRP TV RX black-and-white") app.MainLoop () diff --git a/gnuradio-examples/python/usrp/usrp_tv_rcv_nogui.py b/gnuradio-examples/python/usrp/usrp_tv_rcv_nogui.py index e563188b9..e6a8de1be 100755 --- a/gnuradio-examples/python/usrp/usrp_tv_rcv_nogui.py +++ b/gnuradio-examples/python/usrp/usrp_tv_rcv_nogui.py @@ -1,4 +1,24 @@ #!/usr/bin/env python +# +# Copyright 2005,2006,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. +# """ Reads from a file and generates PAL TV pictures in black and white @@ -24,10 +44,10 @@ except: print "realtime \"sdl\" video output window will not be available" -class my_graph(gr.flow_graph): +class my_top_block(gr.top_block): def __init__(self): - gr.flow_graph.__init__(self) + gr.top_block.__init__(self) usage="%prog: [options] output_filename. \n Special output_filename \"sdl\" will use video_sink_sdl as realtime output window. " \ "You then need to have gr-video-sdl installed. \n" \ @@ -174,6 +194,6 @@ class my_graph(gr.flow_graph): if __name__ == '__main__': try: - my_graph().run() + my_top_block().run() except KeyboardInterrupt: pass diff --git a/gnuradio-examples/python/usrp/usrp_wfm_rcv.py b/gnuradio-examples/python/usrp/usrp_wfm_rcv.py index 9ffb41fb0..40e4d8384 100755 --- a/gnuradio-examples/python/usrp/usrp_wfm_rcv.py +++ b/gnuradio-examples/python/usrp/usrp_wfm_rcv.py @@ -1,12 +1,32 @@ #!/usr/bin/env python +# +# Copyright 2005,2006,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, gru, eng_notation, optfir from gnuradio import audio from gnuradio import usrp -from gnuradio import blks +from gnuradio import blks2 from gnuradio.eng_option import eng_option from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui, fftsink, form +from gnuradio.wxgui import stdgui2, fftsink2, form from optparse import OptionParser from usrpm import usrp_dbid import sys @@ -26,9 +46,9 @@ def pick_subdevice(u): usrp_dbid.BASIC_RX)) -class wfm_rx_graph (stdgui.gui_flow_graph): +class wfm_rx_block (stdgui2.std_top_block): def __init__(self,frame,panel,vbox,argv): - stdgui.gui_flow_graph.__init__ (self,frame,panel,vbox,argv) + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) parser=OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, @@ -84,7 +104,7 @@ class wfm_rx_graph (stdgui.gui_flow_graph): #print len(chan_filt_coeffs) chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) - self.guts = blks.wfm_rcv (self, demod_rate, audio_decimation) + self.guts = blks2.wfm_rcv (demod_rate, audio_decimation) self.volume_control = gr.multiply_const_ff(self.vol) @@ -129,20 +149,20 @@ class wfm_rx_graph (stdgui.gui_flow_graph): if 1: - self.src_fft = fftsink.fft_sink_c (self, self.panel, title="Data from USRP", + self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", fft_size=512, sample_rate=usrp_rate) self.connect (self.u, self.src_fft) vbox.Add (self.src_fft.win, 4, wx.EXPAND) if 1: - post_filt_fft = fftsink.fft_sink_f (self, self.panel, title="Post Demod", + post_filt_fft = fftsink2.fft_sink_f(self.panel, title="Post Demod", fft_size=1024, sample_rate=usrp_rate, y_per_div=10, ref_level=0) self.connect (self.guts.fm_demod, post_filt_fft) vbox.Add (post_filt_fft.win, 4, wx.EXPAND) if 0: - post_deemph_fft = fftsink.fft_sink_f (self, self.panel, title="Post Deemph", + post_deemph_fft = fftsink2.fft_sink_f(self.panel, title="Post Deemph", fft_size=512, sample_rate=audio_rate, y_per_div=10, ref_level=-20) self.connect (self.guts.deemph, post_deemph_fft) @@ -266,5 +286,5 @@ class wfm_rx_graph (stdgui.gui_flow_graph): if __name__ == '__main__': - app = stdgui.stdapp (wfm_rx_graph, "USRP WFM RX") + app = stdgui2.stdapp (wfm_rx_block, "USRP WFM RX") app.MainLoop () diff --git a/gnuradio-examples/python/usrp/usrp_wfm_rcv2_nogui.py b/gnuradio-examples/python/usrp/usrp_wfm_rcv2_nogui.py index efb0448fa..942fd070a 100755 --- a/gnuradio-examples/python/usrp/usrp_wfm_rcv2_nogui.py +++ b/gnuradio-examples/python/usrp/usrp_wfm_rcv2_nogui.py @@ -1,9 +1,29 @@ #!/usr/bin/env python +# +# Copyright 2005,2006,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, gru, eng_notation, optfir from gnuradio import audio from gnuradio import usrp -from gnuradio import blks +from gnuradio import blks2 from gnuradio.eng_option import eng_option from optparse import OptionParser from usrpm import usrp_dbid @@ -22,10 +42,10 @@ def pick_subdevice(u): usrp_dbid.BASIC_RX)) -class wfm_rx_graph (gr.flow_graph): +class wfm_rx_block (gr.top_block): def __init__(self): - gr.flow_graph.__init__(self) + gr.top_block.__init__(self) parser=OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, @@ -107,7 +127,7 @@ class wfm_rx_graph (gr.flow_graph): for n in range(2): chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) - guts = blks.wfm_rcv (self, demod_rate, audio_decimation) + guts = blks2.wfm_rcv (demod_rate, audio_decimation) volume_control = gr.multiply_const_ff(self.vol) self.connect((di, n), chan_filt) self.connect(chan_filt, guts, volume_control) @@ -135,10 +155,13 @@ class wfm_rx_graph (gr.flow_graph): def set_gain(self, gain): self.subdev.set_gain(gain) + def __del__(self): + # Avoid weak-reference error + del self.subdev if __name__ == '__main__': - fg = wfm_rx_graph() + tb = wfm_rx_block() try: - fg.run() + tb.run() except KeyboardInterrupt: pass diff --git a/gnuradio-examples/python/usrp/usrp_wfm_rcv_nogui.py b/gnuradio-examples/python/usrp/usrp_wfm_rcv_nogui.py index 9aeae1171..44f868855 100755 --- a/gnuradio-examples/python/usrp/usrp_wfm_rcv_nogui.py +++ b/gnuradio-examples/python/usrp/usrp_wfm_rcv_nogui.py @@ -1,9 +1,29 @@ #!/usr/bin/env python +# +# Copyright 2005,2006,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, gru, eng_notation, optfir from gnuradio import audio from gnuradio import usrp -from gnuradio import blks +from gnuradio import blks2 from gnuradio.eng_option import eng_option from optparse import OptionParser from usrpm import usrp_dbid @@ -23,10 +43,10 @@ def pick_subdevice(u): usrp_dbid.BASIC_RX)) -class wfm_rx_graph (gr.flow_graph): +class wfm_rx_block (gr.top_block): def __init__(self): - gr.flow_graph.__init__(self) + gr.top_block.__init__(self) parser=OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, @@ -78,7 +98,7 @@ class wfm_rx_graph (gr.flow_graph): #print len(chan_filt_coeffs) chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) - self.guts = blks.wfm_rcv (self, demod_rate, audio_decimation) + self.guts = blks2.wfm_rcv (demod_rate, audio_decimation) self.volume_control = gr.multiply_const_ff(self.vol) @@ -147,8 +167,8 @@ class wfm_rx_graph (gr.flow_graph): if __name__ == '__main__': - fg = wfm_rx_graph() + tb = wfm_rx_block() try: - fg.run() + tb.run() except KeyboardInterrupt: pass diff --git a/gnuradio-examples/python/usrp/usrp_wfm_rcv_pll.py b/gnuradio-examples/python/usrp/usrp_wfm_rcv_pll.py index 58b590841..a85bcdbf4 100755 --- a/gnuradio-examples/python/usrp/usrp_wfm_rcv_pll.py +++ b/gnuradio-examples/python/usrp/usrp_wfm_rcv_pll.py @@ -1,12 +1,32 @@ #!/usr/bin/env python +# +# Copyright 2005,2006,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, gru, eng_notation, optfir from gnuradio import audio from gnuradio import usrp -from gnuradio import blks +from gnuradio import blks2 from gnuradio.eng_option import eng_option from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui, fftsink, form, scopesink +from gnuradio.wxgui import stdgui2, fftsink2, form, scopesink2 from optparse import OptionParser from usrpm import usrp_dbid import sys @@ -25,9 +45,9 @@ def pick_subdevice(u): usrp_dbid.TV_RX_REV_3, usrp_dbid.BASIC_RX)) -class wfm_rx_graph (stdgui.gui_flow_graph): +class wfm_rx_block (stdgui2.std_top_block): def __init__(self,frame,panel,vbox,argv): - stdgui.gui_flow_graph.__init__ (self,frame,panel,vbox,argv) + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) parser=OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, @@ -86,8 +106,8 @@ class wfm_rx_graph (stdgui.gui_flow_graph): chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) - #self.guts = blks.wfm_rcv (self, demod_rate, audio_decimation) - self.guts = blks.wfm_rcv_pll (self, demod_rate, audio_decimation) + #self.guts = blks2.wfm_rcv (demod_rate, audio_decimation) + self.guts = blks2.wfm_rcv_pll (demod_rate, audio_decimation) # FIXME rework {add,multiply}_const_* to handle multiple streams self.volume_control_l = gr.multiply_const_ff(self.vol) @@ -146,34 +166,34 @@ class wfm_rx_graph (stdgui.gui_flow_graph): if 1: - self.src_fft = fftsink.fft_sink_c (self, self.panel, title="Data from USRP", + self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", fft_size=512, sample_rate=usrp_rate) self.connect (self.u, self.src_fft) vbox.Add (self.src_fft.win, 4, wx.EXPAND) if 1: - post_fm_demod_fft = fftsink.fft_sink_f (self, self.panel, title="Post FM Demod", - fft_size=512, sample_rate=demod_rate, - y_per_div=10, ref_level=0) + post_fm_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post FM Demod", + fft_size=512, sample_rate=demod_rate, + y_per_div=10, ref_level=0) self.connect (self.guts.fm_demod, post_fm_demod_fft) vbox.Add (post_fm_demod_fft.win, 4, wx.EXPAND) if 0: - post_stereo_carrier_generator_fft = fftsink.fft_sink_c (self, self.panel, title="Post Stereo_carrier_generator", + post_stereo_carrier_generator_fft = fftsink2.fft_sink_c (self.panel, title="Post Stereo_carrier_generator", fft_size=512, sample_rate=audio_rate, y_per_div=10, ref_level=0) self.connect (self.guts.stereo_carrier_generator, post_stereo_carrier_generator_fft) vbox.Add (post_stereo_carrier_generator_fft.win, 4, wx.EXPAND) if 0: - post_deemphasis_left = fftsink.fft_sink_f (self, self.panel, title="Post_Deemphasis_Left", + post_deemphasis_left = fftsink2.fft_sink_f (self.panel, title="Post_Deemphasis_Left", fft_size=512, sample_rate=audio_rate, y_per_div=10, ref_level=0) self.connect (self.guts.deemph_Left, post_deemphasis_left) vbox.Add (post_deemphasis_left.win, 4, wx.EXPAND) if 0: - post_deemphasis_right = fftsink.fft_sink_f (self, self.panel, title="Post_Deemphasis_Right", + post_deemphasis_right = fftsink2.fft_sink_f(self.panel, title="Post_Deemphasis_Right", fft_size=512, sample_rate=audio_rate, y_per_div=10, ref_level=-20) self.connect (self.guts.deemph_Left, post_deemphasis_right) @@ -181,14 +201,14 @@ class wfm_rx_graph (stdgui.gui_flow_graph): if 0: - LmR_fft = fftsink.fft_sink_f (self, self.panel, title="LmR", - fft_size=512, sample_rate=audio_rate, - y_per_div=10, ref_level=-20) + LmR_fft = fftsink2.fft_sink_f(self.panel, title="LmR", + fft_size=512, sample_rate=audio_rate, + y_per_div=10, ref_level=-20) self.connect (self.guts.LmR_real,LmR_fft) vbox.Add (LmR_fft.win, 4, wx.EXPAND) if 0: - self.scope = scopesink.scope_sink_f(self, self.panel, sample_rate=demod_rate) + self.scope = scopesink2.scope_sink_f(self.panel, sample_rate=demod_rate) self.connect (self.guts.fm_demod_a,self.scope) vbox.Add (self.scope.win,4,wx.EXPAND) @@ -322,5 +342,5 @@ class wfm_rx_graph (stdgui.gui_flow_graph): if __name__ == '__main__': - app = stdgui.stdapp (wfm_rx_graph, "USRP WFM RX") + app = stdgui2.stdapp (wfm_rx_block, "USRP WFM RX") app.MainLoop () diff --git a/gnuradio-examples/python/usrp/usrp_wfm_rcv_sca.py b/gnuradio-examples/python/usrp/usrp_wfm_rcv_sca.py index 64d51e223..1d39c7691 100755 --- a/gnuradio-examples/python/usrp/usrp_wfm_rcv_sca.py +++ b/gnuradio-examples/python/usrp/usrp_wfm_rcv_sca.py @@ -53,11 +53,10 @@ OFDM. from gnuradio import gr, gru, eng_notation, optfir from gnuradio import audio from gnuradio import usrp -from gnuradio import blks -from gnuradio.blksimpl.fm_emph import fm_deemph +from gnuradio.blks2impl.fm_emph import fm_deemph from gnuradio.eng_option import eng_option from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui, fftsink, form +from gnuradio.wxgui import stdgui2, fftsink2, form from optparse import OptionParser from usrpm import usrp_dbid import sys @@ -76,9 +75,9 @@ def pick_subdevice(u): usrp_dbid.BASIC_RX)) -class wfm_rx_sca_graph (stdgui.gui_flow_graph): +class wfm_rx_sca_block (stdgui2.std_top_block): def __init__(self,frame,panel,vbox,argv): - stdgui.gui_flow_graph.__init__ (self,frame,panel,vbox,argv) + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) parser=OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, @@ -179,7 +178,7 @@ class wfm_rx_sca_graph (stdgui.gui_flow_graph): self.audio_filter = gr.fir_filter_fff (audio_decimation, audio_coeffs) # Create deemphasis block that is applied after SCA demodulation - self.deemph = fm_deemph (self, audio_rate, sca_tau) + self.deemph = fm_deemph (audio_rate, sca_tau) self.volume_control = gr.multiply_const_ff(self.vol) @@ -228,27 +227,27 @@ class wfm_rx_sca_graph (stdgui.gui_flow_graph): return self.set_sca_freq(kv['sca_freq']) if 1: - self.src_fft = fftsink.fft_sink_c (self, self.panel, title="Data from USRP", + self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP", fft_size=512, sample_rate=usrp_rate) self.connect (self.u, self.src_fft) vbox.Add (self.src_fft.win, 4, wx.EXPAND) if 1: - post_demod_fft = fftsink.fft_sink_f (self, self.panel, title="Post FM Demod", - fft_size=2048, sample_rate=demod_rate, - y_per_div=10, ref_level=0) + post_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post FM Demod", + fft_size=2048, sample_rate=demod_rate, + y_per_div=10, ref_level=0) self.connect (self.fm_demod, post_demod_fft) vbox.Add (post_demod_fft.win, 4, wx.EXPAND) if 0: - post_demod_sca_fft = fftsink.fft_sink_f (self, self.panel, title="Post SCA Demod", + post_demod_sca_fft = fftsink2.fft_sink_f(self.panel, title="Post SCA Demod", fft_size=1024, sample_rate=sca_demod_rate, y_per_div=10, ref_level=0) self.connect (self.fm_demod_sca, post_demod_sca_fft) vbox.Add (post_demod_sca_fft.win, 4, wx.EXPAND) if 0: - post_deemph_fft = fftsink.fft_sink_f (self, self.panel, title="Post SCA Deemph", + post_deemph_fft = fftsink2.fft_sink_f (self.panel, title="Post SCA Deemph", fft_size=512, sample_rate=audio_rate, y_per_div=10, ref_level=-20) self.connect (self.deemph, post_deemph_fft) @@ -395,5 +394,5 @@ class wfm_rx_sca_graph (stdgui.gui_flow_graph): if __name__ == '__main__': - app = stdgui.stdapp (wfm_rx_sca_graph, "USRP WFM SCA RX") + app = stdgui2.stdapp (wfm_rx_sca_block, "USRP WFM SCA RX") app.MainLoop () diff --git a/gnuradio-examples/python/usrp/usrp_wxapt_rcv.py b/gnuradio-examples/python/usrp/usrp_wxapt_rcv.py index 39ad688e1..983e3ec98 100755 --- a/gnuradio-examples/python/usrp/usrp_wxapt_rcv.py +++ b/gnuradio-examples/python/usrp/usrp_wxapt_rcv.py @@ -1,12 +1,32 @@ #!/usr/bin/env python +# +# Copyright 2005,2006,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, gru, eng_notation, optfir from gnuradio import audio from gnuradio import usrp -from gnuradio import blks +from gnuradio import blks2 from gnuradio.eng_option import eng_option from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui, fftsink, form +from gnuradio.wxgui import stdgui2, fftsink2, form from optparse import OptionParser from usrpm import usrp_dbid import sys @@ -26,9 +46,9 @@ def pick_subdevice(u): usrp_dbid.BASIC_RX)) -class wxapt_rx_graph (stdgui.gui_flow_graph): +class wxapt_rx_block (stdgui2.std_top_block): def __init__(self,frame,panel,vbox,argv): - stdgui.gui_flow_graph.__init__ (self,frame,panel,vbox,argv) + stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) parser=OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, @@ -84,7 +104,7 @@ class wxapt_rx_graph (stdgui.gui_flow_graph): #print len(chan_filt_coeffs) chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) - self.guts = blks.wfm_rcv (self, demod_rate, audio_decimation) + self.guts = blks2.wfm_rcv (demod_rate, audio_decimation) self.volume_control = gr.multiply_const_ff(self.vol) @@ -127,20 +147,20 @@ class wxapt_rx_graph (stdgui.gui_flow_graph): if 1: - self.src_fft = fftsink.fft_sink_c (self, self.panel, title="Data from USRP", + self.src_fft = fftsink2.fft_sink_c (self.panel, title="Data from USRP", fft_size=512, sample_rate=usrp_rate) self.connect (self.u, self.src_fft) vbox.Add (self.src_fft.win, 4, wx.EXPAND) if 1: - post_deemph_fft = fftsink.fft_sink_f (self, self.panel, title="Post Deemph", + post_deemph_fft = fftsink2.fft_sink_f (self.panel, title="Post Deemph", fft_size=512, sample_rate=demod_rate, y_per_div=10, ref_level=-20) self.connect (self.guts.deemph, post_deemph_fft) vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) if 1: - post_filt_fft = fftsink.fft_sink_f (self, self.panel, title="Post Filter", + post_filt_fft = fftsink2.fft_sink_f (self.panel, title="Post Filter", fft_size=512, sample_rate=audio_rate, y_per_div=10, ref_level=0) self.connect (self.guts.audio_filter, post_filt_fft) @@ -264,5 +284,5 @@ class wxapt_rx_graph (stdgui.gui_flow_graph): if __name__ == '__main__': - app = stdgui.stdapp (wxapt_rx_graph, "USRP WXAPT RX") + app = stdgui2.stdapp (wxapt_rx_block, "USRP WXAPT RX") app.MainLoop () |