Fix distcheck error, trunk passes distcheck.
[debian/gnuradio] / usrp2 / host / apps / gen_sine.py
1 #!/usr/bin/env python
2 #
3 # Copyright 2007 Free Software Foundation, Inc.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #
18
19 from gnuradio import gr, eng_notation
20 from gnuradio.eng_option import eng_option
21 from optparse import OptionParser
22 import sys
23
24 master_clock = 100e6
25
26 class my_top_block(gr.top_block):
27
28     def __init__(self):
29         gr.top_block.__init__(self)
30
31         parser = OptionParser(option_class=eng_option)
32         parser.add_option("-f", "--freq", type="eng_float", default=1e6,
33                           help="set waveform frequency to FREQ [default=%default]")
34         parser.add_option ("-a", "--amplitude", type="eng_float", default=16e3,
35                            help="set waveform amplitude to AMPLITUDE [default=%default]", metavar="AMPL")
36
37         parser.add_option("-i", "--interp", type="int", default=32,
38                           help="assume fgpa interpolation rate is INTERP [default=%default]")
39
40         (options, args) = parser.parse_args ()
41         if len(args) != 0:
42             parser.print_help()
43             raise SystemExit, 1
44
45         
46         src0 = gr.sig_source_c(master_clock/options.interp,
47                                gr.GR_SIN_WAVE,
48                                options.freq,
49                                options.amplitude)
50
51         
52         c2s = gr.complex_to_interleaved_short()
53
54         stdout_sink = gr.file_descriptor_sink(gr.sizeof_short, 1)
55
56         self.connect(src0, c2s, stdout_sink)
57
58         
59 if __name__ == '__main__':
60     try:
61         my_top_block().run()
62     except KeyboardInterrupt:
63         pass