def __init__(self, usrp_offset): gr.flow_graph.__init__(self) print "decim = %d, gain = %d, offset = %.2f" % (decim, gain, usrp_offset) print "filter center %.2f, filter width %.2f" % (xcf, xtw) u = usrp.source_c(decim_rate=decim) s = usrp.pick_subdev(u, (usrp_dbid.DBS_RX,)) u.set_mux(usrp.determine_rx_mux_value(u, s)) subdev = usrp.selected_subdev(u, s) if subdev.dbid() != usrp_dbid.DBS_RX: raise Exception("dbs daughterboard not detected!") subdev.set_gain(gain) sps = u.adc_freq() / u.decim_rate() if sps < 2 * gsm_rate: raise Exception("sample rate too low") u.tune(0, subdev, c0 + usrp_offset) xt = gr.firdes.low_pass(1.0, sps, xcf, xtw, gr.firdes.WIN_HAMMING) xf = gr.fir_filter_ccf(1, xt) self.gs = gs = gssm.sink(sps) self.connect(u, xf, gs)
def setup_usrp(freq, gain): ######## set up usrp u = usrp.source_c(decim_rate=32) # 2M sampling freq rx_subdev_spec = usrp.pick_rx_subdevice(u) #print "u.db(0,0).dbid() = ", self.u.db(0,0).dbid() #print "u.db(1,0).dbid() = ", self.u.db(1,0).dbid() #print "rx_subdev_spec = ", options.rx_subdev_spec mux=usrp.determine_rx_mux_value(u, rx_subdev_spec) #print "mux = ", mux u.set_mux(mux) # determine the daughterboard subdevice we're using subdev = usrp.selected_subdev(u, rx_subdev_spec) #print "Using RX d'board %s" % (self.subdev.side_and_name(),) input_rate = u.adc_freq() / u.decim_rate() #print "ADC sampling @ ", eng_notation.num_to_str(self.u.adc_freq()) #print "USB sample rate %s" % (eng_notation.num_to_str(input_rate)) subdev.set_gain(gain) r = u.tune(0, subdev, freq) #print "freq range = [%s, %s]" % (eng_notation.num_to_str(self.subdev.freq_min()), eng_notation.num_to_str(self.subdev.freq_max())) if not r: sys.stderr.write('Failed to set frequency\n') raise SystemExit, 1 return u
class wfm_rx_graph(stdgui.gui_flow_graph): def__init__(self,frame,panel,vbox,argv): stdgui.gui_flow_graph.__init__(self,frame,panel,vbox,argv) IF_freq=parseargs(argv[1:]) adc_rate=64e6 decim=250 quad_rate=adc_rate/decim audo_decimation=9 audio_rate=quad_rate/audio_decimation src=usrp.source_c(0,decim) src.set_rx_freq(0,IF_freq) src.set_pga(0,20) guts=blks.wfm_rcv(self,quad_rate,audio_decimation) audio_sink=audio.sink(int(audio_rate)) self.connect(src,guts) self.connect(guts,(audio_sink,0)) if 1: pre_demod,fft_win1=\ fftsink.make_fft_sink_c(self,panel,"Pre-Demodulation", 512,quad_rate) self.connect(src,pre_demod) vbox.Add(fft_win1,1,wx.EXPAND)
def __init__(self): gr.top_block.__init__ (self) self.u = usrp.source_c(0, usrp_decim) print "USRP Serial: ", self.u.serial_number() usrp_rate = self.u.adc_rate() / usrp_decim # 256 kS/s rx_subdev_spec = usrp.pick_subdev(self.u, dblist) self.u.set_mux(usrp.determine_rx_mux_value(self.u, rx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, rx_subdev_spec) print "Using d'board", self.subdev.side_and_name() self.gain = self.subdev.gain_range()[1] self.subdev.set_gain(self.gain) r = usrp.tune(self.u, 0, self.subdev, freq) if r: print "Freq: ", freq/1e6, "MHz" else: print "Failed to set frequency, quitting!" sys.exit(1) chan_filter_coeffs = gr.firdes.low_pass( 1.0, # gain usrp_rate, # sampling rate 80e3, # passband cutoff 35e3, # transition width gr.firdes.WIN_HAMMING) self.chan_filter = gr.fir_filter_ccf(1, chan_filter_coeffs) print "# channel filter:", len(chan_filter_coeffs), "taps" self.file_sink = gr.file_sink(gr.sizeof_gr_complex*1, "/home/sdr/rds_samples.dat") self.connect(self.u, self.chan_filter, self.file_sink)
def __init__(self,subdev_spec=None,gain=None,length=1,alpha=1.0,msgq=None,loopback=False,verbose=False,debug=False): self._subdev_spec = subdev_spec self._gain = gain self._length = length self._alpha = alpha self._msgq = msgq self._loopback = loopback self._verbose = verbose self._debug = debug self._tb = gr.top_block() self._u = usrp.source_c(fpga_filename='usrp_sounder.rbf') if not self._loopback: if self._subdev_spec == None: self._subdev_spec = pick_subdevice(self._u) self._u.set_mux(usrp.determine_rx_mux_value(self._u, self._subdev_spec)) self._subdev = usrp.selected_subdev(self._u, self._subdev_spec) if self._verbose: print "Using", self._subdev.name(), "for sounder receiver." self.set_gain(self._gain) self._vblen = gr.sizeof_gr_complex*self._length if self._debug: print "Generating impulse vectors of length", self._length, "byte length", self._vblen self._s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self._length) if self._verbose: print "Using smoothing alpha of", self._alpha self._lpf = gr.single_pole_iir_filter_cc(self._alpha, self._length) self._sink = gr.message_sink(self._vblen, self._msgq, True) self._tb.connect(self._u, self._s2v, self._lpf, self._sink)
def __init__(self, options, args, queue): gr.top_block.__init__(self) self.options = options self.args = args self.u = usrp.source_c(which=0, decim_rate=self.options.decim) if self.options.rx_subdev_spec is None: self.options.rx_subdev_spec = pick_subdevice(self.u) self.u.set_mux(usrp.determine_rx_mux_value(self.u, self.options.rx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, self.options.rx_subdev_spec) if options.gain is None: # Select a gain in the middle of the range g = self.subdev.gain_range() options.gain = float(g[0]+g[1])/2 self.subdev.set_gain(options.gain) r = self.u.tune(0, self.subdev, options.freq) if_rate = self.u.adc_freq() / self.u.decim_rate() self.mode_s = ppm_demod(if_rate, options.thresh) pass_all = 0 if options.output_all: pass_all = 1 self.format = air.ms_fmt_log(pass_all, queue) self.connect(self.u, self.mode_s, self.format)
def _setup_usrp_source(self): self.rx_u = usrp.source_c(fusb_block_size=self._fusb_block_size, fusb_nblocks=self._fusb_nblocks) adc_rate = self.rx_u.adc_rate() self.rx_u.set_decim_rate(self._decim) # determine the daughterboard subdevice we're using if self._rx_subdev_spec is None: print 'not set rx subdev' self._rx_subdev_spec = usrp.pick_rx_subdevice(self.rx_u) print self._rx_subdev_spec self.rx_subdev = usrp.selected_subdev(self.rx_u, self._rx_subdev_spec) gains = self.rx_subdev.gain_range() self.rx_subdev.set_gain((gains[0] + gains[1]) / 2) self.rx_u.set_mux( usrp.determine_rx_mux_value(self.rx_u, self._rx_subdev_spec)) print 'subdev size %d' % self.rx_subdev.which() ok = self.rx_u.tune(0, self.rx_subdev, self._rx_freq) if not ok: print "Failed to set Rx frequency to %s" % ( eng_notation.num_to_str(self._rx_freq), ) raise ValueError self.rx_subdev.set_auto_tr(True)
def detect_usrp1(): for i in range(3): try: u = usrp.source_c(i) print "\033[1;31mUSRP found, serial:", u.serial_number(), "\033[1;m" a = usrp.selected_subdev(u, (0,0)) if(a.dbid()!=-1): print "\033[1;33mSide A, RX:", a.name(), "(dbid: 0x%04X)" % (a.dbid()), "\033[1;m" print "freq range: (", a.freq_min()/1e6, "MHz, ", a.freq_max()/1e6, "MHz )" print "gain rainge: (", a.gain_min(), "dB, ", a.gain_max(), "dB )" b = usrp.selected_subdev(u, (1,0)) if(b.dbid()!=-1): print "\033[1;33mSide B, RX:", b.name(), "(dbid: 0x%04X)" % (b.dbid()), "\033[1;m" print "freq range: (", b.freq_min()/1e6, "MHz, ", b.freq_max()/1e6, "MHz )" print "gain rainge: (", b.gain_min(), "dB, ", b.gain_max(), "dB )" u = usrp.sink_c(i) a = usrp.selected_subdev(u, (0,0)) if(a.dbid()!=-1): print "\033[1;33mSide A, TX:", a.name(), "(dbid: 0x%04X)" % (a.dbid()), "\033[1;m" print "freq range: (", a.freq_min()/1e6, "MHz, ", a.freq_max()/1e6, "MHz )" print "gain rainge: (", a.gain_min(), "dB, ", a.gain_max(), "dB )" b = usrp.selected_subdev(u, (1,0)) if(b.dbid()!=-1): print "\033[1;33mSide B, TX:", b.name(), "(dbid: 0x%04X)" % (b.dbid()), "\033[1;m" print "freq range: (", b.freq_min()/1e6, "MHz, ", b.freq_max()/1e6, "MHz )" print "gain rainge: (", b.gain_min(), "dB, ", b.gain_max(), "dB )" except: if(i==0): print "\033[1;31mno USRPs found" break
def __init__(self, usrp_offset): gr.top_block.__init__(self) u = usrp.source_c(decim_rate=decim) s = usrp.pick_subdev(u, (usrp_dbid.DBS_RX, )) u.set_mux(usrp.determine_rx_mux_value(u, s)) subdev = usrp.selected_subdev(u, s) if subdev.dbid() != usrp_dbid.DBS_RX: raise Exception('dbs daughterboard not detected!') subdev.set_gain(gain) sps = u.adc_freq() / u.decim_rate() if sps < 2 * gsm_rate: raise Exception('sample rate too low') u.tune(0, subdev, c0 + usrp_offset) xcf = 150e3 xtw = 50e3 xt = gr.firdes.low_pass(1.0, sps, xcf, xtw, gr.firdes.WIN_HAMMING) xf = gr.fir_filter_ccf(1, xt) g = gssm.sink(sps) self.connect(u, xf, g)
def __init__(self,subdev_spec=None,gain=None,length=1,alpha=1.0,msgq=None,loopback=False,verbose=False,debug=False): self._subdev_spec = subdev_spec self._gain = gain self._length = length self._alpha = alpha self._msgq = msgq self._loopback = loopback self._verbose = verbose self._debug = debug self._fg = gr.flow_graph() self._u = usrp.source_c(fpga_filename='usrp_sounder.rbf') if not self._loopback: if self._subdev_spec == None: self._subdev_spec = pick_subdevice(self._u) self._u.set_mux(usrp.determine_rx_mux_value(self._u, self._subdev_spec)) self._subdev = usrp.selected_subdev(self._u, self._subdev_spec) if self._verbose: print "Using", self._subdev.name(), "for sounder receiver." self.set_gain(self._gain) self._vblen = gr.sizeof_gr_complex*self._length if self._debug: print "Generating impulse vectors of length", self._length, "byte length", self._vblen self._s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self._length) if self._verbose: print "Using smoothing alpha of", self._alpha self._lpf = gr.single_pole_iir_filter_cc(self._alpha, self._length) self._sink = gr.message_sink(self._vblen, self._msgq, True) self._fg.connect(self._u, self._s2v, self._lpf, self._sink)
def _setup_usrp_source(self): self.rx_u = usrp.source_c (fusb_block_size=self._fusb_block_size, fusb_nblocks=self._fusb_nblocks) adc_rate = self.rx_u.adc_rate() self.rx_u.set_decim_rate(self._decim) # determine the daughterboard subdevice we're using if self._rx_subdev_spec is None: print 'not set rx subdev' self._rx_subdev_spec = usrp.pick_rx_subdevice(self.rx_u) print self._rx_subdev_spec self.rx_subdev = usrp.selected_subdev(self.rx_u, self._rx_subdev_spec) gains = self.rx_subdev.gain_range() self.rx_subdev.set_gain((gains[0]+gains[1])/2) self.rx_u.set_mux(usrp.determine_rx_mux_value(self.rx_u, self._rx_subdev_spec)) print 'subdev size %d' % self.rx_subdev.which() ok = self.rx_u.tune(0, self.rx_subdev, self._rx_freq) if not ok: print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(self._rx_freq),) raise ValueError self.rx_subdev.set_auto_tr(True)
def __init__(self, N, fs): gr.hier_block2.__init__(self, "usrp_source", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Parameters. frequency = 1575.6e6 decim_rate = int(64e6 / fs) fpga_filename = "std_4rx_0tx.rbf" # Sources. usrp = usrp.source_c(decim_rate=decim_rate, fpga_filename=fpga_filename) head = gr.head(gr.sizeof_gr_complex, N * fs * 1e-3) self.connect(usrp, head, self) # USRP settings. rx_subdev_spec = usrp.pick_rx_subdevice(usrp) usrp.set_mux(usrp.determine_rx_mux_value(usrp, rx_subdev_spec)) subdev = usrp.selected_subdev(usrp, rx_subdev_spec) print "Subdev gain range: " print subdev.gain_range() subdev.set_gain(70) r = usrp.tune(0, _subdev, frequency) if not r: sys.exit('Failed to set frequency')
def _setup_usrp_source(self, options): #create USRP self._usrp = usrp.source_c(which= options.which, decim_rate = options.decim_rate) if options.rx_subdev_spec is None: options.rx_subdev_spec = usrp.pick_rx_subdevice(self._usrp) self._subdev = usrp.selected_subdev(self._usrp, options.rx_subdev_spec) adc_rate = self._usrp.adc_rate() mux = usrp.determine_rx_mux_value(self._usrp, options.rx_subdev_spec) self._usrp.set_mux(mux) tr = self._usrp.tune(0, self._subdev, options.freq) if not (tr): print "Failed to tune to center frequency!" else: print "Center frequency:", n2s(options.freq) if options.gain is None: g = self._subdev.gain_range(); options.gain = float(g[0]+g[1])/2.0 self._subdev.set_gain(options.gain) #the bitrate option is initialised to value self.rs_rate = options.rate #Hard initialisation of bits per symbol self.bits_per_symbol = 1 if options.verbose: print "USRP source:", self._usrp print "Decimation:", options.decim_rate
def _set_source(self): options = self.options fusb_block_size = gr.prefs().get_long('fusb', 'block_size', 4096) fusb_nblocks = gr.prefs().get_long('fusb', 'nblocks', 16) self.usrp = usrp.source_c(decim_rate=options.decim, fusb_block_size=fusb_block_size, fusb_nblocks=fusb_nblocks) if options.rx_subdev_spec is None: options.rx_subdev_spec = usrp.pick_rx_subdevice(self.usrp) self.usrp.set_mux(usrp.determine_rx_mux_value(self.usrp, options.rx_subdev_spec)) # determine the daughterboard subdevice self.subdev = usrp.selected_subdev(self.usrp, options.rx_subdev_spec) print "Using Rx d'board %s" % (self.subdev.side_and_name(),) input_rate = self.usrp.adc_freq() / self.usrp.decim_rate() print "USB sample rate %s" % (eng_notation.num_to_str(input_rate)) # set initial values if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.subdev.gain_range() options.gain = float(g[0]+g[1])/2 r = self.usrp.tune(0, self.subdev, options.freq) self.subdev.set_gain(options.gain) return self.usrp
def __init__( self, decim ): self.freq = -2.5e6 self.src = usrp.source_c( ) self.subdev = usrp.pick_subdev( self.src, (usrp_dbid.BASIC_RX, usrp_dbid.TV_RX, usrp_dbid.TV_RX_REV_2, usrp_dbid.TV_RX_REV_3, usrp_dbid.TV_RX_MIMO, usrp_dbid.TV_RX_REV_2_MIMO, usrp_dbid.TV_RX_REV_3_MIMO)) print self.subdev self.subdevice = usrp.selected_subdev( self.src, self.subdev ) self.mux = usrp.determine_rx_mux_value( self.src, self.subdev ) self.decim = decim self.adc_rate = self.src.adc_rate() self.usrp_rate = self.adc_rate / self.decim self.src.set_decim_rate( self.decim ) self.src.set_mux( self.mux ) usrp.tune( self.src, 0, self.subdevice, self.freq )
def _set_source(self): options = self.options fusb_block_size = gr.prefs().get_long('fusb', 'block_size', 4096) fusb_nblocks = gr.prefs().get_long('fusb', 'nblocks', 16) self.usrp = usrp.source_c(decim_rate=options.decim, fusb_block_size=fusb_block_size, fusb_nblocks=fusb_nblocks) if options.rx_subdev_spec is None: options.rx_subdev_spec = usrp.pick_rx_subdevice(self.usrp) self.usrp.set_mux( usrp.determine_rx_mux_value(self.usrp, options.rx_subdev_spec)) # determine the daughterboard subdevice self.subdev = usrp.selected_subdev(self.usrp, options.rx_subdev_spec) print "Using Rx d'board %s" % (self.subdev.side_and_name(), ) input_rate = self.usrp.adc_freq() / self.usrp.decim_rate() print "USB sample rate %s" % (eng_notation.num_to_str(input_rate)) # set initial values if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.subdev.gain_range() options.gain = float(g[0] + g[1]) / 2 r = self.usrp.tune(0, self.subdev, options.freq) self.subdev.set_gain(options.gain) return self.usrp
def build_block (tx_enable, rx_enable): max_usb_rate = 8e6 # 8 MS/sec dac_freq = 128e6 adc_freq = 64e6 tx_nchan = 2 tx_mux = 0x0000ba98 tx_interp = int (dac_freq / (max_usb_rate/2 * tx_nchan)) # 16 rx_nchan = 2 rx_mux = 0x00003210 rx_decim = int ((adc_freq * rx_nchan) / (max_usb_rate/2)) # 32 tb = gr.top_block () if tx_enable: tx_src0 = gr.sig_source_c (dac_freq/tx_interp, gr.GR_CONST_WAVE, 0, 16e3, 0) usrp_tx = usrp.sink_c (0, tx_interp, tx_nchan, tx_mux) usrp_tx.set_tx_freq (0, 10e6) usrp_tx.set_tx_freq (1, 9e6) tb.connect (tx_src0, usrp_tx) if rx_enable: usrp_rx = usrp.source_c (0, rx_decim, rx_nchan, rx_mux) usrp_rx.set_rx_freq (0, 5.5e6) usrp_rx.set_rx_freq (1, 6.5e6) rx_dst0 = gr.null_sink (gr.sizeof_gr_complex) tb.connect (usrp_rx, rx_dst0) return tb
def __init__(self, N, fs): gr.hier_block2.__init__(self, "usrp_source", gr.io_signature(0,0,0), gr.io_signature(1,1, gr.sizeof_gr_complex)) # Parameters. frequency = 1575.6e6 decim_rate = int(64e6/fs) fpga_filename = "std_4rx_0tx.rbf" # Sources. usrp = usrp.source_c( decim_rate=decim_rate, fpga_filename=fpga_filename ) head = gr.head( gr.sizeof_gr_complex, N*fs*1e-3 ) self.connect( usrp, head, self ) # USRP settings. rx_subdev_spec = usrp.pick_rx_subdevice(usrp) usrp.set_mux(usrp.determine_rx_mux_value(usrp, rx_subdev_spec)) subdev = usrp.selected_subdev( usrp, rx_subdev_spec ) print "Subdev gain range: " print subdev.gain_range() subdev.set_gain(70) r = usrp.tune( 0,_subdev, frequency ) if not r: sys.exit('Failed to set frequency')
def __init__(self, usrp_offset): gr.top_block.__init__(self) u = usrp.source_c(decim_rate = decim) s = usrp.pick_subdev(u, (usrp_dbid.DBS_RX,)) u.set_mux(usrp.determine_rx_mux_value(u, s)) subdev = usrp.selected_subdev(u, s) if subdev.dbid() != usrp_dbid.DBS_RX: raise Exception('dbs daughterboard not detected!') subdev.set_gain(gain) sps = u.adc_freq() / u.decim_rate() if sps < 2 * gsm_rate: raise Exception('sample rate too low') u.tune(0, subdev, c0 + usrp_offset) xcf = 150e3 xtw = 50e3 xt = gr.firdes.low_pass(1.0, sps, xcf, xtw, gr.firdes.WIN_HAMMING) xf = gr.fir_filter_ccf(1, xt) g = gssm.sink(sps) self.connect(u, xf, g)
def __init__(self): gr.top_block.__init__(self) self.u = usrp.source_c(0, usrp_decim) print "USRP Serial: ", self.u.serial_number() usrp_rate = self.u.adc_rate() / usrp_decim # 256 kS/s rx_subdev_spec = usrp.pick_subdev(self.u, dblist) self.u.set_mux(usrp.determine_rx_mux_value(self.u, rx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, rx_subdev_spec) print "Using d'board", self.subdev.side_and_name() self.gain = self.subdev.gain_range()[1] self.subdev.set_gain(self.gain) r = usrp.tune(self.u, 0, self.subdev, freq) if r: print "Freq: ", freq / 1e6, "MHz" else: print "Failed to set frequency, quitting!" sys.exit(1) chan_filter_coeffs = gr.firdes.low_pass( 1.0, # gain usrp_rate, # sampling rate 80e3, # passband cutoff 35e3, # transition width gr.firdes.WIN_HAMMING) self.chan_filter = gr.fir_filter_ccf(1, chan_filter_coeffs) print "# channel filter:", len(chan_filter_coeffs), "taps" self.file_sink = gr.file_sink(gr.sizeof_gr_complex * 1, "/home/sdr/rds_samples.dat") self.connect(self.u, self.chan_filter, self.file_sink)
def setup_usrp(freq, gain): ######## set up usrp u = usrp.source_c(decim_rate=32) # 2M sampling freq rx_subdev_spec = usrp.pick_rx_subdevice(u) #print "u.db(0,0).dbid() = ", self.u.db(0,0).dbid() #print "u.db(1,0).dbid() = ", self.u.db(1,0).dbid() #print "rx_subdev_spec = ", options.rx_subdev_spec mux = usrp.determine_rx_mux_value(u, rx_subdev_spec) #print "mux = ", mux u.set_mux(mux) # determine the daughterboard subdevice we're using subdev = usrp.selected_subdev(u, rx_subdev_spec) #print "Using RX d'board %s" % (self.subdev.side_and_name(),) input_rate = u.adc_freq() / u.decim_rate() #print "ADC sampling @ ", eng_notation.num_to_str(self.u.adc_freq()) #print "USB sample rate %s" % (eng_notation.num_to_str(input_rate)) subdev.set_gain(gain) r = u.tune(0, subdev, freq) #print "freq range = [%s, %s]" % (eng_notation.num_to_str(self.subdev.freq_min()), eng_notation.num_to_str(self.subdev.freq_max())) if not r: sys.stderr.write('Failed to set frequency\n') raise SystemExit, 1 return u
def __init__(self, options): gr.hier_block2.__init__(self, "transmit_path", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) #Set up usrp block self.u = usrp.source_c() adc_rate = self.u.adc_rate() # 64 MS/s usrp_decim = 16 gain = 65 self.u.set_decim_rate(usrp_decim) usrp_rate = adc_rate / usrp_decim # 320 kS/s print usrp_rate #subdev_spec = usrp.pick_subdev(self.u) subdev_spec = (0, 0) mux_value = usrp.determine_rx_mux_value(self.u, subdev_spec) self.u.set_mux(mux_value) self.subdev = usrp.selected_subdev(self.u, subdev_spec) self.subdev.set_gain(gain) self.subdev.set_auto_tr(False) self.subdev.set_enable(True) if not (self.set_freq(915e6)): print "Failed to set initial frequency" #set up the rest of the path deci = 1 self.agc = gr.agc_cc(rate=1e-7, reference=1.0, gain=0.001, max_gain=0.5) matchtaps = [complex(-1, -1)] * 8 + [complex( 1, 1)] * 8 + [complex(-1, -1)] * 8 + [complex(1, 1)] * 8 #matchtaps = [complex(-1,-1)] * 8 + [complex(1,1)] * 8 self.matchfilter = gr.fir_filter_ccc(1, matchtaps) reverse = [complex(1, 1)] * (8 / deci) + [complex( -1, -1)] * (8 / deci) + [complex( 1, 1)] * (8 / deci) + [complex(-1, -1)] * (8 / deci) #pretaps = matchtaps * 3 + reverse * 4 + matchtaps * 4 + reverse * 8 + matchtaps * 6 + matchtaps * 62 pretaps = matchtaps * 2 + reverse * 2 + matchtaps * 2 + reverse * 4 + matchtaps * 3 + matchtaps * 31 #pretaps = matchtaps * 3 + reverse * 8 + matchtaps * 6 + matchtaps * 64 self.preamble_filter = gr.fir_filter_ccc(1, pretaps) self.c_f = gr.complex_to_real() self.c_f2 = gr.complex_to_real() self.lock = howto.lock_time(32, 5, 32) self.pd = howto.find_pre_ff(55, 200) self.dec = symbols_decoder() self.vect = gr.vector_sink_f() #self.connect(self.u, self.agc, self.matchfilter, self.c_f, (self.lock, 0), self.dec, self.vect) #self.connect(self.agc, self.preamble_filter, self.c_f2, self.pd, (self.lock, 1)) self.connect(self.u, self.agc, self.matchfilter, self.c_f, self.vect)
def main(): tb = gr.top_block() ofdm_rx = howto.ofdm_rx(); #rs = gr.vector_source_c() #rs = gr.file_source(gr.sizeof_gr_complex,'out.dat') src = usrp.source_c(0) #nchannel src.set_nchannels(1) sample_rate = 1e6 ulist = [src] print "ulist" print ulist for u in ulist: rdecim = int(u.adc_rate() / sample_rate) u.set_decim_rate(rdecim) sys.stderr.write("the decimate = %d\n"%(rdecim)) srx1 = usrp.pick_rx_subdevice(src) print "srx1=" print srx1 subdev = () """configure USRP mux and set rx/tx subdev """ ulist = [src] assert len(ulist) == 1 src = ulist[0] src.set_mux( usrp.determine_rx_mux_value(src, srx1)) subdev += (usrp.selected_subdev(src, srx1), ) for s in subdev: exec("if not hasattr(s, '_u'): s._u = src") for s in subdev: s.set_auto_tr(True) print "subdev" print subdev freq = 2400000000.0 for s in subdev: r = usrp.tune(s._u, s.which(), s, freq) if r: sys.stderr.write("setting frequency of %s :\n"%(str(s))) sys.stderr.write(" baseband frequency = %s \n" %(eng_notation.num_to_str(r.baseband_freq))) sys.stderr.write(" DUC/DDC offset = %s\n" %(eng_notation.num_to_str(r.dxc_freq))) elif not r: sys.stderr.write("Unable to set frequency of %s to %g MHz \n"%(str(s), freq/ 1.0e6)) #g = 40.0 for s in subdev: gain_range = s.gain_range() #rx_gain = max(min(g, gain_range[1]), gain_range[0]) rx_gain = 0.3 * gain_range[1] s.set_gain(rx_gain) sys.stderr.write("the rx_gain = %d \n " %(rx_gain)) tb.connect(src, ofdm_rx) print 'connect' tb.run()
def _setup_usrp1(self): self._u = usrp.source_c (self._which, fusb_block_size=self._fusb_block_size, fusb_nblocks=self._fusb_nblocks) # determine the daughterboard subdevice we're using if self._subdev_spec is None: self._subdev_spec = usrp.pick_rx_subdevice(self._u) self._subdev = usrp.selected_subdev(self._u, self._subdev_spec) self._u.set_mux(usrp.determine_rx_mux_value(self._u, self._subdev_spec)) self._dxc = 0
def _setup_usrp1(self): self._u = usrp.source_c(self._which, fusb_block_size=self._fusb_block_size, fusb_nblocks=self._fusb_nblocks) # determine the daughterboard subdevice we're using if self._subdev_spec is None: self._subdev_spec = usrp.pick_rx_subdevice(self._u) self._subdev = usrp.selected_subdev(self._u, self._subdev_spec) self._u.set_mux(usrp.determine_rx_mux_value(self._u, self._subdev_spec)) self._dxc = 0
def __init__(self, options, queue): gr.top_block.__init__(self) self.u = usrp.source_c() self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec) print "Using RX d'board %s" % self.subdev.side_and_name() self.u.set_decim_rate(options.decim) self.centerfreq = options.centerfreq print "Tuning to: %fMHz" % (self.centerfreq - options.error) if not(self.tune(options.centerfreq - options.error)): print "Failed to set initial frequency" if options.gain is None: #set to halfway g = self.subdev.gain_range() options.gain = (g[0]+g[1]) / 2.0 print "Setting gain to %i" % options.gain self.subdev.set_gain(options.gain) if self.subdev.name() == "DBS Rx": self.subdev.set_bw(options.bandwidth) #only for DBSRX print "Setting DBS RX bandwidth to %fMHz" % float(options.bandwidth / 1e6) self.rate = self.u.adc_rate() / options.decim print "Samples per second is %i" % self.rate self._syms_per_sec = 3600; options.audiorate = 11025 options.rate = self.rate options.samples_per_second = self.rate #yeah i know it's on the list options.syms_per_sec = self._syms_per_sec options.gain_mu = 0.01 options.mu=0.5 options.omega_relative_limit = 0.3 options.syms_per_sec = self._syms_per_sec options.offset = options.centerfreq - options.freq print "Control channel offset: %f" % options.offset self.demod = fsk_demod(options) self.start_correlator = gr.correlate_access_code_bb("10101100",0) #should mark start of packet self.smartnet_sync = smartnet.sync() self.smartnet_deinterleave = smartnet.deinterleave() self.smartnet_parity = smartnet.parity() self.smartnet_crc = smartnet.crc() self.smartnet_packetize = smartnet.packetize() self.parse = smartnet.parse(queue) #packet-based. this simply posts lightly-formatted messages to the queue. self.connect(self.u, self.demod) self.connect(self.demod, self.start_correlator, self.smartnet_sync, self.smartnet_deinterleave, self.smartnet_parity, self.smartnet_crc, self.smartnet_packetize, self.parse)
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) # do we have a USRP? try: self.usrp = None from gnuradio import usrp self.usrp = usrp.source_c() except Exception: ignore = True # setup (read-only) attributes self.channel_rate = 125000 self.symbol_rate = 4800 self.symbol_deviation = 600.0 # keep track of flow graph connections self.cnxns = [] # initialize the UI # self.__init_gui(frame, panel, vbox) # command line argument parsing parser = OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=(0, 0), help="select USRP Rx side A or B") parser.add_option("-d", "--decim", type="int", default=256, help="source decimation factor") parser.add_option("-f", "--frequency", type="eng_float", default=None, help="USRP center frequency", metavar="Hz") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set USRP gain in dB (default is midpoint)") parser.add_option("-i", "--input", default=None, help="input file name") parser.add_option("-w", "--wait", action="store_true", default=False, help="block on startup") parser.add_option("-t", "--transient", action="store_true", default=False, help="enable transient capture mode") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.options = options # wait for gdb if options.wait: print 'Ready for GDB to attach (pid = %d)' % (os.getpid(),) raw_input("Press 'Enter' to continue...") # configure specified data source if options.input: self.open_file(options.input) elif options.frequency: self.open_usrp(self.options.rx_subdev_spec, self.options.decim, self.options.gain, self.options.frequency, not self.options.transient) else: self._set_state("STOPPED") # save cmd-line options self.options = options
def _setup_usrp(self): self._u = usrp.source_c(fpga_filename='usrp_radar_mono.rbf') if self._subdev_spec == None: self._subdev_spec = usrp.pick_rx_subdevice(self._u) self._u.set_mux(usrp.determine_rx_mux_value(self._u, self._subdev_spec)) self._subdev = usrp.selected_subdev(self._u, self._subdev_spec) if self._verbose: print "Using", self._subdev.side_and_name(), "for radar receiver." print "Setting receiver gain to", self._gain self.set_gain(self._gain) self.tune(self._frequency)
def __init__(self, options): gr.hier_block2.__init__(self, "transmit_path", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) #Set up usrp block self.u = usrp.source_c() adc_rate = self.u.adc_rate() # 64 MS/s usrp_decim = 16 gain = 65 self.u.set_decim_rate(usrp_decim) usrp_rate = adc_rate / usrp_decim # 320 kS/s print usrp_rate #subdev_spec = usrp.pick_subdev(self.u) subdev_spec = (0,0) mux_value = usrp.determine_rx_mux_value(self.u, subdev_spec) self.u.set_mux(mux_value) self.subdev = usrp.selected_subdev(self.u, subdev_spec) self.subdev.set_gain(gain) self.subdev.set_auto_tr(False) self.subdev.set_enable(True) if not(self.set_freq(915e6)): print "Failed to set initial frequency" #set up the rest of the path deci = 1 self.agc = gr.agc_cc( rate = 1e-7, reference = 1.0, gain = 0.001, max_gain = 0.5) matchtaps = [complex(-1,-1)] * 8 + [complex(1,1)] * 8 + [complex(-1,-1)]* 8 + [complex(1,1)]* 8 #matchtaps = [complex(-1,-1)] * 8 + [complex(1,1)] * 8 self.matchfilter = gr.fir_filter_ccc(1, matchtaps) reverse = [complex(1,1)] * (8 / deci) + [complex(-1,-1)] * (8 / deci) + [complex(1,1)]* (8 / deci) + [complex(-1,-1)]* (8 / deci) #pretaps = matchtaps * 3 + reverse * 4 + matchtaps * 4 + reverse * 8 + matchtaps * 6 + matchtaps * 62 pretaps = matchtaps * 2 + reverse * 2 + matchtaps * 2 + reverse * 4 + matchtaps * 3 + matchtaps * 31 #pretaps = matchtaps * 3 + reverse * 8 + matchtaps * 6 + matchtaps * 64 self.preamble_filter = gr.fir_filter_ccc(1, pretaps) self.c_f = gr.complex_to_real() self.c_f2 = gr.complex_to_real() self.lock = howto.lock_time(32, 5, 32) self.pd = howto.find_pre_ff(55, 200) self.dec = symbols_decoder() self.vect = gr.vector_sink_f() #self.connect(self.u, self.agc, self.matchfilter, self.c_f, (self.lock, 0), self.dec, self.vect) #self.connect(self.agc, self.preamble_filter, self.c_f2, self.pd, (self.lock, 1)) self.connect(self.u, self.agc, self.matchfilter, self.c_f, self.vect)
def __init__(self): gr.top_block.__init__(self) #build graph now #usrp_source self.usrp = usrp.source_c() adc_rate = self.usrp.adc_rate() #64MHz hw_decim = 16 #so Sample rate into host is 4MHz self.usrp.set_decim_rate(hw_decim) self.subdev = usrp.selected_subdev(self.usrp, usrp.pick_rx_subdevice(self.usrp)) self.usrp.set_mux( usrp.determine_rx_mux_value(self.usrp, usrp.pick_rx_subdevice(self.usrp))) print "Using RX d'board %s" % (self.subdev.side_and_name(), ) self.subdev.set_gain(30) rf_freq = 106800000 # 106.8MHz self.set_freq(rf_freq) print "Freq: ", rf_freq self.subdev.select_rx_antenna("TX/RX") #low pass filter self.sample_rate = adc_rate / hw_decim self.lpf_decim = 20 # so after channel filter, the sample rate is 200KHz self.lp_filter = gr.fir_filter_ccf( self.lpf_decim, gr.firdes.low_pass( 1, self.sample_rate, 100e3, # cut off freq 10e3, # transition band gr.firdes.WIN_BLACKMAN, # Window function 6.76 # not used )) # WBFM receiver quad_rate = self.sample_rate #input rate of demodulator max_dev = 75e3 #max deviation of FM Broadcast fm_demod_gain = quad_rate / (2 * math.pi * max_dev) self.fm_decoder = gr.quadrature_demod_cf(fm_demod_gain) # Rational Resampler self.audio_sample_rate = 96000 self.rational_resampler = blks2.rational_resampler_fff( interpolation=int(self.audio_sample_rate / 1000), decimation=int(self.sample_rate / self.lpf_decim / 1000), taps=None, fractional_bw=None, ) self.audio_sink = audio.sink(int(self.audio_sample_rate), "", True) #connections self.connect(self.usrp, self.lp_filter, self.fm_decoder, self.rational_resampler, self.audio_sink)
def _setup_usrp_source(self): self.u = usrp.source_c (fusb_block_size=self._fusb_block_size, fusb_nblocks=self._fusb_nblocks) adc_rate = self.u.adc_rate() self.u.set_decim_rate(self._decim) # determine the daughterboard subdevice we're using if self._rx_subdev_spec is None: self._rx_subdev_spec = usrp.pick_rx_subdevice(self.u) self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec) self.u.set_mux(usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec))
def setup_usrp(self): if (self.usrp2 == False): if (self.dual_mode == False and self.interferometer == False): if (self.decim > 4): self.u = usrp.source_c(decim_rate=self.decim,fusb_block_size=8192) else: self.u = usrp.source_c(decim_rate=self.decim,fusb_block_size=8192, fpga_filename="std_4rx_0tx.rbf") self.u.set_mux(usrp.determine_rx_mux_value(self.u, self.rx_subdev_spec)) # determine the daughterboard subdevice we're using self.subdev[0] = usrp.selected_subdev(self.u, self.rx_subdev_spec) self.subdev[1] = self.subdev[0] self.cardtype = self.subdev[0].dbid() else: self.u=usrp.source_c(decim_rate=self.decim, nchan=2,fusb_block_size=8192) self.subdev[0] = usrp.selected_subdev(self.u, (0, 0)) self.subdev[1] = usrp.selected_subdev(self.u, (1, 0)) self.cardtype = self.subdev[0].dbid() self.u.set_mux(0x32103210) c1 = self.subdev[0].name() c2 = self.subdev[1].name() if (c1 != c2): print "Must have identical cardtypes for --dual_mode or --interferometer" sys.exit(1) # # Set 8-bit mode # width = 8 shift = 8 format = self.u.make_format(width, shift) r = self.u.set_format(format) else: if (self.dual_mode == True or self.interferometer == True): print "Cannot use dual_mode or interferometer with single USRP2" sys.exit(1) self.u = usrp2.source_32fc(self.interface, self.mac_addr) self.u.set_decim (self.decim) self.cardtype = self.u.daughterboard_id()
def __init__(self, options, queue): gr.top_block.__init__(self, "usrp_flex_all") if options.from_file is not None: src = gr.file_source(gr.sizeof_gr_complex, options.from_file) if options.verbose: print "Reading samples from file", options.from_file else: src = usrp.source_c() if options.rx_subdev_spec is None: options.rx_subdev_spec = usrp.pick_rx_subdevice(src) subdev = usrp.selected_subdev(src, options.rx_subdev_spec) src.set_mux( usrp.determine_rx_mux_value(src, options.rx_subdev_spec)) src.set_decim_rate(20) result = usrp.tune(src, 0, subdev, 930.5125e6 + options.calibration) if options.verbose: print "Using", subdev.name(), " for receiving." print "Tuned USRP to", 930.5125e6 + options.calibration taps = gr.firdes.low_pass(1.0, 1.0, 1.0 / 128.0 * 0.4, 1.0 / 128.0 * 0.1, gr.firdes.WIN_HANN) if options.verbose: print "Channel filter has", len(taps), "taps" bank = blks2.analysis_filterbank(128, taps) self.connect(src, bank) if options.log and options.from_file == None: src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') self.connect(src, src_sink) for i in range(128): if i < 64: freq = 930.5e6 + i * 25e3 else: freq = 928.9e6 + (i - 64) * 25e3 if (freq < 929.0e6 or freq > 932.0e6): self.connect((bank, i), gr.null_sink(gr.sizeof_gr_complex)) else: self.connect((bank, i), pager.flex_demod(queue, freq, options.verbose, options.log)) if options.log: self.connect( (bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_' + '%3.3f' % (freq / 1e6) + '.dat'))
def setup_usrp(self): options = self.options #set resonable defaults if no user prefs set if options.realtime: if options.fusb_block_size == 0: options.fusb_block_size = gr.prefs().get_long( 'fusb', 'rt_block_size', 1024) if options.fusb_nblocks == 0: options.fusb_nblocks = gr.prefs().get_long( 'fusb', 'rt_nblocks', 16) else: if options.fusb_block_size == 0: options.fusb_block_size = gr.prefs().get_long( 'fusb', 'block_size', 4096) if options.fusb_nblocks == 0: options.fusb_nblocks = gr.prefs().get_long( 'fusb', 'nblocks', 16) print >> sys.stderr, "fusb_block_size =", options.fusb_block_size print >> sys.stderr, "fusb_nblocks =", options.fusb_nblocks self.ursp = usrp.source_c(decim_rate=options.decim, fusb_block_size=options.fusb_block_size, fusb_nblocks=options.fusb_nblocks) self.ursp.set_fpga_master_clock_freq(options.clock_frequency) if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(self.ursp) self.ursp.set_mux( usrp.determine_rx_mux_value(self.ursp, options.rx_subdev_spec)) # determine the daughterboard subdevice self.subdev = usrp.selected_subdev(self.ursp, options.rx_subdev_spec) input_rate = self.ursp.adc_freq() / self.ursp.decim_rate() if options.antenna is not None: print >> sys.stderr, "USRP antenna %s" % (options.antenna, ) self.subdev.select_rx_antenna(options.antenna) # set initial values if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.subdev.gain_range() options.gain = float(g[0] + g[1]) / 2 self.set_gain(options.gain) self.source = self.ursp
def __init__(self, fg, decim=8, rx_subdev_spec=None, width_16=False, verbose=False, gain=None, freq=None): # build the graph" self.u = usrp.source_c(decim_rate=decim, fpga_filename="usrp_std_d2.rbf") if rx_subdev_spec is None: rx_subdev_spec = pick_subdevice(self.u) self.u.set_mux(usrp.determine_rx_mux_value(self.u, rx_subdev_spec)) if not width_16: width = 8 shift = 8 format = self.u.make_format(width, shift) r = self.u.set_format(format) if verbose: print "Bits Per Encoded Sample = 8" else: if verbose: print "Bits Per Encoded Sample = 16" # determine the daughterboard subdevice we're using self.subdev = usrp.selected_subdev(self.u, rx_subdev_spec) if verbose: print "adc frequency = ", self.u.adc_freq() print "decimation frequency = ", self.u.decim_rate() print "input_rate = ", self.u.adc_freq() / self.u.decim_rate() if gain is None: # if no gain was specified, use the mid-point in dB g = self.subdev.gain_range() gain = float(g[0]+g[1])/2 if verbose: print "gain = ", gain if freq is None: # if no freq was specified, use the mid-point r = self.subdev.freq_range() freq = float(r[0]+r[1])/2 self.subdev.set_gain(gain) r = self.u.tune(0, self.subdev, freq) if verbose: print "desired freq = ", freq #print "baseband frequency", r.baseband_freq #print "dxc frequency", r.dxc_freq gr.hier_block.__init__(self, fg, None, self.u)
def __init__(self, options, rx_callback): """ @param options Optparse option field for command line arguments. @param rx_callback Callback function for the event when a packet is received. """ gr.flow_graph.__init__(self) print "cordic_freq = %s" % (eng_notation.num_to_str (options.cordic_freq_rx)) # ---------------------------------------------------------------- self.data_rate = options.data_rate self.samples_per_symbol = 2 self.usrp_decim = int (64e6 / self.samples_per_symbol / self.data_rate) self.fs = self.data_rate * self.samples_per_symbol payload_size = 128 # bytes print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "fs = ", eng_notation.num_to_str(self.fs) u = usrp.source_c (0, self.usrp_decim) if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(u) u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec)) self.subdev = usrp.selected_subdev(u, options.rx_subdev_spec) print "Using RX d'board %s" % (self.subdev.side_and_name(),) #self.subdev.select_rx_antenna('RX2') u.tune(0, self.subdev, options.cordic_freq_rx) u.set_pga(0, options.gain) u.set_pga(1, options.gain) self.u = u self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) #self.file_sink = gr.file_sink(gr.sizeof_gr_complex, "/dev/null") self.connect(self.u, self.squelch, self.packet_receiver) #self.connect(self.u, self.file_sink) self.set_auto_tr(True) # enable Auto Transmit/Receive switching
def __init__(self, options, queue): gr.top_block.__init__(self, "usrp_flex_all") if options.from_file is not None: src = gr.file_source(gr.sizeof_gr_complex, options.from_file) if options.verbose: print "Reading samples from file", options.from_file else: src = usrp.source_c() if options.rx_subdev_spec is None: options.rx_subdev_spec = usrp.pick_rx_subdevice(src) subdev = usrp.selected_subdev(src, options.rx_subdev_spec) src.set_mux(usrp.determine_rx_mux_value(src, options.rx_subdev_spec)) src.set_decim_rate(20) result = usrp.tune(src, 0, subdev, 930.5125e6+options.calibration) if options.verbose: print "Using", subdev.name(), " for receiving." print "Tuned USRP to", 930.5125e6+options.calibration taps = gr.firdes.low_pass(1.0, 1.0, 1.0/128.0*0.4, 1.0/128.0*0.1, gr.firdes.WIN_HANN) if options.verbose: print "Channel filter has", len(taps), "taps" bank = blks2.analysis_filterbank(128, taps) self.connect(src, bank) if options.log and options.from_file == None: src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') self.connect(src, src_sink) for i in range(128): if i < 64: freq = 930.5e6+i*25e3 else: freq = 928.9e6+(i-64)*25e3 if (freq < 929.0e6 or freq > 932.0e6): self.connect((bank, i), gr.null_sink(gr.sizeof_gr_complex)) else: self.connect((bank, i), pager.flex_demod(queue, freq, options.verbose, options.log)) if options.log: self.connect((bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat'))
def __init__(self): gr.top_block.__init__(self) #build graph now #usrp_source self.usrp = usrp.source_c() adc_rate = self.usrp.adc_rate() #64MHz hw_decim = 16 #so Sample rate into host is 4MHz self.usrp.set_decim_rate(hw_decim) self.subdev = usrp.selected_subdev(self.usrp, usrp.pick_rx_subdevice(self.usrp)) self.usrp.set_mux(usrp.determine_rx_mux_value(self.usrp, usrp.pick_rx_subdevice(self.usrp))) print "Using RX d'board %s" % (self.subdev.side_and_name(),) self.subdev.set_gain(30) rf_freq = 106800000 # 106.8MHz self.set_freq(rf_freq) print "Freq: ", rf_freq self.subdev.select_rx_antenna("TX/RX") #low pass filter self.sample_rate = adc_rate / hw_decim self.lpf_decim = 20 # so after channel filter, the sample rate is 200KHz self.lp_filter = gr.fir_filter_ccf( self.lpf_decim, gr.firdes.low_pass ( 1, self.sample_rate, 100e3, # cut off freq 10e3, # transition band gr.firdes.WIN_BLACKMAN, # Window function 6.76 # not used )) # WBFM receiver quad_rate = self.sample_rate #input rate of demodulator max_dev = 75e3 #max deviation of FM Broadcast fm_demod_gain = quad_rate/(2 * math.pi * max_dev) self.fm_decoder = gr.quadrature_demod_cf (fm_demod_gain) # Rational Resampler self.audio_sample_rate = 96000 self.rational_resampler = blks2.rational_resampler_fff ( interpolation = int(self.audio_sample_rate/1000), decimation = int(self.sample_rate/self.lpf_decim/1000), taps = None, fractional_bw = None, ) self.audio_sink = audio.sink (int(self.audio_sample_rate), "", True) #connections self.connect ( self.usrp, self.lp_filter, self.fm_decoder, self.rational_resampler, self.audio_sink )
def setup_usrp(freq): # Constants interp = 128 decim = 64 # Make USRP instances to TX and RX utx = usrp.sink_c(fpga_filename="local_rssi5.rbf") urx = usrp.source_c(fpga_filename="local_rssi5.rbf") # Set decim and interp rates utx.set_interp_rate(interp) urx.set_decim_rate(decim) # Pick subdevice subdev_spec_tx = usrp.pick_tx_subdevice(utx) subdev_spec_rx = usrp.pick_rx_subdevice(urx) # Set up mux mux_tx = usrp.determine_tx_mux_value(utx, subdev_spec_tx) mux_rx = usrp.determine_rx_mux_value(urx, subdev_spec_rx) utx.set_mux(mux_tx) urx.set_mux(mux_rx) # pick d'board subdev_tx = usrp.selected_subdev(utx, subdev_spec_tx) subdev_rx = usrp.selected_subdev(urx, subdev_spec_rx) print "Using TX d'board %s" %(subdev_tx.side_and_name()) print "Using RX d'board %s" %(subdev_rx.side_and_name()) # Gain subdev_tx.set_gain((subdev_tx.gain_range()[0] + subdev_tx.gain_range()[1]) / 2) subdev_rx.set_gain((subdev_rx.gain_range()[0] + subdev_rx.gain_range()[1]) / 2) # Tune if not utx.tune(subdev_tx._which, subdev_tx, freq): DEBUG( "error tuning TX") if not urx.tune(subdev_rx._which, subdev_rx, freq): DEBUG( "error tuning RX") # Power on subdev_tx.set_enable(True) subdev_rx.set_enable(True) sys.stdout.flush() return utx, urx
def _setup_usrp(self, which, decim, subdev_spec, freq, gain): self._usrp = usrp.source_c(which=which, decim_rate=decim) if subdev_spec is None: subdev_spec = usrp.pick_rx_subdevice(self._usrp) self._subdev = usrp.selected_subdev(self._usrp, subdev_spec) mux = usrp.determine_rx_mux_value(self._usrp, subdev_spec) self._usrp.set_mux(mux) tr = self._usrp.tune(0, self._subdev, freq) if not (tr): print "Failed to tune to center frequency!" else: print "Center frequency:", n2s(freq) if gain is None: g = self._subdev.gain_range() gain = float(g[0] + g[1]) / 2.0 self._subdev.set_gain(gain) print "RX d'board:", self._subdev.side_and_name()
def _setup_usrp(self, which, decim, subdev_spec, freq, gain): self._usrp = usrp.source_c(which=which, decim_rate=decim) if subdev_spec is None: subdev_spec = usrp.pick_rx_subdevice(self._usrp) self._subdev = usrp.selected_subdev(self._usrp, subdev_spec) mux = usrp.determine_rx_mux_value(self._usrp, subdev_spec) self._usrp.set_mux(mux) tr = self._usrp.tune(0, self._subdev, freq) if not (tr): print "Failed to tune to center frequency!" else: print "Center frequency:", n2s(freq) if gain is None: g = self._subdev.gain_range(); gain = float(g[0]+g[1])/2.0 self._subdev.set_gain(gain) print "RX d'board:", self._subdev.side_and_name()
def _setup_usrp_source(self): self.u = usrp.source_c (fusb_block_size=self._fusb_block_size, fusb_nblocks=self._fusb_nblocks) adc_rate = self.u.adc_rate() # derive values of bitrate, samples_per_symbol, and decim from desired info (self._bitrate, self._samples_per_symbol, self._decim) = \ pick_rx_bitrate(self._bitrate, self._demod_class.bits_per_symbol(), \ self._samples_per_symbol, self._decim, adc_rate) self.u.set_decim_rate(self._decim) # determine the daughterboard subdevice we're using if self._rx_subdev_spec is None: self._rx_subdev_spec = usrp.pick_rx_subdevice(self.u) self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec) self.u.set_mux(usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec))
def __init__(self): gr.hier_block2.__init__(self, "rx_path", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) self.frequency = 13.56e6 self.gain = 10 # USRP settings self.u_rx = usrp.source_c() #create the USRP source for RX #try and set the LF_RX for this rx_subdev_spec = usrp.pick_subdev(self.u_rx, (usrp_dbid.LF_RX, usrp_dbid.LF_TX)) #Configure the MUX for the daughterboard self.u_rx.set_mux( usrp.determine_rx_mux_value(self.u_rx, rx_subdev_spec)) #Tell it to use the LF_RX self.subdev_rx = usrp.selected_subdev(self.u_rx, rx_subdev_spec) #Make sure it worked print "Using RX dboard %s" % (self.subdev_rx.side_and_name(), ) #Set gain.. duh self.subdev_rx.set_gain(self.gain) #Tune the center frequency self.u_rx.tune(0, self.subdev_rx, self.frequency) adc_rate = self.u_rx.adc_rate() #64 MS/s usrp_decim = 256 self.u_rx.set_decim_rate(usrp_decim) #BW = 64 MS/s / decim = 64,000,000 / 256 = 250 kHz #Not sure if this decim rate exceeds USRP capabilities, #if it does then some software decim may have to be done as well usrp_rx_rate = adc_rate / usrp_decim self.iir = gr.single_pole_iir_filter_ff(.001) self.mag = gr.complex_to_mag() self.snk = gr.probe_signal_f() # dst = audio.sink (sample_rate, "") # stv = gr.stream_to_vector (gr.sizeof_float, fft_size) # c2m = gr.complex_to_mag_squared (fft_size) self.connect(self.u_rx, self.mag, self.iir, self.snk)
def setup_usrp(self): options = self.options #set resonable defaults if no user prefs set if options.realtime: if options.fusb_block_size == 0: options.fusb_block_size = gr.prefs().get_long('fusb', 'rt_block_size', 1024) if options.fusb_nblocks == 0: options.fusb_nblocks = gr.prefs().get_long('fusb', 'rt_nblocks', 16) else: if options.fusb_block_size == 0: options.fusb_block_size = gr.prefs().get_long('fusb', 'block_size', 4096) if options.fusb_nblocks == 0: options.fusb_nblocks = gr.prefs().get_long('fusb', 'nblocks', 16) print >> sys.stderr, "fusb_block_size =", options.fusb_block_size print >> sys.stderr, "fusb_nblocks =", options.fusb_nblocks self.ursp = usrp.source_c(decim_rate=options.decim,fusb_block_size=options.fusb_block_size,fusb_nblocks=options.fusb_nblocks) self.ursp.set_fpga_master_clock_freq(options.clock_frequency) if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(self.ursp) self.ursp.set_mux(usrp.determine_rx_mux_value(self.ursp, options.rx_subdev_spec)) # determine the daughterboard subdevice self.subdev = usrp.selected_subdev(self.ursp, options.rx_subdev_spec) input_rate = self.ursp.adc_freq() / self.ursp.decim_rate() if options.antenna is not None: print >> sys.stderr, "USRP antenna %s" % (options.antenna,) self.subdev.select_rx_antenna(options.antenna) # set initial values if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.subdev.gain_range() options.gain = float(g[0]+g[1])/2 self.set_gain(options.gain) self.source = self.ursp
def __init__(self): gr.hier_block2.__init__(self, "rx_path", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) self.frequency = 13.56e6 self.gain = 10 # USRP settings self.u_rx = usrp.source_c() #create the USRP source for RX #try and set the LF_RX for this rx_subdev_spec = usrp.pick_subdev(self.u_rx, (usrp_dbid.LF_RX, usrp_dbid.LF_TX)) #Configure the MUX for the daughterboard self.u_rx.set_mux(usrp.determine_rx_mux_value(self.u_rx, rx_subdev_spec)) #Tell it to use the LF_RX self.subdev_rx = usrp.selected_subdev(self.u_rx, rx_subdev_spec) #Make sure it worked print "Using RX dboard %s" % (self.subdev_rx.side_and_name(),) #Set gain.. duh self.subdev_rx.set_gain(self.gain) #Tune the center frequency self.u_rx.tune(0, self.subdev_rx, self.frequency) adc_rate = self.u_rx.adc_rate() #64 MS/s usrp_decim = 256 self.u_rx.set_decim_rate(usrp_decim) #BW = 64 MS/s / decim = 64,000,000 / 256 = 250 kHz #Not sure if this decim rate exceeds USRP capabilities, #if it does then some software decim may have to be done as well usrp_rx_rate = adc_rate / usrp_decim self.iir = gr.single_pole_iir_filter_ff(.001) self.mag = gr.complex_to_mag() self.snk = gr.probe_signal_f() # dst = audio.sink (sample_rate, "") # stv = gr.stream_to_vector (gr.sizeof_float, fft_size) # c2m = gr.complex_to_mag_squared (fft_size) self.connect(self.u_rx, self.mag, self.iir, self.snk)
def listUsrp(option, opt, value, parser): id = 0 while (true) : try: version = usrp._look_for_usrp(id) print "USRP #%i" % id print " Rev: %i" % version dst = usrp.sink_c(id) src = usrp.source_c(id) print " Tx" for db in dst.db: if (db[0].dbid() != -1): print " %s" % db[0].side_and_name() (min, max, offset) = db[0].freq_range() print " Frequency" print " Min: %sHz" % num_to_str(min) print " Max: %sHz" % num_to_str(max) print " Offset: %sHz" % num_to_str(offset) (min, max, offset) = db[0].gain_range() print " Gain" print " Min: %sdB" % num_to_str(min) print " Max: %sdB" % num_to_str(max) print " Offset: %sdB" % num_to_str(offset) print " Rx" for db in src.db: if (db[0].dbid() != -1): print " %s" % db[0].side_and_name() (min, max, offset) = db[0].freq_range() print " Frequency" print " Min: %sHz" % num_to_str(min) print " Max: %sHz" % num_to_str(max) print " Offset: %sHz" % num_to_str(offset) (min, max, offset) = db[0].gain_range() print " Gain" print " Min: %sdB" % num_to_str(min) print " Max: %sdB" % num_to_str(max) print " Offset: %sdB" % num_to_str(offset) except RuntimeError: break id += 1 raise SystemExit
def detect_usrp1(): for i in range(3): try: u = usrp.source_c(i) print "\033[1;31mUSRP found, serial:", u.serial_number( ), "\033[1;m" a = usrp.selected_subdev(u, (0, 0)) if (a.dbid() != -1): print "\033[1;33mSide A, RX:", a.name(), "(dbid: 0x%04X)" % ( a.dbid()), "\033[1;m" print "freq range: (", a.freq_min() / 1e6, "MHz, ", a.freq_max( ) / 1e6, "MHz )" print "gain rainge: (", a.gain_min(), "dB, ", a.gain_max( ), "dB )" b = usrp.selected_subdev(u, (1, 0)) if (b.dbid() != -1): print "\033[1;33mSide B, RX:", b.name(), "(dbid: 0x%04X)" % ( b.dbid()), "\033[1;m" print "freq range: (", b.freq_min() / 1e6, "MHz, ", b.freq_max( ) / 1e6, "MHz )" print "gain rainge: (", b.gain_min(), "dB, ", b.gain_max( ), "dB )" u = usrp.sink_c(i) a = usrp.selected_subdev(u, (0, 0)) if (a.dbid() != -1): print "\033[1;33mSide A, TX:", a.name(), "(dbid: 0x%04X)" % ( a.dbid()), "\033[1;m" print "freq range: (", a.freq_min() / 1e6, "MHz, ", a.freq_max( ) / 1e6, "MHz )" print "gain rainge: (", a.gain_min(), "dB, ", a.gain_max( ), "dB )" b = usrp.selected_subdev(u, (1, 0)) if (b.dbid() != -1): print "\033[1;33mSide B, TX:", b.name(), "(dbid: 0x%04X)" % ( b.dbid()), "\033[1;m" print "freq range: (", b.freq_min() / 1e6, "MHz, ", b.freq_max( ) / 1e6, "MHz )" print "gain rainge: (", b.gain_min(), "dB, ", b.gain_max( ), "dB )" except: if (i == 0): print "\033[1;31mno USRPs found" break
def _setup_usrp_source(self): self.u = usrp.source_c(self._which, fusb_block_size=self._fusb_block_size, fusb_nblocks=self._fusb_nblocks) adc_rate = self.u.adc_rate() # derive values of bitrate, samples_per_symbol, and decim from desired info (self._bitrate, self._samples_per_symbol, self._decim) = \ pick_rx_bitrate(self._bitrate, self._demod_class.bits_per_symbol(), \ self._samples_per_symbol, self._decim, adc_rate) self.u.set_decim_rate(self._decim) # determine the daughterboard subdevice we're using if self._rx_subdev_spec is None: self._rx_subdev_spec = usrp.pick_rx_subdevice(self.u) self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec) self.u.set_mux( usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec))
def __init__(self, options, rx_callback): gr.top_block.__init__(self) print "cordic_freq = %s" % (eng_notation.num_to_str( options.cordic_freq)) # ---------------------------------------------------------------- self.data_rate = options.data_rate self.samples_per_symbol = 2 self.usrp_decim = int(64e6 / self.samples_per_symbol / self.data_rate) self.fs = self.data_rate * self.samples_per_symbol payload_size = 128 # bytes print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "fs = ", eng_notation.num_to_str(self.fs) u = usrp.source_c(0, self.usrp_decim) if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(u) u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec)) subdev = usrp.selected_subdev(u, options.rx_subdev_spec) print "Using RX d'board %s" % (subdev.side_and_name(), ) u.tune(0, subdev, options.cordic_freq) u.set_pga(0, options.gain) u.set_pga(1, options.gain) self.u = u self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) self.connect(self.u, self.squelch, self.packet_receiver)
def __init__(self, decim): self.freq = -2.5e6 self.src = usrp.source_c() self.subdev = usrp.pick_subdev( self.src, (usrp_dbid.BASIC_RX, usrp_dbid.TV_RX, usrp_dbid.TV_RX_REV_2, usrp_dbid.TV_RX_REV_3, usrp_dbid.TV_RX_MIMO, usrp_dbid.TV_RX_REV_2_MIMO, usrp_dbid.TV_RX_REV_3_MIMO)) print self.subdev self.subdevice = usrp.selected_subdev(self.src, self.subdev) self.mux = usrp.determine_rx_mux_value(self.src, self.subdev) self.decim = decim self.adc_rate = self.src.adc_rate() self.usrp_rate = self.adc_rate / self.decim self.src.set_decim_rate(self.decim) self.src.set_mux(self.mux) usrp.tune(self.src, 0, self.subdevice, self.freq)
def __init__(self, rx_callback): gr.top_block.__init__(self) self.data_rate = 2000000 self.samples_per_symbol = 2 self.usrp_decim = int(64e6 / self.samples_per_symbol / self.data_rate) self.fs = self.data_rate * self.samples_per_symbol payload_size = 128 # bytes print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "fs = ", eng_notation.num_to_str(self.fs) self.u = usrp.source_c(0, self.usrp_decim) self.picksubdev = pick_subdevice(self.u) self.u.set_mux(usrp.determine_rx_mux_value(self.u, self.picksubdev)) self.subdev = usrp.selected_subdev(self.u, pick_subdevice(self.u)) print "Using RX d'board %s" % (self.subdev.side_and_name(), ) #self.u.tune(0, self.subdev, 2475000000) #self.u.tune(0, self.subdev, 2480000000) self.u.tune(0, self.subdev, 2425000000) self.u.set_pga(0, 0) self.u.set_pga(1, 0) # receiver self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) self.connect(self.u, self.squelch, self.packet_receiver) # enable Auto Transmit/Receive switching self.set_auto_tr(True)
def __init__(self, subdev_spec, decim, gain=None, calibration=0.0): gr.hier_block2.__init__( self, "usrp_src", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._decim = decim self._src = usrp.source_c() if subdev_spec is None: subdev_spec = usrp.pick_rx_subdevice(self._src) self._subdev = usrp.selected_subdev(self._src, subdev_spec) self._src.set_mux(usrp.determine_rx_mux_value(self._src, subdev_spec)) self._src.set_decim_rate(self._decim) # If no gain specified, set to midrange if gain is None: g = self._subdev.gain_range() gain = (g[0] + g[1]) / 2.0 self._subdev.set_gain(gain) self._cal = calibration self.connect(self._src, self)
def __init__(self): gr.top_block.__init__(self) amplitude = 30000 filt_out = gr.file_sink(gr.sizeof_gr_complex, "./filt.out") filt2_out = gr.file_sink(gr.sizeof_gr_complex, "./filt2.out") ffilt_out = gr.file_sink(gr.sizeof_float, "./ffilt.out") ffilt2_out = gr.file_sink(gr.sizeof_float, "./ffilt2.out") interp_rate = 128 dec_rate = 8 sw_dec = 4 num_taps = int(64000 / ( (dec_rate * 4) * 256 )) #Filter matched to 1/4 of the 256 kHz tag cycle taps = [complex(1,1)] * num_taps matched_filt = gr.fir_filter_ccc(sw_dec, taps); agc = gr.agc2_cc(0.3, 1e-3, 1, 1, 100) to_mag = gr.complex_to_mag() center = rfid.center_ff(4) omega = 2 mu = 0.25 gain_mu = 0.25 gain_omega = .25 * gain_mu * gain_mu omega_relative_limit = .05 mm = gr.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit) self.reader = rfid.reader_f(int(128e6/interp_rate)); tag_decoder = rfid.tag_decoder_f() command_gate = rfid.command_gate_cc(12, 60, 64000000 / dec_rate / sw_dec) to_complex = gr.float_to_complex() amp = gr.multiply_const_ff(amplitude) f_sink = gr.file_sink(gr.sizeof_gr_complex, 'f_sink.out'); f_sink2 = gr.file_sink(gr.sizeof_gr_complex, 'f_sink2.out'); #TX freq = 915e6 rx_gain = 20 tx = usrp.sink_c(fusb_block_size = 1024, fusb_nblocks=8) tx.set_interp_rate(interp_rate) tx_subdev = (0,0) tx.set_mux(usrp.determine_tx_mux_value(tx, tx_subdev)) subdev = usrp.selected_subdev(tx, tx_subdev) subdev.set_enable(True) subdev.set_gain(subdev.gain_range()[2]) t = tx.tune(subdev.which(), subdev, freq) if not t: print "Couldn't set tx freq" #End TX #RX rx = usrp.source_c(0, dec_rate, fusb_block_size = 512 * 4, fusb_nblocks = 16) rx_subdev_spec = (1,0) rx.set_mux(usrp.determine_rx_mux_value(rx, rx_subdev_spec)) rx_subdev = usrp.selected_subdev(rx, rx_subdev_spec) rx_subdev.set_gain(rx_gain) rx_subdev.set_auto_tr(False) rx_subdev.set_enable(True) r = usrp.tune(rx, 0, rx_subdev, freq) self.rx = rx if not r: print "Couldn't set rx freq" #End RX command_gate.set_ctrl_out(self.reader.ctrl_q()) tag_decoder.set_ctrl_out(self.reader.ctrl_q()) agc2 = gr.agc2_ff(0.3, 1e-3, 1, 1, 100) #########Build Graph self.connect(rx, matched_filt) self.connect(matched_filt, command_gate) self.connect(command_gate, agc) self.connect(agc, to_mag) self.connect(to_mag, center, agc2, mm, tag_decoder) self.connect(tag_decoder, self.reader, amp, to_complex, tx); ################# self.connect(matched_filt, filt_out)
def __init__(self, options, queue): gr.top_block.__init__(self) self.u = usrp.source_c() self.u.set_mux( usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec) print "Using RX d'board %s" % self.subdev.side_and_name() self.u.set_decim_rate(options.decim) self.centerfreq = options.centerfreq print "Tuning to: %fMHz" % (self.centerfreq - options.error) if not (self.tune(options.centerfreq - options.error)): print "Failed to set initial frequency" if options.gain is None: #set to halfway g = self.subdev.gain_range() options.gain = (g[0] + g[1]) / 2.0 print "Setting gain to %i" % options.gain self.subdev.set_gain(options.gain) if self.subdev.name() == "DBS Rx": self.subdev.set_bw(options.bandwidth) #only for DBSRX print "Setting DBS RX bandwidth to %fMHz" % float( options.bandwidth / 1e6) self.rate = self.u.adc_rate() / options.decim print "Samples per second is %i" % self.rate self._syms_per_sec = 3600 options.audiorate = 11025 options.rate = self.rate options.samples_per_second = self.rate #yeah i know it's on the list options.syms_per_sec = self._syms_per_sec options.gain_mu = 0.01 options.mu = 0.5 options.omega_relative_limit = 0.3 options.syms_per_sec = self._syms_per_sec options.offset = options.centerfreq - options.freq print "Control channel offset: %f" % options.offset self.demod = fsk_demod(options) self.start_correlator = gr.correlate_access_code_bb( "10101100", 0) #should mark start of packet self.smartnet_sync = smartnet.sync() self.smartnet_deinterleave = smartnet.deinterleave() self.smartnet_parity = smartnet.parity() self.smartnet_crc = smartnet.crc() self.smartnet_packetize = smartnet.packetize() self.parse = smartnet.parse( queue ) #packet-based. this simply posts lightly-formatted messages to the queue. self.connect(self.u, self.demod) self.connect(self.demod, self.start_correlator, self.smartnet_sync, self.smartnet_deinterleave, self.smartnet_parity, self.smartnet_crc, self.smartnet_packetize, self.parse)
def __init__(self, options, queue): gr.top_block.__init__(self, "usrp_flex") self.options = options self.offset = 0.0 self.adj_time = time.time() self.verbose = options.verbose if options.from_file is None: # Set up USRP source with specified RX daughterboard self.src = usrp.source_c() if options.rx_subdev_spec == None: options.rx_subdev_spec = usrp.pick_rx_subdevice(self.src) self.subdev = usrp.selected_subdev(self.src, options.rx_subdev_spec) self.src.set_mux( usrp.determine_rx_mux_value(self.src, options.rx_subdev_spec)) # Grab 250 KHz of spectrum (sample rate becomes 250 ksps complex) self.src.set_decim_rate(256) # If no gain specified, set to midrange if options.gain is None: g = self.subdev.gain_range() options.gain = (g[0] + g[1]) / 2.0 self.subdev.set_gain(options.gain) # Tune daughterboard actual_frequency = options.frequency + options.calibration tune_result = usrp.tune(self.src, 0, self.subdev, actual_frequency) if not tune_result: sys.stderr.write("Failed to set center frequency to " + ` actual_frequency ` + "\n") sys.exit(1) if options.verbose: print "Using RX daughterboard", self.subdev.side_and_name() print "USRP gain is", options.gain print "USRP tuned to", actual_frequency else: # Use supplied file as source of samples self.src = gr.file_source(gr.sizeof_gr_complex, options.from_file) if options.verbose: print "Reading samples from", options.from_file if options.log and not options.from_file: usrp_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat') self.connect(self.src, usrp_sink) # Set up 22KHz-wide bandpass about center frequency. Decimate by 10 # to get channel rate of 25Ksps taps = optfir.low_pass( 1.0, # Filter gain 250e3, # Sample rate 11000, # One-sided modulation bandwidth 12500, # One-sided channel bandwidth 0.1, # Passband ripple 60) # Stopband attenuation if options.verbose: print "Channel filter has", len(taps), "taps." self.chan = gr.freq_xlating_fir_filter_ccf( 10, # Decimation rate taps, # Filter taps 0.0, # Offset frequency 250e3) # Sample rate if options.log: chan_sink = gr.file_sink(gr.sizeof_gr_complex, 'chan.dat') self.connect(self.chan, chan_sink) # FLEX protocol demodulator self.flex = pager.flex_demod(queue, options.frequency, options.verbose, options.log) self.connect(self.src, self.chan, self.flex)