summaryrefslogtreecommitdiff
path: root/gnuradio-examples/python/digital/benchmark_loopback.py
diff options
context:
space:
mode:
authorjcorgan2007-09-18 18:59:00 +0000
committerjcorgan2007-09-18 18:59:00 +0000
commite692e71305ecd71d3681fe37f3d76f350d67e276 (patch)
treedc320c9261303aa9a92f4d12bdba85f82720d1bf /gnuradio-examples/python/digital/benchmark_loopback.py
parent6ad04a094ced626e46c210b9847eae46a1ae8e67 (diff)
downloadgnuradio-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/digital/benchmark_loopback.py')
-rwxr-xr-xgnuradio-examples/python/digital/benchmark_loopback.py40
1 files changed, 21 insertions, 19 deletions
diff --git a/gnuradio-examples/python/digital/benchmark_loopback.py b/gnuradio-examples/python/digital/benchmark_loopback.py
index 34d25812e..7dd36b986 100755
--- a/gnuradio-examples/python/digital/benchmark_loopback.py
+++ b/gnuradio-examples/python/digital/benchmark_loopback.py
@@ -32,10 +32,13 @@ from transmit_path_lb import transmit_path
from receive_path_lb import receive_path
import fusb_options
-class awgn_channel(gr.hier_block):
- def __init__(self, fg, sample_rate, noise_voltage, frequency_offset, seed=False):
- self.input = gr.add_const_cc(0) # dummy input device
-
+class awgn_channel(gr.hier_block2):
+ def __init__(self, sample_rate, noise_voltage, frequency_offset, seed=False):
+
+ gr.hier_block2.__init__(self, "awgn_channel",
+ gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
+ gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
+
# Create the Gaussian noise source
if not seed:
self.noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_voltage)
@@ -51,16 +54,15 @@ class awgn_channel(gr.hier_block):
self.mixer = gr.multiply_cc()
# Connect the components
- fg.connect(self.input, (self.mixer, 0))
- fg.connect(self.offset, (self.mixer, 1))
- fg.connect(self.mixer, (self.adder, 0))
- fg.connect(self.noise, (self.adder, 1))
-
- gr.hier_block.__init__(self, fg, self.input, self.adder)
+ self.connect(self, (self.mixer, 0))
+ self.connect(self.offset, (self.mixer, 1))
+ self.connect(self.mixer, (self.adder, 0))
+ self.connect(self.noise, (self.adder, 1))
+ self.connect(self.adder, self)
-class my_graph(gr.flow_graph):
+class my_top_block(gr.top_block):
def __init__(self, mod_class, demod_class, rx_callback, options):
- gr.flow_graph.__init__(self)
+ gr.top_block.__init__(self)
channelon = True;
@@ -71,12 +73,12 @@ class my_graph(gr.flow_graph):
noise_power = power_in_signal/SNR
noise_voltage = math.sqrt(noise_power)
- self.txpath = transmit_path(self, mod_class, options)
+ self.txpath = transmit_path(mod_class, options)
self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate)
- self.rxpath = receive_path(self, demod_class, rx_callback, options)
+ self.rxpath = receive_path(demod_class, rx_callback, options)
if channelon:
- self.channel = awgn_channel(self, options.sample_rate, noise_voltage,
+ self.channel = awgn_channel(options.sample_rate, noise_voltage,
frequency_offset, options.seed)
if options.discontinuous:
@@ -121,7 +123,7 @@ def main():
# print payload[2:len(payload)]
def send_pkt(payload='', eof=False):
- return fg.txpath.send_pkt(payload, eof)
+ return tb.txpath.send_pkt(payload, eof)
mods = modulation_utils.type_1_mods()
@@ -171,8 +173,8 @@ def main():
print "Warning: failed to enable realtime scheduling"
# Create an instance of a hierarchical block
- fg = my_graph(mods[options.modulation], demods[options.modulation], rx_callback, options)
- fg.start()
+ tb = my_top_block(mods[options.modulation], demods[options.modulation], rx_callback, options)
+ tb.start()
# generate and send packets
nbytes = int(1e6 * options.megabytes)
@@ -187,7 +189,7 @@ def main():
send_pkt(eof=True)
- fg.wait()
+ tb.wait()
if __name__ == '__main__':
try: