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("-T", "--tx-subdev-spec", type="subdev", default=None,
35 help="use transmitter board side A or B (default is first found)")
36 parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
37 help="use receiver board side A or B (default is first found)")
38 parser.add_option("-g", "--gain", type="eng_float", default=None,
39 help="set gain in dB (default is midpoint)")
40 parser.add_option("-f", "--frequency", type="eng_float", default=0.0,
41 help="set transmitter center frequency to FREQ in Hz, default is %default", metavar="FREQ")
42 parser.add_option("-w", "--chirp-width", type="eng_float", default=32e6,
43 help="set LFM chirp bandwidth in Hz, default is %default", metavar="FREQ")
44 parser.add_option("-a", "--amplitude", type="eng_float", default=15,
45 help="set waveform amplitude in % full scale, default is %default,")
46 parser.add_option("", "--ton", type="eng_float", default=5e-6,
47 help="set pulse on period in seconds, default is %default,")
48 parser.add_option("", "--tsw", type="eng_float", default=406.25e-9,
49 help="set transmitter switching period in seconds, default is %default,")
50 parser.add_option("", "--tlook", type="eng_float", default=5e-6,
51 help="set receiver look time in seconds, default is %default,")
52 parser.add_option("", "--prf", type="eng_float", default=10e3,
53 help="set pulse repetition frequency in Hz, default is %default,")
54 parser.add_option("-v", "--verbose", action="store_true", default=False,
55 help="enable verbose output, default is disabled")
56 parser.add_option("-D", "--debug", action="store_true", default=False,
57 help="enable debugging output, default is disabled")
60 #parser.add_option("-l", "--loopback", action="store_true", default=False,
61 # help="enable digital loopback, default is disabled")
62 #parser.add_option("-F", "--filename", default=None,
63 # help="log received echos to file")
65 (options, args) = parser.parse_args()
72 if options.filename == None:
73 print "Must supply filename for logging received data."
77 print "Logging echo records to file: ", options.filename
81 s = radar(msgq=msgq, tx_subdev_spec=options.tx_subdev_spec,
82 rx_subdev_spec=options.rx_subdev_spec,gain=options.gain,
83 verbose=options.verbose, debug=options.debug)
85 s.set_ton(options.ton)
86 s.set_tsw(options.tsw)
87 s.set_tlook(options.tlook)
88 s.set_prf(options.prf)
89 s.set_amplitude(options.amplitude)
90 s.set_freq(options.frequency, options.chirp_width)
94 #f = open(options.filename, "wb")
95 print "Enter CTRL-C to stop."
98 if not msgq.empty_p():
99 msg = msgq.delete_head()
102 echo = msg.to_string()
104 print "Received echo vector of length", len(echo)
107 except KeyboardInterrupt:
112 if __name__ == "__main__":