LTE_fdd_dl_file_gen.py 1.32 KB
Newer Older
1 2 3
#!/usr/bin/env python

from gnuradio import gr
4
from gnuradio import blocks
5 6 7 8 9
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import LTE_fdd_dl_fg
import sys

10
class LTE_fdd_dl_file_gen(gr.top_block):
11 12 13 14

    def __init__(self):
        gr.top_block.__init__(self)

15
        usage = "usage: %prog [options] file"
16 17
        parser=OptionParser(option_class=eng_option, usage=usage)
        # Add options here
18 19
        parser.add_option("-d", "--data-type", type="string", default="int8",
                          help="Output file data type, default=%default, options=[int8, gr_complex]")
20
        (options, args) = parser.parse_args()
21
        if len(args) != 1:
22 23 24
            parser.print_help()
            sys.exit(1)

25 26 27 28 29 30 31 32
        if options.data_type == "gr_complex":
            size = gr.sizeof_gr_complex
        elif options.data_type == "int8":
            size = gr.sizeof_char
        else:
            print("Invalid data type using int8")
            size = gr.sizeof_char

33 34 35
        output_filename = args[0]

        # Build flow graph
36 37
        self.samp_buf = LTE_fdd_dl_fg.samp_buf(size)
        self.fsink = blocks.file_sink(size, output_filename)
38 39 40 41 42 43 44 45
        self.connect(self.samp_buf, self.fsink)

if __name__ == '__main__':
    tb = LTE_fdd_dl_file_gen()
    try:
        tb.run()
    except KeyboardInterrupt:
        pass