From d5acc9af5d826954377b33531ec41f09d44b3ee6 Mon Sep 17 00:00:00 2001 From: sundw Date: Sat, 5 Nov 2016 19:23:48 +0800 Subject: [PATCH] add -b option for gps-sdr-sim-uhd.py --- gps-sdr-sim-uhd.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/gps-sdr-sim-uhd.py b/gps-sdr-sim-uhd.py index 06da2ce..47bfc78 100755 --- a/gps-sdr-sim-uhd.py +++ b/gps-sdr-sim-uhd.py @@ -31,18 +31,30 @@ class top_block(gr.top_block): self.uhd_usrp_sink.set_center_freq(options.frequency, 0) self.uhd_usrp_sink.set_gain(options.gain, 0) - # a file source for the file generated by the gps-sdr-sim - self.blocks_file_source = blocks.file_source(gr.sizeof_char*1, options.filename, True) + if options.bits == 16: + # a file source for the file generated by the gps-sdr-sim + self.blocks_file_source = blocks.file_source(gr.sizeof_short*1, options.filename, True) - # convert from signed bytes to short - self.blocks_char_to_short = blocks.char_to_short(1) + # convert from interleaved short to complex values + self.blocks_interleaved_short_to_complex = blocks.interleaved_short_to_complex(False, False) - # convert from interleaved short to complex values - self.blocks_interleaved_short_to_complex = blocks.interleaved_short_to_complex(False, False) + # establish the connections + self.connect((self.blocks_file_source, 0), (self.blocks_interleaved_short_to_complex, 0)) + + else: + # a file source for the file generated by the gps-sdr-sim + self.blocks_file_source = blocks.file_source(gr.sizeof_char*1, options.filename, True) + + # convert from signed bytes to short + self.blocks_char_to_short = blocks.char_to_short(1) + + # convert from interleaved short to complex values + self.blocks_interleaved_short_to_complex = blocks.interleaved_short_to_complex(False, False) + + # establish the connections + self.connect((self.blocks_file_source, 0), (self.blocks_char_to_short, 0)) + self.connect((self.blocks_char_to_short, 0), (self.blocks_interleaved_short_to_complex, 0)) - # establish the connections - self.connect((self.blocks_file_source, 0), (self.blocks_char_to_short, 0)) - self.connect((self.blocks_char_to_short, 0), (self.blocks_interleaved_short_to_complex, 0)) self.connect((self.blocks_interleaved_short_to_complex, 0), (self.uhd_usrp_sink, 0)) def get_options(): @@ -57,6 +69,8 @@ def get_options(): help="set sample rate [default=2500000]") parser.add_option("-t", "--filename", type="string", default="gpssim.bin", help="set output file name [default=gpssim.bin]") + parser.add_option("-b", "--bits", type="eng_float", default=16, + help="set size of every sample [default=16]") (options, args) = parser.parse_args() if len(args) != 0: