aboutsummaryrefslogtreecommitdiffstats
path: root/op25/gr-op25_repeater/apps/tx/unpack.py
blob: 0a8f0ad8230662b9cec4e041dd1a98a782e8b4b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
from gnuradio import gr, audio, eng_notation, blocks
from gnuradio.eng_option import eng_option
from optparse import OptionParser

class app_top_block(gr.top_block):
    def __init__(self, options):
        gr.top_block.__init__(self)

        IN = blocks.file_source(gr.sizeof_char, options.input_file)
        bits_per_symbol = 2
        UNPACK = blocks.packed_to_unpacked_bb(bits_per_symbol, gr.GR_MSB_FIRST)
        OUT = blocks.file_sink(gr.sizeof_char, options.output)

        self.connect(IN, UNPACK, OUT)

def main():
    parser = OptionParser(option_class=eng_option)
    parser.add_option("-i", "--input-file", type="string", default="in.dat", help="specify the input file")
    parser.add_option("-o", "--output", type="string", default="out.dat", help="specify the output file")

    (options, args) = parser.parse_args()
 
    tb = app_top_block(options)
    try:
        tb.run()
    except KeyboardInterrupt:
        tb.stop()

if __name__ == "__main__":
    main()