def __init__(self, options): gr.top_block.__init__(self) if options.outfile is not None: u = gr.file_sink(gr.sizeof_gr_complex, options.outfile) elif (options.tx_freq is not None) or (options.channel is not None): if options.channel is not None: self.chan_num = options.channel options.tx_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[self.chan_num] u = uhd_transmitter(options.tx_args, options.bandwidth, options.tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose, options.external) else: raise SystemExit("--tx-freq, --channel or --outfile must be specified\n") self.samples_per_symbol = 2 # transmitter self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(self, spb=self.samples_per_symbol, msgq_limit=2, log=options.log) self.amp = gr.multiply_const_cc(1) self.u = u self.connect(self.packet_transmitter, self.amp, self.u) self.connect(self.amp, gr.file_sink(gr.sizeof_gr_complex, 'cc2420-tx-diag.dat'))
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 _setup_logging(self): print "Modulation logging turned on." self.connect(self.nrz, gr.file_sink(gr.sizeof_float, "nrz.dat")) self.connect(self.gaussian_filter, gr.file_sink(gr.sizeof_float, "gaussian_filter.dat")) self.connect(self.fmmod, gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat"))
def __init__(self): gr.top_block.__init__(self) length = 101 data_r = range(length) data_i = range(length,2*length) src_r = gr.vector_source_s(data_r, False) src_i = gr.vector_source_s(data_i, False) s2f_r = gr.short_to_float() s2f_i = gr.short_to_float() f2c = gr.float_to_complex() s2v = gr.stream_to_vector(gr.sizeof_gr_complex, length) shift = True ifft = gr.fft_vcc(length, False, [], shift) fft = gr.fft_vcc(length, True, [], shift) v2s = gr.vector_to_stream(gr.sizeof_gr_complex, length) snk_in = gr.file_sink(gr.sizeof_gr_complex, "fftshift.in") snk_out = gr.file_sink(gr.sizeof_gr_complex, "fftshift.out") self.connect(src_r, s2f_r, (f2c,0)) self.connect(src_i, s2f_i, (f2c,1)) self.connect(f2c, snk_in) self.connect(f2c, s2v, ifft, fft, v2s, snk_out)
def connect_coarse_search(self, rate_var): slicer_dicer_dump = gr.file_sink(gr.sizeof_gr_complex, "search/slicer_dicer.dat") self.connect(self.slicer_dicer, slicer_dicer_dump) for ii in range(2 * rate_var + 1): rr = self.resamplers[ii] cc = self.correlators[ii] cm = gr.complex_to_mag() pd = self.peak_d[ii] pc = rfidbts.peak_count_stream(int(self.frame_size_rn16 * 3), 500) #file sinks ms = gr.file_sink(gr.sizeof_float, "search/resamp_" + str(ii) + ".dat") ps = gr.file_sink(gr.sizeof_float, "search/peak_" + str(ii) + ".dat") strobe = gr.file_sink(gr.sizeof_char, "search/strobe_" + str(ii) + ".dat") #system blocks self.connect(self, rr, cc, cm, pd, pc) self.connect(cm, (pc, 1)) self.connect(pc, (self.pick_peak, ii)) self.connect(rr, (self.slicer_dicer, ii)) #file sinks self.connect(pd, strobe) self.connect((pd, 1), ps) self.connect(cm, ms)
def __init__(self): gr.top_block.__init__(self) sample_rate = 32000 ampl = 0.1 self._fft_length=96 win = [] #win = [1 for i in range(self._fft_length)] win2 = [1 for i in range(self._fft_length)] # Constructing a sine source and the fft blocks src0 = gr.sig_source_c (sample_rate, gr.GR_SIN_WAVE, 350, ampl) ss2v = gr.stream_to_vector(gr.sizeof_gr_complex, self._fft_length) sv2s = gr.vector_to_stream(gr.sizeof_gr_complex, self._fft_length) fft_demod = gr.fft_vcc(self._fft_length, True, win2, False) ifft = gr.fft_vcc(self._fft_length, False, win, False) scale = gr.multiply_const_cc(1.0 / self._fft_length) # Some output data files trans_output = gr.file_sink(gr.sizeof_gr_complex, "trans_output.dat") reg_output = gr.file_sink(gr.sizeof_gr_complex, "reg_output.dat") # make the connections # self.connect(src0, ss2v, fft_demod, ifft, sv2s, scale, trans_output) self.connect(src0, reg_output)
def __init__(self, options): gr.top_block.__init__(self) if options.outfile is not None: u = gr.file_sink(gr.sizeof_gr_complex, options.outfile) elif (options.tx_freq is not None) or (options.channel is not None): if options.channel is not None: self.chan_num = options.channel options.tx_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[ self.chan_num] u = uhd_transmitter(options.tx_args, options.bandwidth, options.tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose, options.external) else: raise SystemExit( "--tx-freq, --channel or --outfile must be specified\n") self.samples_per_symbol = 2 # transmitter self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts( self, spb=self.samples_per_symbol, msgq_limit=2, log=options.log) self.amp = gr.multiply_const_cc(1) self.u = u self.connect(self.packet_transmitter, self.amp, self.u) self.connect(self.amp, gr.file_sink(gr.sizeof_gr_complex, 'cc2420-tx-diag.dat'))
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 __init__(self): gr.top_block.__init__(self) usage="%prog: [options] output_filename" parser = OptionParser(option_class=eng_option, usage=usage) parser.add_option("-I", "--audio-input", type="string", default="", help="pcm input device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-s", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") parser.add_option("-N", "--nsamples", type="eng_float", default=None, help="number of samples to collect [default=+inf]") (options, args) = parser.parse_args () if len(args) != 2: parser.print_help() raise SystemExit, 1 filename = args[0] filename2 = args[1] sample_rate = int(options.sample_rate) src = audio.source (sample_rate, options.audio_input) dst = gr.file_sink (gr.sizeof_float, filename) dst2 = gr.file_sink (gr.sizeof_float, filename2) if options.nsamples is None: self.connect((src, 0), dst) self.connect((src, 1), dst2) else: head = gr.head(gr.sizeof_float, int(options.nsamples)) head2 = gr.head(gr.sizeof_float, int(options.nsamples)) self.connect((src, 0), head, dst) self.connect((src, 1), head2, dst2)
def __init__(self, queue, freq=0.0, verbose=False, log=False): gr.hier_block2.__init__(self, "flex_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) k = 25000 / (2 * pi * 1600) # 4800 Hz max deviation quad = gr.quadrature_demod_cf(k) self.connect(self, quad) rsamp = blks2.rational_resampler_fff(16, 25) self.slicer = pager_swig.slicer_fb( 5e-6) # DC removal averaging filter constant self.sync = pager_swig.flex_sync() self.connect(quad, rsamp, self.slicer, self.sync) for i in range(4): self.connect((self.sync, i), pager_swig.flex_deinterleave(), pager_swig.flex_parse(queue, freq)) if log: suffix = '_' + "%3.3f" % (freq / 1e6, ) + '.dat' quad_sink = gr.file_sink(gr.sizeof_float, 'quad' + suffix) rsamp_sink = gr.file_sink(gr.sizeof_float, 'rsamp' + suffix) slicer_sink = gr.file_sink(gr.sizeof_char, 'slicer' + suffix) self.connect(rsamp, rsamp_sink) self.connect(quad, quad_sink) self.connect(self.slicer, slicer_sink)
def __init__(self, queue, freq=0.0, verbose=False, log=False): gr.hier_block2.__init__(self, "flex_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0,0,0)) k = 25000/(2*pi*1600) # 4800 Hz max deviation quad = gr.quadrature_demod_cf(k) self.connect(self, quad) rsamp = blks2.rational_resampler_fff(16, 25) self.slicer = pager_swig.slicer_fb(5e-6) # DC removal averaging filter constant self.sync = pager_swig.flex_sync() self.connect(quad, rsamp, self.slicer, self.sync) for i in range(4): self.connect((self.sync, i), pager_swig.flex_deinterleave(), pager_swig.flex_parse(queue, freq)) if log: suffix = '_'+ "%3.3f" % (freq/1e6,) + '.dat' quad_sink = gr.file_sink(gr.sizeof_float, 'quad'+suffix) rsamp_sink = gr.file_sink(gr.sizeof_float, 'rsamp'+suffix) slicer_sink = gr.file_sink(gr.sizeof_char, 'slicer'+suffix) self.connect(rsamp, rsamp_sink) self.connect(quad, quad_sink) self.connect(self.slicer, slicer_sink)
def __init__(self, callback, options): gr.top_block.__init__(self) # hard-coded known symbol ks1 = known_symbols_4512_1[0:options.occupied_tones] ks2 = known_symbols_4512_2[0:options.occupied_tones] self._rcvd_pktq = gr.msg_queue() # accepts messages from the outside world self.ofdm_mapper = gr.ofdm_bpsk_mapper(4, options.occupied_tones, options.fft_length, ks1, ks2) self.ofdm_corr = gr.ofdm_correlator(options.occupied_tones, options.fft_length, 0, ks1, ks2) self.ofdm_framer = gr.ofdm_frame_sink(self._rcvd_pktq, options.occupied_tones) if 0: # set to 1 to put the correlator in the path to take over the signalling self.connect((self.ofdm_mapper, 0), (self.ofdm_corr, 0)) self.connect((self.ofdm_corr, 0), (self.ofdm_framer, 0)) self.connect((self.ofdm_corr, 1), (self.ofdm_framer, 1)) self.connect((self.ofdm_mapper,0), gr.file_sink(gr.sizeof_gr_complex*options.fft_length, "ofdm_mapper.dat")) self.connect((self.ofdm_corr,0), gr.file_sink(gr.sizeof_gr_complex*options.occupied_tones, "ofdm_corr.dat")) self.connect((self.ofdm_corr,1), gr.file_sink(gr.sizeof_char, "ofdm_sig.dat")) else: self.connect((self.ofdm_mapper, 0), (self.ofdm_framer, 0)) self.connect((self.ofdm_mapper, 1), (self.ofdm_framer, 1)) self.connect((self.ofdm_mapper,0), gr.file_sink(gr.sizeof_gr_complex*options.fft_length, "ofdm_mapper.dat")) self.connect((self.ofdm_mapper,1), gr.file_sink(gr.sizeof_char, "ofdm_sig.dat")) self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback)
def _setup_logging(self): print "Modulation logging turned on." self.connect(self.bytes2chunks, gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat")) self.connect(self.symbol_mapper, gr.file_sink(gr.sizeof_char, "tx_graycoder.dat")) self.connect(self.diffenc, gr.file_sink(gr.sizeof_char, "tx_diffenc.dat")) self.connect(self.chunks2symbols, gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat")) self.connect(self.rrc_filter, gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat"))
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): 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, 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, length, debug=False): """ Hierarchical block to detect Null symbols @param length length of the Null symbol (in samples) @param debug whether to write signals out to files """ gr.hier_block2.__init__(self,"detect_null", gr.io_signature(1, 1, gr.sizeof_gr_complex), # input signature gr.io_signature(1, 1, gr.sizeof_char)) # output signature # get the magnitude squared self.ns_c2magsquared = gr.complex_to_mag_squared() # this wastes cpu cycles: # ns_detect_taps = [1]*length # self.ns_moving_sum = gr.fir_filter_fff(1,ns_detect_taps) # this isn't better: #self.ns_filter = gr.iir_filter_ffd([1]+[0]*(length-1)+[-1],[0,1]) # this does the same again, but is actually faster (outsourced to an independent block ..): self.ns_moving_sum = dab_swig.moving_sum_ff(length) self.ns_invert = gr.multiply_const_ff(-1) # peak detector on the inverted, summed up signal -> we get the nulls (i.e. the position of the start of a frame) self.ns_peak_detect = gr.peak_detector_fb(0.6,0.7,10,0.0001) # mostly found by try and error -> remember that the values are negative! # connect it all self.connect(self, self.ns_c2magsquared, self.ns_moving_sum, self.ns_invert, self.ns_peak_detect, self) if debug: self.connect(self.ns_invert, gr.file_sink(gr.sizeof_float, "debug/ofdm_sync_dab_ns_filter_inv_f.dat")) self.connect(self.ns_peak_detect,gr.file_sink(gr.sizeof_char, "debug/ofdm_sync_dab_peak_detect_b.dat"))
def __init__(self, options): self.rx = raw.ofdm_demod(options, (options.nsr is not None) and 4 or 2) self.params = self.rx.params symbol_size = self.params.data_tones * gr.sizeof_gr_complex gr.hier_block2.__init__(self, "RX", gr.io_signature(1,1, gr.sizeof_gr_complex), gr.io_signature(1,1, symbol_size)) ff = raw.fix_frame(symbol_size, options.size) self.connect(self, self.rx, (ff,0), self) self.connect((self.rx,1), (ff,1)) # noise-to-signal ratio estimate # TODO: make it a proper output from the block if options.nsr is not None: nsr = gr.divide_ff() self.connect((self.rx,2), gr.integrate_ff(options.size), (nsr,0)) self.connect((self.rx,3), gr.integrate_ff(options.size), (nsr,1)) self.connect(nsr, gr.file_sink(gr.sizeof_float, options.nsr)) # what to do with the output? acq = self.rx.ofdm_recv.frame_acq acq.set_min_symbols(options.size) if options.numpkts is not None: acq.set_num_frames(options.numpkts) self.size = options.size if options.log: self.connect((self.rx,0), gr.file_sink(symbol_size, 'rx-ofdmdemod.dat')) self.connect((self.rx,1), gr.file_sink(gr.sizeof_char, 'rx-ofdmdemod.datb')) self.connect((ff,0), gr.file_sink(symbol_size, 'rx-fixframe.dat'))
def __init__(self, bitrate, ncarriers, nsymbols, log=False): (qambits, (nc, np)) = bitrates[bitrate] frametones = ncarriers * nsymbols self.framebytes = framebytes((qambits, (nc, np)), frametones) self.framebytes -= 1 # room for padding gr.hier_block2.__init__(self, "qam_tx", gr.io_signature(1,1, gr.sizeof_char), gr.io_signature(1,1, gr.sizeof_gr_complex)) conv = raw.conv_enc() punc = raw.conv_punc(nc, np) intrlv = raw.intrlv_bit(ncarriers, qambits, False) qam = raw.qam_enc(qambits) pad = raw.conv_punc(self.framebytes, self.framebytes+1) # main source accepts whole frames! self.connect(self, pad, conv, punc, intrlv, qam, self) if log: self.connect(intrlv, gr.file_sink(gr.sizeof_char, "tx-intrlv.datb")) self.connect(punc, gr.file_sink(gr.sizeof_char, "tx-punc.datb")) self.connect(conv, gr.file_sink(gr.sizeof_char, "tx-conv.datb")) self.connect(pad, gr.file_sink(gr.sizeof_char, "tx-pad.datb"))
def _setup_logging(self): print "Demodulation logging turned on." self.connect(self.fmdemod, gr.file_sink(gr.sizeof_float, "fmdemod.dat")) self.connect(self.clock_recovery, gr.file_sink(gr.sizeof_float, "clock_recovery.dat")) self.connect(self.slicer, gr.file_sink(gr.sizeof_char, "slicer.dat"))
def __init__(self, bitrate, ncarriers, nsymbols, log=False): (qambits, (nc, np)) = bitrates[bitrate] frametones = ncarriers * nsymbols self.framebytes = framebytes((qambits, (nc, np)), frametones) self.framebytes -= 1 # room for padding gr.hier_block2.__init__(self, "qam_rx", gr.io_signature(1,1, gr.sizeof_gr_complex), gr.io_signature(1,1, gr.sizeof_char)) conv = raw.conv_dec((self.framebytes+1)*8) # decoded length in bits including padding punc = raw.conv_punc(np, nc, 128) intrlv = raw.intrlv_bit(ncarriers, qambits, True) qam = raw.qam_dec(qambits) pad = raw.conv_punc(self.framebytes+1, self.framebytes) self.connect(self, qam, intrlv, punc, conv, # output is stream of bytes... includes padding pad, self) if log: self.connect(qam, gr.file_sink(gr.sizeof_char, "rx-intrlv.datb")) self.connect(intrlv, gr.file_sink(gr.sizeof_char, "rx-punc.datb")) self.connect(punc, gr.file_sink(gr.sizeof_char, "rx-conv.datb")) self.connect(conv, gr.file_sink(gr.sizeof_char, "rx-pad.datb"))
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, length, debug=False): """ Hierarchical block to detect Null symbols @param length length of the Null symbol (in samples) @param debug whether to write signals out to files """ gr.hier_block2.__init__(self, "detect_null", gr.io_signature(1, 1, gr.sizeof_gr_complex), # input signature gr.io_signature(1, 1, gr.sizeof_char)) # output signature # get the magnitude squared self.ns_c2magsquared = gr.complex_to_mag_squared() self.ns_moving_sum = dabp.moving_sum_ff(length) self.ns_invert = gr.multiply_const_ff(-1) # peak detector on the inverted, summed up signal -> we get the nulls (i.e. the position of the start of a frame) self.ns_peak_detect = gr.peak_detector_fb(0.6,0.7,10,0.0001) # mostly found by try and error -> remember that the values are negative! # connect it all self.connect(self, self.ns_c2magsquared, self.ns_moving_sum, self.ns_invert, self.ns_peak_detect, self) if debug: self.connect(self.ns_invert, gr.file_sink(gr.sizeof_float, "debug/ofdm_sync_dabp_ns_filter_inv_f.dat")) self.connect(self.ns_peak_detect,gr.file_sink(gr.sizeof_char, "debug/ofdm_sync_dabp_peak_detect_b.dat"))
def _setup_logging(self): print "Modulation logging turned on." self.connect(self.B2s, gr.file_sink(gr.sizeof_float, "symbols.dat")) self.connect(self.pam, gr.file_sink(gr.sizeof_float, "pam.dat")) self.connect(self.filter, gr.file_sink(gr.sizeof_float, "filter.dat")) self.connect(self.fmmod, gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat"))
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()
def __init__(self, *args, **kwargs): """ Hierarchical block for O-QPSK demodulation. The input is the complex modulated signal at baseband and the output is a stream of bytes. @param sps: samples per symbol @type sps: integer """ try: self.sps = kwargs.pop('sps') self.log = kwargs.pop('log') except KeyError: pass gr.hier_block2.__init__( self, "ieee802_15_4_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input gr.io_signature(1, 1, gr.sizeof_float)) # Output # Demodulate FM sensitivity = (pi / 2) / self.sps #self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity) self.fmdemod = gr.quadrature_demod_cf(1) # Low pass the output of fmdemod to allow us to remove # the DC offset resulting from frequency offset alpha = 0.0008 / self.sps self.freq_offset = gr.single_pole_iir_filter_ff(alpha) self.sub = gr.sub_ff() self.connect(self, self.fmdemod) self.connect(self.fmdemod, (self.sub, 0)) self.connect(self.fmdemod, self.freq_offset, (self.sub, 1)) # recover the clock omega = self.sps gain_mu = 0.03 mu = 0.5 omega_relative_limit = 0.0002 freq_error = 0.0 gain_omega = .25 * gain_mu * gain_mu # critically damped self.clock_recovery = digital.clock_recovery_mm_ff( omega, gain_omega, mu, gain_mu, omega_relative_limit) # Connect self.connect(self.sub, self.clock_recovery, self) if self.log: self.connect(self.fmdemod, gr.file_sink(gr.sizeof_float, 'rx-fmdemod.dat')) self.connect(self.freq_offset, gr.file_sink(gr.sizeof_float, 'rx-fo.dat')) self.connect(self.sub, gr.file_sink(gr.sizeof_float, 'rx-sub.dat')) self.connect(self.clock_recovery, gr.file_sink(gr.sizeof_float, 'rx-recovery.dat'))
def _setup_logging(self): print "Modulation logging turned on." self._fg.connect(self.nrz, gr.file_sink(gr.sizeof_float, "nrz.dat")) self._fg.connect(self.gaussian_filter, gr.file_sink(gr.sizeof_float, "gaussian_filter.dat")) self._fg.connect(self.fmmod, gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat"))
def _setup_logging(self): print "Demodulation logging turned on." self._fg.connect(self.fmdemod, gr.file_sink(gr.sizeof_float, "fmdemod.dat")) self._fg.connect(self.clock_recovery, gr.file_sink(gr.sizeof_float, "clock_recovery.dat")) self._fg.connect(self.slicer, gr.file_sink(gr.sizeof_char, "slicer.dat"))
def __init__(self): 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)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate * 10, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="addr0=192.168.10.2,addr1=192.168.10.3", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_clock_source("mimo", 1) self.uhd_usrp_source_0.set_time_source("mimo", 1) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(4.9e9 + 20000, 0) self.uhd_usrp_source_0.set_gain(15, 0) self.uhd_usrp_source_0.set_center_freq(4.9e9 + 20000, 1) self.uhd_usrp_source_0.set_gain(15, 1) self.gr_file_sink_0_0 = gr.file_sink( gr.sizeof_gr_complex * 1, "/home/sdruser/COLLINS/Pre/UChannel2_S.txt") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink( gr.sizeof_gr_complex * 1, "/home/sdruser/COLLINS/Pre/UChannel1_S.txt") self.gr_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.gr_file_sink_0_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.wxgui_fftsink2_0, 0))
def __init__(self, options): gr.top_block.__init__(self) self._fft_length = 64 self._cp_length = 16 self._symbol_length = self._fft_length + self._cp_length N_sym = 25 ofdm_preamble = [list(fft_preamble)] # print len(fft_preamble) gap = [list(gap_sample)] win = [] inchr = ( chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) ) inchr = ( inchr + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) ) inchr = inchr + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) + chr(0x00) a = map(ord, chr(0)) self.source = gr.file_source(gr.sizeof_gr_complex * self._symbol_length, options.from_file) self.vector_source = gr.vector_source_b(a, False, 1) self.preamble = gr_ieee802_11.ofdm_preamble_insert(self._symbol_length, N_sym, ofdm_preamble) self.zerogap = gr_ieee802_11.ofdm_zerogap_insert(self._symbol_length, N_sym, gap) self.sink = gr.file_sink(gr.sizeof_gr_complex * self._symbol_length, options.to_file) self.connect(self.source, (self.preamble, 0)) self.connect(self.vector_source, (self.preamble, 1)) self.connect((self.preamble, 1), (self.zerogap, 1)) self.connect(self.preamble, self.zerogap, self.sink) # self.connect(self.ifft, gr.file_sink(gr.sizeof_gr_complex * self._fft_length, "ofdm_ifft_test.dat")) self.connect( self.preamble, gr.file_sink(gr.sizeof_gr_complex * self._symbol_length, "ofdm_preamble_test_3.6.4.dat") )
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()
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.remove_head = remove_head = 0 ################################################## # Blocks ################################################## self._remove_head_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.remove_head, callback=self.set_remove_head, label="Remove Head", choices=[0,1], labels=[], style=wx.RA_HORIZONTAL, ) self.Add(self._remove_head_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.gr_udp_source_0 = gr.udp_source(gr.sizeof_short*1, "192.168.2.200", 9997, 590, False, True) self.gr_short_to_float_0_0 = gr.short_to_float(1, 1) self.gr_short_to_float_0 = gr.short_to_float(1, 1) self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_short*1, "/home/cgardner/sandbox/gr-csg/gr-fp/grc_testfp/test_fp_odd.bin") self.gr_file_sink_0_1_0.set_unbuffered(True) self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_short*1, "/home/cgardner/sandbox/gr-csg/gr-fp/grc_testfp/test_raw_even.bin") self.gr_file_sink_0_1.set_unbuffered(True) self.gr_deinterleave_0 = gr.deinterleave(gr.sizeof_short*1) self.fpgnu_fpdata_sink_0 = fpgnu_swig.fpdata_sink(remove_head) ################################################## # Connections ################################################## self.connect((self.gr_udp_source_0, 0), (self.fpgnu_fpdata_sink_0, 0)) self.connect((self.gr_short_to_float_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.gr_deinterleave_0, 1), (self.gr_file_sink_0_1_0, 0)) self.connect((self.fpgnu_fpdata_sink_0, 0), (self.gr_deinterleave_0, 0)) self.connect((self.gr_deinterleave_0, 0), (self.gr_file_sink_0_1, 0)) self.connect((self.gr_short_to_float_0_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.gr_deinterleave_0, 1), (self.gr_short_to_float_0_0, 0)) self.connect((self.gr_deinterleave_0, 0), (self.gr_short_to_float_0, 0))
def __init__(self, options): gr.top_block.__init__(self) # Create a USRP source with GPIO FPGA build, then configure u = usrp.source_s(decim_rate=options.decim, fpga_filename=gpio.fpga_filename) if options.force_complex_RXA: # This is a dirty hack to force complex mode (receive both I and Q) on basicRX or LFRX # This forces the receive board in RXA (side A) to be used # FIXME: This has as a side effect that the gain for Q is not set. So only use with gain 0 (--gain 0) options.rx_subdev_spec = (0, 0) u.set_mux(0x10) if not (0 == options.gain): print "WARNING, you should set the gain to 0 with --gain 0 when using --force-complex-RXA" print "The gain for Q will now still be zero while the gain for I is not" #options.gain=0 else: if options.rx_subdev_spec is None: options.rx_subdev_spec = usrp.pick_rx_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(), ) input_rate = u.adc_freq() / u.decim_rate() print "USB sample rate %s" % (eng_notation.num_to_str(input_rate)) if options.gain is None: # if no gain was specified, use the mid-point in dB g = subdev.gain_range() options.gain = float(g[0] + g[1]) / 2 #TODO setting gain on basicRX only sets the I channel, use a second subdev to set gain of Q channel #see gnuradio-examples/multi-antenna for possible solutions subdev.set_gain(options.gain) #TODO check if freq has same problem as gain when trying to use complex mode on basicRX r = u.tune(0, subdev, options.freq) if not r: sys.stderr.write('Failed to set frequency\n') raise SystemExit, 1 # Connect pipeline src = u if options.nsamples is not None: head = gr.head(gr.sizeof_short, int(options.nsamples) * 2) self.connect(u, head) src = head ana_strip = gr.and_const_ss(0xFFFE) dig_strip = gr.and_const_ss(0x0001) ana_sink = gr.file_sink(gr.sizeof_short, options.ana_filename) dig_sink = gr.file_sink(gr.sizeof_short, options.dig_filename) self.connect(src, ana_strip, ana_sink) self.connect(src, dig_strip, dig_sink)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 25000000 self.dec_rate = dec_rate = 25 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate/dec_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.gr_unpacked_to_packed_xx_0 = gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(dec_rate, (firdes.low_pass(1,samp_rate,1000000,100000)), -1000000, samp_rate) self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/shampoo/sdr/capture/j9Pro-capture/2400000000-25M-1.cap", False) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char*1, "/shampoo/sdr/projects/gr-nineeagles/gmsk-packed.out") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char*1, "/shampoo/sdr/projects/gr-nineeagles/gmsk-unpacked.out") self.gr_file_sink_0.set_unbuffered(False) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.gr_unpacked_to_packed_xx_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.digital_gmsk_demod_0, 0))
def __init__(self, options): gr.top_block.__init__(self) # Create a USRP source with GPIO FPGA build, then configure u = usrp.source_s(decim_rate=options.decim,fpga_filename=gpio.fpga_filename) if options.force_complex_RXA: # This is a dirty hack to force complex mode (receive both I and Q) on basicRX or LFRX # This forces the receive board in RXA (side A) to be used # FIXME: This has as a side effect that the gain for Q is not set. So only use with gain 0 (--gain 0) options.rx_subdev_spec=(0,0) u.set_mux(0x10) if not (0==options.gain): print "WARNING, you should set the gain to 0 with --gain 0 when using --force-complex-RXA" print "The gain for Q will now still be zero while the gain for I is not" #options.gain=0 else: if options.rx_subdev_spec is None: options.rx_subdev_spec = usrp.pick_rx_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(),) input_rate = u.adc_freq()/u.decim_rate() print "USB sample rate %s" % (eng_notation.num_to_str(input_rate)) if options.gain is None: # if no gain was specified, use the mid-point in dB g = subdev.gain_range() options.gain = float(g[0]+g[1])/2 #TODO setting gain on basicRX only sets the I channel, use a second subdev to set gain of Q channel #see gnuradio-examples/multi-antenna for possible solutions subdev.set_gain(options.gain) #TODO check if freq has same problem as gain when trying to use complex mode on basicRX r = u.tune(0, subdev, options.freq) if not r: sys.stderr.write('Failed to set frequency\n') raise SystemExit, 1 # Connect pipeline src = u if options.nsamples is not None: head = gr.head(gr.sizeof_short, int(options.nsamples)*2) self.connect(u, head) src = head ana_strip = gpio.and_const_ss(0xFFFE) dig_strip = gpio.and_const_ss(0x0001) ana_sink = gr.file_sink(gr.sizeof_short, options.ana_filename) dig_sink = gr.file_sink(gr.sizeof_short, options.dig_filename) self.connect(src, ana_strip, ana_sink) self.connect(src, dig_strip, dig_sink)
def build_graph(): sample_rate = 8000 scale_factor = 32000 tb = gr.top_block() src = audio.source(sample_rate, "plughw:0,0") src_scale = gr.multiply_const_ff(scale_factor) interp = blks2.rational_resampler_fff(8, 1) f2s = gr.float_to_short () enc = vocoder.cvsd_encode_sb() dec = vocoder.cvsd_decode_bs() s2f = gr.short_to_float () decim = blks2.rational_resampler_fff(1, 8) sink_scale = gr.multiply_const_ff(1.0/scale_factor) sink = audio.sink(sample_rate, "plughw:0,0") tb.connect(src, src_scale, interp, f2s, enc) tb.connect(enc, dec, s2f, decim, sink_scale, sink) if 0: # debug tb.conect(src, gr.file_sink(gr.sizeof_float, "source.dat")) tb.conect(src_scale, gr.file_sink(gr.sizeof_float, "src_scale.dat")) tb.conect(interp, gr.file_sink(gr.sizeof_float, "interp.dat")) tb.conect(f2s, gr.file_sink(gr.sizeof_short, "f2s.dat")) tb.conect(enc, gr.file_sink(gr.sizeof_char, "enc.dat")) tb.conect(dec, gr.file_sink(gr.sizeof_short, "dec.dat")) tb.conect(s2f, gr.file_sink(gr.sizeof_float, "s2f.dat")) tb.conect(decim, gr.file_sink(gr.sizeof_float, "decim.dat")) tb.conect(sink_scale, gr.file_sink(gr.sizeof_float, "sink_scale.dat")) return tb
def __init__(self, options): gr.top_block.__init__(self) if options.freq is not None: u = usrp2.source(options) elif options.infile is not None: u = gr.file_source(gr.sizeof_gr_complex, options.infile) else: import sys sys.stderr.write("--freq or --infile must be specified\n") raise SystemExit self.scope = None if options.outfile is not None: rx = gr.file_sink(gr.sizeof_gr_complex, options.outfile) else: rx = qam_rxtx.RX(options) framebytes = rx.framebytes if options.rxdata is not None: if options.rxdata == '-': self.connect( rx, gr.file_descriptor_sink(gr.sizeof_char * framebytes, 1)) else: self.connect( rx, gr.file_sink(gr.sizeof_char * framebytes, options.rxdata)) if options.berdata is not None: # select one of the ber modes ber = qam_rxtx.BER(framebytes, 100, mode=options.bermode) data = qam_rxtx.make_data(framebytes) self.connect(rx, (ber, 0)) self.connect(data, (ber, 1)) if options.berdata == '-': # print it out msgq = gr.msg_queue(16) self.connect(ber, gr.message_sink(gr.sizeof_float, msgq, True)) self.watcher = ofdm_rxtx.queue_watcher(msgq) elif options.berdata == '.': import scope # scope it out self.scope = scope.scope(self, ber, 'Frame BER') else: self.connect( ber, gr.file_sink(gr.sizeof_float, options.berdata)) else: pass #self.connect(rx, gr.null_sink(symbol_size)) # XXX do we still need this? self.connect(u, rx)
def __init__(self, *args, **kwargs): """ Hierarchical block for O-QPSK demodulation. The input is the complex modulated signal at baseband and the output is a stream of bytes. @param sps: samples per symbol @type sps: integer """ try: self.sps = kwargs.pop('sps') self.log = kwargs.pop('log') except KeyError: pass gr.hier_block2.__init__(self, "ieee802_15_4_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input gr.io_signature(1, 1, gr.sizeof_float)) # Output # Demodulate FM sensitivity = (pi / 2) / self.sps #self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity) self.fmdemod = gr.quadrature_demod_cf(1) # Low pass the output of fmdemod to allow us to remove # the DC offset resulting from frequency offset alpha = 0.0008/self.sps self.freq_offset = gr.single_pole_iir_filter_ff(alpha) self.sub = gr.sub_ff() self.connect(self, self.fmdemod) self.connect(self.fmdemod, (self.sub, 0)) self.connect(self.fmdemod, self.freq_offset, (self.sub, 1)) # recover the clock omega = self.sps gain_mu=0.03 mu=0.5 omega_relative_limit=0.0002 freq_error=0.0 gain_omega = .25*gain_mu*gain_mu # critically damped self.clock_recovery = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit) # Connect self.connect(self.sub, self.clock_recovery, self) if self.log: self.connect(self.fmdemod, gr.file_sink(gr.sizeof_float, 'rx-fmdemod.dat')) self.connect(self.freq_offset, gr.file_sink(gr.sizeof_float, 'rx-fo.dat')) self.connect(self.sub, gr.file_sink(gr.sizeof_float, 'rx-sub.dat')) self.connect(self.clock_recovery, gr.file_sink(gr.sizeof_float, 'rx-recovery.dat'))
def __init__(self, N_id_2, decim=16, avg_halfframes=2 * 8, freq_corr=0, dump=None): gr.hier_block2.__init__( self, "PSS correlator", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float), ) vec_half_frame = 30720 * 5 / decim self.taps = [] for i in range(0, 3): self.taps.append( gen_pss_td(i, N_re=2048 / decim, freq_corr=freq_corr).get_data_conj_rev()) self.corr = filter.fir_filter_ccc(1, self.taps[N_id_2]) self.mag = gr.complex_to_mag_squared() self.vec = gr.stream_to_vector(gr.sizeof_float * 1, vec_half_frame) self.deint = gr.deinterleave(gr.sizeof_float * vec_half_frame) self.add = gr.add_vff(vec_half_frame) self.argmax = gr.argmax_fs(vec_half_frame) self.null = gr.null_sink(gr.sizeof_short * 1) self.max = gr.max_ff(vec_half_frame) self.to_float = gr.short_to_float(1, 1. / decim) self.interleave = gr.interleave(gr.sizeof_float) #self.framestart = gr.add_const_ii(-160-144*5-2048*6+30720*5) self.connect(self, self.corr, self.mag, self.vec) self.connect((self.argmax, 1), self.null) #self.connect(self.argmax, self.to_float, self.to_int, self.framestart, self) self.connect(self.argmax, self.to_float, self.interleave, self) self.connect(self.max, (self.interleave, 1)) if avg_halfframes == 1: self.connect(self.vec, self.argmax) self.connect(self.vec, self.max) else: self.connect(self.vec, self.deint) self.connect(self.add, self.argmax) self.connect(self.add, self.max) for i in range(0, avg_halfframes): self.connect((self.deint, i), (self.add, i)) if dump != None: self.connect( self.mag, gr.file_sink(gr.sizeof_float, dump + "_pss_corr_f.cfile")) self.connect( self.add, gr.file_sink(gr.sizeof_float * vec_half_frame, dump + "_pss_corr_add_f.cfile"))
def build_graph(): sample_rate = 8000 scale_factor = 32000 tb = gr.top_block() src = audio.source(sample_rate, "plughw:0,0") src_scale = gr.multiply_const_ff(scale_factor) interp = blks2.rational_resampler_fff(8, 1) f2s = gr.float_to_short() enc = cvsd_vocoder.encode_sb() dec = cvsd_vocoder.decode_bs() s2f = gr.short_to_float() decim = blks2.rational_resampler_fff(1, 8) sink_scale = gr.multiply_const_ff(1.0 / scale_factor) sink = audio.sink(sample_rate, "plughw:0,0") tb.connect(src, src_scale, interp, f2s, enc) tb.connect(enc, dec, s2f, decim, sink_scale, sink) if 0: # debug tb.conect(src, gr.file_sink(gr.sizeof_float, "source.dat")) tb.conect(src_scale, gr.file_sink(gr.sizeof_float, "src_scale.dat")) tb.conect(interp, gr.file_sink(gr.sizeof_float, "interp.dat")) tb.conect(f2s, gr.file_sink(gr.sizeof_short, "f2s.dat")) tb.conect(enc, gr.file_sink(gr.sizeof_char, "enc.dat")) tb.conect(dec, gr.file_sink(gr.sizeof_short, "dec.dat")) tb.conect(s2f, gr.file_sink(gr.sizeof_float, "s2f.dat")) tb.conect(decim, gr.file_sink(gr.sizeof_float, "decim.dat")) tb.conect(sink_scale, gr.file_sink(gr.sizeof_float, "sink_scale.dat")) return tb
def __init__(self): 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)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate*10, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="addr0=192.168.10.2,addr1=192.168.10.3", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_clock_source("mimo", 1) self.uhd_usrp_source_0.set_time_source("mimo", 1) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(4.9e9+20000, 0) self.uhd_usrp_source_0.set_gain(15, 0) self.uhd_usrp_source_0.set_center_freq(4.9e9+20000, 1) self.uhd_usrp_source_0.set_gain(15, 1) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_gr_complex*1, "/home/sdruser/COLLINS/Pre/UChannel2_S.txt") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_gr_complex*1, "/home/sdruser/COLLINS/Pre/UChannel1_S.txt") self.gr_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.gr_file_sink_0_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self) xmtr_hack = True rcvr_hack = True self.options = self.run_parser() self.transceiver = bts_transceiver.proto_transceiver() if rcvr_hack: self.src = gr.throttle(itemsize = gr.sizeof_gr_complex, samples_per_sec = self.options.rx_samp_rate) self.f_src = gr.file_source( itemsize = gr.sizeof_gr_complex, filename = self.options.test_src, repeat = False) self.connect(self.f_src, self.src) else: self.bb_sink = gr.file_sink( itemsize = gr.sizeof_gr_complex, filename = 'bb_dump.dat') self.src = self.setup_src() self.connect( self.src, self.bb_sink) if xmtr_hack: self.snk = gr.throttle( itemsize = gr.sizeof_gr_complex, samples_per_sec = self.options.tx_samp_rate) self.fsnk = gr.file_sink( itemsize = gr.sizeof_gr_complex, filename = self.options.test_snk) self.connect( self.snk, self.fsnk) else: self.snk = self.setup_snk() self.fsnk = gr.file_sink( itemsize = gr.sizeof_gr_complex, filename = self.options.test_snk) self.connect( self.transceiver, self.fsnk) self.connect( self.src, self.transceiver) self.connect( self.transceiver, self.snk) #sleep for a bit, let the USRP clocks stablize and such time.sleep(1)
def _setup_logging(self): print("Modulation logging turned on.") self.connect(self.C2S, gr.file_sink(gr.sizeof_float, "tx_chunks2symbols.dat")) self.connect(self.polarity, gr.file_sink(gr.sizeof_float, "tx_polarity.dat")) self.connect(self.filter, gr.file_sink(gr.sizeof_float, "tx_filter.dat")) if (self._decimation > 1): self.connect(self.decimator, gr.file_sink(gr.sizeof_float, "tx_decimator.dat"))
def _setup_logging(self): print "Modulation logging turned on." self.connect(self.bytes2chunks, gr.file_sink(gr.sizeof_char, "bytes2chunks.dat")) self.connect(self.symbol_mapper, gr.file_sink(gr.sizeof_char, "graycoder.dat")) self.connect(self.diffenc, gr.file_sink(gr.sizeof_char, "diffenc.dat")) self.connect(self.chunks2symbols, gr.file_sink(gr.sizeof_gr_complex, "chunks2symbols.dat")) self.connect(self.rrc_filter, gr.file_sink(gr.sizeof_gr_complex, "rrc_filter.dat"))
def __init__(self, u, center_freq, hw_dec_rate, downsample_rate, pulse_width, tari, debug_on, output_data): gr.top_block.__init__(self) # sample_rate = 100e6 / hw_dec_rate sample_rate = 2e6 self.u = u # self.u.set_decim(hw_dec_rate) g = u.get_gain_range() print "-----------" self.u.set_gain(float(g.start() + g.stop()) / 4) print "Using gain of", float(g.start() + g.stop()) / 4 , "(", g.stop(), "-", g.start(), ")" tune_req = uhd.tune_request_t(center_freq,sample_rate) # r = rx.set_center_freq(tune_req) x = self.u.set_center_freq(tune_req) if not x: print "Couldn't set rx freq" self.u.set_samp_rate(sample_rate) us_per_sample = 1e6 / sample_rate * downsample_rate print "USRP Sample Rate: "+ str(sample_rate) + " us Per Sample: " + str(us_per_sample) # 25 Msps is too much to process. But we don't want to decimate at the USRP because we want the full band. # We can downsample, because we don't care about aliasing. self.downsample = gr.keep_one_in_n(gr.sizeof_gr_complex, int(downsample_rate)) self.to_mag = gr.complex_to_mag() # For TARI = 24, PW == DELIM. So we can't do a matched filter, or everything becomes a delimiter and a zero. # PW / 2 smooths reasonably well. # self.smooth = gr.moving_average_ff(int(pulse_width / us_per_sample) /2 , int(pulse_width / us_per_sample) /2 ) self.smooth = gr.moving_average_ff(int(1), 1.0) self.rd = rfid.reader_decoder(us_per_sample, tari) if(debug_on): # fileInfo = "_smooth1_b" # time = strftime("%H_%M_%S", localtime()) # threshFileName = "rm_thresh_" + time + fileInfo + ".out" # signalFileName = "rm_signal_" + time + fileInfo + ".out" signalFileName = "rm_signal.out" threshFileName = "rm_thresh.out" self.sink = gr.file_sink(gr.sizeof_float, threshFileName) # self.signal_sink = gr.file_sink(gr.sizeof_float, signalFileName) # self.connect(self.smooth, self.signal_sink) else: self.sink = gr.null_sink(gr.sizeof_float) self.connect(self.u, self.downsample, self.to_mag, self.smooth, self.rd, self.sink) # Change to "gr.sizeof_gr_complex" if "block_x" is "rx" file_rx_sink = gr.file_sink(gr.sizeof_gr_complex, output_data) self.connect(self.u, file_rx_sink)
def __init__(self): gr.top_block.__init__(self, "Top Block Ss R") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(2.4e9, 0) self.uhd_usrp_source_0.set_gain(25, 0) self.gr_pll_carriertracking_cc_0 = gr.pll_carriertracking_cc( 1.5 * 3.1459 / 200, 4, -4) self.gr_head_0 = gr.head(gr.sizeof_gr_complex * 1, 1000000) self.gr_file_sink_0_0 = gr.file_sink( gr.sizeof_float * 1, "/home/sdruser/COLLINS/SS/received_GMSK.txt") self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0 = gr.file_sink( gr.sizeof_gr_complex * 1, "/home/sdruser/COLLINS/SS/received.txt") self.gr_file_sink_0.set_unbuffered(False) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) ################################################## # Connections ################################################## self.connect((self.gr_pll_carriertracking_cc_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.gr_head_0, 0)) self.connect((self.gr_head_0, 0), (self.gr_pll_carriertracking_cc_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.gr_pll_carriertracking_cc_0, 0), (self.digital_gmsk_demod_0, 0))
def _setup_logging(self): print "Modulation logging turned on." self.connect(self.C2S, gr.file_sink(gr.sizeof_float, "tx_chunks2symbols.dat")) self.connect(self.polarity, gr.file_sink(gr.sizeof_float, "tx_polarity.dat")) self.connect(self.rrc_filter, gr.file_sink(gr.sizeof_float, "tx_rrc_filter.dat")) self.connect(self.shaping_filter, gr.file_sink(gr.sizeof_float, "tx_shaping_filter.dat")) if (self._decimation > 1): self.connect(self.decimator, gr.file_sink(gr.sizeof_float, "tx_decimator.dat"))
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_logging(self): print "Modulation logging turned on." self.connect(self.bytes2chunks, gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.8b")) if self._constellation.apply_pre_diff_code(): self.connect(self.symbol_mapper, gr.file_sink(gr.sizeof_char, "tx_symbol_mapper.8b")) if self._differential: self.connect(self.diffenc, gr.file_sink(gr.sizeof_char, "tx_diffenc.8b")) self.connect(self.chunks2symbols, gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.32fc")) self.connect(self.rrc_filter, gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.32fc"))
def build_graph(input, output, acq_coeffs, sync_coeffs, sync_thresh, sync_window): # Initialize our top block fg = gr.top_block() # Source is a file src = gr.file_source (gr.sizeof_gr_complex, input) # Read coefficients for the acquisition filter (FIR filter) dfile = open(acq_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) # Our matched filter! # Read coefficients for the sync block dfile = open(sync_coeffs, 'r') data = [] for line in dfile: data.append(complex(*map(float,line.strip().strip("()").split(" "))).conjugate()) dfile.close() sync = cmusdrg.mf_sync_ccf(data) # Sync block! # Delay component, to sync the original complex with MF output delay = gr.delay(gr.sizeof_gr_complex, len(data)-1) # Acquisition filter with threshold and window acq = cmusdrg.acquisition_filter_ccc(sync_thresh, sync_window) # Connect complex input to matched filter and delay fg.connect(src, mfilter) fg.connect(src, delay) # Connect the mfilter and delay to the acquisition filter fg.connect(mfilter, (acq, 0)) fg.connect(delay, (acq, 1)) # Connect the acquisition filter to the sync block fg.connect((acq, 0), (sync, 0)) fg.connect((acq, 1), (sync, 1)) # Two file sinks for the output fsink = gr.file_sink (gr.sizeof_char, output+"_sync") fsink2 = gr.file_sink (gr.sizeof_gr_complex, output+"_acq") fg.connect((acq,0), fsink2) fg.connect(sync, fsink) return fg
def _setup_logging(self): print "Modulation logging turned on." self.connect(self.bytes2chunks, gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.8b")) if self._constellation.apply_pre_diff_code(): self.connect(self.symbol_mapper, gr.file_sink(gr.sizeof_char, "tx_symbol_mapper.8b")) if self._differential: self.connect(self.diffenc, gr.file_sink(gr.sizeof_char, "tx_diffenc.8b")) self.connect( self.chunks2symbols, gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.32fc")) self.connect(self.rrc_filter, gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.32fc"))
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 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 __set_rx_from_usrp(self, subdev_spec, decimation_rate, gain, frequency, preserve): from gnuradio import usrp # setup USRP self.usrp.set_decim_rate(decimation_rate) if subdev_spec is None: subdev_spec = usrp.pick_rx_subdevice(self.usrp) self.usrp.set_mux(usrp.determine_rx_mux_value(self.usrp, subdev_spec)) subdev = usrp.selected_subdev(self.usrp, subdev_spec) capture_rate = self.usrp.adc_freq() / self.usrp.decim_rate() self.info["capture-rate"] = capture_rate if gain is None: g = subdev.gain_range() gain = float(g[0] + g[1]) / 2 subdev.set_gain(gain) r = self.usrp.tune(0, subdev, frequency) if not r: raise RuntimeError("failed to set USRP frequency") # capture file if preserve: try: self.capture_filename = os.tmpnam() except RuntimeWarning: ignore = True capture_file = gr.file_sink(gr.sizeof_gr_complex, self.capture_filename) self.__connect([[self.usrp, capture_file]]) else: self.capture_filename = None # everything else self.__build_graph(self.usrp, capture_rate)
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, modulator, options): gr.top_block.__init__(self) if (options.tx_freq is not None): # Work-around to get the modulation's bits_per_symbol args = modulator.extract_kwargs_from_options(options) symbol_rate = options.bitrate / modulator(**args).bits_per_symbol() self.sink = uhd_transmitter(options.args, symbol_rate, options.samples_per_symbol, options.tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose) options.samples_per_symbol = self.sink._sps elif (options.to_file is not None): sys.stderr.write( ("Saving samples to '%s'.\n\n" % (options.to_file))) self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) else: sys.stderr.write( "No sink defined, dumping samples to null sink.\n\n") 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(modulator, options) self.connect(self.txpath, self.sink)
def __init__(self, host, port, pkt_size, eof, wait): gr.top_block.__init__(self, "vector_sink") udp = gr.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof, wait=wait) sink = gr.file_sink(gr.sizeof_float, "received.dat") self.connect(udp, sink)