3 # Copyright 2007 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
23 from gnuradio import gr
24 from gnuradio.radar_mono import radar
25 from gnuradio import eng_notation
26 from gnuradio.eng_option import eng_option
27 from optparse import OptionParser
30 n2s = eng_notation.num_to_str
33 parser = OptionParser(option_class=eng_option)
34 parser.add_option("-f", "--frequency", type="eng_float", default=0.0,
35 help="set transmitter center frequency to FREQ in Hz, default is %default", metavar="FREQ")
36 parser.add_option("-w", "--chirp-width", type="eng_float", default=32e6,
37 help="set LFM chirp bandwidth in Hz, default is %default", metavar="FREQ")
38 parser.add_option("-a", "--amplitude", type="eng_float", default=15,
39 help="set waveform amplitude in % full scale, default is %default,")
40 parser.add_option("", "--ton", type="eng_float", default=5e-6,
41 help="set pulse on period in seconds, default is %default,")
42 parser.add_option("", "--tsw", type="eng_float", default=406.25e-9,
43 help="set transmitter switching period in seconds, default is %default,")
44 parser.add_option("", "--tlook", type="eng_float", default=5e-6,
45 help="set receiver look time in seconds, default is %default,")
46 parser.add_option("", "--prf", type="eng_float", default=10e3,
47 help="set pulse repetition frequency in Hz, default is %default,")
48 parser.add_option("-v", "--verbose", action="store_true", default=False,
49 help="enable verbose output, default is disabled")
50 parser.add_option("-D", "--debug", action="store_true", default=False,
51 help="enable debugging output, default is disabled")
54 #parser.add_option("-g", "--gain", type="eng_float", default=None,
55 # help="set gain in dB (default is midpoint)")
56 #parser.add_option("-l", "--loopback", action="store_true", default=False,
57 # help="enable digital loopback, default is disabled")
58 #parser.add_option("-F", "--filename", default=None,
59 # help="log received echos to file")
61 (options, args) = parser.parse_args()
68 if options.filename == None:
69 print "Must supply filename for logging received data."
73 print "Logging echo records to file: ", options.filename
77 s = radar(msgq=msgq,verbose=options.verbose,debug=options.debug)
79 s.set_ton(options.ton)
80 s.set_tsw(options.tsw)
81 s.set_tlook(options.tlook)
82 s.set_prf(options.prf)
83 s.set_amplitude(options.amplitude)
84 s.set_freq(options.frequency, options.chirp_width)
89 f = open(options.filename, "wb")
90 print "Enter CTRL-C to stop."
93 msg = msgq.delete_head()
98 print "Received echo vector of length", len(rec)
101 except KeyboardInterrupt:
105 raw_input("Press enter to stop transmitting.")
108 if __name__ == "__main__":