From: Johnathan Corgan Date: Sun, 11 Oct 2009 19:47:46 +0000 (-0700) Subject: Moved command-line apps into apps subdirectory X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=821aa4341a2ad6b69cbb829bcf2d31638f67a878;p=debian%2Fgnuradio Moved command-line apps into apps subdirectory --- diff --git a/config/grc_gr_pager.m4 b/config/grc_gr_pager.m4 index 23af7a9c..8b493219 100644 --- a/config/grc_gr_pager.m4 +++ b/config/grc_gr_pager.m4 @@ -26,6 +26,7 @@ AC_DEFUN([GRC_GR_PAGER],[ AC_CONFIG_FILES([\ gr-pager/Makefile \ gr-pager/gnuradio-pager.pc \ + gr-pager/apps/Makefile \ gr-pager/src/Makefile \ gr-pager/src/run_tests ]) diff --git a/gr-pager/Makefile.am b/gr-pager/Makefile.am index d73e4050..984e6479 100644 --- a/gr-pager/Makefile.am +++ b/gr-pager/Makefile.am @@ -23,5 +23,9 @@ include $(top_srcdir)/Makefile.common SUBDIRS = src +if PYTHON +SUBDIRS += apps +endif + pkgconfigdir = $(libdir)/pkgconfig dist_pkgconfig_DATA = gnuradio-pager.pc diff --git a/gr-pager/apps/.gitignore b/gr-pager/apps/.gitignore new file mode 100644 index 00000000..282522db --- /dev/null +++ b/gr-pager/apps/.gitignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/gr-pager/apps/Makefile.am b/gr-pager/apps/Makefile.am new file mode 100644 index 00000000..64a79f59 --- /dev/null +++ b/gr-pager/apps/Makefile.am @@ -0,0 +1,31 @@ +# +# Copyright 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. +# + +include $(top_srcdir)/Makefile.common + +if PYTHON + +dist_bin_SCRIPTS = \ + usrp_flex.py \ + usrp_flex_all.py \ + usrp_flex_band.py + +endif diff --git a/gr-pager/apps/usrp_flex.py b/gr-pager/apps/usrp_flex.py new file mode 100755 index 00000000..f8d9d25b --- /dev/null +++ b/gr-pager/apps/usrp_flex.py @@ -0,0 +1,172 @@ +#!/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, pager +from gnuradio.eng_option import eng_option +from optparse import OptionParser +import time, os, sys + +""" +This example application demonstrates receiving and demodulating the +FLEX pager protocol. + +The following are required command line parameters: + +-f FREQ USRP receive frequency + +The following are optional command line parameters: + +-R SUBDEV Daughter board specification, defaults to first found +-F FILE Read samples from a file instead of USRP. +-c FREQ Calibration offset. Gets added to receive frequency. + Defaults to 0.0 Hz. +-g GAIN Daughterboard gain setting. Defaults to mid-range. +-l Log flow graph to files (LOTS of data) +-v Verbose output + +Once the program is running, ctrl-break (Ctrl-C) stops operation. +""" + +class app_top_block(gr.top_block): + def __init__(self, options, queue): + gr.top_block.__init__(self, "usrp_flex") + self.options = options + self.offset = 0.0 + self.adj_time = time.time() + self.verbose = options.verbose + + if options.from_file is None: + # Set up USRP source with specified RX daughterboard + self.src = usrp.source_c() + if options.rx_subdev_spec == None: + options.rx_subdev_spec = usrp.pick_rx_subdevice(self.src) + self.subdev = usrp.selected_subdev(self.src, options.rx_subdev_spec) + self.src.set_mux(usrp.determine_rx_mux_value(self.src, options.rx_subdev_spec)) + + # Grab 250 KHz of spectrum (sample rate becomes 250 ksps complex) + self.src.set_decim_rate(256) + + # If no gain specified, set to midrange + if options.gain is None: + g = self.subdev.gain_range() + options.gain = (g[0]+g[1])/2.0 + self.subdev.set_gain(options.gain) + + # Tune daughterboard + actual_frequency = options.frequency+options.calibration + tune_result = usrp.tune(self.src, 0, self.subdev, actual_frequency) + if not tune_result: + sys.stderr.write("Failed to set center frequency to "+`actual_frequency`+"\n") + sys.exit(1) + + if options.verbose: + print "Using RX daughterboard", self.subdev.side_and_name() + print "USRP gain is", options.gain + print "USRP tuned to", actual_frequency + + else: + # Use supplied file as source of samples + self.src = gr.file_source(gr.sizeof_gr_complex, options.from_file) + if options.verbose: + print "Reading samples from", options.from_file + + if options.log and not options.from_file: + usrp_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') + self.connect(self.src, usrp_sink) + + # Set up 22KHz-wide bandpass about center frequency. Decimate by 10 + # to get channel rate of 25Ksps + taps = optfir.low_pass(1.0, # Filter gain + 250e3, # Sample rate + 11000, # One-sided modulation bandwidth + 12500, # One-sided channel bandwidth + 0.1, # Passband ripple + 60) # Stopband attenuation + + if options.verbose: + 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 + + if options.log: + chan_sink = gr.file_sink(gr.sizeof_gr_complex, 'chan.dat') + self.connect(self.chan, chan_sink) + + # FLEX protocol demodulator + self.flex = pager.flex_demod(queue, options.frequency, options.verbose, options.log) + + self.connect(self.src, self.chan, self.flex) + + def freq_offset(self): + return self.flex.dc_offset()*1600 + + def adjust_freq(self): + if time.time() - self.adj_time > 1.6: # Only do it once per FLEX frame + self.adj_time = time.time() + self.offset -= self.freq_offset() + self.chan.set_center_freq(self.offset) + if self.verbose: + print "Channel frequency offset (Hz):", int(self.offset) + +def main(): + parser = OptionParser(option_class=eng_option) + 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") + parser.add_option("-c", "--calibration", type="eng_float", default=0.0, + help="set frequency offset to Hz", metavar="Hz") + parser.add_option("-g", "--gain", type="int", default=None, + help="set RF gain", metavar="dB") + parser.add_option("-l", "--log", action="store_true", default=False, + help="log flowgraph to files (LOTS of data)") + parser.add_option("-v", "--verbose", action="store_true", default=False, + help="display debug output") + parser.add_option("-F", "--from-file", default=None, + help="read samples from file instead of USRP") + (options, args) = parser.parse_args() + + if len(args) > 0 or (options.frequency == None and options.from_file == None): + print "Run 'usrp_flex.py -h' for options." + sys.exit(1) + + if options.frequency == None: + options.frequency = 0.0 + + # Flow graph emits pages into message queue + queue = gr.msg_queue() + tb = app_top_block(options, queue) + runner = pager.queue_runner(queue) + + try: + tb.run() + except KeyboardInterrupt: + pass + + runner.end() + + +if __name__ == "__main__": + main() diff --git a/gr-pager/apps/usrp_flex_all.py b/gr-pager/apps/usrp_flex_all.py new file mode 100755 index 00000000..14f9151d --- /dev/null +++ b/gr-pager/apps/usrp_flex_all.py @@ -0,0 +1,109 @@ +#!/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): + gr.top_block.__init__(self, "usrp_flex_all") + + if options.from_file is not None: + src = gr.file_source(gr.sizeof_gr_complex, options.from_file) + if options.verbose: + print "Reading samples from file", options.from_file + else: + src = usrp.source_c() + if options.rx_subdev_spec is None: + options.rx_subdev_spec = usrp.pick_rx_subdevice(src) + 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.5125e6+options.calibration) + if options.verbose: + print "Using", subdev.name(), " for receiving." + print "Tuned USRP to", 930.5125e6+options.calibration + + taps = gr.firdes.low_pass(1.0, + 1.0, + 1.0/128.0*0.4, + 1.0/128.0*0.1, + gr.firdes.WIN_HANN) + + if options.verbose: + print "Channel filter has", len(taps), "taps" + + bank = blks2.analysis_filterbank(128, taps) + self.connect(src, bank) + + if options.log and options.from_file == None: + src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') + self.connect(src, src_sink) + + for i in range(128): + if i < 64: + freq = 930.5e6+i*25e3 + else: + freq = 928.9e6+(i-64)*25e3 + + if (freq < 929.0e6 or freq > 932.0e6): + self.connect((bank, i), gr.null_sink(gr.sizeof_gr_complex)) + else: + self.connect((bank, i), pager.flex_demod(queue, freq, options.verbose, options.log)) + if options.log: + self.connect((bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat')) + +def main(): + parser = OptionParser(option_class=eng_option) + parser.add_option("-R", "--rx-subdev-spec", type="subdev", + help="select USRP Rx side A or B (default=first daughterboard found)") + parser.add_option("-c", "--calibration", type="eng_float", default=0.0, + help="set frequency offset to Hz", metavar="Hz") + parser.add_option("-g", "--gain", type="int", + help="set RF gain", metavar="dB") + parser.add_option("-F", "--from-file", default=None, + help="Read from file instead of USRP") + parser.add_option("-l", "--log", action="store_true", default=False, + help="log flowgraph to files (LOTS of data)") + parser.add_option("-v", "--verbose", action="store_true", default=False, + help="display debug output") + (options, args) = parser.parse_args() + + if options.verbose: + print options + + queue = gr.msg_queue() + tb = app_top_block(options, queue) + runner = pager.queue_runner(queue) + + try: + tb.run() + except KeyboardInterrupt: + pass + + runner.end() + +if __name__ == "__main__": + main() diff --git a/gr-pager/apps/usrp_flex_band.py b/gr-pager/apps/usrp_flex_band.py new file mode 100755 index 00000000..06c2488c --- /dev/null +++ b/gr-pager/apps/usrp_flex_band.py @@ -0,0 +1,110 @@ +#!/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 + +class app_top_block(gr.top_block): + def __init__(self, options, queue): + gr.top_block.__init__(self, "usrp_flex_all") + self.subdev = None + + if options.from_file is not None: + self.src = gr.file_source(gr.sizeof_gr_complex, options.from_file) + if options.verbose: + print "Reading samples from file", options.from_file + else: + self.src = usrp.source_c() + if options.rx_subdev_spec is None: + options.rx_subdev_spec = usrp.pick_rx_subdevice(self.src) + self.subdev = usrp.selected_subdev(self.src, options.rx_subdev_spec) + self.src.set_mux(usrp.determine_rx_mux_value(self.src, options.rx_subdev_spec)) + self.src.set_decim_rate(64) + frequency = options.frequency+options.calibration + result = usrp.tune(self.src, 0, self.subdev, frequency) + if options.verbose: + print "Using", self.subdev.name(), " for receiving." + print "Tuned USRP to", frequency + + taps = gr.firdes.low_pass(1.0, + 1.0, + 1.0/40.0*0.4, + 1.0/40.0*0.1, + gr.firdes.WIN_HANN) + + if options.verbose: + print "Channel filter has", len(taps), "taps" + + bank = blks2.analysis_filterbank(40, taps) + self.connect(self.src, bank) + + if options.log and options.from_file == None: + src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') + self.connect(self.src, src_sink) + + for i in range(40): + if i < 20: + freq = options.frequency+i*25e3 + else: + freq = options.frequency-0.5e6+(i-20)*25e3 + + self.connect((bank, i), pager.flex_demod(queue, freq, options.verbose, options.log)) + if options.log: + self.connect((bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat')) + + +def main(): + parser = OptionParser(option_class=eng_option) + parser.add_option("-f", "--frequency", type="eng_float", default=929.5e6, + help="set receive center frequency to Hz", metavar="Hz") + parser.add_option("-R", "--rx-subdev-spec", type="subdev", + help="select USRP Rx side A or B (default=first daughterboard found)") + parser.add_option("-c", "--calibration", type="eng_float", default=0.0, + help="set frequency offset to Hz", metavar="Hz") + parser.add_option("-g", "--gain", type="int", + help="set RF gain", metavar="dB") + parser.add_option("-F", "--from-file", default=None, + help="Read from file instead of USRP") + parser.add_option("-l", "--log", action="store_true", default=False, + help="log flowgraph to files (LOTS of data)") + parser.add_option("-v", "--verbose", action="store_true", default=False, + help="display debug output") + (options, args) = parser.parse_args() + + if options.verbose: + print options + + queue = gr.msg_queue() + tb = app_top_block(options, queue) + runner = pager.queue_runner(queue) + + try: + tb.run() + except KeyboardInterrupt: + pass + + runner.end() + + +if __name__ == "__main__": + main() diff --git a/gr-pager/src/Makefile.am b/gr-pager/src/Makefile.am index d084d05f..8a9f90d5 100644 --- a/gr-pager/src/Makefile.am +++ b/gr-pager/src/Makefile.am @@ -59,11 +59,6 @@ libgnuradio_pager_la_LDFLAGS = \ if PYTHON -dist_bin_SCRIPTS = \ - usrp_flex.py \ - usrp_flex_all.py \ - usrp_flex_band.py - ############################## # SWIG interface and library TESTS = run_tests diff --git a/gr-pager/src/usrp_flex.py b/gr-pager/src/usrp_flex.py deleted file mode 100755 index f8d9d25b..00000000 --- a/gr-pager/src/usrp_flex.py +++ /dev/null @@ -1,172 +0,0 @@ -#!/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, pager -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import time, os, sys - -""" -This example application demonstrates receiving and demodulating the -FLEX pager protocol. - -The following are required command line parameters: - --f FREQ USRP receive frequency - -The following are optional command line parameters: - --R SUBDEV Daughter board specification, defaults to first found --F FILE Read samples from a file instead of USRP. --c FREQ Calibration offset. Gets added to receive frequency. - Defaults to 0.0 Hz. --g GAIN Daughterboard gain setting. Defaults to mid-range. --l Log flow graph to files (LOTS of data) --v Verbose output - -Once the program is running, ctrl-break (Ctrl-C) stops operation. -""" - -class app_top_block(gr.top_block): - def __init__(self, options, queue): - gr.top_block.__init__(self, "usrp_flex") - self.options = options - self.offset = 0.0 - self.adj_time = time.time() - self.verbose = options.verbose - - if options.from_file is None: - # Set up USRP source with specified RX daughterboard - self.src = usrp.source_c() - if options.rx_subdev_spec == None: - options.rx_subdev_spec = usrp.pick_rx_subdevice(self.src) - self.subdev = usrp.selected_subdev(self.src, options.rx_subdev_spec) - self.src.set_mux(usrp.determine_rx_mux_value(self.src, options.rx_subdev_spec)) - - # Grab 250 KHz of spectrum (sample rate becomes 250 ksps complex) - self.src.set_decim_rate(256) - - # If no gain specified, set to midrange - if options.gain is None: - g = self.subdev.gain_range() - options.gain = (g[0]+g[1])/2.0 - self.subdev.set_gain(options.gain) - - # Tune daughterboard - actual_frequency = options.frequency+options.calibration - tune_result = usrp.tune(self.src, 0, self.subdev, actual_frequency) - if not tune_result: - sys.stderr.write("Failed to set center frequency to "+`actual_frequency`+"\n") - sys.exit(1) - - if options.verbose: - print "Using RX daughterboard", self.subdev.side_and_name() - print "USRP gain is", options.gain - print "USRP tuned to", actual_frequency - - else: - # Use supplied file as source of samples - self.src = gr.file_source(gr.sizeof_gr_complex, options.from_file) - if options.verbose: - print "Reading samples from", options.from_file - - if options.log and not options.from_file: - usrp_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') - self.connect(self.src, usrp_sink) - - # Set up 22KHz-wide bandpass about center frequency. Decimate by 10 - # to get channel rate of 25Ksps - taps = optfir.low_pass(1.0, # Filter gain - 250e3, # Sample rate - 11000, # One-sided modulation bandwidth - 12500, # One-sided channel bandwidth - 0.1, # Passband ripple - 60) # Stopband attenuation - - if options.verbose: - 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 - - if options.log: - chan_sink = gr.file_sink(gr.sizeof_gr_complex, 'chan.dat') - self.connect(self.chan, chan_sink) - - # FLEX protocol demodulator - self.flex = pager.flex_demod(queue, options.frequency, options.verbose, options.log) - - self.connect(self.src, self.chan, self.flex) - - def freq_offset(self): - return self.flex.dc_offset()*1600 - - def adjust_freq(self): - if time.time() - self.adj_time > 1.6: # Only do it once per FLEX frame - self.adj_time = time.time() - self.offset -= self.freq_offset() - self.chan.set_center_freq(self.offset) - if self.verbose: - print "Channel frequency offset (Hz):", int(self.offset) - -def main(): - parser = OptionParser(option_class=eng_option) - 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") - parser.add_option("-c", "--calibration", type="eng_float", default=0.0, - help="set frequency offset to Hz", metavar="Hz") - parser.add_option("-g", "--gain", type="int", default=None, - help="set RF gain", metavar="dB") - parser.add_option("-l", "--log", action="store_true", default=False, - help="log flowgraph to files (LOTS of data)") - parser.add_option("-v", "--verbose", action="store_true", default=False, - help="display debug output") - parser.add_option("-F", "--from-file", default=None, - help="read samples from file instead of USRP") - (options, args) = parser.parse_args() - - if len(args) > 0 or (options.frequency == None and options.from_file == None): - print "Run 'usrp_flex.py -h' for options." - sys.exit(1) - - if options.frequency == None: - options.frequency = 0.0 - - # Flow graph emits pages into message queue - queue = gr.msg_queue() - tb = app_top_block(options, queue) - runner = pager.queue_runner(queue) - - try: - tb.run() - except KeyboardInterrupt: - 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 deleted file mode 100755 index 14f9151d..00000000 --- a/gr-pager/src/usrp_flex_all.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/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): - gr.top_block.__init__(self, "usrp_flex_all") - - if options.from_file is not None: - src = gr.file_source(gr.sizeof_gr_complex, options.from_file) - if options.verbose: - print "Reading samples from file", options.from_file - else: - src = usrp.source_c() - if options.rx_subdev_spec is None: - options.rx_subdev_spec = usrp.pick_rx_subdevice(src) - 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.5125e6+options.calibration) - if options.verbose: - print "Using", subdev.name(), " for receiving." - print "Tuned USRP to", 930.5125e6+options.calibration - - taps = gr.firdes.low_pass(1.0, - 1.0, - 1.0/128.0*0.4, - 1.0/128.0*0.1, - gr.firdes.WIN_HANN) - - if options.verbose: - print "Channel filter has", len(taps), "taps" - - bank = blks2.analysis_filterbank(128, taps) - self.connect(src, bank) - - if options.log and options.from_file == None: - src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') - self.connect(src, src_sink) - - for i in range(128): - if i < 64: - freq = 930.5e6+i*25e3 - else: - freq = 928.9e6+(i-64)*25e3 - - if (freq < 929.0e6 or freq > 932.0e6): - self.connect((bank, i), gr.null_sink(gr.sizeof_gr_complex)) - else: - self.connect((bank, i), pager.flex_demod(queue, freq, options.verbose, options.log)) - if options.log: - self.connect((bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat')) - -def main(): - parser = OptionParser(option_class=eng_option) - parser.add_option("-R", "--rx-subdev-spec", type="subdev", - help="select USRP Rx side A or B (default=first daughterboard found)") - parser.add_option("-c", "--calibration", type="eng_float", default=0.0, - help="set frequency offset to Hz", metavar="Hz") - parser.add_option("-g", "--gain", type="int", - help="set RF gain", metavar="dB") - parser.add_option("-F", "--from-file", default=None, - help="Read from file instead of USRP") - parser.add_option("-l", "--log", action="store_true", default=False, - help="log flowgraph to files (LOTS of data)") - parser.add_option("-v", "--verbose", action="store_true", default=False, - help="display debug output") - (options, args) = parser.parse_args() - - if options.verbose: - print options - - queue = gr.msg_queue() - tb = app_top_block(options, queue) - runner = pager.queue_runner(queue) - - try: - tb.run() - except KeyboardInterrupt: - 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 deleted file mode 100755 index 06c2488c..00000000 --- a/gr-pager/src/usrp_flex_band.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/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 - -class app_top_block(gr.top_block): - def __init__(self, options, queue): - gr.top_block.__init__(self, "usrp_flex_all") - self.subdev = None - - if options.from_file is not None: - self.src = gr.file_source(gr.sizeof_gr_complex, options.from_file) - if options.verbose: - print "Reading samples from file", options.from_file - else: - self.src = usrp.source_c() - if options.rx_subdev_spec is None: - options.rx_subdev_spec = usrp.pick_rx_subdevice(self.src) - self.subdev = usrp.selected_subdev(self.src, options.rx_subdev_spec) - self.src.set_mux(usrp.determine_rx_mux_value(self.src, options.rx_subdev_spec)) - self.src.set_decim_rate(64) - frequency = options.frequency+options.calibration - result = usrp.tune(self.src, 0, self.subdev, frequency) - if options.verbose: - print "Using", self.subdev.name(), " for receiving." - print "Tuned USRP to", frequency - - taps = gr.firdes.low_pass(1.0, - 1.0, - 1.0/40.0*0.4, - 1.0/40.0*0.1, - gr.firdes.WIN_HANN) - - if options.verbose: - print "Channel filter has", len(taps), "taps" - - bank = blks2.analysis_filterbank(40, taps) - self.connect(self.src, bank) - - if options.log and options.from_file == None: - src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') - self.connect(self.src, src_sink) - - for i in range(40): - if i < 20: - freq = options.frequency+i*25e3 - else: - freq = options.frequency-0.5e6+(i-20)*25e3 - - self.connect((bank, i), pager.flex_demod(queue, freq, options.verbose, options.log)) - if options.log: - self.connect((bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat')) - - -def main(): - parser = OptionParser(option_class=eng_option) - parser.add_option("-f", "--frequency", type="eng_float", default=929.5e6, - help="set receive center frequency to Hz", metavar="Hz") - parser.add_option("-R", "--rx-subdev-spec", type="subdev", - help="select USRP Rx side A or B (default=first daughterboard found)") - parser.add_option("-c", "--calibration", type="eng_float", default=0.0, - help="set frequency offset to Hz", metavar="Hz") - parser.add_option("-g", "--gain", type="int", - help="set RF gain", metavar="dB") - parser.add_option("-F", "--from-file", default=None, - help="Read from file instead of USRP") - parser.add_option("-l", "--log", action="store_true", default=False, - help="log flowgraph to files (LOTS of data)") - parser.add_option("-v", "--verbose", action="store_true", default=False, - help="display debug output") - (options, args) = parser.parse_args() - - if options.verbose: - print options - - queue = gr.msg_queue() - tb = app_top_block(options, queue) - runner = pager.queue_runner(queue) - - try: - tb.run() - except KeyboardInterrupt: - pass - - runner.end() - - -if __name__ == "__main__": - main()