def __init__(self, options): gr.top_block.__init__(self) self._src = gr.sig_source_c(options.samp_rate, gr.GR_SIN_WAVE, 200, 1) self._snk = shd.smini_sink(device_addr=options.address, io_type=shd.io_type.COMPLEX_FLOAT32, num_channels=1) # Set receiver sample rate self._snk.set_samp_rate(options.samp_rate) # Set receive daughterboard gain if options.gain is None: g = self._snk.get_gain_range() options.gain = float(g.start()+g.stop())/2 print "Using mid-point gain of", \ options.gain, "(", g.start(), "-", g.stop(), ")" self._snk.set_gain(options.gain) # Set the antenna if(options.antenna): self._snk.set_antenna(options.antenna, 0) # Set frequency (tune request takes lo_offset) if(options.lo_offset is not None): treq = shd.tune_request(options.freq, options.lo_offset) else: treq = shd.tune_request(options.freq) tr = self._snk.set_center_freq(treq) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 # Create head block if needed and wire it up self.connect(self._src, self._snk) input_rate = self._snk.get_samp_rate() if options.verbose: print "Address:", options.address print "Rx gain:", options.gain print "Rx baseband frequency:", n2s(tr.actual_rf_freq) print "Rx DDC frequency:", n2s(tr.actual_dsp_freq) print "Rx Sample Rate:", n2s(input_rate)
def __init__(self, options): gr.top_block.__init__(self) self._src = gr.sig_source_c(options.samp_rate, gr.GR_SIN_WAVE, 200, 1) self._snk = shd.smini_sink(device_addr=options.address, io_type=shd.io_type.COMPLEX_FLOAT32, num_channels=1) # Set receiver sample rate self._snk.set_samp_rate(options.samp_rate) # Set receive daughterboard gain if options.gain is None: g = self._snk.get_gain_range() options.gain = float(g.start() + g.stop()) / 2 print "Using mid-point gain of", \ options.gain, "(", g.start(), "-", g.stop(), ")" self._snk.set_gain(options.gain) # Set the antenna if (options.antenna): self._snk.set_antenna(options.antenna, 0) # Set frequency (tune request takes lo_offset) if (options.lo_offset is not None): treq = shd.tune_request(options.freq, options.lo_offset) else: treq = shd.tune_request(options.freq) tr = self._snk.set_center_freq(treq) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 # Create head block if needed and wire it up self.connect(self._src, self._snk) input_rate = self._snk.get_samp_rate() if options.verbose: print "Address:", options.address print "Rx gain:", options.gain print "Rx baseband frequency:", n2s(tr.actual_rf_freq) print "Rx DDC frequency:", n2s(tr.actual_dsp_freq) print "Rx Sample Rate:", n2s(input_rate)
def __init__(self, options, filename): gr.top_block.__init__(self) # Create a SHD device source if options.output_shorts: self._src = shd.smini_source(device_addr=options.address, io_type=shd.io_type.COMPLEX_INT16, num_channels=1) self._sink = gr.file_sink(gr.sizeof_short * 2, filename) else: self._src = shd.smini_source(device_addr=options.address, io_type=shd.io_type.COMPLEX_FLOAT32, num_channels=1) self._sink = gr.file_sink(gr.sizeof_gr_complex, filename) # Set receiver sample rate self._src.set_samp_rate(options.samp_rate) # Set receive daughterboard gain if options.gain is None: g = self._src.get_gain_range() options.gain = float(g.start() + g.stop()) / 2 print "Using mid-point gain of", \ options.gain, "(", g.start(), "-", g.stop(), ")" self._src.set_gain(options.gain) # Set the antenna if (options.antenna): self._src.set_antenna(options.antenna, 0) # Set frequency (tune request takes lo_offset) if (options.lo_offset is not None): treq = shd.tune_request(options.freq, options.lo_offset) else: treq = shd.tune_request(options.freq) tr = self._src.set_center_freq(treq) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 # Create head block if needed and wire it up if options.nsamples is None: self.connect(self._src, self._sink) else: if options.output_shorts: self._head = gr.head(gr.sizeof_short * 2, int(options.nsamples)) else: self._head = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) self.connect(self._src, self._head, self._sink) input_rate = self._src.get_samp_rate() if options.verbose: print "Address:", options.address print "Rx gain:", options.gain print "Rx baseband frequency:", n2s(tr.actual_rf_freq) print "Rx DDC frequency:", n2s(tr.actual_dsp_freq) print "Rx Sample Rate:", n2s(input_rate) if options.nsamples is None: print "Receiving samples until Ctrl-C" else: print "Receving", n2s(options.nsamples), "samples" if options.output_shorts: print "Writing 16-bit complex shorts" else: print "Writing 32-bit complex floats" print "Output filename:", filename
def __init__(self, options, filename): gr.top_block.__init__(self) # Create a SHD device source if options.output_shorts: self._src = shd.smini_source(device_addr=options.address, io_type=shd.io_type.COMPLEX_INT16, num_channels=1) self._sink = gr.file_sink(gr.sizeof_short*2, filename) else: self._src = shd.smini_source(device_addr=options.address, io_type=shd.io_type.COMPLEX_FLOAT32, num_channels=1) self._sink = gr.file_sink(gr.sizeof_gr_complex, filename) # Set receiver sample rate self._src.set_samp_rate(options.samp_rate) # Set receive daughterboard gain if options.gain is None: g = self._src.get_gain_range() options.gain = float(g.start()+g.stop())/2 print "Using mid-point gain of", \ options.gain, "(", g.start(), "-", g.stop(), ")" self._src.set_gain(options.gain) # Set the antenna if(options.antenna): self._src.set_antenna(options.antenna, 0) # Set frequency (tune request takes lo_offset) if(options.lo_offset is not None): treq = shd.tune_request(options.freq, options.lo_offset) else: treq = shd.tune_request(options.freq) tr = self._src.set_center_freq(treq) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 # Create head block if needed and wire it up if options.nsamples is None: self.connect(self._src, self._sink) else: if options.output_shorts: self._head = gr.head(gr.sizeof_short*2, int(options.nsamples)) else: self._head = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) self.connect(self._src, self._head, self._sink) input_rate = self._src.get_samp_rate() if options.verbose: print "Address:", options.address print "Rx gain:", options.gain print "Rx baseband frequency:", n2s(tr.actual_rf_freq) print "Rx DDC frequency:", n2s(tr.actual_dsp_freq) print "Rx Sample Rate:", n2s(input_rate) if options.nsamples is None: print "Receiving samples until Ctrl-C" else: print "Receving", n2s(options.nsamples), "samples" if options.output_shorts: print "Writing 16-bit complex shorts" else: print "Writing 32-bit complex floats" print "Output filename:", filename