diff options
Diffstat (limited to 'gr-pager/src')
-rw-r--r-- | gr-pager/src/pager_utils.py | 25 | ||||
-rwxr-xr-x | gr-pager/src/usrp_flex.py | 31 | ||||
-rwxr-xr-x | gr-pager/src/usrp_flex_all.py | 43 | ||||
-rwxr-xr-x | gr-pager/src/usrp_flex_band.py | 46 |
4 files changed, 82 insertions, 63 deletions
diff --git a/gr-pager/src/pager_utils.py b/gr-pager/src/pager_utils.py index bbcb633fd..72aac6826 100644 --- a/gr-pager/src/pager_utils.py +++ b/gr-pager/src/pager_utils.py @@ -1,5 +1,5 @@ # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2009 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -18,7 +18,10 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # +from gnuradio import gr import gnuradio.gr.gr_threading as _threading +from string import split, join, printable +import time def make_trans_table(): table = 256 * ['.'] @@ -34,14 +37,24 @@ _trans_table = make_trans_table() def make_printable(s): return s.translate(_trans_table) -class top_block_runner(_threading.Thread): - def __init__(self, tb): + +class queue_runner(_threading.Thread): + def __init__(self, msgq): _threading.Thread.__init__(self) - self.setDaemon(1) - self.tb = tb + self.msgq = msgq self.done = False self.start() def run(self): - self.tb.run() + while 1: + msg = self.msgq.delete_head() # Blocking read + if msg.type() != 0: + break + + page = join(split(msg.to_string(), chr(128)), '|') + s = make_printable(page) + print msg.type(), s + + def end(self): + self.msgq.insert_tail(gr.message(1)) self.done = True diff --git a/gr-pager/src/usrp_flex.py b/gr-pager/src/usrp_flex.py index 6e09b3df6..f8d9d25b1 100755 --- a/gr-pager/src/usrp_flex.py +++ b/gr-pager/src/usrp_flex.py @@ -1,7 +1,6 @@ #!/usr/bin/env python - # -# Copyright 2006,2007 Free Software Foundation, Inc. +# Copyright 2006,2007,2009 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -25,7 +24,6 @@ from gnuradio import gr, gru, usrp, optfir, eng_notation, pager from gnuradio.eng_option import eng_option from optparse import OptionParser import time, os, sys -from string import split, join """ This example application demonstrates receiving and demodulating the @@ -108,9 +106,9 @@ class app_top_block(gr.top_block): print "Channel filter has", len(taps), "taps." self.chan = gr.freq_xlating_fir_filter_ccf(10, # Decimation rate - taps, # Filter taps - 0.0, # Offset frequency - 250e3) # Sample rate + taps, # Filter taps + 0.0, # Offset frequency + 250e3) # Sample rate if options.log: chan_sink = gr.file_sink(gr.sizeof_gr_complex, 'chan.dat') @@ -160,24 +158,15 @@ def main(): # Flow graph emits pages into message queue queue = gr.msg_queue() tb = app_top_block(options, queue) - runner = pager.top_block_runner(tb) + runner = pager.queue_runner(queue) try: - while 1: - if not queue.empty_p(): - msg = queue.delete_head() # Blocking read - page = join(split(msg.to_string(), chr(128)), '|') - s = pager.make_printable(page) - print s - tb.adjust_freq() - elif runner.done: - break - else: - time.sleep(1) - + tb.run() except KeyboardInterrupt: - tb.stop() - runner = None + pass + + runner.end() + if __name__ == "__main__": main() diff --git a/gr-pager/src/usrp_flex_all.py b/gr-pager/src/usrp_flex_all.py index b37c6a5da..14f9151de 100755 --- a/gr-pager/src/usrp_flex_all.py +++ b/gr-pager/src/usrp_flex_all.py @@ -1,4 +1,24 @@ #!/usr/bin/env python +# +# Copyright 2006,2007,2009 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, eng_notation, blks2, pager from gnuradio.eng_option import eng_option @@ -21,10 +41,10 @@ class app_top_block(gr.top_block): subdev = usrp.selected_subdev(src, options.rx_subdev_spec) src.set_mux(usrp.determine_rx_mux_value(src, options.rx_subdev_spec)) src.set_decim_rate(20) - result = usrp.tune(src, 0, subdev, 930.5e6+options.calibration) + result = usrp.tune(src, 0, subdev, 930.5125e6+options.calibration) if options.verbose: print "Using", subdev.name(), " for receiving." - print "Tuned USRP to", 930.5e6+options.calibration + print "Tuned USRP to", 930.5125e6+options.calibration taps = gr.firdes.low_pass(1.0, 1.0, @@ -76,23 +96,14 @@ def main(): queue = gr.msg_queue() tb = app_top_block(options, queue) + runner = pager.queue_runner(queue) - runner = pager.top_block_runner(tb) try: - while 1: - if not queue.empty_p(): - msg = queue.delete_head() # Blocking read - page = join(split(msg.to_string(), chr(128)), '|') - s = pager.make_printable(page) - print s - elif runner.done: - break - else: - time.sleep(0.05) - + tb.run() except KeyboardInterrupt: - tb.stop() - runner = None + pass + + runner.end() if __name__ == "__main__": main() diff --git a/gr-pager/src/usrp_flex_band.py b/gr-pager/src/usrp_flex_band.py index 62307385b..06c2488c0 100755 --- a/gr-pager/src/usrp_flex_band.py +++ b/gr-pager/src/usrp_flex_band.py @@ -1,10 +1,28 @@ #!/usr/bin/env python +# +# Copyright 2006,2007,2009 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, eng_notation, blks2, pager from gnuradio.eng_option import eng_option from optparse import OptionParser -from string import split, join, printable -import time class app_top_block(gr.top_block): def __init__(self, options, queue): @@ -54,10 +72,6 @@ class app_top_block(gr.top_block): if options.log: self.connect((bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat')) - def __del__(self): - # Avoid weak-ref error - del self.subdev - def main(): parser = OptionParser(option_class=eng_option) @@ -82,23 +96,15 @@ def main(): queue = gr.msg_queue() tb = app_top_block(options, queue) + runner = pager.queue_runner(queue) - runner = pager.top_block_runner(tb) try: - while 1: - if not queue.empty_p(): - msg = queue.delete_head() # Blocking read - page = join(split(msg.to_string(), chr(128)), '|') - s = pager.make_printable(page) - print s - elif runner.done: - break - else: - time.sleep(0.05) - + tb.run() except KeyboardInterrupt: - tb.stop() - runner = None + pass + + runner.end() + if __name__ == "__main__": main() |