From 689699fb8a26486fedb2838b8a3b468372364903 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 2 Apr 2012 19:19:03 -0400 Subject: build: removed .py extensions from uhd and shd installed Python programs. --- gr-pager/apps/CMakeLists.txt | 6 +- gr-pager/apps/usrp_flex | 161 +++++++++++++++++++++++++++++++++++++++ gr-pager/apps/usrp_flex.py | 161 --------------------------------------- gr-pager/apps/usrp_flex_all | 164 ++++++++++++++++++++++++++++++++++++++++ gr-pager/apps/usrp_flex_all.py | 164 ---------------------------------------- gr-pager/apps/usrp_flex_band | 142 ++++++++++++++++++++++++++++++++++ gr-pager/apps/usrp_flex_band.py | 142 ---------------------------------- 7 files changed, 470 insertions(+), 470 deletions(-) create mode 100755 gr-pager/apps/usrp_flex delete mode 100755 gr-pager/apps/usrp_flex.py create mode 100755 gr-pager/apps/usrp_flex_all delete mode 100755 gr-pager/apps/usrp_flex_all.py create mode 100755 gr-pager/apps/usrp_flex_band delete mode 100755 gr-pager/apps/usrp_flex_band.py (limited to 'gr-pager/apps') diff --git a/gr-pager/apps/CMakeLists.txt b/gr-pager/apps/CMakeLists.txt index 1965c6e66..5fa926031 100644 --- a/gr-pager/apps/CMakeLists.txt +++ b/gr-pager/apps/CMakeLists.txt @@ -21,9 +21,9 @@ include(GrPython) GR_PYTHON_INSTALL( PROGRAMS - usrp_flex.py - usrp_flex_all.py - usrp_flex_band.py + usrp_flex + usrp_flex_all + usrp_flex_band DESTINATION ${GR_RUNTIME_DIR} COMPONENT "pager_python" ) diff --git a/gr-pager/apps/usrp_flex b/gr-pager/apps/usrp_flex new file mode 100755 index 000000000..7d0d66a95 --- /dev/null +++ b/gr-pager/apps/usrp_flex @@ -0,0 +1,161 @@ +#!/usr/bin/env python +# +# Copyright 2006,2007,2009,2011 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, uhd, optfir, eng_notation, pager +from gnuradio.eng_option import eng_option +from optparse import OptionParser +import time, os, sys + +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 + self.u = uhd.usrp_source(device_addr=options.address, stream_args=uhd.stream_args('fc32')) + + # Grab 250 KHz of spectrum + # (A UHD facility to get sample rate range and granularity would be useful) + self.u.set_samp_rate(250e3) + rate = self.u.get_samp_rate() + if rate != 250e3: + print "Unable to set required sample rate of 250 Ksps (got %f)" % rate + sys.exit(1) + + # Tune daughterboard + r = self.u.set_center_freq(options.freq+options.calibration, 0) + if not r: + frange = self.u.get_freq_range() + sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \ + (freq, frange.start(), frange.stop())) + sys.exit(1) + + # if no gain was specified, use the mid-point in dB + if options.rx_gain is None: + grange = self.u.get_gain_range() + options.rx_gain = float(grange.start()+grange.stop())/2.0 + print "\nNo gain specified." + print "Setting gain to %f (from [%f, %f])" % \ + (options.rx_gain, grange.start(), grange.stop()) + + self.u.set_gain(options.rx_gain, 0) + + else: + # Use supplied file as source of samples + self.u = 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.u, 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.freq, options.verbose, options.log) + + self.connect(self.u, 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 get_options(): + parser = OptionParser(option_class=eng_option) + + parser.add_option('-f', '--freq', type="eng_float", default=None, + help="Set receive frequency to FREQ [default=%default]", + metavar="FREQ") + parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", + help="Address of UHD device, [default=%default]") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("", "--rx-gain", type="eng_float", default=None, + help="set receive gain in dB (default is midpoint)") + parser.add_option("-c", "--calibration", type="eng_float", default=0.0, + help="set frequency offset to Hz", metavar="Hz") + parser.add_option("-v", "--verbose", action="store_true", default=False) + parser.add_option("-l", "--log", action="store_true", default=False, + help="log flowgraph to files (LOTS of data)") + 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: + print "Run 'usrp_flex.py -h' for options." + sys.exit(1) + + if (options.freq is None): + sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") + sys.exit(1) + + return (options, args) + +if __name__ == "__main__": + + (options, args) = get_options() + + # 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() + diff --git a/gr-pager/apps/usrp_flex.py b/gr-pager/apps/usrp_flex.py deleted file mode 100755 index 7d0d66a95..000000000 --- a/gr-pager/apps/usrp_flex.py +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007,2009,2011 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, uhd, optfir, eng_notation, pager -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import time, os, sys - -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 - self.u = uhd.usrp_source(device_addr=options.address, stream_args=uhd.stream_args('fc32')) - - # Grab 250 KHz of spectrum - # (A UHD facility to get sample rate range and granularity would be useful) - self.u.set_samp_rate(250e3) - rate = self.u.get_samp_rate() - if rate != 250e3: - print "Unable to set required sample rate of 250 Ksps (got %f)" % rate - sys.exit(1) - - # Tune daughterboard - r = self.u.set_center_freq(options.freq+options.calibration, 0) - if not r: - frange = self.u.get_freq_range() - sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \ - (freq, frange.start(), frange.stop())) - sys.exit(1) - - # if no gain was specified, use the mid-point in dB - if options.rx_gain is None: - grange = self.u.get_gain_range() - options.rx_gain = float(grange.start()+grange.stop())/2.0 - print "\nNo gain specified." - print "Setting gain to %f (from [%f, %f])" % \ - (options.rx_gain, grange.start(), grange.stop()) - - self.u.set_gain(options.rx_gain, 0) - - else: - # Use supplied file as source of samples - self.u = 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.u, 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.freq, options.verbose, options.log) - - self.connect(self.u, 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 get_options(): - parser = OptionParser(option_class=eng_option) - - parser.add_option('-f', '--freq', type="eng_float", default=None, - help="Set receive frequency to FREQ [default=%default]", - metavar="FREQ") - parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", - help="Address of UHD device, [default=%default]") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("", "--rx-gain", type="eng_float", default=None, - help="set receive gain in dB (default is midpoint)") - parser.add_option("-c", "--calibration", type="eng_float", default=0.0, - help="set frequency offset to Hz", metavar="Hz") - parser.add_option("-v", "--verbose", action="store_true", default=False) - parser.add_option("-l", "--log", action="store_true", default=False, - help="log flowgraph to files (LOTS of data)") - 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: - print "Run 'usrp_flex.py -h' for options." - sys.exit(1) - - if (options.freq is None): - sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") - sys.exit(1) - - return (options, args) - -if __name__ == "__main__": - - (options, args) = get_options() - - # 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() - diff --git a/gr-pager/apps/usrp_flex_all b/gr-pager/apps/usrp_flex_all new file mode 100755 index 000000000..36bd90034 --- /dev/null +++ b/gr-pager/apps/usrp_flex_all @@ -0,0 +1,164 @@ +#!/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, uhd, optfir, eng_notation, blks2, pager +from gnuradio.eng_option import eng_option +from optparse import OptionParser +from string import split, join, printable +import sys + +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: + self.u = gr.file_source(gr.sizeof_gr_complex, options.from_file) + self.nchan = options.nchan + if options.verbose: + print "Reading samples from file", options.from_file + print "User specified file contains", options.nchan, "25 KHz channels." + + else: + # Set up USRP source + self.u = uhd.usrp_source(device_addr=options.address, stream_args=uhd.stream_args('fc32')) + + # Tune daughterboard + r = self.u.set_center_freq(options.freq+options.calibration, 0) + if not r: + frange = self.u.get_freq_range() + sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \ + (freq, frange.start(), frange.stop())) + sys.exit(1) + + if options.verbose: + print "Tuned to center frequency", (options.freq+options.calibration)/1e6, "MHz" + + # if no gain was specified, use the mid-point in dB + if options.rx_gain is None: + grange = self.u.get_gain_range() + options.rx_gain = float(grange.start()+grange.stop())/2.0 + print "\nNo gain specified." + print "Setting gain to %f (from [%f, %f])" % \ + (options.rx_gain, grange.start(), grange.stop()) + + self.u.set_gain(options.rx_gain, 0) + + # Grab >=3 MHz of spectrum, evenly divisible by 25 KHz channels + # (A UHD facility to get sample rate range and granularity would be useful) + + self.u.set_samp_rate(3.125e6) # Works if USRP is 100 Msps and can decimate by 32 + rate = self.u.get_samp_rate() + + if rate != 3.125e6: + self.u.set_samp_rate(3.2e6) # Works if USRP is 64 Msps and can decimate by 20 + rate = self.u.get_samp_rate() + if (rate != 3.2e6): + print "Unable to set required sample rate for >= 3MHz of 25 KHz channels." + sys.exit(1) + + self.nchan = int(rate/25e3) + if options.verbose: + print "\nReceiving", rate/1e6, "MHz of bandwidth containing", self.nchan, "baseband channels." + + taps = gr.firdes.low_pass(1.0, + 1.0, + 1.0/self.nchan*0.4, + 1.0/self.nchan*0.1, + gr.firdes.WIN_HANN) + + if options.verbose: + print "Channel filter has", len(taps), "taps" + + self.bank = blks2.analysis_filterbank(self.nchan, taps) + self.connect(self.u, self.bank) + + if options.log and options.from_file == None: + src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') + self.connect(self.u, src_sink) + + mid_chan = int(self.nchan/2) + for i in range(self.nchan): + if i < mid_chan: + freq = 930.5e6+i*25e3 + else: + freq = 930.5e6-(self.nchan-i)*25e3 + + if (freq < 929.0e6 or freq > 932.0e6): + self.connect((self.bank, i), gr.null_sink(gr.sizeof_gr_complex)) + else: + self.connect((self.bank, i), pager.flex_demod(queue, freq, options.verbose, options.log)) + if options.log: + self.connect((self.bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat')) + + +def get_options(): + parser = OptionParser(option_class=eng_option) + + parser.add_option('-f', '--freq', type="eng_float", default=929.5125e6, + help="Set receive frequency to FREQ [default=%default]", + metavar="FREQ") + parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", + help="Address of UHD device, [default=%default]") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("", "--rx-gain", type="eng_float", default=None, + help="set receive gain in dB (default is midpoint)") + parser.add_option("-c", "--calibration", type="eng_float", default=0.0, + help="set frequency offset to Hz", metavar="Hz") + parser.add_option("-v", "--verbose", action="store_true", default=False) + parser.add_option("-l", "--log", action="store_true", default=False, + help="log flowgraph to files (LOTS of data)") + parser.add_option("-F", "--from-file", default=None, + help="read samples from file instead of USRP") + parser.add_option("", "--nchan", type="int", default=None, + help="set to number of channels in capture file", metavar="nchan") + + (options, args) = parser.parse_args() + + if len(args) > 0: + print "Run 'usrp_flex_all.py -h' for options." + sys.exit(1) + + if options.nchan is None and options.from_file is not None: + print "You must specify the number of baseband channels with --nchan when reading from a file" + sys.exit(1) + + return (options, args) + + +def main(): + + (options, args) = get_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_all.py b/gr-pager/apps/usrp_flex_all.py deleted file mode 100755 index 36bd90034..000000000 --- a/gr-pager/apps/usrp_flex_all.py +++ /dev/null @@ -1,164 +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, uhd, optfir, eng_notation, blks2, pager -from gnuradio.eng_option import eng_option -from optparse import OptionParser -from string import split, join, printable -import sys - -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: - self.u = gr.file_source(gr.sizeof_gr_complex, options.from_file) - self.nchan = options.nchan - if options.verbose: - print "Reading samples from file", options.from_file - print "User specified file contains", options.nchan, "25 KHz channels." - - else: - # Set up USRP source - self.u = uhd.usrp_source(device_addr=options.address, stream_args=uhd.stream_args('fc32')) - - # Tune daughterboard - r = self.u.set_center_freq(options.freq+options.calibration, 0) - if not r: - frange = self.u.get_freq_range() - sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \ - (freq, frange.start(), frange.stop())) - sys.exit(1) - - if options.verbose: - print "Tuned to center frequency", (options.freq+options.calibration)/1e6, "MHz" - - # if no gain was specified, use the mid-point in dB - if options.rx_gain is None: - grange = self.u.get_gain_range() - options.rx_gain = float(grange.start()+grange.stop())/2.0 - print "\nNo gain specified." - print "Setting gain to %f (from [%f, %f])" % \ - (options.rx_gain, grange.start(), grange.stop()) - - self.u.set_gain(options.rx_gain, 0) - - # Grab >=3 MHz of spectrum, evenly divisible by 25 KHz channels - # (A UHD facility to get sample rate range and granularity would be useful) - - self.u.set_samp_rate(3.125e6) # Works if USRP is 100 Msps and can decimate by 32 - rate = self.u.get_samp_rate() - - if rate != 3.125e6: - self.u.set_samp_rate(3.2e6) # Works if USRP is 64 Msps and can decimate by 20 - rate = self.u.get_samp_rate() - if (rate != 3.2e6): - print "Unable to set required sample rate for >= 3MHz of 25 KHz channels." - sys.exit(1) - - self.nchan = int(rate/25e3) - if options.verbose: - print "\nReceiving", rate/1e6, "MHz of bandwidth containing", self.nchan, "baseband channels." - - taps = gr.firdes.low_pass(1.0, - 1.0, - 1.0/self.nchan*0.4, - 1.0/self.nchan*0.1, - gr.firdes.WIN_HANN) - - if options.verbose: - print "Channel filter has", len(taps), "taps" - - self.bank = blks2.analysis_filterbank(self.nchan, taps) - self.connect(self.u, self.bank) - - if options.log and options.from_file == None: - src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') - self.connect(self.u, src_sink) - - mid_chan = int(self.nchan/2) - for i in range(self.nchan): - if i < mid_chan: - freq = 930.5e6+i*25e3 - else: - freq = 930.5e6-(self.nchan-i)*25e3 - - if (freq < 929.0e6 or freq > 932.0e6): - self.connect((self.bank, i), gr.null_sink(gr.sizeof_gr_complex)) - else: - self.connect((self.bank, i), pager.flex_demod(queue, freq, options.verbose, options.log)) - if options.log: - self.connect((self.bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat')) - - -def get_options(): - parser = OptionParser(option_class=eng_option) - - parser.add_option('-f', '--freq', type="eng_float", default=929.5125e6, - help="Set receive frequency to FREQ [default=%default]", - metavar="FREQ") - parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", - help="Address of UHD device, [default=%default]") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("", "--rx-gain", type="eng_float", default=None, - help="set receive gain in dB (default is midpoint)") - parser.add_option("-c", "--calibration", type="eng_float", default=0.0, - help="set frequency offset to Hz", metavar="Hz") - parser.add_option("-v", "--verbose", action="store_true", default=False) - parser.add_option("-l", "--log", action="store_true", default=False, - help="log flowgraph to files (LOTS of data)") - parser.add_option("-F", "--from-file", default=None, - help="read samples from file instead of USRP") - parser.add_option("", "--nchan", type="int", default=None, - help="set to number of channels in capture file", metavar="nchan") - - (options, args) = parser.parse_args() - - if len(args) > 0: - print "Run 'usrp_flex_all.py -h' for options." - sys.exit(1) - - if options.nchan is None and options.from_file is not None: - print "You must specify the number of baseband channels with --nchan when reading from a file" - sys.exit(1) - - return (options, args) - - -def main(): - - (options, args) = get_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 b/gr-pager/apps/usrp_flex_band new file mode 100755 index 000000000..63fb93fa1 --- /dev/null +++ b/gr-pager/apps/usrp_flex_band @@ -0,0 +1,142 @@ +#!/usr/bin/env python +# +# Copyright 2006,2007,2009,2011 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, uhd, optfir, eng_notation, blks2, pager +from gnuradio.eng_option import eng_option +from optparse import OptionParser +import sys + +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: + self.u = gr.file_source(gr.sizeof_gr_complex, options.from_file) + if options.verbose: + print "Reading samples from file", options.from_file + else: + # Set up USRP source + self.u = uhd.usrp_source(device_addr=options.address, stream_args=uhd.stream_args('fc32')) + + # Grab 1 MHz of spectrum + # (A UHD facility to get sample rate range and granularity would be useful) + self.u.set_samp_rate(1e6) + rate = self.u.get_samp_rate() + if rate != 1e6: + print "Unable to set required sample rate of 1 Msps (got %f)" % rate + sys.exit(1) + + # Tune daughterboard + r = self.u.set_center_freq(options.freq+options.calibration, 0) + if not r: + frange = self.u.get_freq_range() + sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \ + (freq, frange.start(), frange.stop())) + sys.exit(1) + + # if no gain was specified, use the mid-point in dB + if options.rx_gain is None: + grange = self.u.get_gain_range() + options.rx_gain = float(grange.start()+grange.stop())/2.0 + print "\nNo gain specified." + print "Setting gain to %f (from [%f, %f])" % \ + (options.rx_gain, grange.start(), grange.stop()) + + self.u.set_gain(options.rx_gain, 0) + + + 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.u, bank) + + if options.log and options.from_file == None: + src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') + self.connect(self.u, src_sink) + + for i in range(40): + if i < 20: + freq = options.freq+i*25e3 + else: + freq = options.freq-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 get_options(): + parser = OptionParser(option_class=eng_option) + + parser.add_option('-f', '--freq', type="eng_float", default=None, + help="Set receive frequency to FREQ [default=%default]", + metavar="FREQ") + parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", + help="Address of UHD device, [default=%default]") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("", "--rx-gain", type="eng_float", default=None, + help="set receive gain in dB (default is midpoint)") + parser.add_option("-c", "--calibration", type="eng_float", default=0.0, + help="set frequency offset to Hz", metavar="Hz") + parser.add_option("-v", "--verbose", action="store_true", default=False) + parser.add_option("-l", "--log", action="store_true", default=False, + help="log flowgraph to files (LOTS of data)") + 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: + print "Run 'usrp_flex_band.py -h' for options." + sys.exit(1) + + if (options.freq is None): + sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") + sys.exit(1) + + return (options, args) + + +if __name__ == "__main__": + + (options, args) = get_options() + + queue = gr.msg_queue() + tb = app_top_block(options, queue) + runner = pager.queue_runner(queue) + + try: + tb.run() + except KeyboardInterrupt: + pass + + runner.end() + + diff --git a/gr-pager/apps/usrp_flex_band.py b/gr-pager/apps/usrp_flex_band.py deleted file mode 100755 index 63fb93fa1..000000000 --- a/gr-pager/apps/usrp_flex_band.py +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007,2009,2011 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, uhd, optfir, eng_notation, blks2, pager -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import sys - -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: - self.u = gr.file_source(gr.sizeof_gr_complex, options.from_file) - if options.verbose: - print "Reading samples from file", options.from_file - else: - # Set up USRP source - self.u = uhd.usrp_source(device_addr=options.address, stream_args=uhd.stream_args('fc32')) - - # Grab 1 MHz of spectrum - # (A UHD facility to get sample rate range and granularity would be useful) - self.u.set_samp_rate(1e6) - rate = self.u.get_samp_rate() - if rate != 1e6: - print "Unable to set required sample rate of 1 Msps (got %f)" % rate - sys.exit(1) - - # Tune daughterboard - r = self.u.set_center_freq(options.freq+options.calibration, 0) - if not r: - frange = self.u.get_freq_range() - sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \ - (freq, frange.start(), frange.stop())) - sys.exit(1) - - # if no gain was specified, use the mid-point in dB - if options.rx_gain is None: - grange = self.u.get_gain_range() - options.rx_gain = float(grange.start()+grange.stop())/2.0 - print "\nNo gain specified." - print "Setting gain to %f (from [%f, %f])" % \ - (options.rx_gain, grange.start(), grange.stop()) - - self.u.set_gain(options.rx_gain, 0) - - - 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.u, bank) - - if options.log and options.from_file == None: - src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') - self.connect(self.u, src_sink) - - for i in range(40): - if i < 20: - freq = options.freq+i*25e3 - else: - freq = options.freq-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 get_options(): - parser = OptionParser(option_class=eng_option) - - parser.add_option('-f', '--freq', type="eng_float", default=None, - help="Set receive frequency to FREQ [default=%default]", - metavar="FREQ") - parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", - help="Address of UHD device, [default=%default]") - parser.add_option("-A", "--antenna", type="string", default=None, - help="select Rx Antenna where appropriate") - parser.add_option("", "--rx-gain", type="eng_float", default=None, - help="set receive gain in dB (default is midpoint)") - parser.add_option("-c", "--calibration", type="eng_float", default=0.0, - help="set frequency offset to Hz", metavar="Hz") - parser.add_option("-v", "--verbose", action="store_true", default=False) - parser.add_option("-l", "--log", action="store_true", default=False, - help="log flowgraph to files (LOTS of data)") - 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: - print "Run 'usrp_flex_band.py -h' for options." - sys.exit(1) - - if (options.freq is None): - sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") - sys.exit(1) - - return (options, args) - - -if __name__ == "__main__": - - (options, args) = get_options() - - queue = gr.msg_queue() - tb = app_top_block(options, queue) - runner = pager.queue_runner(queue) - - try: - tb.run() - except KeyboardInterrupt: - pass - - runner.end() - - -- cgit