summaryrefslogtreecommitdiff
path: root/gr-utils
diff options
context:
space:
mode:
Diffstat (limited to 'gr-utils')
-rwxr-xr-xgr-utils/src/python/usrp_fft.py16
-rwxr-xr-xgr-utils/src/python/usrp_oscope.py12
-rwxr-xr-xgr-utils/src/python/usrp_rx_cfile.py10
-rwxr-xr-xgr-utils/src/python/usrp_rx_nogui.py71
-rwxr-xr-xgr-utils/src/python/usrp_siggen.py36
-rwxr-xr-xgr-utils/src/python/usrp_test_counting.py14
-rwxr-xr-xgr-utils/src/python/usrp_test_loopback.py20
7 files changed, 105 insertions, 74 deletions
diff --git a/gr-utils/src/python/usrp_fft.py b/gr-utils/src/python/usrp_fft.py
index a8466092d..bdec44ce5 100755
--- a/gr-utils/src/python/usrp_fft.py
+++ b/gr-utils/src/python/usrp_fft.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2005 Free Software Foundation, Inc.
+# Copyright 2004,2005,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -24,7 +24,7 @@ from gnuradio import gr, gru
from gnuradio import usrp
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import stdgui, fftsink, waterfallsink, scopesink, form, slider
+from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2, scopesink2, form, slider
from optparse import OptionParser
import wx
import sys
@@ -44,9 +44,9 @@ def pick_subdevice(u):
return (0, 0)
-class app_flow_graph(stdgui.gui_flow_graph):
+class app_top_block(stdgui2.std_top_block):
def __init__(self, frame, panel, vbox, argv):
- stdgui.gui_flow_graph.__init__(self)
+ stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
self.frame = frame
self.panel = panel
@@ -100,11 +100,11 @@ class app_flow_graph(stdgui.gui_flow_graph):
if options.waterfall:
self.scope = \
- waterfallsink.waterfall_sink_c (self, panel, fft_size=1024, sample_rate=input_rate)
+ waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate)
elif options.oscilloscope:
- self.scope = scopesink.scope_sink_c(self, panel, sample_rate=input_rate)
+ self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate)
else:
- self.scope = fftsink.fft_sink_c (self, panel, fft_size=1024, sample_rate=input_rate)
+ self.scope = fftsink2.fft_sink_c (panel, fft_size=1024, sample_rate=input_rate)
self.connect(self.u, self.scope)
@@ -253,7 +253,7 @@ class app_flow_graph(stdgui.gui_flow_graph):
return ok
def main ():
- app = stdgui.stdapp(app_flow_graph, "USRP FFT", nstatus=1)
+ app = stdgui2.stdapp(app_top_block, "USRP FFT", nstatus=1)
app.MainLoop()
if __name__ == '__main__':
diff --git a/gr-utils/src/python/usrp_oscope.py b/gr-utils/src/python/usrp_oscope.py
index 5d7149281..7c202136e 100755
--- a/gr-utils/src/python/usrp_oscope.py
+++ b/gr-utils/src/python/usrp_oscope.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2005,2006 Free Software Foundation, Inc.
+# Copyright 2004,2005,2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -26,7 +26,7 @@ from gnuradio import gr, gru
from gnuradio import usrp
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import stdgui, fftsink, waterfallsink, scopesink, form, slider
+from gnuradio.wxgui import stdgui2, scopesink2, form, slider
from optparse import OptionParser
import wx
import sys
@@ -46,9 +46,9 @@ def pick_subdevice(u):
return (0, 0)
-class app_flow_graph(stdgui.gui_flow_graph):
+class app_top_block(stdgui2.std_top_block):
def __init__(self, frame, panel, vbox, argv):
- stdgui.gui_flow_graph.__init__(self)
+ stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
self.frame = frame
self.panel = panel
@@ -97,7 +97,7 @@ class app_flow_graph(stdgui.gui_flow_graph):
input_rate = self.u.adc_freq() / self.u.decim_rate()
- self.scope = scopesink.scope_sink_c(self, panel, sample_rate=input_rate,
+ self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate,
frame_decim=options.frame_decim,
v_scale=options.v_scale,
t_scale=options.t_scale)
@@ -245,7 +245,7 @@ class app_flow_graph(stdgui.gui_flow_graph):
return ok
def main ():
- app = stdgui.stdapp(app_flow_graph, "USRP O'scope", nstatus=1)
+ app = stdgui2.stdapp(app_top_block, "USRP O'scope", nstatus=1)
app.MainLoop()
if __name__ == '__main__':
diff --git a/gr-utils/src/python/usrp_rx_cfile.py b/gr-utils/src/python/usrp_rx_cfile.py
index 306e101d3..23a7a94d8 100755
--- a/gr-utils/src/python/usrp_rx_cfile.py
+++ b/gr-utils/src/python/usrp_rx_cfile.py
@@ -11,11 +11,12 @@ from gnuradio import audio
from gnuradio import usrp
from gnuradio.eng_option import eng_option
from optparse import OptionParser
+import sys
-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"
parser = OptionParser(option_class=eng_option, usage=usage)
@@ -99,9 +100,12 @@ class my_graph(gr.flow_graph):
sys.stderr.write('Failed to set frequency\n')
raise SystemExit, 1
+ def __del__(self):
+ # Avoid weak reference error
+ del self.subdev
if __name__ == '__main__':
try:
- my_graph().run()
+ my_top_block().run()
except KeyboardInterrupt:
pass
diff --git a/gr-utils/src/python/usrp_rx_nogui.py b/gr-utils/src/python/usrp_rx_nogui.py
index b33d626e2..a5d792c8b 100755
--- a/gr-utils/src/python/usrp_rx_nogui.py
+++ b/gr-utils/src/python/usrp_rx_nogui.py
@@ -1,8 +1,29 @@
#!/usr/bin/env python
-
-from gnuradio import gr, gru, usrp, optfir, audio, eng_notation, blks
+#
+# Copyright 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, usrp, optfir, audio, eng_notation, blks2
from gnuradio.eng_option import eng_option
from optparse import OptionParser
+import sys
"""
This example application demonstrates receiving and demodulating
@@ -47,12 +68,12 @@ blocks.
# (usrp_decim, channel_decim, audio_decim, channel_pass, channel_stop, demod)
demod_params = {
- 'AM' : (250, 16, 1, 5000, 8000, blks.demod_10k0a3e_cf),
- 'FM' : (250, 8, 4, 8000, 9000, blks.demod_20k0f3e_cf),
- 'WFM' : (250, 1, 8, 90000, 100000, blks.demod_200kf3e_cf)
+ 'AM' : (250, 16, 1, 5000, 8000, blks2.demod_10k0a3e_cf),
+ 'FM' : (250, 8, 4, 8000, 9000, blks2.demod_20k0f3e_cf),
+ 'WFM' : (250, 1, 8, 90000, 100000, blks2.demod_200kf3e_cf)
}
-class usrp_source_c(gr.hier_block):
+class usrp_src(gr.hier_block2):
"""
Create a USRP source object supplying complex floats.
@@ -61,7 +82,11 @@ class usrp_source_c(gr.hier_block):
Calibration value is the offset from the tuned frequency to
the actual frequency.
"""
- def __init__(self, fg, subdev_spec, decim, gain=None, calibration=0.0):
+ def __init__(self, subdev_spec, decim, gain=None, calibration=0.0):
+ gr.hier_block2.__init__(self, "usrp_src",
+ gr.io_signature(0, 0, 0), # Input signature
+ gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
+
self._decim = decim
self._src = usrp.source_c()
if subdev_spec is None:
@@ -77,7 +102,7 @@ class usrp_source_c(gr.hier_block):
self._subdev.set_gain(gain)
self._cal = calibration
- gr.hier_block.__init__(self, fg, self._src, self._src)
+ self.connect(self._src, self)
def tune(self, freq):
result = usrp.tune(self._src, 0, self._subdev, freq+self._cal)
@@ -86,20 +111,18 @@ class usrp_source_c(gr.hier_block):
def rate(self):
return self._src.adc_rate()/self._decim
-class app_flow_graph(gr.flow_graph):
- def __init__(self, options, args):
- gr.flow_graph.__init__(self)
+class app_top_block(gr.top_block):
+ def __init__(self, options):
+ gr.top_block.__init__(self)
self.options = options
- self.args = args
(usrp_decim, channel_decim, audio_decim,
channel_pass, channel_stop, demod) = demod_params[options.modulation]
- USRP = usrp_source_c(self, # Flow graph
- options.rx_subdev_spec, # Daugherboard spec
- usrp_decim, # IF decimation ratio
- options.gain, # Receiver gain
- options.calibration) # Frequency offset
+ USRP = usrp_src(options.rx_subdev_spec, # Daugherboard spec
+ usrp_decim, # IF decimation ratio
+ options.gain, # Receiver gain
+ options.calibration) # Frequency offset
USRP.tune(options.frequency)
if_rate = USRP.rate()
@@ -128,7 +151,7 @@ class app_flow_graph(gr.flow_graph):
1.0, # Initial gain
1.0) # Maximum gain
- DEMOD = demod(self, channel_rate, audio_decim)
+ DEMOD = demod(channel_rate, audio_decim)
# From RF to audio
self.connect(USRP, CHAN, RFSQL, AGC, DEMOD)
@@ -145,7 +168,7 @@ class app_flow_graph(gr.flow_graph):
out_lcm = gru.lcm(audio_rate, options.output_rate)
out_interp = int(out_lcm // audio_rate)
out_decim = int(out_lcm // options.output_rate)
- RSAMP = blks.rational_resampler_fff(self, out_interp, out_decim)
+ RSAMP = blks2.rational_resampler_fff(out_interp, out_decim)
self.connect(tail, RSAMP)
tail = RSAMP
@@ -155,7 +178,7 @@ class app_flow_graph(gr.flow_graph):
def main():
parser = OptionParser(option_class=eng_option)
- parser.add_option("-f", "--frequency", type="eng_float",
+ parser.add_option("-f", "--frequency", type="eng_float", default=None,
help="set receive frequency to Hz", metavar="Hz")
parser.add_option("-R", "--rx-subdev-spec", type="subdev",
help="select USRP Rx side A or B", metavar="SUBDEV")
@@ -173,12 +196,16 @@ def main():
help="set CTCSS squelch to FREQ", metavar="FREQ")
(options, args) = parser.parse_args()
+ if options.frequency is None:
+ print "Must supply receive frequency with -f"
+ sys.exit(1)
+
if options.frequency < 1e6:
options.frequency *= 1e6
- fg = app_flow_graph(options, args)
+ tb = app_top_block(options)
try:
- fg.run()
+ tb.run()
except KeyboardInterrupt:
pass
diff --git a/gr-utils/src/python/usrp_siggen.py b/gr-utils/src/python/usrp_siggen.py
index c2929939c..af6eee167 100755
--- a/gr-utils/src/python/usrp_siggen.py
+++ b/gr-utils/src/python/usrp_siggen.py
@@ -8,9 +8,9 @@ from optparse import OptionParser
import sys
-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)
# controllable values
self.interp = 64
@@ -148,36 +148,36 @@ def main ():
parser.print_help()
raise SystemExit
- fg = my_graph()
- fg.set_interpolator (options.interp)
- fg.set_waveform_type (options.type)
- fg.set_waveform_freq (options.waveform_freq)
- fg.set_waveform_ampl (options.amplitude)
- fg.set_waveform_offset (options.offset)
+ tb = my_top_block()
+ tb.set_interpolator (options.interp)
+ tb.set_waveform_type (options.type)
+ tb.set_waveform_freq (options.waveform_freq)
+ tb.set_waveform_ampl (options.amplitude)
+ tb.set_waveform_offset (options.offset)
# determine the daughterboard subdevice we're using
if options.tx_subdev_spec is None:
- options.tx_subdev_spec = usrp.pick_tx_subdevice(fg.u)
+ options.tx_subdev_spec = usrp.pick_tx_subdevice(tb.u)
- m = usrp.determine_tx_mux_value(fg.u, options.tx_subdev_spec)
+ m = usrp.determine_tx_mux_value(tb.u, options.tx_subdev_spec)
#print "mux = %#04x" % (m,)
- fg.u.set_mux(m)
- fg.subdev = usrp.selected_subdev(fg.u, options.tx_subdev_spec)
- print "Using TX d'board %s" % (fg.subdev.side_and_name(),)
+ tb.u.set_mux(m)
+ tb.subdev = usrp.selected_subdev(tb.u, options.tx_subdev_spec)
+ print "Using TX d'board %s" % (tb.subdev.side_and_name(),)
if options.gain is None:
- fg.subdev.set_gain(fg.subdev.gain_range()[1]) # set max Tx gain
+ tb.subdev.set_gain(fg.subdev.gain_range()[1]) # set max Tx gain
else:
- fg.subdev.set_gain(options.gain) # set max Tx gain
+ tb.subdev.set_gain(options.gain) # set max Tx gain
- if not fg.set_freq(options.rf_freq):
+ if not tb.set_freq(options.rf_freq):
sys.stderr.write('Failed to set RF frequency\n')
raise SystemExit
- fg.subdev.set_enable(True) # enable transmitter
+ tb.subdev.set_enable(True) # enable transmitter
try:
- fg.run()
+ tb.run()
except KeyboardInterrupt:
pass
diff --git a/gr-utils/src/python/usrp_test_counting.py b/gr-utils/src/python/usrp_test_counting.py
index ccfa948c6..a8300afe2 100755
--- a/gr-utils/src/python/usrp_test_counting.py
+++ b/gr-utils/src/python/usrp_test_counting.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,20 +32,20 @@ from gnuradio import usrp
def build_graph ():
rx_decim = 32
- fg = gr.flow_graph ()
+ tb = gr.top_block ()
usrp_rx = usrp.source_s (0, rx_decim, 1, 0x32103210, usrp.FPGA_MODE_COUNTING)
sink = gr.check_counting_s ()
- fg.connect (usrp_rx, sink)
+ tb.connect (usrp_rx, sink)
# file_sink = gr.file_sink (gr.sizeof_short, 'counting.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/gr-utils/src/python/usrp_test_loopback.py b/gr-utils/src/python/usrp_test_loopback.py
index 51a705a05..b58ac06ae 100755
--- a/gr-utils/src/python/usrp_test_loopback.py
+++ b/gr-utils/src/python/usrp_test_loopback.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
#
@@ -29,7 +29,7 @@ from gnuradio import gr
from gnuradio import usrp
-def ramp_source (fg):
+def ramp_source (tb):
period = 2**16
src = gr.vector_source_s (range (-period/2, period/2, 1), True)
return src
@@ -38,26 +38,26 @@ def build_graph ():
tx_interp = 32 # tx should be twice rx
rx_decim = 16
- fg = gr.flow_graph ()
+ tb = gr.top_block ()
- data_src = ramp_source (fg)
+ data_src = ramp_source (tb)
# 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_counting_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