def __init__(self, Np=32, P=128, L=2, filename=None, sample_type='complex', verbose=True): gr.top_block.__init__(self) if filename is None: src = gr.noise_source_c(gr.GR_GAUSSIAN, 1) if verbose: print "Using Gaussian noise source." else: if sample_type == 'complex': src = gr.file_source(gr.sizeof_gr_complex, filename, True) else: fsrc = gr.file_source(gr.sizeof_float, filename, True) src = gr.float_to_complex() self.connect(fsrc, src) if verbose: print "Reading data from %s" % filename if verbose: print "FAM configuration:" print "N' = %d" % Np print "P = %d" % P print "L = %d" % L #print "Δf = %f" % asfd sink = gr.null_sink(gr.sizeof_float * 2 * Np) self.cyclo_fam = specest.cyclo_fam(Np, P, L) self.connect(src, self.cyclo_fam, sink)
def __init__(self, options): gr.top_block.__init__(self) if options.freq is not None: u = usrp2.sink(options) elif options.outfile is not None: u = gr.file_sink(gr.sizeof_gr_complex, options.outfile) else: raise SystemExit("--freq or --outfile must be specified\n") if options.infile is not None: tx = gr.file_source(gr.sizeof_gr_complex, options.infile) else: tx = qam_rxtx.TX(options) framebytes = tx.framebytes if options.txdata is not None: data = gr.file_source(framebytes * gr.sizeof_char, options.txdata, options.repeat) else: data = qam_rxtx.make_data(framebytes) if options.log: self.connect( data, gr.file_sink(framebytes * gr.sizeof_char, 'tx-data.datb')) self.connect(data, tx) self.sender = ofdm_rxtx.sender_thread(tx.ofdm, options) if options.amp != 1: amp = gr.multiply_const_cc(options.amp) self.connect(tx, amp, u) else: self.connect(tx, u)
def __init__(self, options): gr.top_block.__init__(self) if options.freq is not None: u = usrp2.sink(options) elif options.outfile is not None: u = gr.file_sink(gr.sizeof_gr_complex, options.outfile) else: raise SystemExit("--freq or --outfile must be specified\n") if options.infile is not None: tx = gr.file_source(gr.sizeof_gr_complex, options.infile) else: tx = qam_rxtx.TX(options) framebytes = tx.framebytes if options.txdata is not None: data = gr.file_source(framebytes * gr.sizeof_char, options.txdata, options.repeat) else: data = qam_rxtx.make_data(framebytes) if options.log: self.connect(data, gr.file_sink(framebytes * gr.sizeof_char, 'tx-data.datb')) self.connect(data, tx) self.sender = ofdm_rxtx.sender_thread(tx.ofdm, options) if options.amp != 1: amp = gr.multiply_const_cc(options.amp) self.connect(tx, amp, u) else: self.connect(tx, u)
def __init__(self): #grc_wxgui.top_block_gui.__init__(self, title="Top Block") gr.top_block.__init__(self) print "abc" ################################################## # Variables ################################################## #self.samp_rate = samp_rate = 32000 self.osr = 4 self.key = '' self.configuration = '' self.clock_rate = 52e6 self.input_rate = self.clock_rate / 72 #TODO: what about usrp value? self.gsm_symb_rate = 1625000.0 / 6.0 self.sps = self.input_rate / self.gsm_symb_rate # configure channel filter filter_cutoff = 135e3 #135,417Hz is GSM bandwidth filter_t_width = 10e3 offset = 0.0 ################################################## # Blocks ################################################## self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex*1) print "Input files: ", downfile, " ", upfile self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, downfile, False) self.gr_file_source_1 = gr.file_source(gr.sizeof_gr_complex*1, upfile, False) filter_taps = gr.firdes.low_pass(1.0, self.input_rate, filter_cutoff, filter_t_width, gr.firdes.WIN_HAMMING) print len(filter_taps) self.filter0 = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset, self.input_rate) self.filter1 = gr.freq_xlating_fir_filter_ccf(1, filter_taps, offset, self.input_rate) self.interpolator_1 = gr.fractional_interpolator_cc(0, self.sps) self.tuner_callback = tuner(self) self.synchronizer_callback = synchronizer(self) #self.buffer = howto.buffer_cc() self.burst_cb = burst_callback(self) print ">>>>>Input rate: ", self.input_rate #self.burst = gsm.burst_cf(self.burst_cb,self.input_rate) self.receiver = gsm.receiver_cf(self.tuner_callback, self.synchronizer_callback, self.osr, self.key.replace(' ', '').lower(), self.configuration.upper()) ################################################## # Connections ################################################## #self.connect((self.gr_file_source_0, 0), (self.filter0, 0), (self.burst, 0)) self.connect((self.gr_file_source_1, 0), (self.filter1, 0), (self.interpolator_1, 0), (self.receiver, 0))
def __init__(self): gr.top_block.__init__(self) usage = "%prog: [options] samples_file" parser = OptionParser(option_class=eng_option, usage=usage) parser.add_option("-m", "--dab-mode", type="int", default=1, help="DAB mode [default=%default]") parser.add_option("-c", "--complex", action="store_true", default=False, help="Sample file is float complex (64 bit per sample, 32 I + 32 Q) format") parser.add_option("-n", "--config", type="string", default="channel.conf", help="DAB+ channel configuration file [default=%default]") (options, args) = parser.parse_args () if len(args)<1: print "error: need file with samples" sys.exit(1) else: filename = args[0] if options.complex: src = gr.file_source(gr.sizeof_gr_complex, filename, True) else: sinput = gr.file_source(gr.sizeof_short, filename, True) src = gr.interleaved_short_to_complex() self.connect(sinput, src) self.conf = options.config mode=options.dab_mode param = dabp.parameters(mode) # null symbol detector samples_per_null_sym=param.get_Nnull() #print "samples per null symbol : %d" % samples_per_null_sym nulldet = dabp.detect_null(samples_per_null_sym) # ofdm demod demod = dabp.ofdm_demod(mode) # FIC/MSC demultiplexer demux = dabp.fic_msc_demux(0, mode) # depuncturer punc = dabp.depuncturer_fic(mode) I=punc.getI() # viterbi vit = dabp.vitdec(I) # descrambler scram = dabp.scrambler(I) # FIB sink self.dst = dabp.fib_sink() nullsink = gr.null_sink(gr.sizeof_char) # connect everything self.connect(src, nulldet) self.connect(src, (demod,0)) self.connect(nulldet, (demod,1)) self.connect((demod,0), demux, punc, vit, scram, self.dst) self.connect((demod,1), nullsink)
def __init__(self, demod_class, rx_callback, options): gr.top_block.__init__(self) self.rxpath = receive_path(demod_class, rx_callback, options) self.audio_tx = audio_tx(options.audio_output) if (options.rx_freq is not None): self.source = uhd_receiver(options.args, options.bitrate, options.samples_per_symbol, options.rx_freq, options.rx_gain, options.antenna, options.verbose) options.samples_per_symbol = self.source._sps audio_rate = self.audio_tx.sample_rate usrp_rate = self.source.get_sample_rate() rrate = audio_rate / usrp_rate self.resampler = blks2.pfb_arb_resampler_ccf(rrate) self.connect(self.source, self.resampler, self.rxpath) elif (options.from_file is not None): self.thr = gr.throttle(gr.sizeof_gr_complex, options.bitrate) self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) self.connect(self.source, self.thr, self.rxpath) else: self.thr = gr.throttle(gr.sizeof_gr_complex, 1e6) self.source = gr.null_source(gr.sizeof_gr_complex) self.connect(self.source, self.thr, self.rxpath) self.connect(self.audio_tx)
def __init__(self, decim=32, sync_check=False, satellite='METEOR-M-1', baseband_file=os.environ['HOME'] + '/METEOR-M-1.dat', frames_file=os.environ['HOME'] + '/METEOR-M-1.hrpt'): gr.top_block.__init__(self, "Meteor M N1 HRPT Baseband To Frames") ################################################## # Parameters ################################################## self.decim = decim self.sync_check = sync_check self.satellite = satellite self.baseband_file = baseband_file self.frames_file = frames_file ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim self.sps = sps = sample_rate/sym_rate self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/mn1_hrpt.conf' self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(config_filename) try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat("satname", 'pll_alpha') except: saved_pll_alpha = 0.01 self.saved_pll_alpha = saved_pll_alpha self._saved_clock_alpha_config = ConfigParser.ConfigParser() self._saved_clock_alpha_config.read(config_filename) try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat("satname", 'clock_alpha') except: saved_clock_alpha = 0.01 self.saved_clock_alpha = saved_clock_alpha self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.hs = hs = int(sps/2.0) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.frame_sink = gr.file_sink(gr.sizeof_short*1, frames_file) self.frame_sink.set_unbuffered(False) self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb() self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, saved_clock_alpha**2/4.0, 0.5, saved_clock_alpha, max_clock_offset) self.gr_file_source_0 = gr.file_source(gr.sizeof_short*1, baseband_file, False) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex() self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) self.pll = noaa.hrpt_pll_cf(saved_pll_alpha, saved_pll_alpha**2/4.0, max_carrier_offset) self.poesweather_mn1_hrpt_deframer_0 = poesweather.mn1_hrpt_deframer(sync_check) self.throttle = gr.throttle(gr.sizeof_short*1, sample_rate*10) ################################################## # Connections ################################################## self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.gr_file_source_0, 0), (self.throttle, 0)) self.connect((self.throttle, 0), (self.gr_interleaved_short_to_complex_0, 0)) self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0)) self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_mn1_hrpt_deframer_0, 0)) self.connect((self.poesweather_mn1_hrpt_deframer_0, 0), (self.frame_sink, 0))
def __init__(self, callback, options): gr.top_block.__init__(self) if (options.rx_freq is not None): self.source = uhd_receiver(options.args, options.bandwidth, options.rx_freq, options.rx_gain, options.spec, options.antenna, options.verbose, options.external) elif (options.from_file is not None): self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) else: self.source = gr.null_source(gr.sizeof_gr_complex) # Set up receive path # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) self.rxpath = receive_path(callback, options) self.connect(self.source, self.rxpath) if options.log: self.connect( self.source, gr.file_sink(gr.sizeof_gr_complex, 'rx_benchmark.dat'))
def main(): parser = OptionParser(conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") add_options(parser, expert_grp) (options, args) = parser.parse_args () fft_length = options.fft_length or 512 file = options.file or "input.compl" out = options.out or "output.compl" src = gr.file_source(gr.sizeof_gr_complex,file) sampler = ofdm.vector_sampler( gr.sizeof_gr_complex, fft_length ) trig = gr.vector_source_b([1],True) fft = gr.fft_vcc( fft_length, True, [], True ) mag = gr.complex_to_mag( fft_length ) avg = gr.single_pole_iir_filter_ff(0.01, fft_length) nlog = gr.nlog10_ff( 20, fft_length, -10*math.log10(fft_length) ) dst = gr.file_sink( gr.sizeof_float * fft_length, out ) fg = gr.top_block() fg.connect( src, sampler, fft, mag, avg, nlog, dst ) fg.connect( trig, (sampler,1)) # fg.connect(src,limit, # gr.stream_to_vector(gr.sizeof_gr_complex,fft_length), # fft, # gr.multiply_const_vcc([1./fft_length]*fft_length), # gr.complex_to_mag(fft_length), # gr.nlog10_ff(10.0,fft_length), # dst) # fg.connect( src, fft, dst ) fg.run() print "done"
def build_graph (input, output, coeffs, mag): # Initialize empty flow graph fg = gr.top_block () # Set up file source src = gr.file_source (gr.sizeof_gr_complex, input) # Read coefficients for the matched filter dfile = open(coeffs, 'r') data = [] for line in dfile: data.append(complex(*map(float,line.strip().strip("()").split(" "))).conjugate()) dfile.close() data.reverse() mfilter = gr.fir_filter_ccc(1, data) # If the output is magnitude, it is float, else its complex if mag: magnitude = gr.complex_to_mag(1) dst = gr.file_sink (gr.sizeof_float, output) fg.connect(src, mfilter, magnitude, dst) else: dst = gr.file_sink (gr.sizeof_gr_complex, output) fg.connect(src, mfilter, dst) return fg
def __init__(self, app, samp_rate, at, filename, repeat, sine): ''' in: - app = object of type RXApp - samp_rate = sample rate in Hertz - at = attenuation factor - filename = filename - repeat = if True them reads in a loop the file - sine ''' gr.hier_block2.__init__(self, "RXData", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)) # instance variables self.app = app if sine: self.fileSrc = gr.sig_source_f(samp_rate, gr.GR_SIN_WAVE, 1000, 1.0) else: self.fileSrc = gr.file_source(gr.sizeof_float*1, filename, repeat) # self.fileSrc = gr.sig_source_f(samp_rate, gr.GR_SIN_WAVE, 1000, 1.0) # self.fileSrc = gr.sig_source_f(samp_rate, gr.GR_CONST_WAVE, 1000, 1.0) self.mulitplyCte = gr.multiply_const_vff((at, )) self.f2c = gr.float_to_complex(1) #EO instance variables self.__makeConnections()
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-c", "--calibration", type="eng_float", default=0, help="freq offset") parser.add_option("-g", "--gain", type="eng_float", default=1) parser.add_option("-i", "--input-file", type="string", default="in.dat", help="specify the input file") parser.add_option("-o", "--output-file", type="string", default="out.dat", help="specify the output file") parser.add_option("-r", "--new-sample-rate", type="int", default=96000, help="output sample rate") parser.add_option("-s", "--sample-rate", type="int", default=48000, help="input sample rate") (options, args) = parser.parse_args() sample_rate = options.sample_rate new_sample_rate = options.new_sample_rate IN = gr.file_source(gr.sizeof_gr_complex, options.input_file) OUT = gr.file_sink(gr.sizeof_gr_complex, options.output_file) LO = gr.sig_source_c(sample_rate, gr.GR_COS_WAVE, options.calibration, 1.0, 0) MIXER = gr.multiply_cc() AMP = gr.multiply_const_cc(options.gain) nphases = 32 frac_bw = 0.05 p1 = frac_bw p2 = frac_bw rs_taps = gr.firdes.low_pass(nphases, nphases, p1, p2) #RESAMP = blks2.pfb_arb_resampler_ccf(float(sample_rate) / float(new_sample_rate), (rs_taps), nphases, ) RESAMP = blks2.pfb_arb_resampler_ccf(float(new_sample_rate) / float(sample_rate), (rs_taps), nphases, ) self.connect(IN, (MIXER, 0)) self.connect(LO, (MIXER, 1)) self.connect(MIXER, AMP, RESAMP, OUT)
def __init__(self, options, queue): gr.top_block.__init__(self) if options.filename is not None: self.u = gr.file_source(gr.sizeof_gr_complex, options.filename) else: self.u = uhd.usrp_source(options.addr, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) if options.subdev is not None: self.u.set_subdev_spec(options.subdev, 0) self.u.set_samp_rate(options.rate) self._freq_offset = options.error #print "Frequency offset is %i" % self._freq_offset self._actual_freq = 162.0e6 - self._freq_offset #tune between the two AIS freqs #print "Tuning to: %fMHz" % float(self._actual_freq / 1e6) if not (self.tune(self._actual_freq)): print "Failed to set initial frequency" if options.gain is None: #set to halfway g = self.u.get_gain_range() options.gain = (g.start() + g.stop()) / 2.0 #print "Setting gain to %i" % options.gain self.u.set_gain(options.gain) #here we're setting up TWO receivers, designated A and B. A is on 161.975, B is on 162.025. they both output data to the queue. self.ais_rx(self.u, 161.975e6 - 162.0e6, "A", options, queue) self.ais_rx(self.u, 162.025e6 - 162.0e6, "B", options, queue)
def __init__(self, demodulator, rx_callback, options): gr.top_block.__init__(self) if (options.rx_freq is not None): # Work-around to get the modulation's bits_per_symbol args = demodulator.extract_kwargs_from_options(options) symbol_rate = options.bitrate / demodulator( **args).bits_per_symbol() self.source = uhd_receiver(options.args, symbol_rate, options.samples_per_symbol, options.rx_freq, options.rx_gain, options.spec, options.antenna, options.verbose) options.samples_per_symbol = self.source._sps elif (options.from_file is not None): sys.stderr.write( ("Reading samples from '%s'.\n\n" % (options.from_file))) self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) else: sys.stderr.write( "No source defined, pulling samples from null source.\n\n") self.source = gr.null_source(gr.sizeof_gr_complex) # Set up receive path # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) self.rxpath = receive_path(demodulator, rx_callback, options) self.connect(self.source, self.rxpath)
def __init__(self): gr.top_block.__init__(self) input_sample_rate = 1e6 symbol_rate = 152.34e3 output_samples_per_symbol = 5 output_sample_rate = output_samples_per_symbol * symbol_rate # least common multiple lcm = gru.lcm(input_sample_rate, output_sample_rate) intrp = int(lcm // input_sample_rate) decim = int(lcm // output_sample_rate) print intrp print decim resampler = blks2.rational_resampler_ccc(intrp, decim, None, None) src = gr.file_source(gr.sizeof_gr_complex, "infile") sink = gr.file_sink(gr.sizeof_float, "outfile") f2c = gr.float_to_complex() c2r = gr.complex_to_real() #ddc_coeffs = \ #gr.firdes.low_pass (1.0, # gain #input_sample_rate, # sampling rate #2e3, # low pass cutoff freq #6e3, # width of trans. band #gr.firdes.WIN_HANN) # just grab the lower sideband: #ddc = gr.freq_xlating_fir_filter_ccf(1,ddc_coeffs,-111.5e3,input_sample_rate) qdemod = gr.quadrature_demod_cf(1.0) lp_coeffs = \ gr.firdes.low_pass (1.0, # gain output_sample_rate, # sampling rate symbol_rate, # low pass cutoff freq symbol_rate, # width of trans. band gr.firdes.WIN_HANN) lp = gr.fir_filter_fff(1, lp_coeffs) self.connect(src, resampler, qdemod, lp, sink)
def __init__(self,options): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) #CHANGE ME self.cog_phy_0=phy.cog_phy(options.args) # dest_addt,source_addr,max_attempts,time_out #self.probe_0=probe.probe(0,1) self.probe_0=gr.probe_avg_mag_sqrd_c(-30) #self.ss_chain_0=spectrum_sense.pwrfft_c(200e3,1024,25,) self.mac_0=csma.csma_mac(options.dest_addr,options.source_addr,options.max_attempts,options.time_out,0.05,0.0001,10000,self.probe_0,1e-6) self.wake_up=heart_beat.heart_beat("check","wake_up",0.001) #CHANGE ME print options.input_file self.gr_file_source_0 = gr.file_source(gr.sizeof_char*1,options.input_file, True) #CHANGE ME self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char*1, options.output_file) self.gr_file_sink_0.set_unbuffered(True) self.extras_stream_to_datagram_0 = grextras.Stream2Datagram(1, options.pkt_size) self.extras_datagram_to_stream_0 = grextras.Datagram2Stream(1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=990e6, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=1e6, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot of source usrp", peak_hold=True, ) #self.Add(self.wxgui_fftsink2_0.win) #self.tags_d_0=tags_demo.tags_demo() #self.extras_stream_to_datagram_1 = grextras.Stream2Datagram(1, 256) #self.extras_datagram_to_stream_1 = grextras.Datagram2Stream(1) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.extras_stream_to_datagram_0, 0)) self.connect((self.extras_stream_to_datagram_0,0),(self.mac_0,1)) self.connect((self.cog_phy_0,0),(self.mac_0,0)) self.connect((self.mac_0,0),(self.cog_phy_0,0)) self.connect((self.mac_0,1),(self.extras_datagram_to_stream_0,0)) self.connect((self.extras_datagram_to_stream_0,0),(self.gr_file_sink_0,0)) #self.connect((self.cog_phy_0,1),(self.wxgui_fftsink2_0,0)) self.connect((self.wake_up,0),(self.mac_0,2)) #self.connect((self.cog_phy_0,1),(self.mac_0,3)) self.connect((self.cog_phy_0,1),(self.probe_0,0)) """self.connect((self.gr_file_source_1, 0), (self.extras_stream_to_datagram_1, 0))
def setUp (self): self.tb = gr.top_block () print "qa_block_tests" fftl = 512 I = 768 D = 1000 #mod=scipy.io.loadmat('/home/demel/exchange/matlab_mat_t.mat') #mat_u1=tuple(mod['mat_t'].flatten()) #mat_d=range(len(mat_u1)) #for idx, val in enumerate(mat_u1): # mat_d[idx]=val #intu1=tuple(mat_d) #print len(intu1)/fftl # source and conversion from float to char #self.src = gr.vector_source_c(intu1,False,fftl) #self.fft = gr.fft_vcc(fftl,True,window.rectangular(fftl),False,1) #self.snk = gr.vector_sink_c(fftl)Messung_LTE_2012-05-23_12:49:57_xae self.src = gr.file_source(gr.sizeof_gr_complex,'/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:49:57_xae.dat', False) self.resample = blks2.rational_resampler_ccc(I, D) self.snk = gr.file_sink(gr.sizeof_gr_complex, '/home/demel/Dokumente/LTE_Resample_test.dat') self.tb.connect(self.src,self.resample,self.snk)
def __init__(self, filename=None, capture=None, verbose=False, freq_error=-0.0021875): gr.top_block.__init__(self) self.verbose = verbose self.rx_chips_min = 16 self.chip_error_threshold = 10 if None != filename: self.source = gr.file_source(gr.sizeof_gr_complex, filename) else: self.source = osmosdr.source_c( args="nchan=" + str(1) + " " + "" ) #print self.source.get_gain_range().to_pp_string() self.source.set_sample_rate(1.6e6) self.source.set_center_freq(868.95e6, 0) self.source.set_freq_corr(0, 0) self.source.set_gain_mode(0, 0) # -1.0 1.5 4.0 6.5 9.0 11.5 14.0 16.5 19.0 21.5 24.0 29.0 34.0 42.0 self.source.set_gain(14, 0) self.source.set_if_gain(42, 0) if None != capture: self.sink = gr.file_sink(gr.sizeof_gr_complex, capture) else: self.msgq = gr.msg_queue(4) self.sink = wmbus_phy1(msgq=self.msgq, verbose=verbose, freq_error=freq_error); self._watcher = _queue_watcher_thread(self.msgq, self.callback) self.connect(self.source, self.sink)
def __init__(self, input_path, sample_rate, output_path): gr.top_block.__init__(self) # We don't use the existing NBFM demodulator block because it # contains a lowpass output filter which is unsuitable for 9600 # GMSK (it's designed for voice). self.source = gr.file_source(gr.sizeof_gr_complex * 1, input_path, False) self.low_pass_filter = gr.fir_filter_ccf( 4, firdes.low_pass(1, sample_rate, 15000, 100, firdes.WIN_HAMMING, 6.76) ) # High pass filter to remove the DC component. This is important # when the signal is near the SDR's local oscillator. # NOTE(tstranex): Disabled since we are now shifting the FCD # center frequency instead. # self.high_pass_filter = gr.fir_filter_ccf(1, firdes.high_pass( # 1, sample_rate/4, 100, 100, firdes.WIN_HAMMING, 6.76)) self.quadrature_demod = gr.quadrature_demod_cf(sample_rate / 4 / (2 * 3.14 * 3000)) self.fm_deemph = blks2.fm_deemph(fs=sample_rate / 4, tau=75e-6) self.boost_volume = gr.multiply_const_vff((1.52,)) self.sink = gr.wavfile_sink(output_path, 1, sample_rate / 4, 16) self.connect((self.source, 0), (self.low_pass_filter, 0)) # self.connect((self.low_pass_filter, 0), (self.high_pass_filter, 0)) # self.connect((self.high_pass_filter, 0), (self.quadrature_demod, 0)) self.connect((self.low_pass_filter, 0), (self.quadrature_demod, 0)) self.connect((self.quadrature_demod, 0), (self.fm_deemph, 0)) self.connect((self.fm_deemph, 0), (self.boost_volume, 0)) self.connect((self.boost_volume, 0), (self.sink, 0))
def build_graph (input, raw, snr, freq_offset, coeffs, mag): # Initialize empty flow graph fg = gr.top_block () # Set up file source src = gr.file_source (1, input) # Set up GMSK modulator, 2 samples per symbol mod = gmsk_mod(2) # Amplify the signal tx_amp = 1 amp = gr.multiply_const_cc(1) amp.set_k(tx_amp) # Compute proper noise voltage based on SNR SNR = 10.0**(snr/10.0) power_in_signal = abs(tx_amp)**2 noise_power = power_in_signal/SNR noise_voltage = math.sqrt(noise_power) # Generate noise rseed = int(time.time()) noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_voltage, rseed) adder = gr.add_cc() fg.connect(noise, (adder, 1)) # Create the frequency offset, 0 for now offset = gr.sig_source_c(1, gr.GR_SIN_WAVE, freq_offset, 1.0, 0.0) mixer = gr.multiply_cc() fg.connect(offset, (mixer, 1)) # Pass the noisy data to the matched filter dfile = open(coeffs, 'r') data = [] for line in dfile: data.append(complex(*map(float,line.strip().strip("()").split(" "))).conjugate()) dfile.close() data.reverse() mfilter = gr.fir_filter_ccc(1, data) # Connect the flow graph fg.connect(src, mod) fg.connect(mod, (mixer, 0)) fg.connect(mixer, (adder, 0)) if mag: raw_dst = gr.file_sink (gr.sizeof_float, raw) magnitude = gr.complex_to_mag(1) fg.connect(adder, mfilter, magnitude, raw_dst) else: raw_dst = gr.file_sink (gr.sizeof_gr_complex, raw) fg.connect(adder, mfilter, raw_dst) print "SNR(db): " + str(snr) print "Frequency Offset: " + str(freq_offset) return fg
def main(): gr.enable_realtime_scheduling() tb = gr.top_block () src = gr.file_source(gr.sizeof_gr_complex, "transmit-data.dat", True) parser = OptionParser(option_class=eng_option, conflict_handler="resolve") (options, args) = parser.parse_args () d = {'verbose': True, 'discontinuous': False, 'samples_per_symbol': 2, 'usrpx': None, 'interp': INTERP, 'fusb_block_size': 0, 'megabytes': 1.0, 'rx_freq': 2.475e9, 'size': 1500, 'show_tx_gain_range': False, 'log': False, 'tx_subdev_spec': None, 'fusb_nblocks': 0, 'lo_offset': None, 'tx_gain': TXGAIN, 'which': 0, 'modulation': 'gmsk', 'excess_bw': 0.34999999999999998, 'bt': 0.34999999999999998, 'interface': 'eth0', 'freq': None, 'bitrate': 100000.0, 'from_file': None, 'tx_freq': 2475000000.0, 'mac_addr': '', 'tx_amplitude': 0.1, 'gray_code': True} for i, j in d.items(): setattr(options, i, j) u = usrp_options.create_usrp_sink(options) dac_rate = u.dac_rate() if options.verbose: print 'USRP Sink:', u (_bitrate, _samples_per_symbol, _interp) = \ pick_tx_bitrate(options.bitrate, 2, \ options.samples_per_symbol, options.interp, dac_rate, \ u.get_interp_rates()) u.set_interp(_interp) u.set_auto_tr(True) if not u.set_center_freq(options.tx_freq): print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(options.tx_freq)) raise ValueError, eng_notation.num_to_str(options.tx_freq) m = gr.multiply_const_cc(CONSTANT) tb.connect(src, m, u) tb.run()
def __init__(self): gr.top_block.__init__(self) input_sample_rate = 1e6 symbol_rate = 152.34e3 output_samples_per_symbol = 5 output_sample_rate = output_samples_per_symbol * symbol_rate # least common multiple lcm = gru.lcm(input_sample_rate, output_sample_rate) intrp = int(lcm // input_sample_rate) decim = int(lcm // output_sample_rate) print intrp print decim resampler = blks2.rational_resampler_ccc(intrp, decim, None, None) src = gr.file_source(gr.sizeof_gr_complex, "infile") sink = gr.file_sink(gr.sizeof_float, "outfile") f2c = gr.float_to_complex() c2r = gr.complex_to_real() #ddc_coeffs = \ #gr.firdes.low_pass (1.0, # gain #input_sample_rate, # sampling rate #2e3, # low pass cutoff freq #6e3, # width of trans. band #gr.firdes.WIN_HANN) # just grab the lower sideband: #ddc = gr.freq_xlating_fir_filter_ccf(1,ddc_coeffs,-111.5e3,input_sample_rate) qdemod = gr.quadrature_demod_cf(1.0) lp_coeffs = \ gr.firdes.low_pass (1.0, # gain output_sample_rate, # sampling rate symbol_rate, # low pass cutoff freq symbol_rate, # width of trans. band gr.firdes.WIN_HANN) lp = gr.fir_filter_fff (1,lp_coeffs) self.connect(src,resampler,qdemod,lp,sink)
def __init__(self): gr.top_block.__init__(self, "Top Block") options = get_options() self.input_file = options.input_file self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex * 1, self.input_file, True) symbol_rate = 18000 sps = 2 # output rate will be 36,000 out_sample_rate = symbol_rate * sps options.low_pass = options.low_pass / 2.0 self.demod = cqpsk.cqpsk_demod(samples_per_symbol=sps, excess_bw=0.35, costas_alpha=0.03, gain_mu=0.05, mu=0.05, omega_relative_limit=0.05, log=options.log, verbose=options.verbose) self.output = gr.file_sink(gr.sizeof_float, options.output_file) self.connect(self.gr_file_source_0, self.demod, self.output)
def __init__(self, callback, options): gr.top_block.__init__(self) if (options.rx_freq is not None): self.source = uhd_receiver(options.args, options.bandwidth, options.rx_freq, options.rx_gain, options.spec, options.antenna, options.verbose) elif (options.from_file is not None): self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) else: self.source = gr.null_source(gr.sizeof_gr_complex) # Set up receive path # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) if (options.tx_freq is not None): self.sink = uhd_transmitter(options.args, options.bandwidth, options.tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose) elif (options.to_file is not None): self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) else: self.sink = gr.null_sink(gr.sizeof_gr_complex) self.source.set_sample_rate(1500000) #rx sample rate self.sink.set_sample_rate(640000) self.rxpath = receive_path(callback, options) self.txpath = transmit_path(options) self.connect(self.source, self.rxpath) self.connect(self.txpath, self.sink) self.source.set_antenna("RX2") global freq freq = options.tx_freq # - 12e6
def __init__(self, input_path, sample_rate, output_path): gr.top_block.__init__(self) # We don't use the existing NBFM demodulator block because it # contains a lowpass output filter which is unsuitable for 9600 # GMSK (it's designed for voice). self.source = gr.file_source(gr.sizeof_gr_complex * 1, input_path, False) self.low_pass_filter = gr.fir_filter_ccf( 4, firdes.low_pass(1, sample_rate, 15000, 100, firdes.WIN_HAMMING, 6.76)) # High pass filter to remove the DC component. This is important # when the signal is near the SDR's local oscillator. # NOTE(tstranex): Disabled since we are now shifting the FCD # center frequency instead. #self.high_pass_filter = gr.fir_filter_ccf(1, firdes.high_pass( # 1, sample_rate/4, 100, 100, firdes.WIN_HAMMING, 6.76)) self.quadrature_demod = gr.quadrature_demod_cf(sample_rate / 4 / (2 * 3.14 * 3000)) self.fm_deemph = blks2.fm_deemph(fs=sample_rate / 4, tau=75e-6) self.boost_volume = gr.multiply_const_vff((1.52, )) self.sink = gr.wavfile_sink(output_path, 1, sample_rate / 4, 16) self.connect((self.source, 0), (self.low_pass_filter, 0)) #self.connect((self.low_pass_filter, 0), (self.high_pass_filter, 0)) #self.connect((self.high_pass_filter, 0), (self.quadrature_demod, 0)) self.connect((self.low_pass_filter, 0), (self.quadrature_demod, 0)) self.connect((self.quadrature_demod, 0), (self.fm_deemph, 0)) self.connect((self.fm_deemph, 0), (self.boost_volume, 0)) self.connect((self.boost_volume, 0), (self.sink, 0))
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-F", "--filename", type="string", default="audio.dat", help="read input from FILE") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") parser.add_option("-R", "--repeat", action="store_true", default=False) parser.add_option( "-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) src = gr.file_source(gr.sizeof_float, options.filename, options.repeat) dst = audio.sink(sample_rate, options.audio_output) self.connect(src, dst)
def _setup_head(self): """ Sets up the input of the flow graph, i.e. determine which kind of file source is necessary. """ if self.filename[-4:].lower() == '.wav': if self.options.verbose: print 'Reading data from a WAV file.' src = gr.wavfile_source(self.filename, True) f2c = gr.float_to_complex() self.connect((src, 0), (f2c, 0)) if src.channels() == 2: self.connect((src, 1), (f2c, 1)) self.connect(f2c, self.head) else: if self.options.verbose: print 'Reading data from a raw data file.' src = gr.file_source(self.options.sample_size, self.filename, True) if self.options.sample_size == gr.sizeof_float: f2c = gr.float_to_complex() self.connect(src, f2c, self.head) if self.options.verbose: print ' Input data is considered real.' else: self.connect(src, self.head) if self.options.verbose: print ' Input data is considered complex.'
def graph (args): print os.getpid() nargs = len (args) if nargs == 1: infile = args[0] else: sys.stderr.write('usage: interp.py input_file\n') sys.exit (1) tb = gr.top_block () srcf = gr.file_source (gr.sizeof_short,infile) s2ss = gr.stream_to_streams(gr.sizeof_short,2) s2f1 = gr.short_to_float() s2f2 = gr.short_to_float() src0 = gr.float_to_complex() lp_coeffs = gr.firdes.low_pass ( 3, 19.2e6, 3.2e6, .5e6, gr.firdes.WIN_HAMMING ) lp = gr.interp_fir_filter_ccf ( 3, lp_coeffs ) file = gr.file_sink(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1") tb.connect( srcf, s2ss ) tb.connect( (s2ss, 0), s2f1, (src0,0) ) tb.connect( (s2ss, 1), s2f2, (src0,1) ) tb.connect( src0, lp, file) tb.start() raw_input ('Head End: Press Enter to stop') tb.stop()
def __init__(self, options): gr.hier_block2.__init__(self, "transmit_path", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) # constants for usrp usrp_rate = 128000000 usrp_interp = 200 tari_rate = 40000 gain = 5000 run_usrp = True testit = False if testit: self.downlink = gr.file_source(gr.sizeof_gr_complex, "readout.dat", True) else: self.downlink = rfidbts.downlink_src(samp_per_delimiter=8, samp_per_cw=64 * 16 * 60, samp_per_wait=64 * 16 * 4, samp_per_tari=16, samp_per_pw=8, samp_per_trcal=53, samp_per_data1=32) if run_usrp: self.sink = downlink_usrp_sink(options, usrp_rate, usrp_interp, tari_rate) else: self.sink = downlink_test_file_sink(usrp_rate, usrp_interp) self.gain = gr.multiply_const_cc(gain) self.connect(self.downlink, self.gain, self.sink)
def __init__(self, filename=None, capture=None, verbose=False, freq_error=-0.0021875): gr.top_block.__init__(self) self.verbose = verbose self.rx_chips_min = 16 self.chip_error_threshold = 10 if None != filename: self.source = gr.file_source(gr.sizeof_gr_complex, filename) else: self.source = osmosdr.source_c(args="nchan=" + str(1) + " " + "") #print self.source.get_gain_range().to_pp_string() self.source.set_sample_rate(1.6e6) self.source.set_center_freq(868.95e6, 0) self.source.set_freq_corr(0, 0) self.source.set_gain_mode(0, 0) # -1.0 1.5 4.0 6.5 9.0 11.5 14.0 16.5 19.0 21.5 24.0 29.0 34.0 42.0 self.source.set_gain(14, 0) self.source.set_if_gain(42, 0) if None != capture: self.sink = gr.file_sink(gr.sizeof_gr_complex, capture) else: self.msgq = gr.msg_queue(4) self.sink = wmbus_phy1(msgq=self.msgq, verbose=verbose, freq_error=freq_error) self._watcher = _queue_watcher_thread(self.msgq, self.callback) self.connect(self.source, self.sink)
def __init__(self, filename, lo_freq, audio_rate, if_rate): gr.hier_block2.__init__(self, "pipeline", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)) try: src = gr.file_source (gr.sizeof_float, filename, True) except RuntimeError: sys.stderr.write(("\nError: Could not open file '%s'\n\n" % \ filename)) sys.exit(1) print audio_rate, if_rate fmtx = blks2.nbfm_tx (audio_rate, if_rate, max_dev=5e3, tau=75e-6) # Local oscillator lo = gr.sig_source_c (if_rate, # sample rate gr.GR_SIN_WAVE, # waveform type lo_freq, #frequency 1.0, # amplitude 0) # DC Offset mixer = gr.multiply_cc () self.connect (src, fmtx, (mixer, 0)) self.connect (lo, (mixer, 1)) self.connect (mixer, self)
def graph(args): print os.getpid() nargs = len(args) if nargs == 1: infile = args[0] else: sys.stderr.write('usage: interp.py input_file\n') sys.exit(1) tb = gr.top_block() srcf = gr.file_source(gr.sizeof_short, infile) s2ss = gr.stream_to_streams(gr.sizeof_short, 2) s2f1 = gr.short_to_float() s2f2 = gr.short_to_float() src0 = gr.float_to_complex() lp_coeffs = gr.firdes.low_pass(3, 19.2e6, 3.2e6, .5e6, gr.firdes.WIN_HAMMING) lp = gr.interp_fir_filter_ccf(3, lp_coeffs) file = gr.file_sink(gr.sizeof_gr_complex, "/tmp/atsc_pipe_1") tb.connect(srcf, s2ss) tb.connect((s2ss, 0), s2f1, (src0, 0)) tb.connect((s2ss, 1), s2f2, (src0, 1)) tb.connect(src0, lp, file) tb.start() raw_input('Head End: Press Enter to stop') tb.stop()
def __init__(self): gr.top_block.__init__(self) usage = "%prog: [options] samples_file" parser = OptionParser(option_class=eng_option, usage=usage) (options, args) = parser.parse_args () if len(args)<1: # print "using gaussian noise as source" # self.sigsrc = gr.noise_source_c(gr.GR_GAUSSIAN,10e6) print "using repeating random vector as source" self.sigsrc = gr.vector_source_c([10e6*(random.random() + 1j*random.random()) for i in range(0,100000)],True) self.src = gr.throttle( gr.sizeof_gr_complex,2048000) self.connect(self.sigsrc, self.src) else: filename = args[0] print "using samples from file " + filename self.src = gr.file_source(gr.sizeof_gr_complex, filename, False) dp = parameters.dab_parameters(1) rp = parameters.receiver_parameters(1) self.sync_dab = ofdm_sync_dab(dp, rp, False) self.nop0 = gr.nop(gr.sizeof_gr_complex) self.nop1 = gr.nop(gr.sizeof_char) self.connect(self.src, self.sync_dab, self.nop0) self.connect((self.sync_dab,1), self.nop1)
def __init__(self, decim=32, pll_alpha=0.01, clock_alpha=0.01, input_filename="frames.hrpt"): gr.top_block.__init__(self, "Hrpt Decode") ################################################## # Parameters ################################################## self.decim = decim self.pll_alpha = pll_alpha self.clock_alpha = clock_alpha self.input_filename = input_filename ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim self.sps = sps = sample_rate/sym_rate self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.hs = hs = int(sps/2.0) ################################################## # Blocks ################################################## self.decoder = noaa.hrpt_decoder(True,True) self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False) ################################################## # Connections ################################################## self.connect((self.file_source, 0), (self.decoder, 0))
def __init__(self): gr.top_block.__init__(self, "Resample measured data") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:47:32.dat", False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_gr_complex*1, "/home/demel/gr-lte/data/Messung_Resampled_3072MSps.dat") self.gr_file_sink_0.set_unbuffered(False) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=3072, decimation=1000, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_file_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
def __init__(self, demodulator, rx_callback, options): gr.top_block.__init__(self) if(options.rx_freq is not None): # Work-around to get the modulation's bits_per_symbol args = demodulator.extract_kwargs_from_options(options) symbol_rate = options.bitrate / demodulator(**args).bits_per_symbol() self.source = uhd_receiver(options.args, symbol_rate, options.samples_per_symbol, options.rx_freq, options.rx_gain, options.spec, options.antenna,1) #options.verbose) options.samples_per_symbol = self.source._sps elif(options.from_file is not None): sys.stderr.write(("Reading samples from '%s'.\n\n" % (options.from_file))) self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) else: sys.stderr.write("No source defined, pulling samples from null source.\n\n") self.source = gr.null_source(gr.sizeof_gr_complex) # Set up receive path # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) self.rxpath = receive_path(demodulator, rx_callback, options) self.connect(self.source, self.rxpath)
def __init__(self, options, queue): gr.top_block.__init__(self) if options.filename is not None: self.u = gr.file_source(gr.sizeof_gr_complex, options.filename) else: self.u = uhd.usrp_source(options.addr, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) if options.subdev is not None: self.u.set_subdev_spec(options.subdev, 0) self.u.set_samp_rate(options.rate) self._freq_offset = options.error #print "Frequency offset is %i" % self._freq_offset self._actual_freq = 162.0e6 - self._freq_offset #tune between the two AIS freqs #print "Tuning to: %fMHz" % float(self._actual_freq / 1e6) if not(self.tune(self._actual_freq)): print "Failed to set initial frequency" if options.gain is None: #set to halfway g = self.u.get_gain_range() options.gain = (g.start()+g.stop()) / 2.0 #print "Setting gain to %i" % options.gain self.u.set_gain(options.gain) #here we're setting up TWO receivers, designated A and B. A is on 161.975, B is on 162.025. they both output data to the queue. self.ais_rx(self.u, 161.975e6 - 162.0e6, "A", options, queue); self.ais_rx(self.u, 162.025e6 - 162.0e6, "B", options, queue);
def __init__(self, ifile, ofile, options): gr.top_block.__init__(self) SNR = 10.0**(options.snr / 10.0) time_offset = options.time_offset phase_offset = options.phase_offset * (math.pi / 180.0) # calculate noise voltage from SNR power_in_signal = abs(options.tx_amplitude)**2 noise_power = power_in_signal / SNR noise_voltage = math.sqrt(noise_power) print "Noise voltage: ", noise_voltage frequency_offset = options.frequency_offset / options.fft_length self.src = gr.file_source(gr.sizeof_gr_complex, ifile) #self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate) self.channel = gr.channel_model(noise_voltage, frequency_offset, time_offset, noise_seed=-random.randint(0, 100000)) self.phase = gr.multiply_const_cc( complex(math.cos(phase_offset), math.sin(phase_offset))) self.snk = gr.file_sink(gr.sizeof_gr_complex, ofile) self.connect(self.src, self.channel, self.phase, self.snk)
def __init__(self,options,Freq): gr.top_block.__init__(self) if options.input_file == "": self.IS_USRP2 = True else: self.IS_USRP2 = False #self.min_freq = options.start #self.max_freq = options.stop self.min_freq = Freq.value-(3*10**6) # same as that of the transmitter bandwidth ie 6MHZ approx for a given value of decimation line option any more self.max_freq = Freq.value+(3*10**6) if self.min_freq > self.max_freq: self.min_freq, self.max_freq = self.max_freq, self.min_freq # swap them print "Start and stop frequencies order swapped!" self.fft_size = options.fft_size self.ofdm_bins = options.sense_bins # build graph s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) mywindow = window.blackmanharris(self.fft_size) fft = gr.fft_vcc(self.fft_size, True, mywindow) power = 0 for tap in mywindow: power += tap*tap c2mag = gr.complex_to_mag_squared(self.fft_size) #log = gr.nlog10_ff(10, self.fft_size, -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) # modifications for USRP2 if self.IS_USRP2: self.u = uhd.usrp_source(options.args,uhd.io_type.COMPLEX_FLOAT32,num_channels=1) # Modified Line # self.u.set_decim(options.decim) # samp_rate = self.u.adc_rate()/self.u.decim() samp_rate = 100e6/options.decim # modified sampling rate self.u.set_samp_rate(samp_rate) else: self.u = gr.file_source(gr.sizeof_gr_complex,options.input_file, True) samp_rate = 100e6 /options.decim # modified sampling rate self.freq_step =0 #0.75* samp_rate self.min_center_freq = (self.min_freq + self.max_freq)/2 global BW BW = self.max_freq - self.min_freq global size size=self.fft_size global ofdm_bins ofdm_bins = self.ofdm_bins global usr #global thrshold_inorder usr=samp_rate nsteps = 10 self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step) self.next_freq = self.min_center_freq tune_delay = max(0, int(round(options.tune_delay * samp_rate / self.fft_size))) # in fft_frames dwell_delay = max(1, int(round(options.dwell_delay * samp_rate / self.fft_size))) # in fft_frames self.msgq = gr.msg_queue(16) # thread-safe message queue self._tune_callback = tune(self) # hang on to this to keep it from being GC'd stats = gr.bin_statistics_f(self.fft_size, self.msgq, self._tune_callback, tune_delay, dwell_delay) # control scanning and record frequency domain statistics self.connect(self.u, s2v, fft,c2mag,stats) if options.gain is None: g = self.u.get_gain_range() options.gain = float(g.start()+g.stop())/2 # if no gain was specified, use the mid-point in dB
def __init__(self, infile="data", samp_rate=1000000): gr.top_block.__init__(self, "Replay") ################################################## # Parameters ################################################## self.infile = infile self.samp_rate = samp_rate ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(915000000, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, infile, False) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self, options, payload=''): gr.top_block.__init__(self) if(options.tx_freq is not None): self.sink = uhd_transmitter(options.args, options.bandwidth, options.tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose) elif(options.to_file is not None): self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) else: self.sink = gr.null_sink(gr.sizeof_gr_complex) options.interp = 100e6/options.bandwidth # FTW-specific convertion # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) if(options.from_file is None): self.txpath = ftw_transmit_path(options, payload) else: self.txpath = gr.file_source(gr.sizeof_gr_complex, options.from_file); # options.tx_amplitude = 1 # static value to make sure we do not exceed +-1 for the floats being sent to the sink self._tx_amplitude = options.tx_amplitude self.amp = gr.multiply_const_cc(self._tx_amplitude) # self.txpath = ftw_pnc_transmit_path(options, payload) self.connect(self.txpath, self.amp, self.sink) if options.log: self.connect(self.txpath, gr.file_sink(gr.sizeof_gr_complex, 'ftw_benchmark.dat'))
def __init__(self,file): """ Pad tranport stream packets to 256 bytes,add header bytes and reformat appropriately. @param ts: MPEG transport stream. @type ts: MPEG TS sequence of bytes; len(ts) % 188 == 0 """ ######################################################### # Python code for creating MPEG TS source and padding. #ts = create_transport_stream_packet(packets_number,file) #src = gr.file_source(gr.sizeof_char*1, file, False) #pad = pad_stream(ts, 256, 68) #src = gr.vector_source_b(ts,False,1) ######################################################### src = gr.file_source(gr.sizeof_char*1, file, False) pad = dvbt_swig.pad() #randomizer = dvbt_swig.randomizer() gr.hier_block2.__init__(self, "dvbt_source", gr.io_signature(0, 0, 0), pad.output_signature()) self.connect(src, pad, self)
def __init__(self, demod_class, rx_callback, options): gr.top_block.__init__(self) self.rxpath = receive_path(demod_class, rx_callback, options) self.audio_tx = audio_tx(options.audio_output) if(options.rx_freq is not None): self.source = uhd_receiver(options.args, options.bitrate, options.samples_per_symbol, options.rx_freq, options.rx_gain, options.antenna, options.verbose) options.samples_per_symbol = self.source._sps audio_rate = self.audio_tx.sample_rate usrp_rate = self.source.get_sample_rate() rrate = audio_rate / usrp_rate self.resampler = blks2.pfb_arb_resampler_ccf(rrate) self.connect(self.source, self.resampler, self.rxpath) elif(options.from_file is not None): self.thr = gr.throttle(gr.sizeof_gr_complex, options.bitrate) self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) self.connect(self.source, self.thr, self.rxpath) else: self.thr = gr.throttle(gr.sizeof_gr_complex, 1e6) self.source = gr.null_source(gr.sizeof_gr_complex) self.connect(self.source, self.thr, self.rxpath) self.connect(self.audio_tx)
def __init__(self, infile="data", samp_rate=1000000, outfile="data.wav", amp=70): gr.top_block.__init__(self, "Analyze") ################################################## # Parameters ################################################## self.infile = infile self.samp_rate = samp_rate self.outfile = outfile self.amp = amp ################################################## # Blocks ################################################## self.gr_wavfile_sink_0 = gr.wavfile_sink(outfile, 3, samp_rate, 16) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((amp, )) self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, infile, False) self.gr_complex_to_mag_0 = gr.complex_to_mag(1) self.gr_complex_to_float_0 = gr.complex_to_float(1) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_complex_to_float_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_complex_to_mag_0, 0)) self.connect((self.gr_complex_to_mag_0, 0), (self.gr_wavfile_sink_0, 2)) self.connect((self.gr_complex_to_float_0, 1), (self.gr_wavfile_sink_0, 1)) self.connect((self.gr_complex_to_float_0, 0), (self.gr_wavfile_sink_0, 0))
def __init__(self, options, payload=''): gr.top_block.__init__(self) if (options.tx_freq is not None): self.sink = uhd_transmitter(options.args, options.bandwidth, options.tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose) elif (options.to_file is not None): self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) else: self.sink = gr.null_sink(gr.sizeof_gr_complex) options.interp = 100e6 / options.bandwidth # FTW-specific convertion # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) if (options.from_file is None): self.txpath = ftw_transmit_path(options, payload) else: self.txpath = gr.file_source(gr.sizeof_gr_complex, options.from_file) # options.tx_amplitude = 1 # static value to make sure we do not exceed +-1 for the floats being sent to the sink self._tx_amplitude = options.tx_amplitude self.amp = gr.multiply_const_cc(self._tx_amplitude) # self.txpath = ftw_pnc_transmit_path(options, payload) self.connect(self.txpath, self.amp, self.sink) if options.log: self.connect( self.txpath, gr.file_sink(gr.sizeof_gr_complex, 'ftw_benchmark.dat'))
def __init__(self,options,Freq): gr.top_block.__init__(self) if options.input_file == "": self.IS_USRP2 = True else: self.IS_USRP2 = False #self.min_freq = options.start #self.max_freq = options.stop self.min_freq = Freq.value-(3*10**6) # same as that of the transmitter bandwidth ie 6MHZ approx for a given value of decimation line option any more self.max_freq = Freq.value+(3*10**6) if self.min_freq > self.max_freq: self.min_freq, self.max_freq = self.max_freq, self.min_freq # swap them print "Start and stop frequencies order swapped!" self.fft_size = options.fft_size self.ofdm_bins = options.sense_bins # build graph s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) mywindow = window.blackmanharris(self.fft_size) fft = gr.fft_vcc(self.fft_size, True, mywindow) power = 0 for tap in mywindow: power += tap*tap c2mag = gr.complex_to_mag_squared(self.fft_size) #log = gr.nlog10_ff(10, self.fft_size, -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) # modifications for USRP2 if self.IS_USRP2: self.u = uhd.usrp_source(options.args,uhd.io_type.COMPLEX_FLOAT32,num_channels=1) # Modified Line # self.u.set_decim(options.decim) # samp_rate = self.u.adc_rate()/self.u.decim() samp_rate = 100e6/options.decim # modified sampling rate self.u.set_samp_rate(samp_rate) else: self.u = gr.file_source(gr.sizeof_gr_complex,options.input_file, True) samp_rate = 100e6 /options.decim # modified sampling rate self.freq_step =0 #0.75* samp_rate self.min_center_freq = (self.min_freq + self.max_freq)/2 global BW BW = self.max_freq - self.min_freq global size size=self.fft_size global ofdm_bins ofdm_bins = self.ofdm_bins global usr #global thrshold_inorder usr=samp_rate nsteps = 10 #math.ceil((self.max_freq - self.min_freq) / self.freq_step) self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step) self.next_freq = self.min_center_freq tune_delay = max(0, int(round(options.tune_delay * samp_rate / self.fft_size))) # in fft_frames dwell_delay = max(1, int(round(options.dwell_delay * samp_rate / self.fft_size))) # in fft_frames self.msgq = gr.msg_queue(16) # thread-safe message queue self._tune_callback = tune(self) # hang on to this to keep it from being GC'd stats = gr.bin_statistics_f(self.fft_size, self.msgq, self._tune_callback, tune_delay, dwell_delay) # control scanning and record frequency domain statistics self.connect(self.u, s2v, fft,c2mag,stats) if options.gain is None: g = self.u.get_gain_range() options.gain = float(g.start()+g.stop())/2 # if no gain was specified, use the mid-point in dB
def __init__(self): gr.top_block.__init__(self, "Top Block") options = get_options() self.input_file=options.input_file self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, self.input_file, True) symbol_rate = 18000 sps = 2 # output rate will be 36,000 out_sample_rate = symbol_rate * sps options.low_pass = options.low_pass / 2.0 self.demod = cqpsk.cqpsk_demod( samples_per_symbol = sps, excess_bw=0.35, costas_alpha=0.03, gain_mu=0.05, mu=0.05, omega_relative_limit=0.05, log=options.log, verbose=options.verbose) self.output = gr.file_sink(gr.sizeof_float, options.output_file) self.connect(self.gr_file_source_0, self.demod, self.output)
def main(): parser = OptionParser(conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") add_options(parser, expert_grp) (options, args) = parser.parse_args() fft_length = options.fft_length or 512 file = options.file or "input.compl" out = options.out or "output.compl" src = gr.file_source(gr.sizeof_gr_complex, file) sampler = ofdm.vector_sampler(gr.sizeof_gr_complex, fft_length) trig = gr.vector_source_b([1], True) fft = gr.fft_vcc(fft_length, True, [], True) mag = gr.complex_to_mag(fft_length) avg = gr.single_pole_iir_filter_ff(0.01, fft_length) nlog = gr.nlog10_ff(20, fft_length, -10 * math.log10(fft_length)) dst = gr.file_sink(gr.sizeof_float * fft_length, out) fg = gr.top_block() fg.connect(src, sampler, fft, mag, avg, nlog, dst) fg.connect(trig, (sampler, 1)) # fg.connect(src,limit, # gr.stream_to_vector(gr.sizeof_gr_complex,fft_length), # fft, # gr.multiply_const_vcc([1./fft_length]*fft_length), # gr.complex_to_mag(fft_length), # gr.nlog10_ff(10.0,fft_length), # dst) # fg.connect( src, fft, dst ) fg.run() print "done"
def __init__(self, decim=16, N_id_1=134, N_id_2=0): grc_wxgui.top_block_gui.__init__(self, title="Sss Corr Gui") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.decim = decim self.N_id_1 = N_id_1 self.N_id_2 = N_id_2 ################################################## # Variables ################################################## self.sss_start_ts = sss_start_ts = 10608 - 2048 - 144 self.samp_rate = samp_rate = 30720e3/decim ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=200, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.gr_vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, 2048/decim) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate*decim) self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, 2048/decim) self.gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, sss_start_ts) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((gen_sss_fd(N_id_1, N_id_2, 2048/decim).get_sss_conj_rev())) self.gr_integrate_xx_0 = gr.integrate_cc(2048/decim) self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/home/user/git/gr-lte/gr-lte/test/traces/lte_02_796m_30720k_frame.cfile", True) self.gr_fft_vxx_0 = gr.fft_vcc(2048/decim, True, (window.blackmanharris(1024)), True, 1) self.gr_complex_to_mag_0 = gr.complex_to_mag(1) self.fir_filter_xxx_0 = filter.fir_filter_ccc(decim, (firdes.low_pass(1, decim*samp_rate, 550e3, 100e3))) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_stream_to_vector_0, 0), (self.gr_fft_vxx_0, 0)) self.connect((self.gr_fft_vxx_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_vector_to_stream_0, 0)) self.connect((self.gr_vector_to_stream_0, 0), (self.gr_integrate_xx_0, 0)) self.connect((self.gr_integrate_xx_0, 0), (self.gr_complex_to_mag_0, 0)) self.connect((self.gr_complex_to_mag_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_skiphead_0, 0)) self.connect((self.gr_skiphead_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.gr_stream_to_vector_0, 0))
def __init__(self, options, args, queue): gr.top_block.__init__(self) self.options = options self.args = args rate = int(options.rate) if options.filename is None: self.u = uhd.single_usrp_source("", uhd.io_type_t.COMPLEX_FLOAT32, 1) time_spec = uhd.time_spec(0.0) self.u.set_time_now(time_spec) #if(options.rx_subdev_spec is None): # options.rx_subdev_spec = "" #self.u.set_subdev_spec(options.rx_subdev_spec) if not options.antenna is None: self.u.set_antenna(options.antenna) self.u.set_samp_rate(rate) rate = int(self.u.get_samp_rate()) #retrieve actual if options.gain is None: #set to halfway g = self.u.get_gain_range() options.gain = (g.start() + g.stop()) / 2.0 if not (self.tune(options.freq)): print "Failed to set initial frequency" print "Setting gain to %i" % (options.gain, ) self.u.set_gain(options.gain) print "Gain is %i" % (self.u.get_gain(), ) else: self.u = gr.file_source(gr.sizeof_gr_complex, options.filename) print "Rate is %i" % (rate, ) pass_all = 0 if options.output_all: pass_all = 1 self.demod = gr.complex_to_mag() self.avg = gr.moving_average_ff(100, 1.0 / 100, 400) #the DBSRX especially tends to be spur-prone; the LPF keeps out the #spur multiple that shows up at 2MHz self.lpfiltcoeffs = gr.firdes.low_pass(1, rate, 1.8e6, 100e3) self.lpfilter = gr.fir_filter_ccf(1, self.lpfiltcoeffs) self.preamble = air.modes_preamble(rate, options.threshold) #self.framer = air.modes_framer(rate) self.slicer = air.modes_slicer(rate, queue) self.connect(self.u, self.lpfilter, self.demod) self.connect(self.demod, self.avg) self.connect(self.demod, (self.preamble, 0)) self.connect(self.avg, (self.preamble, 1)) self.connect((self.preamble, 0), (self.slicer, 0))
def __init__(self, options): gr.top_block.__init__(self) if options.tx_freq is not None: u = uhd_transmitter(options.args, options.bandwidth, options.tx_freq, options.tx_gain, options.spec, options.antenna, options.external, options.verbose) elif options.outfile is not None: u = gr.file_sink(gr.sizeof_gr_complex, options.outfile) else: raise SystemExit("--freq or --outfile must be specified\n") if options.infile is not None: tx = gr.file_source(gr.sizeof_gr_complex, options.infile, repeat=options.repeat) else: tx = ofdm_rxtx.TX(options) data_tones = tx.params.data_tones if options.char > 0: # read char from file data = gr.stream_to_vector(gr.sizeof_float, data_tones * 2) # NOTE: we use repeat, assuming the file is long enough or properly aligned self.connect( gr.file_source(gr.sizeof_char, options.txdata, repeat=True), gr.char_to_float(), gr.multiply_const_ff(options.char * (2**-0.5) / 128.0), data) else: data = ofdm_rxtx.make_data(data_tones, options.size, options.txdata) if options.log: self.connect( data, gr.file_sink(data_tones * gr.sizeof_gr_complex, 'tx-data.dat')) self.connect(data, tx) self.sender = ofdm_rxtx.sender_thread(tx, options) if options.amp != 1: amp = gr.multiply_const_cc(options.amp) self.connect(tx, amp, u) else: self.connect(tx, u)
def __init__(self): sense_band_start=900*10**6 sense_band_stop=940*10**6 self.fft_size = options.fft_size self.ofdm_bins = options.sense_bins # build graph s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) mywindow = window.blackmanharris(self.fft_size) fft = gr.fft_vcc(self.fft_size, True, mywindow) power = 0 for tap in mywindow: power += tap*tap c2mag = gr.complex_to_mag_squared(self.fft_size) #log = gr.nlog10_ff(10, self.fft_size, -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) # modifications for USRP2 print "*******************in sensor init********************" if self.IS_USRP2: self.u = usrp2.source_32fc(options.interface, options.MAC_addr) self.u.set_decim(options.decim) samp_rate = self.u.adc_rate() / self.u.decim() else: self.u = gr.file_source(gr.sizeof_gr_complex,options.input_file, True) samp_rate = 100e6 / options.decim self.freq_step =0.75* samp_rate #self.min_center_freq = (self.min_freq + self.max_freq)/2 global BW BW = 0.75* samp_rate #self.max_freq - self.min_freq global size size=self.fft_size global ofdm_bins ofdm_bins = self.ofdm_bins global usr #global thrshold_inorder usr=samp_rate nsteps = 10 #math.ceil((self.max_freq - self.min_freq) / self.freq_step) self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step) self.next_freq = self.min_center_freq tune_delay = max(0, int(round(options.tune_delay * samp_rate / self.fft_size))) # in fft_frames print tune_delay dwell_delay = max(1, int(round(options.dwell_delay * samp_rate / self.fft_size))) # in fft_frames print dwell_delay self.msgq = gr.msg_queue(16) self._tune_callback = tune(self) # hang on to this to keep it from being GC'd stats = gr.bin_statistics_f(self.fft_size, self.msgq, self._tune_callback, tune_delay, dwell_delay) self.connect(self.u, s2v, fft,c2mag,stats) if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.u.gain_range() options.gain = float(g[0]+g[1])/2
def __init__(self): gr.top_block.__init__(self, "LTE hierarchical Flowgraph") ################################################## # Variables ################################################## self.style = style = "tx_diversity" self.samp_rate = samp_rate = 7.68e6 self.fftlen = fftlen = 512 self.N_rb_dl = N_rb_dl = 6 ################################################## # Blocks ################################################## self.ext = lte_pbch_extraction( N_rb_dl=6, style=style, ) self.eq = demod_and_eq( fftlen=512, N_rb_dl=6, ) self.daemon = lte.cell_id_daemon(self.eq.eq.eq, self.ext.demux, self.ext.descr) self.synchronization_0 = synchronization( fftlen=512, daemon="daemon", ) self.lte_mib_unpack_vb_0 = lte.mib_unpack_vb() self.lte_bch_decode_0 = lte_bch_decode() self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate) self.gr_file_source_0 = gr.file_source( gr.sizeof_gr_complex * 1, "/home/demel/Dokumente/Messungen/Messung_LTE_2012-05-23_12:47:32.dat", False) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=768, decimation=1000, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.eq, 2), (self.ext, 2)) self.connect((self.eq, 1), (self.ext, 1)) self.connect((self.eq, 0), (self.ext, 0)) self.connect((self.synchronization_0, 0), (self.eq, 0)) self.connect((self.ext, 0), (self.lte_bch_decode_0, 0)) self.connect((self.lte_bch_decode_0, 1), (self.lte_mib_unpack_vb_0, 1)) self.connect((self.lte_bch_decode_0, 0), (self.lte_mib_unpack_vb_0, 0)) self.connect((self.gr_throttle_0, 0), (self.synchronization_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_file_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
def __init__(self, callback, options): gr.top_block.__init__(self) ### Rx Side ### if (options.rx_freq is not None): self.source = uhd_receiver(options.args_rx, options.bandwidth, options.rx_freq, options.rx_gain, options.spec, options.antenna, options.verbose) elif (options.from_file is not None): self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) else: self.source = gr.null_source(gr.sizeof_gr_complex) # Set up receive path # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) self.rxpath = receive_path(callback, options) ## Tx Side ### if (options.tx_freq is not None): self.sink = uhd_transmitter(options.args_tx, options.bandwidth, options.tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose) elif (options.to_file is not None): self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) else: self.sink = gr.null_sink(gr.sizeof_gr_complex) # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) self.txpath = transmit_path(options) self.connect(self.txpath, self.sink) # self.txpath = gr.message_source(gr.sizeof_gr_complex, 3) # nco_sensitivity = 2.0/options.fft_length # correct for fine frequency # self.nco = ftw.pnc_frequency_modulator_fc(nco_sensitivity) # self.connect(self.txpath, self.sink) # self.nco, # if you use two USRPs and want to synchonized # need to change uhd_interface.py # self.source.config_mimo() # time.sleep(1) # to make sync stable if options.debug: self.connect(self.source, gr.file_sink(gr.sizeof_gr_complex, 'rx.dat')) # Save reception signal else: self.connect(self.source, self.rxpath) #self.connect(self.source, gr.file_sink(gr.sizeof_gr_complex, 'rx.dat')) if (options.verbose): self._print_verbage()