Merge pull request #51 from sundw2014/master

add -b option for gps-sdr-sim-uhd.py
This commit is contained in:
OSQZSS 2016-11-06 08:44:49 +09:00 committed by GitHub
commit b1a38572c9

View File

@ -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_center_freq(options.frequency, 0)
self.uhd_usrp_sink.set_gain(options.gain, 0) self.uhd_usrp_sink.set_gain(options.gain, 0)
# a file source for the file generated by the gps-sdr-sim if options.bits == 16:
self.blocks_file_source = blocks.file_source(gr.sizeof_char*1, options.filename, True) # 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 # convert from interleaved short to complex values
self.blocks_char_to_short = blocks.char_to_short(1) self.blocks_interleaved_short_to_complex = blocks.interleaved_short_to_complex(False, False)
# convert from interleaved short to complex values # establish the connections
self.blocks_interleaved_short_to_complex = blocks.interleaved_short_to_complex(False, False) 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)) self.connect((self.blocks_interleaved_short_to_complex, 0), (self.uhd_usrp_sink, 0))
def get_options(): def get_options():
@ -57,6 +69,8 @@ def get_options():
help="set sample rate [default=2500000]") help="set sample rate [default=2500000]")
parser.add_option("-t", "--filename", type="string", default="gpssim.bin", parser.add_option("-t", "--filename", type="string", default="gpssim.bin",
help="set output file name [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() (options, args) = parser.parse_args()
if len(args) != 0: if len(args) != 0: