[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r6361 - gnuradio/branches/developers/jcorgan/t162/gnur
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r6361 - gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital |
Date: |
Fri, 7 Sep 2007 23:47:35 -0600 (MDT) |
Author: jcorgan
Date: 2007-09-07 23:47:35 -0600 (Fri, 07 Sep 2007)
New Revision: 6361
Modified:
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/Makefile.am
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_loopback.py
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_rx.py
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_tx.py
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/receive_path.py
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/rx_voice.py
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/transmit_path.py
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/tunnel.py
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/tx_voice.py
Log:
Finished converting digital example directory to new top block code; still need
to do the remainder of the mod/demod in blks2impl.
Modified:
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/Makefile.am
===================================================================
---
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/Makefile.am
2007-09-08 05:06:49 UTC (rev 6360)
+++
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/Makefile.am
2007-09-08 05:47:35 UTC (rev 6361)
@@ -37,3 +37,5 @@
ourdatadir = $(exampledir)/digital
ourdata_DATA = $(EXTRA_DIST)
+
+MOSTLYCLEANFILES = *.pyc *.pyo *~
Modified:
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_loopback.py
===================================================================
---
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_loopback.py
2007-09-08 05:06:49 UTC (rev 6360)
+++
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_loopback.py
2007-09-08 05:47:35 UTC (rev 6361)
@@ -174,7 +174,6 @@
# Create an instance of a hierarchical block
tb = my_top_block(mods[options.modulation], demods[options.modulation],
rx_callback, options)
- tb.set_verbose(1)
tb.start()
# generate and send packets
Modified:
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_rx.py
===================================================================
---
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_rx.py
2007-09-08 05:06:49 UTC (rev 6360)
+++
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_rx.py
2007-09-08 05:47:35 UTC (rev 6361)
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005,2006 Free Software Foundation, Inc.
+# Copyright 2005,2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -38,6 +38,11 @@
#print os.getpid()
#raw_input('Attach and press enter: ')
+class my_top_block(gr.top_block):
+ def __init__(self, demodulator, rx_callback, options):
+ gr.top_block.__init__(self)
+ self.rxpath = receive_path(demodulator, rx_callback, options)
+ self.connect(self.rxpath)
# /////////////////////////////////////////////////////////////////////////////
# main
@@ -92,7 +97,7 @@
# build the graph
- tb = receive_path(demods[options.modulation], rx_callback, options)
+ tb = my_top_block(demods[options.modulation], rx_callback, options)
r = gr.enable_realtime_scheduling()
if r != gr.RT_OK:
Modified:
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_tx.py
===================================================================
---
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_tx.py
2007-09-08 05:06:49 UTC (rev 6360)
+++
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/benchmark_tx.py
2007-09-08 05:47:35 UTC (rev 6361)
@@ -36,6 +36,11 @@
#print os.getpid()
#raw_input('Attach and press enter')
+class my_top_block(gr.top_block):
+ def __init__(self, modulator, options):
+ gr.top_block.__init__(self)
+ self.txpath = transmit_path(modulator, options)
+ self.connect(self.txpath)
# /////////////////////////////////////////////////////////////////////////////
# main
@@ -44,7 +49,7 @@
def main():
def send_pkt(payload='', eof=False):
- return tb.send_pkt(payload, eof)
+ return tb.txpath.send_pkt(payload, eof)
def rx_callback(ok, payload):
print "ok = %r, payload = '%s'" % (ok, payload)
@@ -89,7 +94,7 @@
source_file = open(options.from_file, 'r')
# build the graph
- tb = transmit_path(mods[options.modulation], options)
+ tb = my_top_block(mods[options.modulation], options)
r = gr.enable_realtime_scheduling()
if r != gr.RT_OK:
Modified:
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/receive_path.py
===================================================================
---
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/receive_path.py
2007-09-08 05:06:49 UTC (rev 6360)
+++
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/receive_path.py
2007-09-08 05:47:35 UTC (rev 6361)
@@ -33,10 +33,12 @@
# receive path
# /////////////////////////////////////////////////////////////////////////////
-class receive_path(gr.top_block):
+class receive_path(gr.hier_block2):
def __init__(self, demod_class, rx_callback, options):
- gr.top_block.__init__(self, "receive_path")
+ gr.hier_block2.__init__(self, "receive_path",
+ gr.io_signature(0, 0, 0), # Input signature
+ gr.io_signature(0, 0, 0)) # Output signature
options = copy.copy(options) # make a copy so we can destructively
modify
@@ -246,6 +248,10 @@
print "decim: %3d" % (self._decim)
print "Rx Frequency: %s" %
(eng_notation.num_to_str(self._rx_freq))
# print "Rx Frequency: %f" % (self._rx_freq)
+
+ def __del__(self):
+ # Avoid weak reference error
+ del self.subdev
def add_freq_option(parser):
"""
Modified:
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/rx_voice.py
===================================================================
---
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/rx_voice.py
2007-09-08 05:06:49 UTC (rev 6360)
+++
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/rx_voice.py
2007-09-08 05:47:35 UTC (rev 6361)
@@ -31,6 +31,7 @@
import random
import struct
+import sys
# from current dir
from receive_path import receive_path
@@ -41,27 +42,30 @@
#raw_input('Attach and press enter')
-class audio_tx(gr.hier_block):
- def __init__(self, fg, audio_output_dev):
+class audio_tx(gr.hier_block2):
+ def __init__(self, audio_output_dev):
+ gr.hier_block2.__init__(self, "audio_tx",
+ gr.io_signature(0, 0, 0), # Input signature
+ gr.io_signature(0, 0, 0)) # Output signature
+
self.packet_src = gr.message_source(33)
voice_decoder = gsm_full_rate.decode_ps()
s2f = gr.short_to_float ()
sink_scale = gr.multiply_const_ff(1.0/32767.)
audio_sink = audio.sink(8000, audio_output_dev)
- fg.connect(self.packet_src, voice_decoder, s2f, sink_scale, audio_sink)
- gr.hier_block.__init__(self, fg, self.packet_src, audio_sink)
+ self.connect(self.packet_src, voice_decoder, s2f, sink_scale,
audio_sink)
def msgq(self):
return self.packet_src.msgq()
-class my_graph(gr.flow_graph):
-
+class my_top_block(gr.top_block):
def __init__(self, demod_class, rx_callback, options):
- gr.flow_graph.__init__(self)
- self.rxpath = receive_path(self, demod_class, rx_callback, options)
- self.audio_tx = audio_tx(self, options.audio_output)
-
+ gr.top_block.__init__(self)
+ self.rxpath = receive_path(demod_class, rx_callback, options)
+ self.audio_tx = audio_tx(options.audio_output)
+ self.connect(self.rxpath)
+ self.connect(self.audio_tx)
# /////////////////////////////////////////////////////////////////////////////
# main
@@ -120,14 +124,13 @@
# build the graph
- fg = my_graph(demods[options.modulation], rx_callback, options)
+ tb = my_top_block(demods[options.modulation], rx_callback, options)
r = gr.enable_realtime_scheduling()
if r != gr.RT_OK:
print "Warning: Failed to enable realtime scheduling."
- fg.start() # start flow graph
- fg.wait() # wait for it to finish
+ tb.run()
if __name__ == '__main__':
try:
Modified:
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/transmit_path.py
===================================================================
---
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/transmit_path.py
2007-09-08 05:06:49 UTC (rev 6360)
+++
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/transmit_path.py
2007-09-08 05:47:35 UTC (rev 6361)
@@ -33,12 +33,14 @@
# transmit path
# /////////////////////////////////////////////////////////////////////////////
-class transmit_path(gr.top_block):
+class transmit_path(gr.hier_block2):
def __init__(self, modulator_class, options):
'''
See below for what options should hold
'''
- gr.top_block.__init__(self, "transmit_path");
+ gr.hier_block2.__init__(self, "transmit_path",
+ gr.io_signature(0, 0, 0), # Input signature
+ gr.io_signature(0, 0, 0)) # Output signature
options = copy.copy(options) # make a copy so we can destructively
modify
Modified:
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/tunnel.py
===================================================================
---
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/tunnel.py
2007-09-08 05:06:49 UTC (rev 6360)
+++
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/tunnel.py
2007-09-08 05:47:35 UTC (rev 6361)
@@ -86,14 +86,14 @@
# the flow graph
# /////////////////////////////////////////////////////////////////////////////
-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)
- self.txpath = transmit_path(self, mod_class, options)
- self.rxpath = receive_path(self, demod_class, rx_callback, options)
+ gr.top_block.__init__(self)
+ self.txpath = transmit_path(mod_class, options)
+ self.rxpath = receive_path(demod_class, rx_callback, options)
def send_pkt(self, payload='', eof=False):
return self.txpath.send_pkt(payload, eof)
@@ -123,10 +123,10 @@
def __init__(self, tun_fd, verbose=False):
self.tun_fd = tun_fd # file descriptor for TUN/TAP interface
self.verbose = verbose
- self.fg = None # flow graph (access to PHY)
+ self.tb = None # top block (access to PHY)
- def set_flow_graph(self, fg):
- self.fg = fg
+ def set_top_block(self, tb):
+ self.tb = tb
def phy_rx_callback(self, ok, payload):
"""
@@ -152,20 +152,20 @@
while 1:
payload = os.read(self.tun_fd, 10*1024)
if not payload:
- self.fg.send_pkt(eof=True)
+ self.tb.send_pkt(eof=True)
break
if self.verbose:
print "Tx: len(payload) = %4d" % (len(payload),)
delay = min_delay
- while self.fg.carrier_sensed():
+ while self.tb.carrier_sensed():
sys.stderr.write('B')
time.sleep(delay)
if delay < 0.050:
delay = delay * 2 # exponential back-off
- self.fg.send_pkt(payload)
+ self.tb.send_pkt(payload)
# /////////////////////////////////////////////////////////////////////////////
@@ -243,26 +243,26 @@
# build the graph (PHY)
- fg = my_graph(mods[options.modulation],
- demods[options.modulation],
- mac.phy_rx_callback,
- options)
+ tb = my_top_block(mods[options.modulation],
+ demods[options.modulation],
+ mac.phy_rx_callback,
+ options)
- mac.set_flow_graph(fg) # give the MAC a handle for the PHY
+ mac.set_top_block(tb) # give the MAC a handle for the PHY
- if fg.txpath.bitrate() != fg.rxpath.bitrate():
+ if tb.txpath.bitrate() != tb.rxpath.bitrate():
print "WARNING: Transmit bitrate = %sb/sec, Receive bitrate = %sb/sec"
% (
- eng_notation.num_to_str(fg.txpath.bitrate()),
- eng_notation.num_to_str(fg.rxpath.bitrate()))
+ eng_notation.num_to_str(tb.txpath.bitrate()),
+ eng_notation.num_to_str(tb.rxpath.bitrate()))
print "modulation: %s" % (options.modulation,)
print "freq: %s" %
(eng_notation.num_to_str(options.tx_freq))
- print "bitrate: %sb/sec" %
(eng_notation.num_to_str(fg.txpath.bitrate()),)
- print "samples/symbol: %3d" % (fg.txpath.samples_per_symbol(),)
- #print "interp: %3d" % (fg.txpath.interp(),)
- #print "decim: %3d" % (fg.rxpath.decim(),)
+ print "bitrate: %sb/sec" %
(eng_notation.num_to_str(tb.txpath.bitrate()),)
+ print "samples/symbol: %3d" % (tb.txpath.samples_per_symbol(),)
+ #print "interp: %3d" % (tb.txpath.interp(),)
+ #print "decim: %3d" % (tb.rxpath.decim(),)
- fg.rxpath.set_carrier_threshold(options.carrier_threshold)
+ tb.rxpath.set_carrier_threshold(options.carrier_threshold)
print "Carrier sense threshold:", options.carrier_threshold, "dB"
print
@@ -275,12 +275,12 @@
print
- fg.start() # Start executing the flow graph (runs in separate threads)
+ tb.start() # Start executing the flow graph (runs in separate threads)
mac.main_loop() # don't expect this to return...
- fg.stop() # but if it does, tell flow graph to stop.
- fg.wait() # wait for it to finish
+ tb.stop() # but if it does, tell flow graph to stop.
+ tb.wait() # wait for it to finish
if __name__ == '__main__':
Modified:
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/tx_voice.py
===================================================================
---
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/tx_voice.py
2007-09-08 05:06:49 UTC (rev 6360)
+++
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital/tx_voice.py
2007-09-08 05:47:35 UTC (rev 6361)
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005,2006 Free Software Foundation, Inc.
+# Copyright 2005,2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -43,8 +43,11 @@
#raw_input('Attach and press enter')
-class audio_rx(gr.hier_block):
- def __init__(self, fg, audio_input_dev):
+class audio_rx(gr.hier_block2):
+ def __init__(self, audio_input_dev):
+ gr.hier_block2.__init__(self, "audio_rx",
+ gr.io_signature(0, 0, 0), # Input signature
+ gr.io_signature(0, 0, 0)) # Output signature
sample_rate = 8000
src = audio.source(sample_rate, audio_input_dev)
src_scale = gr.multiply_const_ff(32767)
@@ -52,22 +55,22 @@
voice_coder = gsm_full_rate.encode_sp()
self.packets_from_encoder = gr.msg_queue()
packet_sink = gr.message_sink(33, self.packets_from_encoder, False)
- fg.connect(src, src_scale, f2s, voice_coder, packet_sink)
- gr.hier_block.__init__(self, fg, src, packet_sink)
+ self.connect(src, src_scale, f2s, voice_coder, packet_sink)
def get_encoded_voice_packet(self):
return self.packets_from_encoder.delete_head()
-class my_graph(gr.flow_graph):
+class my_top_block(gr.top_block):
def __init__(self, modulator_class, options):
- gr.flow_graph.__init__(self)
- self.txpath = transmit_path(self, modulator_class, options)
- self.audio_rx = audio_rx(self, options.audio_input)
+ gr.top_block.__init__(self)
+ self.txpath = transmit_path(modulator_class, options)
+ self.audio_rx = audio_rx(options.audio_input)
+ self.connect(self.txpath)
+ self.connect(self.audio_rx)
-
# /////////////////////////////////////////////////////////////////////////////
# main
# /////////////////////////////////////////////////////////////////////////////
@@ -75,7 +78,7 @@
def main():
def send_pkt(payload='', eof=False):
- return fg.txpath.send_pkt(payload, eof)
+ return tb.txpath.send_pkt(payload, eof)
def rx_callback(ok, payload):
print "ok = %r, payload = '%s'" % (ok, payload)
@@ -115,14 +118,14 @@
# build the graph
- fg = my_graph(mods[options.modulation], options)
+ tb = my_top_block(mods[options.modulation], options)
r = gr.enable_realtime_scheduling()
if r != gr.RT_OK:
print "Warning: failed to enable realtime scheduling"
- fg.start() # start flow graph
+ tb.start() # start flow graph
# generate and send packets
nbytes = int(1e6 * options.megabytes)
@@ -130,7 +133,7 @@
pktno = 0
while nbytes == 0 or n < nbytes:
- packet = fg.audio_rx.get_encoded_voice_packet()
+ packet = tb.audio_rx.get_encoded_voice_packet()
s = packet.to_string()
send_pkt(s)
n += len(s)
@@ -138,12 +141,12 @@
pktno += 1
send_pkt(eof=True)
- fg.wait() # wait for it to finish
- fg.txpath.set_auto_tr(False)
+ tb.wait() # wait for it to finish
+ tb.txpath.set_auto_tr(False)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
- pass
+ pass
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r6361 - gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/digital,
jcorgan <=