def setUpFor(self, mode, demod_class=None, state=None, skip_if_unavailable=False): # pylint: disable=attribute-defined-outside-init if state is None: state = {} mode_def = lookup_mode(mode, include_unavailable=True) if mode_def and not mode_def.available and skip_if_unavailable: raise unittest.SkipTest('mode {!r} marked unavailable'.format(mode)) if mode_def is not None and demod_class is None: demod_class = mode_def.demod_class if demod_class is None: if mode_def is None: raise Exception('Mode {!r} not registered'.format(mode)) else: raise Exception('Demodulator not registered for mode {!r}'.format(mode)) # Wire up top block. We don't actually want to inspect the signal processing; we just want to see if GR has a complaint about the flow graph connectivity. self.__top = gr.top_block() self.__adapter = DemodulatorAdapter( mode=mode, demod_class=demod_class, input_rate=100000, output_rate=22050, quiet=True) self.demodulator = self.__adapter.get_demodulator() self.__top.connect( blocks.vector_source_c([]), (self.__adapter, 0), blocks.null_sink(gr.sizeof_float)) self.__top.connect( (self.__adapter, 1), blocks.null_sink(gr.sizeof_float)) DemodulatorTestCase.setUp(self) # neither super nor self call
def test_008_connect_invalid_dst_port_exceeds(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.null_sink(gr.sizeof_int) nop2 = blocks.null_sink(gr.sizeof_int) self.assertRaises(RuntimeError, lambda: hblock.connect(nop1, (nop2, 1)))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Onoff Bare Test") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 200000 self.onoff = onoff = 1 ################################################## # Blocks ################################################## self.sinusoid = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 10, 0) self.throttle = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) # This is the ON block (a very CPU intensive block) self.ONblock = filter.interp_fir_filter_ccc(1, 5000*(1,) ) # This is the OFF block (a low CPU intensity block) self.OFFblock=blocks.multiply_const_cc(1.0) # null sink self.null_sink = blocks.null_sink(gr.sizeof_gr_complex*1) # An auxiliary null source+header 0 to connect the disconnected blocks self.nsa=blocks.null_source(gr.sizeof_gr_complex*1) self.head_aux=blocks.head(gr.sizeof_gr_complex*1, 0) self.connect(self.nsa, self.head_aux) # An auxiliary null sink to connect the disconnected blocks self.nullsink_aux=blocks.null_sink(gr.sizeof_gr_complex*1) self._onoff_chooser = forms.button( parent=self.GetWin(), value=self.onoff, callback=self.set_onoff, label="On/Off", choices=[0,1], labels=['Off', 'On'], ) self.Add(self._onoff_chooser) ################################################## # Connections ################################################## self.connect((self.sinusoid, 0), (self.throttle, 0)) if self.onoff==1: self.connect(self.throttle, self.ONblock) self.connect(self.ONblock, self.null_sink) self.connect(self.head_aux,self.OFFblock) self.connect(self.OFFblock,self.nullsink_aux) else: self.connect(self.throttle, self.OFFblock) self.connect(self.OFFblock, self.null_sink) self.connect(self.head_aux,self.ONblock) self.connect(self.ONblock,self.nullsink_aux)
def __init__(self): gr.top_block.__init__(self, "Channel Measurement") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.cent_freq = cent_freq = 2600e6 ################################################## # Blocks ################################################## self.usrp_tx = uhd.usrp_sink( ",".join(("addr=134.147.118.216", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.usrp_tx.set_subdev_spec("A:0 B:0", 0) self.usrp_tx.set_samp_rate(samp_rate) self.usrp_tx.set_center_freq(cent_freq, 0) self.usrp_tx.set_gain(15, 0) self.usrp_tx.set_antenna("TX/RX", 0) self.usrp_tx.set_center_freq(cent_freq, 1) self.usrp_tx.set_gain(15, 1) self.usrp_tx.set_antenna("TX/RX", 1) self.usrp_rx = uhd.usrp_source( ",".join(("addr=134.147.118.217", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.usrp_rx.set_subdev_spec("A:0 B:0", 0) self.usrp_rx.set_samp_rate(samp_rate) self.usrp_rx.set_center_freq(cent_freq, 0) self.usrp_rx.set_gain(15, 0) self.usrp_rx.set_antenna("TX/RX", 0) self.usrp_rx.set_center_freq(cent_freq, 1) self.usrp_rx.set_gain(15, 1) self.usrp_rx.set_antenna("TX/RX", 1) self.blocks_null_source_1 = blocks.null_source(gr.sizeof_gr_complex*1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*1) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) ################################################## # Connections ################################################## self.connect((self.blocks_null_source_0, 0), (self.usrp_tx, 0)) self.connect((self.blocks_null_source_1, 0), (self.usrp_tx, 1)) self.connect((self.usrp_rx, 0), (self.blocks_null_sink_0, 0)) self.connect((self.usrp_rx, 1), (self.blocks_null_sink_1, 0))
def __init__(self): gr.top_block.__init__(self, "Test Start Stop") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10e6 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.40.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(2.45e9, 0) self.uhd_usrp_source_0.set_gain(10, 0) self.uhd_usrp_source_0.set_center_freq(2.45e9, 1) self.uhd_usrp_source_0.set_gain(10, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_null_sink_0, 1))
def __init__(self, modulator_class, options): gr.top_block.__init__(self) self.txpath = transmit_path(modulator_class, options) self.audio_rx = audio_rx(options.audio_input) if(options.tx_freq is not None): self.sink = uhd_transmitter(options.address, options.bitrate, options.samples_per_symbol, options.tx_freq, options.tx_gain, options.antenna, options.verbose) options.samples_per_symbol = self.sink._sps audio_rate = self.audio_rx.sample_rate usrp_rate = self.sink.get_sample_rate() rrate = usrp_rate / audio_rate elif(options.to_file is not None): self.sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file) rrate = 1 else: self.sink = blocks.null_sink(gr.sizeof_gr_complex) rrate = 1 self.resampler = filter.pfb.arb_resampler_ccf(rrate) self.connect(self.audio_rx) self.connect(self.txpath, self.resampler, self.sink)
def __init__(self, access_code='', threshold=-1): packet_sink=packet_decoder_sink(access_code, threshold, lambda ok, payload: self.recv_pkt(ok, payload)) self._item_size_out = gr.sizeof_char #initialize hier2 gr.hier_block2.__init__( self, "ofdm_mod", gr.io_signature(1, 1, packet_sink.input_signature().sizeof_stream_item(0)), # Input signature gr.io_signature(1, 1, self._item_size_out) # Output signature ) #create blocks #msg_source = blocks.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT) #self._msgq_out = msg_source.msgq() # create message queue self._msgq_out = gr.msg_queue(DEFAULT_MSGQ_LIMIT) # map message queue to tagged stream block msg_source=blocks.message_source(self._item_size_out, self._msgq_out, "packet_len") #connect self.connect(self, packet_sink) self.connect(msg_source, self) if packet_sink.output_signature().sizeof_stream_item(0): self.connect(packet_sink, blocks.null_sink(packet_sink.output_signature().sizeof_stream_item(0)))
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.transition = transition = 1000000 self.samp_rate = samp_rate = 2000000 self.quadrature = quadrature = 500000 self.cutoff = cutoff = 100000 self.audio_decimation = audio_decimation = 10 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(107.8e6, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(20, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=2000, decimation=500, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, cutoff, transition, firdes.WIN_HAMMING, 6.76)) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, )) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=quadrature, audio_decimation=audio_decimation, ) ################################################## # Connections ################################################## self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_null_sink_0, 0))
def __init__(self, item_size, num_outputs, default_output): """ Selector constructor. Args: item_size: the size of the gr data stream in bytes num_inputs: the number of inputs (integer) num_outputs: the number of outputs (integer) input_index: the index for the source data output_index: the index for the destination data """ gr.hier_block2.__init__( self, 'selector', gr.io_signature(1, 1, item_size), gr.io_signature(num_outputs, num_outputs, item_size), ) num_inputs = 1 # Terminator blocks for unused inputs and outputs self.input_terminators = [blocks.null_sink(item_size) for i in range(num_inputs)] self.output_terminators = [blocks.head(item_size, 0) for i in range(num_outputs)] self.copy = blocks.copy(item_size) # Connections for i in range(num_inputs): self.connect((self, i), self.input_terminators[i]) for i in range(num_outputs): self.connect(blocks.null_source(item_size), self.output_terminators[i], (self, i)) # Set parameters self.num_outputs = num_outputs self.input_index = 0 self.output_index = default_output # Register the message port self.message_port_register_hier_in("selection") self.mb = message_receiver(self); # Connect message port self.msg_connect(self, "selection", self.mb,"selection") # Connect default self._connect_current()
def setup_bpsk0(self): self.tb = gr.top_block() # Build the constellation object arity = 2 bps = 1 pts, code = digital.psk_2_0x0() constellation = digital.constellation_psk(pts, code, 2) # Create BPSK data to pass to the demodulator src = blocks.vector_source_b(self.src_data_bpsk) p2u = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) mod = digital.generic_mod(constellation, True, self.sps, True, self.eb) snk = blocks.vector_sink_c() tb = gr.top_block() tb.connect(src, p2u, mod, snk) tb.run() self.src = blocks.vector_source_c(snk.data()) self.freq_recov = digital.fll_band_edge_cc(self.sps, self.eb, self.fll_ntaps, self.freq_bw) self.time_recov = digital.pfb_clock_sync_ccf(self.sps, self.timing_bw, self.taps, self.nfilts, self.nfilts//2, self.timing_max_dev) self.receiver = digital.constellation_receiver_cb( constellation.base(), self.phase_bw, self.fmin, self.fmax) self.diffdec = digital.diff_decoder_bb(arity) self.symbol_mapper = digital.map_bb( mod_codes.invert_code(constellation.pre_diff_code())) self.unpack = blocks.unpack_k_bits_bb(bps) self.snk = blocks.null_sink(gr.sizeof_char) self.tb.connect(self.src, self.freq_recov, self.time_recov, self.receiver) self.tb.connect(self.receiver, self.diffdec, self.symbol_mapper, self.unpack) self.tb.connect(self.unpack, self.snk)
def __init__(self, src="uhd", dst="uhd", in_rate=2e6, out_rate=2e6, extra=None): super(tag_emulate, self).__init__() uhd = dst == "uhd" if uhd: dst = None self._bin_src = binary_src.binary_src(out_rate, encode="manchester", idle_bit=0) parser = Parser(extra) self._tag = parser.get_tag(self._bin_src.set_bits) # Do not record here self._dec = decoder.decoder(src=src, dst=None, reader=True, tag=False, samp_rate=in_rate, emulator=self._tag) self.connect(self._dec) self._mult = multiplier.multiplier(samp_rate=out_rate) self.connect(self._bin_src, self._mult) if uhd: # active load modulation self._real = blocks.complex_to_real(1) self._thres = blocks.threshold_ff(0.02, 0.1, 0) self._r2c = blocks.float_to_complex(1) self._sink = usrp_sink.usrp_sink(out_rate) self.connect(self._mult, self._real, self._thres, self._r2c, self._sink) elif dst: self._sink = record.record(dst, out_rate) self.connect(self._mult, self._sink) else: self._sink = blocks.null_sink(gr.sizeof_gr_complex) self.connect(self._mult, self._sink)
def __init__(self, addr, port, freq, rate, corr, ptt): gr.hier_block2.__init__( self, name = "red_pitaya_sink", input_signature = gr.io_signature(1, 1, gr.sizeof_gr_complex), output_signature = gr.io_signature(0, 0, 0) ) self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.ctrl_sock.connect((addr, port)) self.ctrl_sock.send(struct.pack('<I', 2)) self.data_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.data_sock.connect((addr, port)) self.data_sock.send(struct.pack('<I', 3)) fd = os.dup(self.data_sock.fileno()) self.null_sink = blocks.null_sink(gr.sizeof_gr_complex) self.file_sink = blocks.file_descriptor_sink(gr.sizeof_gr_complex, fd) self.set_freq(freq, corr) self.set_rate(rate) if ptt: self.ptt = True self.ctrl_sock.send(struct.pack('<I', 2<<28)) self.connect(self, self.file_sink) else: self.ptt = False self.ctrl_sock.send(struct.pack('<I', 3<<28)) self.connect(self, self.null_sink)
def setup_test05(self): print "... benchmarking 8-PSK demapper" self.nobits = 4 self.data_subcarriers = 200 self.blks = self.N*(10 + 1) self.tb = gr.top_block() #self.bitmap = [self.nobits]*self.data_subcarriers self.demodulator = generic_demapper_vcb(self.data_subcarriers,10) const = self.demodulator.get_constellation( self.nobits ) assert( len( const ) == 2**self.nobits ) self.bitdata = [random()+1j*random() for i in range(self.blks*self.data_subcarriers)] self.src = blocks.vector_source_c(self.bitdata,False, self.data_subcarriers) #self.src = symbol_random_src( const, self.data_subcarriers ) self.bitmap = [0]*self.data_subcarriers + [self.nobits]*self.data_subcarriers self.bitmap_src = blocks.vector_source_b(self.bitmap,True, self.data_subcarriers) #self.bmaptrig_stream = [1, 2]+[0]*(11-2) #self.bitmap_trigger = blocks.vector_source_b(self.bmaptrig_stream, True) self.snk = blocks.null_sink(gr.sizeof_char) self.tb.connect(self.src,self.demodulator,self.snk) self.tb.connect(self.bitmap_src,(self.demodulator,1))
def run_fir_filters_fff(self): self.blocks = [] self.tb = gr.top_block() self.blocks.append(blocks.null_source(gr.sizeof_float)) self.blocks.append(blocks.head(gr.sizeof_float, self.N)) # First filter is much larger than others taps = numpy.random.random(self.mult*self.ntaps) self.blocks.append(filter.fir_filter_fff(1, taps)) self.blocks[0].set_processor_affinity([0,]) # Set up rest of mfirs filters with new taps for each filter for m in xrange(1, self.mfirs): taps = numpy.random.random(self.ntaps) self.blocks.append(filter.fir_filter_fff(1, taps)) #self.blocks[m].set_processor_affinity([1,]) #self.blocks[m].set_processor_affinity([1,]) #self.blocks[m].set_processor_affinity([1,]) #self.blocks[m].set_processor_affinity([1,]) #self.blocks[m].set_processor_affinity([1,]) #self.blocks[m].set_processor_affinity([1,]) #self.blocks[m].set_processor_affinity([1,]) # Add a null sink self.blocks.append(blocks.null_sink(gr.sizeof_float)) # Connect the blocks and run self.tb.connect(*self.blocks) self.tb.run()
def __init__(self, modulator, audio_rate, rf_rate, freq): modulator = IModulator(modulator) gr.hier_block2.__init__( self, 'SimulatedChannel', gr.io_signature(1, 1, gr.sizeof_float * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) self.__freq = freq self.__rf_rate = rf_rate self.__modulator = modulator modulator_input_type = modulator.get_input_type() if modulator_input_type.get_kind() == 'MONO': audio_resampler = make_resampler(audio_rate, modulator_input_type.get_sample_rate()) self.connect(self, audio_resampler, modulator) elif modulator_input_type.get_kind() == 'NONE': self.connect(self, blocks.null_sink(gr.sizeof_float)) else: raise Exception('don\'t know how to supply input of type %s' % modulator_input_type) rf_resampler = rational_resampler.rational_resampler_ccf( interpolation=int(rf_rate), decimation=int(modulator.get_output_type().get_sample_rate())) self.__rotator = blocks.rotator_cc(rotator_inc(rate=rf_rate, shift=freq)) self.__mult = blocks.multiply_const_cc(dB(-10)) self.connect(modulator, rf_resampler, self.__rotator, self.__mult, self)
def __init__(self, src="uhd", dst="uhd", in_rate=2e6, out_rate=2e6, extra=None): super(reader_emulate, self).__init__() uhd = dst == "uhd" if uhd: dst = None self._bin_src = binary_src.binary_src(out_rate, encode="miller", idle_bit=1, repeat=[0, 1, 1, 0, 0, 1, 0]) # repeat REQA parser = Parser(extra) self._reader = parser.get_reader(self._bin_src.set_bits) # Do not record this self._dec = decoder.decoder(src=src, dst=None, reader=False, tag=True, samp_rate=in_rate, emulator=self._reader) self.connect(self._dec) self._mult = multiplier.multiplier(samp_rate=out_rate) self.connect(self._bin_src, self._mult) if uhd: self._sink = usrp_sink.usrp_sink(out_rate) elif dst: self._sink = record.record(dst, out_rate) else: self._sink = blocks.null_sink(gr.sizeof_gr_complex) self.connect(self._mult, self._sink)
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 = analog.noise_source_c(analog.GR_GAUSSIAN, 1) if verbose: print "Using Gaussian noise source." else: if sample_type == 'complex': src = blocks.file_source(gr.sizeof_gr_complex, filename, True) else: fsrc = blocks.file_source(gr.sizeof_float, filename, True) src = blocks.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 = blocks.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): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = BW ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="sc16", args="spp=80", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(FREQ, 0) self.uhd_usrp_source_0.set_gain(GAIN, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) #self.uhd_usrp_source_0.set_antenna("/RX", 0) self.uhd_usrp_source_0.set_bandwidth(BW, 0) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short*2) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.blocks_null_sink_0, 0))
def _build(self, input_signature, output_signature): """ @param input_signature The input signature. @param output_signature The output signature. """ self._sink = blocks.null_sink(gr.sizeof_gr_complex) #pylint: disable=E1101 return self._sink
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.lo_offset, options.tx_gain, options.spec, options.antenna, options.clock_source, 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 = blocks.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 = blocks.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) print >> sys.stderr, options
def __init__(self, item_size, num_inputs, num_outputs, input_index, output_index): """ Selector constructor. Args: item_size: the size of the gr data stream in bytes num_inputs: the number of inputs (integer) num_outputs: the number of outputs (integer) input_index: the index for the source data output_index: the index for the destination data """ gr.hier_block2.__init__( self, 'selector', gr.io_signature(num_inputs, num_inputs, item_size), gr.io_signature(num_outputs, num_outputs, item_size), ) #terminator blocks for unused inputs and outputs self.input_terminators = [blocks.null_sink(item_size) for i in range(num_inputs)] self.output_terminators = [blocks.head(item_size, 0) for i in range(num_outputs)] self.copy = blocks.copy(item_size) #connections for i in range(num_inputs): self.connect((self, i), self.input_terminators[i]) for i in range(num_outputs): self.connect(blocks.null_source(item_size), self.output_terminators[i], (self, i)) self.item_size = item_size self.input_index = input_index self.output_index = output_index self.num_inputs = num_inputs self.num_outputs = num_outputs self._connect_current()
def __init__(self): gr.top_block.__init__(self, "Affinity Set Test") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## vec_len = 1 self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*vec_len, samp_rate) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*vec_len) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*vec_len) self.filter_filt_0 = filter.fir_filter_ccc(1, 40000*[0.2+0.3j,]) self.filter_filt_1 = filter.fir_filter_ccc(1, 40000*[0.2+0.3j,]) self.filter_filt_0.set_processor_affinity([0,]) self.filter_filt_1.set_processor_affinity([0,1]) ################################################## # Connections ################################################## self.connect((self.blocks_null_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.filter_filt_0, 0)) self.connect((self.filter_filt_0, 0), (self.filter_filt_1, 0)) self.connect((self.filter_filt_1, 0), (self.blocks_null_sink_0, 0))
def __init__(self, mode, input_rate=0, audio_rate=0, context=None): assert input_rate > 0 gr.hier_block2.__init__( self, str(mode) + " (Multimon-NG) demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), # TODO: Add generic support for demodulators with no audio output gr.io_signature(2, 2, gr.sizeof_float * 1), ) self.mode = mode self.input_rate = input_rate # FM demod self.fm_demod = NFMDemodulator( mode="NFM", input_rate=input_rate, audio_rate=pipe_rate, tau=None ) # no deemphasis # Subprocess self.process = SubprocessSink( args=["multimon-ng", "-t", "raw", "-a", "AFSK1200", "-A", "-v", "10", "-"], # args=['python', '../play16bit.py'], itemsize=gr.sizeof_short, ) # Output converter = blocks.float_to_short(vlen=1, scale=int_scale) self.connect(self, self.fm_demod, converter, self.process) # Dummy sink for useless stereo output of demod self.connect((self.fm_demod, 1), blocks.null_sink(gr.sizeof_float)) # Audio copy output resampler = make_resampler(pipe_rate, audio_rate) self.connect(converter, blocks.short_to_float(vlen=1, scale=int_scale), resampler) # self.connect(self.fm_demod, resampler) self.connect(resampler, (self, 0)) self.connect(resampler, (self, 1))
def test01(self): sps = 4 rolloff = 0.35 bw = 2*math.pi/100.0 ntaps = 45 # Create pulse shape filter rrc_taps = filter.firdes.root_raised_cosine( sps, sps, 1.0, rolloff, ntaps) # The frequency offset to correct foffset = 0.2 / (2.0*math.pi) # Create a set of 1's and -1's, pulse shape and interpolate to sps random.seed(0) data = [2.0*random.randint(0, 2) - 1.0 for i in range(200)] self.src = blocks.vector_source_c(data, False) self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) # Mix symbols with a complex sinusoid to spin them self.nco = analog.sig_source_c(1, analog.GR_SIN_WAVE, foffset, 1) self.mix = blocks.multiply_cc() # FLL will despin the symbols to an arbitrary phase self.fll = digital.fll_band_edge_cc(sps, rolloff, ntaps, bw) # Create sinks for all outputs of the FLL # we will only care about the freq and error outputs self.vsnk_frq = blocks.vector_sink_f() self.nsnk_fll = blocks.null_sink(gr.sizeof_gr_complex) self.nsnk_phs = blocks.null_sink(gr.sizeof_float) self.nsnk_err = blocks.null_sink(gr.sizeof_float) # Connect the blocks self.tb.connect(self.nco, (self.mix,1)) self.tb.connect(self.src, self.rrc, (self.mix,0)) self.tb.connect(self.mix, self.fll, self.nsnk_fll) self.tb.connect((self.fll,1), self.vsnk_frq) self.tb.connect((self.fll,2), self.nsnk_phs) self.tb.connect((self.fll,3), self.nsnk_err) self.tb.run() N = 700 dst_data = self.vsnk_frq.data()[N:] expected_result = len(dst_data)* [-0.20,] self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)
def test_001(self): # We're using a really simple preamble so that the correlation # is straight forward. preamble = [0, 0, 0, 1, 0, 0, 0] # Our pulse shape has this width (in units of symbols). pulse_width = 1.5 # The number of filters to use for resampling. n_filters = 12 sps = 3 data = [0]*10 + preamble + [0]*40 src = blocks.vector_source_c(data) # We want to generate taps with a sampling rate of sps=n_filters for resampling # purposes. pulse_shape = make_parabolic_pulse_shape(sps=n_filters, N=0.5, scale=35) # Create our resampling filter to generate the data for the correlator. shape = filter.pfb_arb_resampler_ccf(sps, pulse_shape, n_filters) # Generate the correlator block itself. correlator = digital.correlate_and_sync_cc(preamble, pulse_shape, sps, n_filters) # Connect it all up and go. snk = blocks.vector_sink_c() null = blocks.null_sink(gr.sizeof_gr_complex) tb = gr.top_block() tb.connect(src, shape, correlator, snk) tb.connect((correlator, 1), null) tb.run() # Look at the tags. Retrieve the timing offset. data = snk.data() offset = None timing_error = None for tag in snk.tags(): key = pmt.symbol_to_string(tag.key) if key == "time_est": offset = tag.offset timing_error = pmt.to_double(tag.value) if offset is None: raise ValueError("No tags found.") # Detect where the middle of the preamble is. # Assume we have only one peak and that it is symmetric. sum_id = 0 sum_d = 0 for i, d in enumerate(data): sum_id += i*abs(d) sum_d += abs(d) data_i = sum_id/sum_d if offset is not None: diff = data_i-offset remainder = -(diff%sps) if remainder < -sps/2.0: remainder += sps tol = 0.2 difference = timing_error - remainder difference = difference % sps if abs(difference) >= tol: print("Tag gives timing estimate of {0}. QA calculates it as {1}. Tolerance is {2}".format(timing_error, remainder, tol)) self.assertTrue(abs(difference) < tol)
def test_001(self): # Just running some data through null source/sink src = blocks.null_source(gr.sizeof_float) hed = blocks.head(gr.sizeof_float, 100) dst = blocks.null_sink(gr.sizeof_float) self.tb.connect(src, hed, dst) self.tb.run()
def disable_driver(self): din, dout = self.driver_connection if din == self.driver: replacement = blocks.vector_source_c([]) elif dout == self.driver: replacement = blocks.null_sink(gr.sizeof_gr_complex) else: raise Exception((self.driver, din, dout)) self.__replace_driver(replacement)
def __init__(self, chan_est=1, encoding=0, freq_offset=0, interval=500, nmessages=50, snr=10): gr.top_block.__init__(self, "Wifi Loopback Nogui") ################################################## # Parameters ################################################## self.chan_est = chan_est self.encoding = encoding self.freq_offset = freq_offset self.interval = interval self.nmessages = nmessages self.snr = snr ################################################## # Variables ################################################## self.out_buf_size = out_buf_size = 96000 ################################################## # Blocks ################################################## self.wifi_phy_hier_0 = wifi_phy_hier( encoding=encoding, chan_est=chan_est, ) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.foo_periodic_msg_source_0 = foo.periodic_msg_source(pmt.intern("Hello World!"), interval, nmessages, True, False) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 1000, 1000) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.channels_channel_model_0 = channels.channel_model( noise_voltage=.5**.5, frequency_offset=freq_offset, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(((10**(snr/10.0))**.5, )) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm_n" + str(nmessages) + "_s" + str(snr) + "_e" + str(encoding) + "_i" + str(interval) + ".pcap", False) self.blocks_file_sink_0_0.set_unbuffered(True) ################################################## # Connections ################################################## self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0))
def __init__(self): gr.top_block.__init__(self, type(self).__name__) OptionalDriverMixin.__init__(self) # replace this with actual modulator const = analog.sig_source_c(1, analog.GR_CONST_WAVE, 0, 0, 1) self.driver = blocks.null_sink(gr.sizeof_gr_complex) self.driver_connection = (const, self.driver) self.connect(*self.driver_connection)
def __init__(self): gr.top_block.__init__(self, "Scanner Grc") ################################################## # Variables ################################################## self.f_symb = f_symb = 1625000.0/6.0 self.f_900_b = f_900_b = 921.2e6 self.samp_rate = samp_rate = f_symb*4 self.fs = fs = f_900_b self.f_900_e = f_900_e = 959.8e6 self.f_1800_e = f_1800_e = 1879.8e6 self.f_1800_b = f_1800_b = 1805.2e6 self.OSR = OSR = 4 ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(fs, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(30, 0) self.osmosdr_source_0.set_if_gain(30, 0) self.osmosdr_source_0.set_bb_gain(30, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(200000, 0) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 200e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.threshold_result = blocks.threshold_ff(0, 0.2, 0) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(int((138)*samp_rate/f_symb), int((138)*samp_rate/f_symb), 0) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int((142)*samp_rate/f_symb), 1, int(1e6)) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(OSR)) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.threshold_result, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.threshold_result, 0), (self.blocks_null_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_delay_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
def __init__(self): gr.top_block.__init__(self, "recursion") Qt.QWidget.__init__(self) self.setWindowTitle("recursion") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "experiment2") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.length = length = 96 ################################################## # Blocks ################################################## self.timesvl_TimeSVL_2_0 = timesvl.TimeSVL( gr.sizeof_gr_complex * 1, 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/output_time_map2_1.txt', '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/output_2_1.txt' ) self.timesvl_TimeSVL_2 = timesvl.TimeSVL( gr.sizeof_gr_complex * 1, 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/output_time_map2_2.txt', '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/output_2_2.txt' ) self.timesvl_TimeSVL_1 = timesvl.TimeSVL( gr.sizeof_gr_complex * 1, 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/input_time_map2_2.txt', '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/input_2_2.txt' ) self.timesvl_TimeSVL_0 = timesvl.TimeSVL( gr.sizeof_gr_complex * 1, 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/input_time_map2_1.txt', '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/input_2_1.txt' ) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "Real spectrum", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(True) self.qtgui_time_sink_x_1_0.enable_grid(True) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['Byte', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 2, 0, 1, 8) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 8)] self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "Virtual spectrum 1", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(True) self.qtgui_time_sink_x_1.enable_grid(True) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['Byte', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 0, 1, 7) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 7)] self.qtgui_time_sink_x_0_2 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Demodulated GMSK Data", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_2.set_update_time(0.10) self.qtgui_time_sink_x_0_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_2.enable_tags(-1, True) self.qtgui_time_sink_x_0_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_2.enable_autoscale(True) self.qtgui_time_sink_x_0_2.enable_grid(True) self.qtgui_time_sink_x_0_2.enable_axis_labels(True) self.qtgui_time_sink_x_0_2.enable_control_panel(False) self.qtgui_time_sink_x_0_2.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_2.disable_legend() labels = ['Bytes', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_2_win = sip.wrapinstance( self.qtgui_time_sink_x_0_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_2_win, 3, 0, 1, 8) [self.top_grid_layout.setRowStretch(r, 1) for r in range(3, 4)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 8)] self.qtgui_time_sink_x_0_1 = qtgui.time_sink_c( 512, #size samp_rate, #samp_rate "GMSK Modulated Signal", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 1, 7, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(7, 8)] self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 512, #size samp_rate, #samp_rate "OFDM", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 0, 0, 1, 4) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 4)] self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 512, #size samp_rate, #samp_rate "Constant source", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0, 4, 1, 3) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(4, 7)] self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key='length', bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=64, cp_len=16, frame_length_tag_key='frame_' + "length", packet_length_tag_key="length", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.75, mu=0.5, omega_relative_limit=0.025, freq_error=0.0, verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, length, "length") self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc( (2.0 / 4, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_file_source_0_1 = blocks.file_source( gr.sizeof_char * 1, '/media/tamanna/Seagate Expansion Drive/TCD 2018-2019/4E2 Final year project/gr-mysvl/examples/inputs/Memory_and_Forgetting.mp3', True) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/media/tamanna/Seagate Expansion Drive/TCD 2018-2019/4E2 Final year project/gr-mysvl/examples/inputs/Memory_and_Forgetting.mp3', True) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/outputs/output_audio1.mp3', False) self.blocks_file_sink_0_0.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/outputs/output_audio2.mp3', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blks2_packet_encoder_1 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=0, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code='', threshold=1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.analog_const_source_x_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 0.5) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.timesvl_TimeSVL_0, 1)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blks2_packet_encoder_1, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_2, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_file_source_0_1, 0), (self.blks2_packet_encoder_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.timesvl_TimeSVL_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.timesvl_TimeSVL_1, 1)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.timesvl_TimeSVL_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.timesvl_TimeSVL_0, 0), (self.timesvl_TimeSVL_1, 0)) self.connect((self.timesvl_TimeSVL_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.timesvl_TimeSVL_1, 0), (self.timesvl_TimeSVL_2, 0)) self.connect((self.timesvl_TimeSVL_2, 1), (self.digital_gmsk_demod_0, 0)) self.connect((self.timesvl_TimeSVL_2, 0), (self.timesvl_TimeSVL_2_0, 0)) self.connect((self.timesvl_TimeSVL_2_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.timesvl_TimeSVL_2_0, 0), (self.digital_ofdm_rx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100e3 self.FFT_bank = FFT_bank = 1024 ################################################## # Blocks ################################################## self.qtgui_sink_x_1_0 = qtgui.sink_c( 8192, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 24e8, #fc 20e6, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_1_0.set_update_time(1.0 / 10) self._qtgui_sink_x_1_0_win = sip.wrapinstance( self.qtgui_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_1_0_win) self.qtgui_sink_x_1_0.enable_rf_freq(True) self.fft_vxx_0 = fft.fft_vcc(FFT_bank, True, (window.blackmanharris(FFT_bank)), True, 1) self.epy_block_0 = epy_block_0.blk(example_param=1.0) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_float * 1, FFT_bank) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, 200e3, True) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, FFT_bank) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, FFT_bank, 0) self.blocks_file_source_1 = blocks.file_source( gr.sizeof_gr_complex * 1, 'D:\\WIFI_BL\\IQ_WB', False) self.blocks_file_source_1.set_begin_tag(pmt.PMT_NIL) self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared( FFT_bank) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_file_source_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.epy_block_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_1_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.epy_block_0, 1)) self.connect((self.epy_block_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_1, 0))
def __init__(self): gr.top_block.__init__(self, "Wifi Rx From Reco 150920") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Rx From Reco 150920") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wifi_rx_from_reco_150920") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.threshold = threshold = 1000 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 0.5e6 self.lo_offset = lo_offset = 0 self.gain = gain = 20 self.freq = freq = 943000000.0 self.decimation = decimation = 40 self.chan_est = chan_est = 1 ################################################## # Blocks ################################################## self._samp_rate_options = [0.5e6, 1e6, 5e6, 10e6, 20e6] self._samp_rate_labels = [ "500 KHz", "1 MHz", "5 MHz", "10 MHz", "20 MHz" ] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate" + ": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_tool_bar) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) if not True: self.qtgui_const_sink_x_1.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_win) self.ofdm_80211_short_MF_v2_0 = ofdm_80211.short_MF_v2(160, 16) self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long( sync_length, False, False) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac( False, True) self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols( ieee802_11.LMS, False) self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal( False, False) self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac( False, False) self._gain_range = Range(0, 100, 1, 20, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "slider") self.top_layout.addWidget(self._gain_win) self._freq_options = [ 943000000.0, 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ] self._freq_labels = [ ' 0 | 943.0 | ??', ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("Channel" + ": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.carajito = ofdm_80211.ofdm_sync_short(threshold, 2, False, False) self.blocks_vector_to_stream_2 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 48) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) (self.blocks_throttle_0).set_min_output_buffer(2048) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_null_sink_0_1_0_0_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_file_source_0_1_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/home/juan/COWN/waveforms/80211_ofdm_padded_waveform_direct_fromTX_20150930.bin", True) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1)) self.connect((self.blocks_file_source_0_1_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.ofdm_80211_short_MF_v2_0, 0)) self.connect((self.blocks_vector_to_stream_2, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.carajito, 0), (self.blocks_delay_0, 0)) self.connect((self.carajito, 0), (self.ieee802_11_ofdm_sync_long_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.blocks_vector_to_stream_2, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0)) self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ofdm_80211_short_MF_v2_0, 2), (self.blocks_null_sink_0_1_0_0_0_0, 0)) self.connect((self.ofdm_80211_short_MF_v2_0, 1), (self.carajito, 1)) self.connect((self.ofdm_80211_short_MF_v2_0, 3), (self.carajito, 2)) self.connect((self.ofdm_80211_short_MF_v2_0, 0), (self.carajito, 0))
def __init__(self, syncword="1ACFFC1D"): gr.top_block.__init__(self, "Turbo Verification V2") Qt.QWidget.__init__(self) self.setWindowTitle("Turbo Verification V2") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "turbo_verification_v2") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.syncword = syncword ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 500e3 self.sps = sps = 4 self.vcdu_size = vcdu_size = 223 - 10 self.samp_rate = samp_rate = symbol_rate * sps self.ntaps = ntaps = 40 * sps self.nfilts = nfilts = 32 self.value = value = [0, 1] self.to = to = 0.0 self.taps = taps = firdes.root_raised_cosine(sps, samp_rate, symbol_rate, 0.35, ntaps) self.symbol = symbol = [-1, 1] self.scramble = scramble = 0 self.rs = rs = 1 self.reset = reset = vcdu_size self.polyphase_taps = polyphase_taps = firdes.root_raised_cosine( sps * nfilts, nfilts, 1.0 / float(sps), 0.35, 20 * sps * nfilts) self.parity = parity = 32 self.linecode = linecode = 1 self.intDepth = intDepth = 1 self.frame_size = frame_size = vcdu_size + 10 self.cfo = cfo = 0.25 self.SNR = SNR = 2.5 self.Rc = Rc = 0.5 ################################################## # Blocks ################################################## self.tdd_ferMsgGen_0 = tdd.ferMsgGen(vcdu_size, 'cadu_len', 'vcdu_len') self.tdd_ferMsgCount_0 = tdd.ferMsgCount(0) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 0 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 0 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.mapper_prbs_source_b_0 = mapper.prbs_source_b("PRBS31", reset * 8) self.mapper_prbs_sink_b_0 = mapper.prbs_sink_b("PRBS31", reset * 8) self.dslwp_frame_spliter_f_0 = dslwp.frame_spliter_f( 'payload_start', 3576) self.dslwp_ccsds_turbo_decode_0 = dslwp.ccsds_turbo_decode( 223, 1, 2, 1, 0.707, 1) self.digital_map_bb_0_0 = digital.map_bb((-1, 1)) self.digital_map_bb_0 = digital.map_bb((-1, 1)) self.ccsds_synchronizeCADU_0 = ccsds.synchronizeCADU( '1ACFFC1D', 0, "sync") self.ccsds_synchronizeCADUSoft_0 = ccsds.synchronizeCADUSoft( '1ACFFC1D', 0, 'syncsoft') self.ccsds_recoverCADU_1 = ccsds.recoverCADU( int(frame_size / Rc) + 1, scramble, 'sync') self.ccsds_recoverCADUSoft_0 = ccsds.recoverCADUSoft( int(frame_size / Rc) + 1, scramble, 'syncsoft') self.ccsds_encodeTurbo_0 = ccsds.encodeTurbo(frame_size, 2, 'cadu_len') self.ccsds_createCADU_0 = ccsds.createCADU( int(frame_size / Rc) + 1, '1ACFFC1D', scramble, 'xx_len') self.blocks_unpack_k_bits_bb_1 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_tag_debug_1 = blocks.tag_debug(gr.sizeof_float * 1, '', "syncsoft") self.blocks_tag_debug_1.set_display(False) self.blocks_stream_to_tagged_stream_2 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, 3576, "payload_start") self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, int(frame_size / Rc) + 1, "xx_len") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, vcdu_size, "vcdu_len") self.blocks_pdu_to_tagged_stream_0_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1.0) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1.0) ################################################## # Connections ################################################## self.msg_connect((self.ccsds_recoverCADUSoft_0, 'cadu'), (self.dslwp_ccsds_turbo_decode_0, 'in')) self.msg_connect((self.ccsds_recoverCADUSoft_0, 'cadu'), (self.qtgui_time_sink_x_0, 'in')) self.msg_connect((self.ccsds_recoverCADU_1, 'cadu'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.dslwp_ccsds_turbo_decode_0, 'out'), (self.tdd_ferMsgCount_0, 'in')) self.msg_connect((self.dslwp_frame_spliter_f_0, 'out'), (self.qtgui_time_sink_x_0_0, 'in')) self.msg_connect((self.tdd_ferMsgCount_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus')) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_stream_to_tagged_stream_2, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.ccsds_synchronizeCADUSoft_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.blocks_unpack_k_bits_bb_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.tdd_ferMsgGen_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.ccsds_createCADU_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_2, 0), (self.dslwp_frame_spliter_f_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.ccsds_synchronizeCADU_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_1, 0), (self.mapper_prbs_sink_b_0, 0)) self.connect((self.ccsds_createCADU_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.ccsds_encodeTurbo_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.ccsds_synchronizeCADUSoft_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.ccsds_synchronizeCADUSoft_0, 0), (self.blocks_tag_debug_1, 0)) self.connect((self.ccsds_synchronizeCADUSoft_0, 0), (self.ccsds_recoverCADUSoft_0, 0)) self.connect((self.ccsds_synchronizeCADU_0, 0), (self.ccsds_recoverCADU_1, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_map_bb_0_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.mapper_prbs_source_b_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.tdd_ferMsgGen_0, 0), (self.ccsds_encodeTurbo_0, 0))
def __init__(self): gr.top_block.__init__(self, "Usrp Echotimer Fmcw Edited") Qt.QWidget.__init__(self) self.setWindowTitle("Usrp Echotimer Fmcw Edited") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "usrp_echotimer_fmcw_edited") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 40000000 self.sweep_freq = sweep_freq = samp_rate / 2 self.samp_up = samp_up = 2**15 self.wait_to_start = wait_to_start = 0.02 self.tx_gain = tx_gain = 40 self.threshold = threshold = -150 self.rx_gain = rx_gain = 60 self.range_time = range_time = 30 self.range_res = range_res = 3e8 / 2 / sweep_freq self.protect_samp = protect_samp = 0 self.min_output_buffer = min_output_buffer = int((samp_up) * 2) self.max_output_buffer = max_output_buffer = 0 self.freq_res_up = freq_res_up = samp_rate / samp_up self.delay_samp = delay_samp = 79 self.decim_fac = decim_fac = 2**3 self.center_freq = center_freq = 5.2e9 ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 100, 1, 40, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 0, 0) self._threshold_range = Range(-150, 0, 1, -150, 200) self._threshold_win = RangeWidget(self._threshold_range, self.set_threshold, "threshold", "counter_slider", float) self.top_grid_layout.addWidget(self._threshold_win, 1, 0) self._rx_gain_range = Range(0, 100, 1, 60, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 0, 1) self._protect_samp_range = Range(0, 100, 1, 0, 200) self._protect_samp_win = RangeWidget(self._protect_samp_range, self.set_protect_samp, "protect_samp", "counter_slider", float) self.top_grid_layout.addWidget(self._protect_samp_win, 1, 1) self._delay_samp_range = Range(0, 100, 1, 79, 200) self._delay_samp_win = RangeWidget(self._delay_samp_range, self.set_delay_samp, 'Number delay samples', "counter_slider", float) self.top_layout.addWidget(self._delay_samp_win) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.radar_usrp_echotimer_cc_0 = radar.usrp_echotimer_cc( samp_rate, center_freq, int(delay_samp), '', '', 'internal', 'none', 'TX/RX', tx_gain, 0.1, wait_to_start, 0, '', '', 'internal', 'none', 'RX2', rx_gain, 0.1, wait_to_start, 0, "packet_len") (self.radar_usrp_echotimer_cc_0).set_min_output_buffer(65536) self.radar_ts_fft_cc_1 = radar.ts_fft_cc(samp_up / decim_fac, "packet_len") self.radar_signal_generator_fmcw_c_0 = radar.signal_generator_fmcw_c( samp_rate, samp_up, 0, 0, -sweep_freq / 2, sweep_freq, 1, "packet_len") (self.radar_signal_generator_fmcw_c_0).set_min_output_buffer(65536) self.radar_my_find_max_peak_c_0 = radar.my_find_max_peak_c( samp_rate / decim_fac, threshold, int(protect_samp), (), False, 44, "packet_len") self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 300, #size samp_rate / decim_fac, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-4, 4) self.qtgui_time_sink_x_1.set_y_label('power', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.epy_block_0 = epy_block_0.blk() self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", 1.0 / decim_fac) (self.blocks_tagged_stream_multiply_length_0 ).set_min_output_buffer(65536) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(65536) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_float * 1, '/home/tmatko/Desktop/grstuff/acquired-signals/time13.dat', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_float * 1, '/home/tmatko/Desktop/grstuff/acquired-signals/phase13.dat', False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.msg_connect((self.radar_my_find_max_peak_c_0, 'Msg out'), (self.epy_block_0, 'msg_in')) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.radar_ts_fft_cc_1, 0)) self.connect((self.epy_block_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.epy_block_0, 1), (self.blocks_file_sink_0_0, 0)) self.connect((self.epy_block_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.epy_block_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.epy_block_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.radar_signal_generator_fmcw_c_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.radar_signal_generator_fmcw_c_0, 0), (self.radar_usrp_echotimer_cc_0, 0)) self.connect((self.radar_ts_fft_cc_1, 0), (self.radar_my_find_max_peak_c_0, 0)) self.connect((self.radar_usrp_echotimer_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))
def __init__(self): gr.top_block.__init__(self, "Receive Single FM Station") Qt.QWidget.__init__(self) self.setWindowTitle("Receive Single FM Station") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "rcv_single_fm") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.rf_rate = rf_rate = 20e6 self.rf_frequency_h = rf_frequency_h = 88.5 self.fm_taps = fm_taps = firdes.low_pass_2(32., rf_rate, 96e3, 25e3, 50) self.audio_rate = audio_rate = 44100 self.taps_len = taps_len = fm_taps.__len__() self.rf_gain = rf_gain = 50 self.rf_frequency = rf_frequency = 98.1e6 self.fm_channel_rate = fm_channel_rate = audio_rate*5 self.channel_number = channel_number = int(10*(rf_frequency_h-98)) /2if rf_frequency_h>=98 else 50 + int(10*(rf_frequency_h-88.1))/2 ################################################## # Blocks ################################################## self._rf_rate_range = Range(100e3, 20e6, 200e3, 20e6, 200) self._rf_rate_win = RangeWidget(self._rf_rate_range, self.set_rf_rate, 'RF sample rate', "counter_slider", float) self.top_layout.addWidget(self._rf_rate_win) self._rf_gain_range = Range(0, 90, 1, 50, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, 'RF gain', "counter_slider", float) self.top_layout.addWidget(self._rf_gain_win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(rf_rate) self.uhd_usrp_source_0.set_center_freq(rf_frequency, 0) self.uhd_usrp_source_0.set_gain(rf_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self._rf_frequency_h_range = Range(88.0, 108.0, .2, 88.5, 200) self._rf_frequency_h_win = RangeWidget(self._rf_frequency_h_range, self.set_rf_frequency_h, 'RF Frequency', "counter_slider", float) self.top_layout.addWidget(self._rf_frequency_h_win) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=fm_channel_rate, decimation=int(200e3), taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rf_frequency, #fc rf_rate, #bw "Received Spectrum", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rf_frequency, #fc fm_channel_rate, #bw "Selected Channel", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 1., #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf( 100, (fm_taps), 1.0, 100) self.pfb_channelizer_ccf_0.set_channel_map(([channel_number])) self.pfb_channelizer_ccf_0.declare_sample_delay(0) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.audio_sink_0 = audio.sink(audio_rate, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=fm_channel_rate, audio_decimation=fm_channel_rate/audio_rate, ) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-20, .1) ################################################## # Connections ################################################## self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.blocks_null_sink_0, 1)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.blocks_null_sink_0, 2)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.blocks_null_sink_0, 3)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.blocks_null_sink_0, 4)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_null_sink_0, 5)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0, 6)) self.connect((self.pfb_channelizer_ccf_0, 8), (self.blocks_null_sink_0, 7)) self.connect((self.pfb_channelizer_ccf_0, 9), (self.blocks_null_sink_0, 8)) self.connect((self.pfb_channelizer_ccf_0, 10), (self.blocks_null_sink_0, 9)) self.connect((self.pfb_channelizer_ccf_0, 11), (self.blocks_null_sink_0, 10)) self.connect((self.pfb_channelizer_ccf_0, 12), (self.blocks_null_sink_0, 11)) self.connect((self.pfb_channelizer_ccf_0, 13), (self.blocks_null_sink_0, 12)) self.connect((self.pfb_channelizer_ccf_0, 14), (self.blocks_null_sink_0, 13)) self.connect((self.pfb_channelizer_ccf_0, 15), (self.blocks_null_sink_0, 14)) self.connect((self.pfb_channelizer_ccf_0, 16), (self.blocks_null_sink_0, 15)) self.connect((self.pfb_channelizer_ccf_0, 17), (self.blocks_null_sink_0, 16)) self.connect((self.pfb_channelizer_ccf_0, 18), (self.blocks_null_sink_0, 17)) self.connect((self.pfb_channelizer_ccf_0, 19), (self.blocks_null_sink_0, 18)) self.connect((self.pfb_channelizer_ccf_0, 20), (self.blocks_null_sink_0, 19)) self.connect((self.pfb_channelizer_ccf_0, 21), (self.blocks_null_sink_0, 20)) self.connect((self.pfb_channelizer_ccf_0, 22), (self.blocks_null_sink_0, 21)) self.connect((self.pfb_channelizer_ccf_0, 23), (self.blocks_null_sink_0, 22)) self.connect((self.pfb_channelizer_ccf_0, 24), (self.blocks_null_sink_0, 23)) self.connect((self.pfb_channelizer_ccf_0, 25), (self.blocks_null_sink_0, 24)) self.connect((self.pfb_channelizer_ccf_0, 26), (self.blocks_null_sink_0, 25)) self.connect((self.pfb_channelizer_ccf_0, 27), (self.blocks_null_sink_0, 26)) self.connect((self.pfb_channelizer_ccf_0, 28), (self.blocks_null_sink_0, 27)) self.connect((self.pfb_channelizer_ccf_0, 29), (self.blocks_null_sink_0, 28)) self.connect((self.pfb_channelizer_ccf_0, 30), (self.blocks_null_sink_0, 29)) self.connect((self.pfb_channelizer_ccf_0, 31), (self.blocks_null_sink_0, 30)) self.connect((self.pfb_channelizer_ccf_0, 32), (self.blocks_null_sink_0, 31)) self.connect((self.pfb_channelizer_ccf_0, 33), (self.blocks_null_sink_0, 32)) self.connect((self.pfb_channelizer_ccf_0, 34), (self.blocks_null_sink_0, 33)) self.connect((self.pfb_channelizer_ccf_0, 35), (self.blocks_null_sink_0, 34)) self.connect((self.pfb_channelizer_ccf_0, 36), (self.blocks_null_sink_0, 35)) self.connect((self.pfb_channelizer_ccf_0, 37), (self.blocks_null_sink_0, 36)) self.connect((self.pfb_channelizer_ccf_0, 38), (self.blocks_null_sink_0, 37)) self.connect((self.pfb_channelizer_ccf_0, 39), (self.blocks_null_sink_0, 38)) self.connect((self.pfb_channelizer_ccf_0, 40), (self.blocks_null_sink_0, 39)) self.connect((self.pfb_channelizer_ccf_0, 41), (self.blocks_null_sink_0, 40)) self.connect((self.pfb_channelizer_ccf_0, 42), (self.blocks_null_sink_0, 41)) self.connect((self.pfb_channelizer_ccf_0, 43), (self.blocks_null_sink_0, 42)) self.connect((self.pfb_channelizer_ccf_0, 44), (self.blocks_null_sink_0, 43)) self.connect((self.pfb_channelizer_ccf_0, 45), (self.blocks_null_sink_0, 44)) self.connect((self.pfb_channelizer_ccf_0, 46), (self.blocks_null_sink_0, 45)) self.connect((self.pfb_channelizer_ccf_0, 47), (self.blocks_null_sink_0, 46)) self.connect((self.pfb_channelizer_ccf_0, 48), (self.blocks_null_sink_0, 47)) self.connect((self.pfb_channelizer_ccf_0, 49), (self.blocks_null_sink_0, 48)) self.connect((self.pfb_channelizer_ccf_0, 50), (self.blocks_null_sink_0, 49)) self.connect((self.pfb_channelizer_ccf_0, 51), (self.blocks_null_sink_0, 50)) self.connect((self.pfb_channelizer_ccf_0, 52), (self.blocks_null_sink_0, 51)) self.connect((self.pfb_channelizer_ccf_0, 53), (self.blocks_null_sink_0, 52)) self.connect((self.pfb_channelizer_ccf_0, 54), (self.blocks_null_sink_0, 53)) self.connect((self.pfb_channelizer_ccf_0, 55), (self.blocks_null_sink_0, 54)) self.connect((self.pfb_channelizer_ccf_0, 56), (self.blocks_null_sink_0, 55)) self.connect((self.pfb_channelizer_ccf_0, 57), (self.blocks_null_sink_0, 56)) self.connect((self.pfb_channelizer_ccf_0, 58), (self.blocks_null_sink_0, 57)) self.connect((self.pfb_channelizer_ccf_0, 59), (self.blocks_null_sink_0, 58)) self.connect((self.pfb_channelizer_ccf_0, 60), (self.blocks_null_sink_0, 59)) self.connect((self.pfb_channelizer_ccf_0, 61), (self.blocks_null_sink_0, 60)) self.connect((self.pfb_channelizer_ccf_0, 62), (self.blocks_null_sink_0, 61)) self.connect((self.pfb_channelizer_ccf_0, 63), (self.blocks_null_sink_0, 62)) self.connect((self.pfb_channelizer_ccf_0, 64), (self.blocks_null_sink_0, 63)) self.connect((self.pfb_channelizer_ccf_0, 65), (self.blocks_null_sink_0, 64)) self.connect((self.pfb_channelizer_ccf_0, 66), (self.blocks_null_sink_0, 65)) self.connect((self.pfb_channelizer_ccf_0, 67), (self.blocks_null_sink_0, 66)) self.connect((self.pfb_channelizer_ccf_0, 68), (self.blocks_null_sink_0, 67)) self.connect((self.pfb_channelizer_ccf_0, 69), (self.blocks_null_sink_0, 68)) self.connect((self.pfb_channelizer_ccf_0, 70), (self.blocks_null_sink_0, 69)) self.connect((self.pfb_channelizer_ccf_0, 71), (self.blocks_null_sink_0, 70)) self.connect((self.pfb_channelizer_ccf_0, 72), (self.blocks_null_sink_0, 71)) self.connect((self.pfb_channelizer_ccf_0, 73), (self.blocks_null_sink_0, 72)) self.connect((self.pfb_channelizer_ccf_0, 74), (self.blocks_null_sink_0, 73)) self.connect((self.pfb_channelizer_ccf_0, 75), (self.blocks_null_sink_0, 74)) self.connect((self.pfb_channelizer_ccf_0, 76), (self.blocks_null_sink_0, 75)) self.connect((self.pfb_channelizer_ccf_0, 77), (self.blocks_null_sink_0, 76)) self.connect((self.pfb_channelizer_ccf_0, 78), (self.blocks_null_sink_0, 77)) self.connect((self.pfb_channelizer_ccf_0, 79), (self.blocks_null_sink_0, 78)) self.connect((self.pfb_channelizer_ccf_0, 80), (self.blocks_null_sink_0, 79)) self.connect((self.pfb_channelizer_ccf_0, 81), (self.blocks_null_sink_0, 80)) self.connect((self.pfb_channelizer_ccf_0, 82), (self.blocks_null_sink_0, 81)) self.connect((self.pfb_channelizer_ccf_0, 83), (self.blocks_null_sink_0, 82)) self.connect((self.pfb_channelizer_ccf_0, 84), (self.blocks_null_sink_0, 83)) self.connect((self.pfb_channelizer_ccf_0, 85), (self.blocks_null_sink_0, 84)) self.connect((self.pfb_channelizer_ccf_0, 86), (self.blocks_null_sink_0, 85)) self.connect((self.pfb_channelizer_ccf_0, 87), (self.blocks_null_sink_0, 86)) self.connect((self.pfb_channelizer_ccf_0, 88), (self.blocks_null_sink_0, 87)) self.connect((self.pfb_channelizer_ccf_0, 89), (self.blocks_null_sink_0, 88)) self.connect((self.pfb_channelizer_ccf_0, 90), (self.blocks_null_sink_0, 89)) self.connect((self.pfb_channelizer_ccf_0, 91), (self.blocks_null_sink_0, 90)) self.connect((self.pfb_channelizer_ccf_0, 92), (self.blocks_null_sink_0, 91)) self.connect((self.pfb_channelizer_ccf_0, 93), (self.blocks_null_sink_0, 92)) self.connect((self.pfb_channelizer_ccf_0, 94), (self.blocks_null_sink_0, 93)) self.connect((self.pfb_channelizer_ccf_0, 95), (self.blocks_null_sink_0, 94)) self.connect((self.pfb_channelizer_ccf_0, 96), (self.blocks_null_sink_0, 95)) self.connect((self.pfb_channelizer_ccf_0, 97), (self.blocks_null_sink_0, 96)) self.connect((self.pfb_channelizer_ccf_0, 98), (self.blocks_null_sink_0, 97)) self.connect((self.pfb_channelizer_ccf_0, 99), (self.blocks_null_sink_0, 98)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.pfb_channelizer_ccf_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fhss Sync") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_sym = samp_sym = 32 self.tone_freq = tone_freq = 2000 self.samp_rate = samp_rate = 800e3 self.init = init = 1, 1, 1, 1, 1, 1, 1 self.generator = generator = 1, 1, 0, 0, 1, 0, 1, 1 self.code_rate = code_rate = int(samp_sym * 10000) ################################################## # Blocks ################################################## _tone_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._tone_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_tone_freq_sizer, value=self.tone_freq, callback=self.set_tone_freq, label='Tone Frequency', converter=forms.float_converter(), proportion=0, ) self._tone_freq_slider = forms.slider( parent=self.GetWin(), sizer=_tone_freq_sizer, value=self.tone_freq, callback=self.set_tone_freq, minimum=-1 * samp_rate / 2, maximum=samp_rate / 2, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tone_freq_sizer) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title='Received Spread Spectrum ', ) self.Add(self.wxgui_waterfallsink2_0.win) 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, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='Despread Signal', peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0.win, 0, 2, 2, 4) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.1, frequency_offset=1 / samp_rate, epsilon=1 + 0.0000, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, tone_freq, 2, 0) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, 1000)), True) self.Spread_synthesizer_0 = Spread.synthesizer(code_rate, 0, samp_rate, (generator), (init)) self.Spread_rx_synthesizer_0 = Spread.rx_synthesizer( code_rate, samp_sym, samp_rate, 12000, 50000, 0.16, (generator), (init)) self.Spread_cpfsk_mod_0 = Spread.cpfsk_mod(samp_sym) self.Spread_cpfsk_demod_0 = Spread.cpfsk_demod(samp_sym) ################################################## # Connections ################################################## self.connect((self.Spread_cpfsk_demod_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.Spread_cpfsk_mod_0, 0), (self.Spread_synthesizer_0, 0)) self.connect((self.Spread_rx_synthesizer_0, 0), (self.Spread_cpfsk_demod_0, 0)) self.connect((self.Spread_rx_synthesizer_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.Spread_synthesizer_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.Spread_cpfsk_mod_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.Spread_rx_synthesizer_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Wifi Rx Jun28") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Rx Jun28") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wifi_rx_jun28") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.threshold = threshold = 1000 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 0.5e6 self.lo_offset = lo_offset = 0 self.gain = gain = 20 self.freq = freq = 943000000.0 self.decimation = decimation = 40 self.chan_est = chan_est = 1 ################################################## # Blocks ################################################## self._samp_rate_options = [0.5e6, 1e6, 5e6, 10e6, 20e6] self._samp_rate_labels = [ "500 KHz", "1 MHz", "5 MHz", "10 MHz", "20 MHz" ] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate" + ": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_tool_bar) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 32, #size 10, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 110) self.qtgui_time_sink_x_2.set_y_label("Amplitude", "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(True) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ["Packets Reveiced", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance( self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_c( 2**17, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0_0_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.02, 0.1, 0, "ofdm_start") self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0_0.disable_legend() labels = [ "samples", "corr", "correlation_big", "", "", "", "", "", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_win) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 2**17, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-0.1, 1000) self.qtgui_time_sink_x_0_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, threshold, 5e-3, 0, "FISTOR") self.qtgui_time_sink_x_0_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = [ "correlation I", "correlation Q", "correlation_big", "", "", "", "", "", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0.99, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.0000010) self.qtgui_number_sink_0.set_title("Frame error Rata") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 100) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.ofdm_80211_short_MF_v2_0 = ofdm_80211.short_MF_v2(160, 16) self.ofdm_80211_ftc_0 = ofdm_80211.ftc() self.nutaq_rtdex_source_0 = nutaq.rtdex_source( "nutaq_carrier_perseus_0", gr.sizeof_float, 1, 3) self.nutaq_rtdex_source_0.set_type(0) self.nutaq_rtdex_source_0.set_packet_size(8192) self.nutaq_rtdex_source_0.set_channels("2") self.nutaq_radio420_tx_0_0_0 = nutaq.radio420_tx( "nutaq_carrier_perseus_0", 2, 2) self.nutaq_radio420_tx_0_0_0.set_default_enable(0) self.nutaq_radio420_tx_0_0_0.set_default_tx_freq(743e6) self.nutaq_radio420_tx_0_0_0.set_default_reference(0) self.nutaq_radio420_tx_0_0_0.set_default_datarate(samp_rate * 2 * decimation) self.nutaq_radio420_tx_0_0_0.set_default_calibrate(1) self.nutaq_radio420_tx_0_0_0.set_default_band(0) self.nutaq_radio420_tx_0_0_0.set_default_update_rate(1) self.nutaq_radio420_tx_0_0_0.set_default_tx_vga1_gain(-10) self.nutaq_radio420_tx_0_0_0.set_default_tx_vga2_gain(15) self.nutaq_radio420_tx_0_0_0.set_default_tx_gain3(3) self.nutaq_radio420_tx_0_0_0.set_default_tx_lpf_bandwidth(6) self.nutaq_radio420_tx_0_0_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_tx_0_0_0.set_default_rf_ctrl(0) self.nutaq_radio420_tx_0_0_0.set_default_tx_gain_ctrl(0) self.nutaq_radio420_tx_0_0_0.set_default_pll_cpld_ctrl(0) self.nutaq_radio420_tx_0_0 = nutaq.radio420_tx( "nutaq_carrier_perseus_0", 1, 0) self.nutaq_radio420_tx_0_0.set_default_enable(0) self.nutaq_radio420_tx_0_0.set_default_tx_freq(743e6) self.nutaq_radio420_tx_0_0.set_default_reference(0) self.nutaq_radio420_tx_0_0.set_default_datarate(samp_rate * 2 * decimation) self.nutaq_radio420_tx_0_0.set_default_calibrate(1) self.nutaq_radio420_tx_0_0.set_default_band(0) self.nutaq_radio420_tx_0_0.set_default_update_rate(1) self.nutaq_radio420_tx_0_0.set_default_tx_vga1_gain(-10) self.nutaq_radio420_tx_0_0.set_default_tx_vga2_gain(15) self.nutaq_radio420_tx_0_0.set_default_tx_gain3(3) self.nutaq_radio420_tx_0_0.set_default_tx_lpf_bandwidth(6) self.nutaq_radio420_tx_0_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_rf_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_tx_gain_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_pll_cpld_ctrl(0) self.nutaq_radio420_rx_0_0 = nutaq.radio420_rx( "nutaq_carrier_perseus_0", 2, 3) self.nutaq_radio420_rx_0_0.set_default_enable(1) self.nutaq_radio420_rx_0_0.set_default_rx_freq(943e6) self.nutaq_radio420_rx_0_0.set_default_reference(0) self.nutaq_radio420_rx_0_0.set_default_datarate(samp_rate * 2 * decimation) self.nutaq_radio420_rx_0_0.set_default_calibrate(1) self.nutaq_radio420_rx_0_0.set_default_band(0) self.nutaq_radio420_rx_0_0.set_default_update_rate(1) self.nutaq_radio420_rx_0_0.set_default_rx_lna_gain(3) self.nutaq_radio420_rx_0_0.set_default_rx_vga1_gain(3) self.nutaq_radio420_rx_0_0.set_default_rx_gain2(0) self.nutaq_radio420_rx_0_0.set_default_rx_gain3(8) self.nutaq_radio420_rx_0_0.set_default_rx_rf_filter(2) self.nutaq_radio420_rx_0_0.set_default_rx_lpf_bandwidth(2) self.nutaq_radio420_rx_0_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_rx_0_0.set_default_rf_ctrl(0) self.nutaq_radio420_rx_0_0.set_default_rx_gain_ctrl(0) self.nutaq_radio420_rx_0_0.set_default_pll_cpld_ctrl(0) self.nutaq_radio420_rx_0 = nutaq.radio420_rx("nutaq_carrier_perseus_0", 1, 1) self.nutaq_radio420_rx_0.set_default_enable(0) self.nutaq_radio420_rx_0.set_default_rx_freq(943e6) self.nutaq_radio420_rx_0.set_default_reference(0) self.nutaq_radio420_rx_0.set_default_datarate(samp_rate * 2 * decimation) self.nutaq_radio420_rx_0.set_default_calibrate(1) self.nutaq_radio420_rx_0.set_default_band(0) self.nutaq_radio420_rx_0.set_default_update_rate(1) self.nutaq_radio420_rx_0.set_default_rx_lna_gain(2) self.nutaq_radio420_rx_0.set_default_rx_vga1_gain(1) self.nutaq_radio420_rx_0.set_default_rx_gain2(0) self.nutaq_radio420_rx_0.set_default_rx_gain3(3) self.nutaq_radio420_rx_0.set_default_rx_rf_filter(2) self.nutaq_radio420_rx_0.set_default_rx_lpf_bandwidth(2) self.nutaq_radio420_rx_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_rx_0.set_default_rf_ctrl(0) self.nutaq_radio420_rx_0.set_default_rx_gain_ctrl(0) self.nutaq_radio420_rx_0.set_default_pll_cpld_ctrl(0) self.nutaq_custom_register_0_2 = nutaq.custom_register( "nutaq_carrier_perseus_0", 4) self.nutaq_custom_register_0_2.set_index(0) self.nutaq_custom_register_0_2.set_default_value( int((4e6) / samp_rate / 40 * (2**32))) self.nutaq_custom_register_0_2.set_update_rate(1) self.nutaq_custom_register_0_1 = nutaq.custom_register( "nutaq_carrier_perseus_0", 4) self.nutaq_custom_register_0_1.set_index(2) self.nutaq_custom_register_0_1.set_update_rate(1) self.nutaq_custom_register_0_0_1 = nutaq.custom_register( "nutaq_carrier_perseus_0", 5) self.nutaq_custom_register_0_0_1.set_index(3) self.nutaq_custom_register_0_0_1.set_default_value(7) self.nutaq_custom_register_0_0_1.set_update_rate(1) self.nutaq_custom_register_0_0_0 = nutaq.custom_register( "nutaq_carrier_perseus_0", 5) self.nutaq_custom_register_0_0_0.set_index(6) self.nutaq_custom_register_0_0_0.set_default_value(600) self.nutaq_custom_register_0_0_0.set_update_rate(1) self.nutaq_custom_register_0_0 = nutaq.custom_register( "nutaq_carrier_perseus_0", 5) self.nutaq_custom_register_0_0.set_index(4) self.nutaq_custom_register_0_0.set_update_rate(1) self.nutaq_custom_register_0 = nutaq.custom_register( "nutaq_carrier_perseus_0", 4) self.nutaq_custom_register_0.set_index(1) self.nutaq_custom_register_0.set_default_value(3) self.nutaq_custom_register_0.set_update_rate(1) self.nutaq_carrier_perseus_0 = nutaq.carrier( 0, "nutaq_carrier_perseus_0", "192.168.0.101") self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long( sync_length, False, False) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac( False, False) self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols( ieee802_11.LMS, False) self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal( False, False) self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac( False, False) self._gain_range = Range(0, 100, 1, 20, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "slider") self.top_layout.addWidget(self._gain_win) self._freq_options = [ 943000000.0, 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ] self._freq_labels = [ ' 0 | 943.0 | ??', ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("Channel" + ": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.carajito = ofdm_80211.ofdm_sync_short(threshold, 2, False, False) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.float_t, "packet_len") self.blocks_null_sink_0_1_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.carajito, 0), (self.blocks_delay_0, 0)) self.connect((self.carajito, 0), (self.ieee802_11_ofdm_sync_long_0, 0)) self.connect((self.carajito, 0), (self.qtgui_time_sink_x_0_0_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0)) self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.nutaq_rtdex_source_0, 0), (self.ofdm_80211_ftc_0, 0)) self.connect((self.ofdm_80211_ftc_0, 0), (self.ofdm_80211_short_MF_v2_0, 0)) self.connect((self.ofdm_80211_ftc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.ofdm_80211_short_MF_v2_0, 2), (self.blocks_null_sink_0_1_0_0, 0)) self.connect((self.ofdm_80211_short_MF_v2_0, 0), (self.carajito, 0)) self.connect((self.ofdm_80211_short_MF_v2_0, 1), (self.carajito, 1)) self.connect((self.ofdm_80211_short_MF_v2_0, 3), (self.carajito, 2)) self.connect((self.ofdm_80211_short_MF_v2_0, 3), (self.qtgui_time_sink_x_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tlm Ana") Qt.QWidget.__init__(self) self.setWindowTitle("Tlm Ana") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "tlm_ana") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 40 self.nfilt = nfilt = 40 self.audio_rate = audio_rate = 48e3 self.samp_rate = samp_rate = 300e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilt * 1.0, audio_rate, 1200.0, 0.35, 16 * sps) self.ch_rate = ch_rate = 96e3 ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.fir_filter_fff( 1, firdes.root_raised_cosine(1.0, audio_rate, 1200.0, 0.35, 16 * 40)) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(ch_rate), decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 8192 * 8, #size audio_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-15, 15) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 50e-3, 0, 'start') self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "red", "blue", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-100, -20) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fft_filter_xxx_2 = filter.fft_filter_ccc( 1, (firdes.low_pass(1, audio_rate, 1e3, 1e3, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_2.declare_sample_delay(0) self.fft_filter_xxx_1 = filter.fft_filter_fff(1, (firdes.band_pass( 1, audio_rate, 700, 2700, 500, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_1.declare_sample_delay(0) self.fft_filter_xxx_0 = filter.fft_filter_ccc( 1, (firdes.low_pass(1, samp_rate, 5e3, 1e3, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_threshold_ff_0 = blocks.threshold_ff(0.5, 0.7, 0) self.blocks_tagged_file_sink_0 = blocks.tagged_file_sink( gr.sizeof_char * 1, int(audio_rate)) self.blocks_rotator_cc_1 = blocks.rotator_cc( (-1700 / audio_rate) * 2 * math.pi) self.blocks_rotator_cc_0 = blocks.rotator_cc(-(-16.2e3 / samp_rate) * 2 * math.pi) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_multiply_const_vxx_5 = blocks.multiply_const_vcc((2, )) self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vff((1.0, )) self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vff((1, )) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((7, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1e4, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 400, 1.0 / 400, 4000) self.blocks_keep_one_in_n_2 = blocks.keep_one_in_n( gr.sizeof_float * 1, 5) self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n( gr.sizeof_float * 1, 2) self.blocks_float_to_short_0 = blocks.float_to_short(1, 1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/handiko/gqrx_20180319_072938_433268400_300000_fc.raw', True) self.blocks_delay_3 = blocks.delay(gr.sizeof_float * 1, 0) self.blocks_delay_2 = blocks.delay(gr.sizeof_short * 1, 2400) self.blocks_delay_1 = blocks.delay(gr.sizeof_short * 1, 400) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 400) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_burst_tagger_1 = blocks.burst_tagger(gr.sizeof_float) self.blocks_burst_tagger_1.set_true_tag('burst', True) self.blocks_burst_tagger_1.set_false_tag('burst', False) self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_float) self.blocks_burst_tagger_0.set_true_tag('start', True) self.blocks_burst_tagger_0.set_false_tag('stop', False) self.blocks_add_const_vxx_3 = blocks.add_const_vff((-5, )) self.blocks_add_const_vxx_2 = blocks.add_const_vff((5, )) self.blocks_add_const_vxx_1 = blocks.add_const_vff((48, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0, )) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( audio_rate / (2 * math.pi * 1e3 / 8.0)) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=int(audio_rate), quad_rate=int(ch_rate), tau=75e-6, max_dev=5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.fft_filter_xxx_1, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_burst_tagger_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_keep_one_in_n_2, 0)) self.connect((self.blocks_add_const_vxx_2, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_add_const_vxx_3, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_burst_tagger_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_burst_tagger_1, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_burst_tagger_0, 1)) self.connect((self.blocks_delay_2, 0), (self.blocks_burst_tagger_1, 1)) self.connect((self.blocks_delay_3, 0), (self.blocks_multiply_const_vxx_3, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_tagged_file_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_rotator_cc_1, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_delay_1, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_delay_2, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.blocks_keep_one_in_n_2, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_add_const_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_const_vxx_3, 0)) self.connect((self.blocks_multiply_const_vxx_4, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_multiply_const_vxx_5, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.blocks_multiply_const_vxx_5, 0)) self.connect((self.blocks_rotator_cc_1, 0), (self.fft_filter_xxx_2, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_keep_one_in_n_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.fft_filter_xxx_1, 0), (self.blocks_burst_tagger_0, 0)) self.connect((self.fft_filter_xxx_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_delay_3, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_const_vxx_4, 0))
def __init__(self, meta_rate=10): gr.top_block.__init__(self, "Fox1D Playback Sigmf") Qt.QWidget.__init__(self) self.setWindowTitle("Fox1D Playback Sigmf") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fox1d_playback_sigmf") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.meta_rate = meta_rate ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.decim = decim = 5 self.baud = baud = 9600 self.xlate_taps_old = xlate_taps_old = firdes.low_pass( 1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate, 15e3, 1000, firdes.WIN_HAMMING, 6.76) self.volume = volume = 0.01 self.throttle_factor = throttle_factor = 1 self.samps_per_symb = samps_per_symb = samp_rate / decim / baud self.rf_lpf_cutoff = rf_lpf_cutoff = 8e3 self.fsk_deviation_hz = fsk_deviation_hz = 4000 self.fll_loop_bw_fine = fll_loop_bw_fine = 0.0001 self.fll_loop_bw = fll_loop_bw = math.pi / 200 self.audio_lpf_cutoff = audio_lpf_cutoff = 7e3 ################################################## # Blocks ################################################## self._volume_tool_bar = Qt.QToolBar(self) self._volume_tool_bar.addWidget(Qt.QLabel("volume" + ": ")) self._volume_line_edit = Qt.QLineEdit(str(self.volume)) self._volume_tool_bar.addWidget(self._volume_line_edit) self._volume_line_edit.returnPressed.connect(lambda: self.set_volume( eng_notation.str_to_num( str(self._volume_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._volume_tool_bar, 7, 4, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._throttle_factor_tool_bar = Qt.QToolBar(self) self._throttle_factor_tool_bar.addWidget( Qt.QLabel("throttle_factor" + ": ")) self._throttle_factor_line_edit = Qt.QLineEdit( str(self.throttle_factor)) self._throttle_factor_tool_bar.addWidget( self._throttle_factor_line_edit) self._throttle_factor_line_edit.returnPressed.connect( lambda: self.set_throttle_factor( eng_notation.str_to_num( str(self._throttle_factor_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._throttle_factor_tool_bar, 6, 4, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._rf_lpf_cutoff_tool_bar = Qt.QToolBar(self) self._rf_lpf_cutoff_tool_bar.addWidget( Qt.QLabel("rf_lpf_cutoff" + ": ")) self._rf_lpf_cutoff_line_edit = Qt.QLineEdit(str(self.rf_lpf_cutoff)) self._rf_lpf_cutoff_tool_bar.addWidget(self._rf_lpf_cutoff_line_edit) self._rf_lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_rf_lpf_cutoff( eng_notation.str_to_num( str(self._rf_lpf_cutoff_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rf_lpf_cutoff_tool_bar, 6, 0, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._fll_loop_bw_fine_tool_bar = Qt.QToolBar(self) self._fll_loop_bw_fine_tool_bar.addWidget( Qt.QLabel("fll_loop_bw_fine" + ": ")) self._fll_loop_bw_fine_line_edit = Qt.QLineEdit( str(self.fll_loop_bw_fine)) self._fll_loop_bw_fine_tool_bar.addWidget( self._fll_loop_bw_fine_line_edit) self._fll_loop_bw_fine_line_edit.returnPressed.connect( lambda: self.set_fll_loop_bw_fine( eng_notation.str_to_num( str(self._fll_loop_bw_fine_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._fll_loop_bw_fine_tool_bar, 7, 2, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._fll_loop_bw_tool_bar = Qt.QToolBar(self) self._fll_loop_bw_tool_bar.addWidget(Qt.QLabel("fll_loop_bw" + ": ")) self._fll_loop_bw_line_edit = Qt.QLineEdit(str(self.fll_loop_bw)) self._fll_loop_bw_tool_bar.addWidget(self._fll_loop_bw_line_edit) self._fll_loop_bw_line_edit.returnPressed.connect( lambda: self.set_fll_loop_bw( eng_notation.str_to_num( str(self._fll_loop_bw_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._fll_loop_bw_tool_bar, 6, 2, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._audio_lpf_cutoff_tool_bar = Qt.QToolBar(self) self._audio_lpf_cutoff_tool_bar.addWidget( Qt.QLabel("audio_lpf_cutoff" + ": ")) self._audio_lpf_cutoff_line_edit = Qt.QLineEdit( str(self.audio_lpf_cutoff)) self._audio_lpf_cutoff_tool_bar.addWidget( self._audio_lpf_cutoff_line_edit) self._audio_lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_audio_lpf_cutoff( eng_notation.str_to_num( str(self._audio_lpf_cutoff_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_lpf_cutoff_tool_bar, 7, 0, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.sigmf_sink_0 = sigmf.sink("cf32", '', sigmf.sigmf_time_mode_relative, False) self.sigmf_sink_0.set_global_meta("core:sample_rate", samp_rate) self.sigmf_sink_0.set_global_meta("core:description", '') self.sigmf_sink_0.set_global_meta("core:author", '') self.sigmf_sink_0.set_global_meta("core:license", '') self.sigmf_sink_0.set_global_meta("core:hw", '') self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "corrected", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-80, 0) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 2, 4, 2, 4) for r in range(2, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "Pre-D", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-80, 0) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0, 4, 2, 4) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate / decim / 50 * 48, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8, 0, 1, 8) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0_0.set_title("") labels = ['SNR', '', '', '', '', '', '', '', '', ''] units = ['dB', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0_0.set_max(i, 30) self.qtgui_number_sink_0_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_0_win, 6, 6, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0_0_0.set_update_time(0.010) self.qtgui_number_sink_0_0_0_0.set_title("") labels = ['Freq Offset', 'Phase', 'Error', '', '', '', '', '', '', ''] units = ['Hz', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0_0.set_min(i, -32767) self.qtgui_number_sink_0_0_0_0.set_max(i, 32767) self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 6, 7, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "Pre-D", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-60, 0) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['pre-d', 'corr', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0_0_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate / decim / 50 * 48, audio_lpf_cutoff, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim, rf_lpf_cutoff, 2e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( decim, (xlate_taps), 0, samp_rate) self.digital_fll_band_edge_cc_0_0 = digital.fll_band_edge_cc( samps_per_symb, .5, 1024, fll_loop_bw_fine) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( samps_per_symb, .5, 1024, fll_loop_bw) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * throttle_factor, True) self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.float_t, 'snr') self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.float_t, 'rfo') self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, 1, "snr") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, 1, "rfo") self.blocks_socket_pdu_0_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '52002', 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '52001', 10000, False) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (-1 * samp_rate / decim / (2 * math.pi), )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff( 10000, 0.0001, 4000, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 100000, 0.00001, 4000, 1) self.blocks_keep_one_in_n_0_0_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate / decim / meta_rate)) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate * meta_rate)) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate / 4 * meta_rate)) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/zleffke/captures/fox1d/20180913/FOX-1D_USRP_20180913_151002.518249_UTC_250k.fc32', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, samp_rate / decim / 4, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0)) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.blocks_socket_pdu_0_0, 'pdus')) self.connect((self.analog_agc2_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.sigmf_sink_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0_0, 0), (self.qtgui_number_sink_0_0_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.qtgui_number_sink_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_keep_one_in_n_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_nlog10_ff_0_1, 0), (self.blocks_moving_average_xx_0_0_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 1), (self.blocks_add_xx_0, 1)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 2), (self.blocks_null_sink_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 3), (self.blocks_null_sink_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 1), (self.blocks_add_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 3), (self.blocks_null_sink_0_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 2), (self.blocks_null_sink_0_1, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.digital_fll_band_edge_cc_0_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_fll_band_edge_cc_0_0, 0)) self.connect((self.low_pass_filter_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_squared_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Example5A Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Example5A Rx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "example5a_rx") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.time_preamble = time_preamble = [ 0.125000 + 0.000000j, 0.522104 - 0.148216j, -0.495528 + 0.114832j, -0.267916 + 0.091700j, 0.236544 - 0.138456j, -0.098500 + 0.473800j, 0.476480 - 0.225344j, -0.187516 + 0.035372j, 0.051776 - 0.353552j, -0.104936 + 0.059916j, 0.228684 + 0.117504j, -0.530912 + 0.560756j, 0.359128 + 0.015872j, -0.132852 + 0.632840j, -0.105164 - 0.368872j, 0.368272 - 0.032412j, 0.125000 + 0.750000j, 0.463968 + 0.457792j, 0.151476 - 0.430948j, 0.685052 + 0.238524j, 0.494428 + 0.119428j, -0.557540 - 0.050056j, 0.416348 + 0.017368j, 0.104256 - 0.568836j, -0.301776 - 0.353552j, 0.079812 + 0.451516j, 0.439152 + 0.528072j, 0.642060 + 0.178484j, -0.090096 + 0.465096j, -0.446492 + 0.305776j, -0.111440 - 0.093688j, -0.538848 - 0.320228j, 0.125000 + 0.000000j, -0.538848 + 0.320228j, -0.111440 + 0.093688j, -0.446492 - 0.305776j, -0.090096 - 0.465096j, 0.642060 - 0.178484j, 0.439152 - 0.528072j, 0.079812 - 0.451516j, -0.301776 + 0.353552j, 0.104256 + 0.568836j, 0.416348 - 0.017368j, -0.557540 + 0.050056j, 0.494428 - 0.119428j, 0.685052 - 0.238524j, 0.151476 + 0.430948j, 0.463968 - 0.457792j, 0.125000 - 0.750000j, 0.368272 + 0.032412j, -0.105164 + 0.368872j, -0.132852 - 0.632840j, 0.359128 - 0.015872j, -0.530912 - 0.560756j, 0.228684 - 0.117504j, -0.104936 - 0.059916j, 0.051776 + 0.353552j, -0.187516 - 0.035372j, 0.476480 + 0.225344j, -0.098500 - 0.473800j, 0.236544 + 0.138456j, -0.267916 - 0.091700j, -0.495528 - 0.114832j, 0.522104 + 0.148216j ] self.threshold = threshold = 1 self.samp_rate = samp_rate = 1000000 self.preamble_len = preamble_len = 64 self.packet_len = packet_len = 1024 ################################################## # Blocks ################################################## self._threshold_range = Range(0, 2, 0.01, 1, 200) self._threshold_win = RangeWidget(self._threshold_range, self.set_threshold, 'Threshold', "counter_slider", float) self.top_grid_layout.addWidget(self._threshold_win, 0, 0, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self.qtgui_time_sink_x_1 = qtgui.time_sink_f( preamble_len + packet_len, #size samp_rate, #samp_rate "Synchronization", #name 2 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-0.2, 2) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, False) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "Packet Samples", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-0.2, 0.2) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, False) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.mysvl_triggered_demux_0 = mysvl.triggered_demux( gr.sizeof_gr_complex * 1, gr.sizeof_float, (preamble_len, packet_len), 1, True) self.digital_corr_est_cc_0 = digital.corr_est_cc((time_preamble), 1, 0, 0.99) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1, '127.0.0.1', 4000, 1472 * 16, True) (self.blocks_udp_source_0).set_min_output_buffer(1000000) self.blocks_threshold_ff_0 = blocks.threshold_ff( threshold, threshold, 0) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_abs_xx_1 = blocks.abs_ff(1) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, threshold) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_abs_xx_1, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_abs_xx_1, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_abs_xx_1, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.mysvl_triggered_demux_0, 1)) self.connect((self.blocks_udp_source_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_float_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.mysvl_triggered_demux_0, 0)) self.connect((self.mysvl_triggered_demux_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.mysvl_triggered_demux_0, 1), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "ORBCOMM UHF Beacon RX") Qt.QWidget.__init__(self) self.setWindowTitle("ORBCOMM UHF Beacon RX") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "orbcomm_beacon_rx_exp") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 50e3 self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y%m%d_%H%M%S.%f") + '_UTC' self.offset = offset = 0 self.fft_size = fft_size = 4096 * 1 self.delay = delay = 10 ################################################## # Blocks ################################################## self._offset_tool_bar = Qt.QToolBar(self) self._offset_tool_bar.addWidget(Qt.QLabel('OFFSET' + ": ")) self._offset_line_edit = Qt.QLineEdit(str(self.offset)) self._offset_tool_bar.addWidget(self._offset_line_edit) self._offset_line_edit.returnPressed.connect(lambda: self.set_offset( eng_notation.str_to_num( str(self._offset_line_edit.text().toAscii())))) self.top_layout.addWidget(self._offset_tool_bar) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( .005, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -40) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0, 6, 3, 6) self.qtgui_number_sink_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 4) self.qtgui_number_sink_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0.set_title("") labels = [ 'Freq', 'Sig_Ampl', 'Noise_Ampl', 'SNR', '', '', '', '', '', '' ] units = ['Hz', 'dB', 'dB', 'dB', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(4): self.qtgui_number_sink_0_0_0.set_min(i, -32767) self.qtgui_number_sink_0_0_0.set_max(i, 32767) self.qtgui_number_sink_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_0_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['Doppler Rate', '', '', '', '', '', '', '', '', ''] units = ['Hz/s', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( 10, 1000, 0, 100, "Doppler Rate [Hz/s]", 1) self.qtgui_histogram_sink_x_0.set_update_time(0.010) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not False: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['Doppler Rate', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance( self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 3, 6, 3, 6) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-140, -80) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 6, 6) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (xlate_taps), offset, samp_rate) self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.blackmanharris(fft_size)), True, 2) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_float * 1, 4096) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * 4, True) self.blocks_sub_xx_0_0 = blocks.sub_ff(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_size) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, fft_size, -20 * math.log10(fft_size)) self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff( ((samp_rate / fft_size) / delay, )) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff( (samp_rate / fft_size, )) self.blocks_moving_average_xx_1 = blocks.moving_average_ff( fft_size, float(1.0 / fft_size), 4000, 1) self.blocks_max_xx_0 = blocks.max_ff(fft_size, 1) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, fft_size) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/zleffke/captures/orbcomm/ORBCOMM_FMXX_USRP_20171203_013912.497704_UTC_50k.fc32', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, delay) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( fft_size) self.blocks_argmax_xx_0 = blocks.argmax_fs(fft_size) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-samp_rate / 2, )) self.blocks_abs_xx_0 = blocks.abs_ff(1) ################################################## # Connections ################################################## self.connect((self.blocks_abs_xx_0, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_sub_xx_0_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_0_0_0, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.qtgui_number_sink_0_0_0, 2)) self.connect((self.blocks_max_xx_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0_0_0, 1)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_max_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_number_sink_0_0_0, 3)) self.connect((self.blocks_sub_xx_0_0, 0), (self.blocks_multiply_const_vxx_1_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_moving_average_xx_1, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.qtgui_number_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Run Music Calib Lin Array Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("Run Music Calib Lin Array Simulation") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "run_MUSIC_calib_lin_array_simulation") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.theta1_deg = theta1_deg = 123 self.theta0_deg = theta0_deg = 30 self.input_variables = input_variables = struct({ 'SampleRate': 320000, 'ToneFreq1': 10000, 'ToneFreq2': 20000, 'NormSpacing': 0.5, 'NumTargets': 2, 'NumArrayElements': 4, 'PSpectrumLength': 2**10, 'SnapshotSize': 2**11, 'OverlapSize': 2**9, 'AntGains': numpy.array([0.94984789, 0.4544107, 0.34649469, 0.25083929]), 'AntPhases': numpy.array([0.28647672, 5.27248071, 2.71271102, 1.36970886]), 'DirectoryConfigFiles': "/tmp", 'AntennaCalibration': "calibration_lin_array_simulated.cfg", }) self.theta1 = theta1 = numpy.pi * theta1_deg / 180 self.theta0 = theta0 = numpy.pi * theta0_deg / 180 self.ant_locs = ant_locs = numpy.dot( 0.5, numpy.arange(input_variables.NumArrayElements / 2, -input_variables.NumArrayElements / 2, -1) if (input_variables.NumArrayElements % 2 == 1) else numpy.arange( input_variables.NumArrayElements / 2 - 0.5, -input_variables.NumArrayElements / 2 - 0.5, -1)) self.ant_coeffs = ant_coeffs = input_variables.AntGains * numpy.exp( 1j * input_variables.AntPhases) self.amv1_true = amv1_true = numpy.exp(-1j * ant_locs * 2 * numpy.pi * numpy.cos(theta1)) self.amv0_true = amv0_true = numpy.exp(-1j * ant_locs * 2 * numpy.pi * numpy.cos(theta0)) self.amv1 = amv1 = numpy.multiply(ant_coeffs, amv1_true) self.amv0 = amv0 = numpy.multiply(ant_coeffs, amv0_true) self.array_manifold_matrix = array_manifold_matrix = numpy.array( [amv0, amv1]).transpose() self.antenna_calibration_file_name = antenna_calibration_file_name = os.path.join( input_variables.DirectoryConfigFiles, input_variables.AntennaCalibration) ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Pseudo-Spectrum') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Direction of Arrival') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Direction of Arrival') self.top_layout.addWidget(self.tab) self._theta1_deg_range = Range(0, 180, 1, 123, 200) self._theta1_deg_win = RangeWidget(self._theta1_deg_range, self.set_theta1_deg, 'AoA', "counter_slider", float) self.top_layout.addWidget(self._theta1_deg_win) self._theta0_deg_range = Range(0, 180, 1, 30, 200) self._theta0_deg_win = RangeWidget(self._theta0_deg_range, self.set_theta0_deg, 'AoA', "counter_slider", float) self.top_layout.addWidget(self._theta0_deg_win) self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f( input_variables.PSpectrumLength, 0, 180.0 / input_variables.PSpectrumLength, "angle (in degrees)", "Pseudo-Spectrum (dB)", "", 1 # Number of inputs ) self.qtgui_vector_sink_f_0.set_update_time(0.05) self.qtgui_vector_sink_f_0.set_y_axis(-50, 0) self.qtgui_vector_sink_f_0.enable_autoscale(False) self.qtgui_vector_sink_f_0.enable_grid(True) self.qtgui_vector_sink_f_0.set_x_axis_units("") self.qtgui_vector_sink_f_0.set_y_axis_units("") self.qtgui_vector_sink_f_0.set_ref_level(0) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_vector_sink_f_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_vector_sink_f_0.set_line_label(i, labels[i]) self.qtgui_vector_sink_f_0.set_line_width(i, widths[i]) self.qtgui_vector_sink_f_0.set_line_color(i, colors[i]) self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i]) self._qtgui_vector_sink_f_0_win = sip.wrapinstance( self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_vector_sink_f_0_win) self.doa_find_local_max_0 = doa.find_local_max( input_variables.NumTargets, input_variables.PSpectrumLength, 0.0, 180.0) self.doa_compass_0 = doa.compass("", 0, 180, 10, 0) self.tab_layout_1.addLayout(self.doa_compass_0.this_layout) self.doa_compass = doa.compass("", 0, 180, 10, 0) self.tab_layout_2.addLayout(self.doa_compass.this_layout) self.doa_autocorrelate_0 = doa.autocorrelate( input_variables.NumArrayElements, input_variables.SnapshotSize, input_variables.OverlapSize, 1) self.doa_antenna_correction_0 = doa.antenna_correction( input_variables.NumArrayElements, antenna_calibration_file_name) self.doa_MUSIC_lin_array_0 = doa.MUSIC_lin_array( input_variables.NormSpacing, input_variables.NumTargets, input_variables.NumArrayElements, input_variables.PSpectrumLength) self.blocks_vector_to_streams_0 = blocks.vector_to_streams( gr.sizeof_float * 1, input_variables.NumTargets) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, input_variables.SampleRate, True) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * input_variables.NumTargets) self.blocks_multiply_matrix_xx_0 = blocks.multiply_matrix_cc( array_manifold_matrix, gr.TPP_ALL_TO_ALL) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0_0 = analog.sig_source_c( input_variables.SampleRate, analog.GR_COS_WAVE, input_variables.ToneFreq2, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( input_variables.SampleRate, analog.GR_COS_WAVE, input_variables.ToneFreq1, 1, 0) self.analog_noise_source_x_0_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0.5, 0) self.analog_noise_source_x_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0.0005, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_noise_source_x_0_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_matrix_xx_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0, 0), (self.doa_antenna_correction_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0, 1), (self.doa_antenna_correction_0, 1)) self.connect((self.blocks_multiply_matrix_xx_0, 2), (self.doa_antenna_correction_0, 2)) self.connect((self.blocks_multiply_matrix_xx_0, 3), (self.doa_antenna_correction_0, 3)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_matrix_xx_0, 1)) self.connect((self.blocks_vector_to_streams_0, 0), (self.doa_compass, 0)) self.connect((self.blocks_vector_to_streams_0, 1), (self.doa_compass_0, 0)) self.connect((self.doa_MUSIC_lin_array_0, 0), (self.doa_find_local_max_0, 0)) self.connect((self.doa_MUSIC_lin_array_0, 0), (self.qtgui_vector_sink_f_0, 0)) self.connect((self.doa_antenna_correction_0, 0), (self.doa_autocorrelate_0, 0)) self.connect((self.doa_antenna_correction_0, 1), (self.doa_autocorrelate_0, 1)) self.connect((self.doa_antenna_correction_0, 2), (self.doa_autocorrelate_0, 2)) self.connect((self.doa_antenna_correction_0, 3), (self.doa_autocorrelate_0, 3)) self.connect((self.doa_autocorrelate_0, 0), (self.doa_MUSIC_lin_array_0, 0)) self.connect((self.doa_find_local_max_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.doa_find_local_max_0, 1), (self.blocks_vector_to_streams_0, 0))
def __init__(self): gr.top_block.__init__(self, "Simple X310 Grc") Qt.QWidget.__init__(self) self.setWindowTitle("Simple X310 Grc") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "simple_x310_grc") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 800e3 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(800e6, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) ##self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 250e3, 1, 0) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000)), True) # time sink self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) channel_prop = { 'sample_rate': self.samp_rate, # Input sample rate in Hz 'sro_std_dev': 0.01, # sample rate drift process standard deviation per sample in Hz 'sro_max_dev': 0.1, # maximum sample rate offset in Hz 'cfo_std_dev': 0.01, # carrier frequnecy drift process standard deviation per sample in Hz 'cfo_max_dev': 0.1, # maximum carrier frequency offset in Hz 'N_sinusoids': 8, # number of sinusoids used in frequency selective fading simulation 'fD': 1, # doppler frequency 'LOS_model': True, # defines whether the fading model should include a line of site component. LOS->Rician, NLOS->Rayleigh 'K_factor': 4, # Rician K-factor, the ratio of specular to diffuse power in the model 'delays': [ 0.0 ], # A list of fractional sample delays making up the power delay profile 'mags': [ 1 ], # A list of magnitudes corresponding to each delay time in the power delay profile 'ntaps': 8, # The length of the filter to interpolate the power delay profile over. Delays in the PDP must lie between 0 and ntaps_mpath, fractional delays will be sinc-interpolated only to the width of this filter. 'snr': 20 } #src, mod, chan = gen_cpfsk(channel_prop) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, 'offline/gfsk.dat', True) ################################################## # Connections ################################################## # self.connect((src, 0), (mod, 0)) #self.connect((mod, 0)), (chan, 0)) ##self.connect((self.analog_sig_source_x_0, 0), (self.qtgui_freq_sink_x_0, 0)) # self.connect((mod, 0), (self.qtgui_freq_sink_x_0, 0)) # self.connect((mod, 0), (self.qtgui_time_sink_x_0, 0)) # self.connect((mod, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.uhd_usrp_sink_0, 0))
def terminate_stream(hb, block): streamsize = determine_streamsize(block) hb.connect(block, blocks.null_sink(streamsize))
def __init__(self): gr.top_block.__init__(self, "Testbench") Qt.QWidget.__init__(self) self.setWindowTitle("Testbench") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "testbench") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.decim = decim = 1 self.audio_samp_rate = audio_samp_rate = 40e3 self.symbol_rate = symbol_rate = 20e3 self.samp_rate = samp_rate = audio_samp_rate / decim self.sps = sps = float(samp_rate) / symbol_rate self.rolloff = rolloff = 0.2 self.ntaps = ntaps = 31 self.tx_taps_hex = tx_taps_hex = [ 119, -19, -111, 129, 21, -277, 199, 446, -619, -616, 1385, 760, -3014, -857, 10233, 17209, 10233, -857, -3014, 760, 1385, -616, -619, 446, 199, -277, 21, 129, -111, -19, 119 ] self.sym_per_arm = sym_per_arm = 8 self.nfilts = nfilts = 16 self.ideal_taps = ideal_taps = firdes.root_raised_cosine( int(sps), samp_rate, symbol_rate, rolloff, ntaps) self.thresh = thresh = 70 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), rolloff, int(sym_per_arm * sps * nfilts)) self.quant_taps = quant_taps = [ round(2**15 * x) / 2**15 for x in ideal_taps ] self.constel = constel = digital.constellation_calcdist([ +0.70711 + +0.70711j, +1.0 + +0.0j, -1.0 + +0.0j, -0.70711 + -0.70711j, +0.0 + +1.0j, +0.70711 + -0.70711j, -0.70711 + +0.70711j, -0.0 + -1.0j ], list(range(0, 8)), 8, 1).base() self.constel.gen_soft_dec_lut(8) self.act_taps = act_taps = [x * 2**-15 for x in tx_taps_hex] ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(0, 50) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, thresh, 512 / samp_rate, 0, "phase_est") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0, 1, 2, 1) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 3, 0, 1, 2) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "EVM Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.001) self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) labels = [ 'Reclocked', 'Reference', 'Filtered', 'Raw', '', '', '', '', '', '' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "cyan", "yellow", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [2, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0, 0, 2, 1) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.kc2qol_ldpc_decoder_fb_0 = kc2qol.ldpc_decoder_fb() self.kc2qol_dvbs2_pl_deframer_0 = kc2qol.dvbs2_pl_deframer( 21600, pmt.intern('corr_est'), 0) self.kc2qol_dvbs2_8psk_demod_0 = kc2qol.dvbs2_8psk_demod(None) self.digital_symbol_sync_xx_0 = digital.symbol_sync_cc( digital.TED_MOD_MUELLER_AND_MULLER, sps, 2 * numpy.pi / 100 * 0.6, 1.0, 1.0, 1.5, 1, constel, digital.IR_MMSE_8TAP, 128, []) self.digital_corr_est_cc_0 = digital.corr_est_cc([ 0.707 + 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, 0.707 + 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j, 0.707 + 0.707j, 0.707 - 0.707j, -0.707 - 0.707j, -0.707 + 0.707j ], 1, 1, thresh / 90, digital.THRESHOLD_ABSOLUTE) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 1, 8, "", False, gr.GR_MSB_FIRST) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(2**-12) self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex( False, False) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_short * 1, '/Users/iracigt/Developer/DVB_hat/hdl/iq_bytes.bin', True, 0 * 21690 * 2, ) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_3 = blocks.file_sink( gr.sizeof_char * 1, '/Users/iracigt/Desktop/packets_ldpc.bin', False) self.blocks_file_sink_3.set_unbuffered(True) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_0 = blocks.add_const_cc(-3.8 * (1 + 1j)) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_interleaved_short_to_complex_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_file_sink_3, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_symbol_sync_xx_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.kc2qol_dvbs2_pl_deframer_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.kc2qol_dvbs2_8psk_demod_0, 0), (self.kc2qol_ldpc_decoder_fb_0, 0)) self.connect((self.kc2qol_dvbs2_pl_deframer_0, 0), (self.kc2qol_dvbs2_8psk_demod_0, 0)) self.connect((self.kc2qol_ldpc_decoder_fb_0, 0), (self.blocks_repack_bits_bb_0, 0))
def test_22(self): """ Test case generated by test-case generator """ ################################################## # Variables ################################################## # Input data into the system src_data = "PKdhtXMmr18n2L9K88eMlGn7CcctT9RwKSB1FebW397VI5uG1yhc3uavuaOb9vyJ" self.bw = bw = 250000 self.sf = sf = 8 self.samp_rate = samp_rate = 250000 self.pay_len = pay_len = 64 self.n_frame = n_frame = 2 self.impl_head = impl_head = True self.has_crc = has_crc = False self.frame_period = frame_period = 200 self.cr = cr = 5 ################################################## # Blocks ################################################## # Tx side self.lora_sdr_whitening_0 = lora_sdr.whitening() self.lora_sdr_modulate_0 = lora_sdr.modulate(sf, samp_rate, bw) self.lora_sdr_modulate_0.set_min_output_buffer(10000000) self.lora_sdr_interleaver_0 = lora_sdr.interleaver(cr, sf) self.lora_sdr_header_0 = lora_sdr.header(impl_head, has_crc, cr) self.lora_sdr_hamming_enc_0 = lora_sdr.hamming_enc(cr, sf) self.lora_sdr_gray_decode_0 = lora_sdr.gray_decode(sf) self.lora_sdr_data_source_0_1_0 = lora_sdr.data_source( pay_len, n_frame, src_data) self.lora_sdr_add_crc_0 = lora_sdr.add_crc(has_crc) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_message_strobe_random_0_1_0 = blocks.message_strobe_random( pmt.intern(''), blocks.STROBE_UNIFORM, frame_period, 5) # Rx side self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=4, decimation=1, taps=None, fractional_bw=None) self.lora_sdr_header_decoder_0 = lora_sdr.header_decoder( impl_head, cr, pay_len, has_crc) self.lora_sdr_hamming_dec_0 = lora_sdr.hamming_dec() self.lora_sdr_gray_enc_0 = lora_sdr.gray_enc() self.lora_sdr_frame_sync_0 = lora_sdr.frame_sync( samp_rate, bw, sf, impl_head) self.lora_sdr_fft_demod_0 = lora_sdr.fft_demod( samp_rate, bw, sf, impl_head) self.lora_sdr_dewhitening_0 = lora_sdr.dewhitening() self.lora_sdr_deinterleaver_0 = lora_sdr.deinterleaver(sf) self.lora_sdr_crc_verif_0 = lora_sdr.crc_verif() self.blocks_message_debug_0 = blocks.message_debug() self.blocks_throttle_0 = blocks.throttle( gr.sizeof_gr_complex*1, samp_rate, True) ################################################## # Connections ################################################## # Tx side self.tb.msg_connect((self.blocks_message_strobe_random_0_1_0, 'strobe'), (self.lora_sdr_data_source_0_1_0, 'trigg')) self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'), (self.lora_sdr_add_crc_0, 'msg')) self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'), (self.lora_sdr_header_0, 'msg')) self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'), (self.lora_sdr_interleaver_0, 'msg')) self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'), (self.lora_sdr_modulate_0, 'msg')) self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'), (self.lora_sdr_whitening_0, 'msg')) self.tb.connect((self.lora_sdr_add_crc_0, 0), (self.lora_sdr_hamming_enc_0, 0)) self.tb.connect((self.lora_sdr_gray_decode_0, 0), (self.lora_sdr_modulate_0, 0)) self.tb.connect((self.lora_sdr_hamming_enc_0, 0), (self.lora_sdr_interleaver_0, 0)) self.tb.connect((self.lora_sdr_header_0, 0), (self.lora_sdr_add_crc_0, 0)) self.tb.connect((self.lora_sdr_interleaver_0, 0), (self.lora_sdr_gray_decode_0, 0)) self.tb.connect((self.lora_sdr_whitening_0, 0), (self.lora_sdr_header_0, 0)) self.tb.connect((self.lora_sdr_modulate_0, 0), (self.blocks_throttle_0, 0)) # Rx side self.tb.connect((self.blocks_throttle_0, 0), (self.rational_resampler_xxx_0, 0)) self.tb.msg_connect((self.lora_sdr_crc_verif_0, 'msg'), (self.blocks_message_debug_0, 'store')) self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'), (self.lora_sdr_deinterleaver_0, 'new_frame')) self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'), (self.lora_sdr_dewhitening_0, 'new_frame')) self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'), (self.lora_sdr_fft_demod_0, 'new_frame')) self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'), (self.lora_sdr_hamming_dec_0, 'new_frame')) self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'), (self.lora_sdr_header_decoder_0, 'new_frame')) self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'), (self.lora_sdr_crc_verif_0, 'pay_len')) self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'), (self.lora_sdr_crc_verif_0, 'CRC')) self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'), (self.lora_sdr_deinterleaver_0, 'CR')) self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'), (self.lora_sdr_dewhitening_0, 'pay_len')) self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'), (self.lora_sdr_dewhitening_0, 'CRC')) self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'), (self.lora_sdr_fft_demod_0, 'CR')) self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'), (self.lora_sdr_frame_sync_0, 'CR')) self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'err'), (self.lora_sdr_frame_sync_0, 'err')) self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'), (self.lora_sdr_frame_sync_0, 'crc')) self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'), (self.lora_sdr_frame_sync_0, 'pay_len')) self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'), (self.lora_sdr_hamming_dec_0, 'CR')) self.tb.connect((self.lora_sdr_deinterleaver_0, 0), (self.lora_sdr_hamming_dec_0, 0)) self.tb.connect((self.lora_sdr_dewhitening_0, 0), (self.lora_sdr_crc_verif_0, 0)) self.tb.connect((self.lora_sdr_fft_demod_0, 0), (self.lora_sdr_gray_enc_0, 0)) self.tb.connect((self.lora_sdr_frame_sync_0, 0), (self.lora_sdr_fft_demod_0, 0)) self.tb.connect((self.lora_sdr_gray_enc_0, 0), (self.lora_sdr_deinterleaver_0, 0)) self.tb.connect((self.lora_sdr_hamming_dec_0, 0), (self.lora_sdr_header_decoder_0, 0)) self.tb.connect((self.lora_sdr_header_decoder_0, 0), (self.lora_sdr_dewhitening_0, 0)) self.tb.connect((self.rational_resampler_xxx_0, 0), (self.lora_sdr_frame_sync_0, 0)) # run the flowgraph, since we use a message strobe we have to run and stop the flowgraph with some computation time inbetween self.tb.start() time.sleep(10) self.tb.stop() self.tb.wait() # try to get get the message from the store port of the message debug printer and convert to string from pmt message try: msg = pmt.symbol_to_string( self.blocks_message_debug_0.get_message(0)) except: # if not possible set message to be None msg = None # check if message received is the same as the message decoded self.assertMultiLineEqual( src_data, msg, msg="Error decoded data {0} is not the same as input data {1}".format(msg, src_data))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Rx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952 ] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.H_dec = H_dec = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 30 self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 52 self.variable_qtgui_check_box_0 = variable_qtgui_check_box_0 = True self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.pld_dec = pld_dec = map((lambda a: fec.ldpc_bit_flip_decoder.make( H_dec.get_base_sptr(), 100)), range(0, 8)) self.pld_const = pld_const = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 484e6 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 30, 200) self._variable_qtgui_range_0_1_win = RangeWidget( self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 52, 200) self._variable_qtgui_range_0_0_win = RangeWidget( self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_Jamming', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 3, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) _variable_qtgui_check_box_0_check_box = Qt.QCheckBox('ENABLE JAM') self._variable_qtgui_check_box_0_choices = {True: True, False: False} self._variable_qtgui_check_box_0_choices_inv = dict( (v, k) for k, v in self._variable_qtgui_check_box_0_choices.iteritems()) self._variable_qtgui_check_box_0_callback = lambda i: Qt.QMetaObject.invokeMethod( _variable_qtgui_check_box_0_check_box, "setChecked", Qt.Q_ARG("bool", self._variable_qtgui_check_box_0_choices_inv[i])) self._variable_qtgui_check_box_0_callback( self.variable_qtgui_check_box_0) _variable_qtgui_check_box_0_check_box.stateChanged.connect( lambda i: self.set_variable_qtgui_check_box_0( self._variable_qtgui_check_box_0_choices[bool(i)])) self.top_grid_layout.addWidget(_variable_qtgui_check_box_0_check_box, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("serial=F5EAC0", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F5EAC0", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.scrambler_cpp_custom_descrambler_0 = scrambler_cpp.custom_descrambler( 0x8A, 0x7F, 7, 440 - 32) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX JAMMING USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "RX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "RX Treated", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc( 4, ([1, 0, 0, 0])) self.interp_fir_filter_xxx_1.declare_sample_delay(0) self.fec_extended_decoder_0_0_1_0_1_0_0 = fec.extended_decoder( decoder_obj_list=pld_dec, threading='capillary', ann=None, puncpat=puncpat, integration_period=10000) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_map_bb_0_0_0_0_0_0 = digital.map_bb(([-1, 1])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb( pld_const.arity()) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 100.0, pld_const.arity(), False) self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 4, 'packet_len') self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( pld_const) self.custom_corr = correlate_and_delay.corr_and_delay( 200 * sps, 0, 0.99, sps) self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb( 1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_keep_m_in_n_0_1_1_0 = blocks.keep_m_in_n( gr.sizeof_char, 440, 442, 0) self.blocks_keep_m_in_n_0_0_2_0_0 = blocks.keep_m_in_n( gr.sizeof_char, 1100, 1104, 0) self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink( gr.sizeof_char * 1, '/home/it/Desktop/Trasmited/depois.txt', False) self.blocks_file_sink_0_0_0_0_2.set_unbuffered(False) self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1) self.blocks_copy_0.set_enabled(variable_qtgui_check_box_0) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_2_0_0_0 = blocks.char_to_float(1, 1) self.analog_noise_source_x_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, -5) self.adapt_lms_filter_xx_0 = adapt.lms_filter_cc( True, 32, 0.0001, 0, 1, True, False, False) ################################################## # Connections ################################################## self.connect((self.adapt_lms_filter_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_noise_source_x_0_0, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.blocks_char_to_float_0_2_0_0_0, 0), (self.fec_extended_decoder_0_0_1_0_1_0_0, 0)) self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_copy_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_keep_m_in_n_0_0_2_0_0, 0), (self.digital_map_bb_0_0_0_0_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0_1_1_0, 0), (self.scrambler_cpp_custom_descrambler_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_copy_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.custom_corr, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_correlate_access_code_xx_ts_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_char_to_float_1_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_file_sink_0_0_0_0_2, 0)) self.connect((self.custom_corr, 0), (self.adapt_lms_filter_xx_0, 1)) self.connect((self.custom_corr, 1), (self.adapt_lms_filter_xx_0, 0)) self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_keep_m_in_n_0_0_2_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_map_bb_0_0_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.fec_extended_decoder_0_0_1_0_1_0_0, 0), (self.blocks_keep_m_in_n_0_1_1_0, 0)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.scrambler_cpp_custom_descrambler_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self, options, log=False): ## Read configuration config = station_configuration() fft_length = config.fft_length cp_length = config.cp_length block_header = config.training_data data_subc = config.data_subcarriers virtual_subc = config.virtual_subcarriers total_subc = config.subcarriers block_length = config.block_length frame_length = config.frame_length L = block_header.mm_periodic_parts frame_data_blocks = options.data_blocks ## Set Input/Output signature gr.hier_block2.__init__( self, "ofdm_inner_receiver", gr.io_signature(2, 2, gr.sizeof_gr_complex), gr.io_signature5( 5, 5, gr.sizeof_gr_complex * total_subc, # OFDM blocks gr.sizeof_char, # Frame start gr.sizeof_float * total_subc, # Normalized |CTF|^2 gr.sizeof_char, # Frame start gr.sizeof_float * total_subc)) # Normalized |CTF|^2 ## Input and output ports self.input = rx_input = (self, 0) self.input2 = rx2_input = (self, 1) out_ofdm_blocks = (self, 0) out_frame_start = (self, 1) out_disp_ctf = (self, 2) out_frame_start2 = (self, 3) out_disp_ctf2 = (self, 4) ## pre-FFT processing ## Compute autocorrelations for S&C preamble ## and cyclic prefix sc_metric = autocorrelator(fft_length / 2, fft_length / 2) gi_metric = autocorrelator(fft_length, cp_length) self.connect(rx_input, sc_metric) self.connect(rx_input, gi_metric) sc_metric2 = autocorrelator(fft_length / 2, fft_length / 2) gi_metric2 = autocorrelator(fft_length, cp_length) self.connect(rx2_input, sc_metric2) self.connect(rx2_input, gi_metric2) ## Sync. Output contains OFDM blocks sync = ofdm.time_sync(fft_length, cp_length) self.connect(rx_input, (sync, 0)) self.connect(sc_metric, (sync, 1)) self.connect(gi_metric, (sync, 2)) ofdm_blocks = (sync, 0) frame_start = (sync, 1) sync2 = ofdm.time_sync(fft_length, cp_length) self.connect(rx2_input, (sync2, 0)) self.connect(sc_metric2, (sync2, 1)) self.connect(gi_metric2, (sync2, 2)) ofdm_blocks2 = (sync2, 0) frame_start2 = (sync2, 1) if options.disable_time_sync or options.ideal: terminate_stream(self, ofdm_blocks) terminate_stream(self, ofdm_blocks2) terminate_stream(self, frame_start) terminate_stream(self, frame_start2) serial_to_parallel = blocks.stream_to_vector( gr.sizeof_gr_complex, block_length) serial_to_parallel2 = blocks.stream_to_vector( gr.sizeof_gr_complex, block_length) discard_cp = ofdm.vector_mask(block_length, cp_length, fft_length, []) discard_cp2 = ofdm.vector_mask(block_length, cp_length, fft_length, []) ofdm_blocks = discard_cp ofdm_blocks2 = discard_cp2 self.connect(rx_input, serial_to_parallel, discard_cp) self.connect(rx2_input, serial_to_parallel2, discard_cp2) frame_start = [0] * frame_length frame_start[0] = 1 frame_start = blocks.vector_source_b(frame_start, True) frame_start2 = [0] * frame_length frame_start2[0] = 1 frame_start2 = blocks.vector_source_b(frame_start2, True) print "Disabled time synchronization stage" ## Extract preamble, feed to Morelli & Mengali frequency offset estimator assert (block_header.mm_preamble_pos == 0) morelli_foe = ofdm.mm_frequency_estimator(fft_length, L) sampler_preamble = ofdm.vector_sampler( gr.sizeof_gr_complex * fft_length, 1) self.connect(ofdm_blocks, (sampler_preamble, 0)) self.connect(frame_start, (sampler_preamble, 1)) self.connect(sampler_preamble, morelli_foe) freq_offset = morelli_foe morelli_foe2 = ofdm.mm_frequency_estimator(fft_length, L) sampler_preamble2 = ofdm.vector_sampler( gr.sizeof_gr_complex * fft_length, 1) self.connect(ofdm_blocks2, (sampler_preamble2, 0)) self.connect(frame_start2, (sampler_preamble2, 1)) self.connect(sampler_preamble2, morelli_foe2) freq_offset2 = morelli_foe2 ## Adaptive LMS FIR filtering of frequency offset lms_fir = ofdm.lms_fir_ff(20, 1e-3) # TODO: verify parameter choice self.connect(freq_offset, lms_fir) freq_offset = lms_fir lms_fir2 = ofdm.lms_fir_ff(20, 1e-3) # TODO: verify parameter choice self.connect(freq_offset2, lms_fir2) freq_offset2 = lms_fir2 # log_to_file(self, lms_fir, "data/lms_fir.float") # log_to_file(self, lms_fir2, "data/lms_fir2.float") if options.disable_freq_sync or options.ideal: terminate_stream(self, freq_offset) terminate_stream(self, freq_offset2) freq_offset = blocks.vector_source_f([0.0], True) freq_offset2 = blocks.vector_source_f([0.0], True) print "Disabled frequency synchronization stage" ## Correct frequency shift, feed-forward structure frequency_shift = ofdm.frequency_shift_vcc(fft_length, -1.0 / fft_length, cp_length) self.connect(ofdm_blocks, (frequency_shift, 0)) self.connect(freq_offset, (frequency_shift, 1)) self.connect(frame_start, (frequency_shift, 2)) ofdm_blocks = frequency_shift frequency_shift2 = ofdm.frequency_shift_vcc(fft_length, -1.0 / fft_length, cp_length) self.connect(ofdm_blocks2, (frequency_shift2, 0)) self.connect(freq_offset2, (frequency_shift2, 1)) self.connect(frame_start2, (frequency_shift2, 2)) ofdm_blocks2 = frequency_shift2 ## FFT fft = fft_blocks.fft_vcc(fft_length, True, [], True) self.connect(ofdm_blocks, fft) ofdm_blocks = fft fft2 = fft_blocks.fft_vcc(fft_length, True, [], True) self.connect(ofdm_blocks2, fft2) ofdm_blocks2 = fft2 ## Remove virtual subcarriers if fft_length > data_subc: subcarrier_mask = ofdm.vector_mask(fft_length, virtual_subc / 2, total_subc, []) self.connect(ofdm_blocks, subcarrier_mask) ofdm_blocks = subcarrier_mask subcarrier_mask2 = ofdm.vector_mask(fft_length, virtual_subc / 2, total_subc, []) self.connect(ofdm_blocks2, subcarrier_mask2) ofdm_blocks2 = subcarrier_mask2 ## Least Squares estimator for channel transfer function (CTF) # if options.logcir: # log_to_file( self, ofdm_blocks, "data/OFDM_Blocks.compl" ) # inv_preamble_fd = numpy.array( block_header.pilotsym_fd[ # block_header.channel_estimation_pilot[0] ] ) # print "Channel estimation pilot: ", inv_preamble_fd # inv_preamble_fd = 1. / inv_preamble_fd # LS_channel_estimator0 = ofdm.multiply_const_vcc( list( inv_preamble_fd ) ) # self.connect( ofdm_blocks, LS_channel_estimator0, blocks.null_sink(gr.sizeof_gr_complex*total_subc)) # log_to_file( self, LS_channel_estimator0, "data/OFDM_Blocks_eq.compl" ) ## post-FFT processing if options.est_preamble == 1: ## extract channel estimation preamble from frame chest_pre_trigger = blocks.delay(gr.sizeof_char, 1) sampled_chest_preamble = \ ofdm.vector_sampler( gr.sizeof_gr_complex * total_subc, 1 ) self.connect(frame_start, chest_pre_trigger) self.connect(chest_pre_trigger, (sampled_chest_preamble, 1)) self.connect(ofdm_blocks, (sampled_chest_preamble, 0)) chest_pre_trigger2 = blocks.delay(gr.sizeof_char, 1) sampled_chest_preamble2 = \ ofdm.vector_sampler( gr.sizeof_gr_complex * total_subc, 1 ) self.connect(frame_start2, chest_pre_trigger2) self.connect(chest_pre_trigger2, (sampled_chest_preamble2, 1)) self.connect(ofdm_blocks2, (sampled_chest_preamble2, 0)) ## Least Squares estimator for channel transfer function (CTF) # Taking inverse for estimating h11 (h12) inv_preamble_fd_1 = numpy.array(block_header.pilotsym_fd_1[ block_header.channel_estimation_pilot[0]]) inv_preamble_fd_1 = inv_preamble_fd_1[0::2] # Taking inverse for estimating h21 (h22) inv_preamble_fd_2 = numpy.array(block_header.pilotsym_fd_2[ block_header.channel_estimation_pilot[0]]) inv_preamble_fd_2 = inv_preamble_fd_2[1::2] inv_preamble_fd_1 = 1. / inv_preamble_fd_1 inv_preamble_fd_2 = 1. / inv_preamble_fd_2 ## Least Squares estimator for channel transfer function (CTF) dd = [] for i in range(total_subc / 2): dd.extend([i * 2]) skip_block_1 = ofdm.int_skip(total_subc, 2, 0) skip_block_2 = ofdm.int_skip(total_subc, 2, 1) # inta_estim_1 = ofdm.interpolator(total_subc,2,dd) # inta_estim_2 = ofdm.interpolator(total_subc,2,dd) LS_channel_estimator_1 = ofdm.multiply_const_vcc( list(inv_preamble_fd_1)) LS_channel_estimator_2 = ofdm.multiply_const_vcc( list(inv_preamble_fd_2)) self.connect(sampled_chest_preamble, skip_block_1, LS_channel_estimator_1) #,inta_estim_1 ) self.connect(sampled_chest_preamble, skip_block_2, LS_channel_estimator_2) #,inta_estim_2 ) estimated_CTF_1 = LS_channel_estimator_1 # h0 estimated_CTF_2 = LS_channel_estimator_2 # h1 skip_block_3 = ofdm.int_skip(total_subc, 2, 0) skip_block_4 = ofdm.int_skip(total_subc, 2, 1) # inta_estim_3 = ofdm.interpolator(total_subc,2,dd) # inta_estim_4 = ofdm.interpolator(total_subc,2,dd) LS_channel_estimator_3 = ofdm.multiply_const_vcc( list(inv_preamble_fd_1)) LS_channel_estimator_4 = ofdm.multiply_const_vcc( list(inv_preamble_fd_2)) self.connect(sampled_chest_preamble2, skip_block_3, LS_channel_estimator_3) #,inta_estim_3 ) self.connect(sampled_chest_preamble2, skip_block_4, LS_channel_estimator_4) #,inta_estim_4 ) estimated_CTF_3 = LS_channel_estimator_3 # h2 estimated_CTF_4 = LS_channel_estimator_4 # h3 if not options.disable_ctf_enhancer: # if options.logcir: # ifft1 = fft_blocks.fft_vcc(total_subc,False,[],True) # self.connect( estimated_CTF, ifft1,blocks.null_sink(gr.sizeof_gr_complex*total_subc)) # summ1 = ofdm.vector_sum_vcc(total_subc) # c2m =gr.complex_to_mag(total_subc) # self.connect( estimated_CTF,summ1 ,blocks.null_sink(gr.sizeof_gr_complex)) # self.connect( estimated_CTF, c2m,blocks.null_sink(gr.sizeof_float*total_subc)) # log_to_file( self, ifft1, "data/CIR1.compl" ) # log_to_file( self, summ1, "data/CTFsumm1.compl" ) # log_to_file( self, estimated_CTF, "data/CTF1.compl" ) # log_to_file( self, c2m, "data/CTFmag1.float" ) ## MSE enhancer ctf_mse_enhancer_1 = ofdm.CTF_MSE_enhancer( total_subc, cp_length + cp_length) ctf_mse_enhancer_2 = ofdm.CTF_MSE_enhancer( total_subc, cp_length + cp_length) self.connect(estimated_CTF_1, ctf_mse_enhancer_1) self.connect(estimated_CTF_2, ctf_mse_enhancer_2) ctf_mse_enhancer_3 = ofdm.CTF_MSE_enhancer( total_subc, cp_length + cp_length) ctf_mse_enhancer_4 = ofdm.CTF_MSE_enhancer( total_subc, cp_length + cp_length) self.connect(estimated_CTF_3, ctf_mse_enhancer_3) self.connect(estimated_CTF_4, ctf_mse_enhancer_4) estimated_CTF_1 = ctf_mse_enhancer_1 estimated_CTF_2 = ctf_mse_enhancer_2 estimated_CTF_3 = ctf_mse_enhancer_3 estimated_CTF_4 = ctf_mse_enhancer_4 print "Disabled CTF MSE enhancer" ctf_postprocess_1 = ofdm.postprocess_CTF_estimate(total_subc / 2) self.connect(estimated_CTF_1, (ctf_postprocess_1, 0)) ctf_postprocess_2 = ofdm.postprocess_CTF_estimate(total_subc / 2) self.connect(estimated_CTF_2, (ctf_postprocess_2, 0)) ctf_postprocess_3 = ofdm.postprocess_CTF_estimate(total_subc / 2) self.connect(estimated_CTF_3, (ctf_postprocess_3, 0)) ctf_postprocess_4 = ofdm.postprocess_CTF_estimate(total_subc / 2) self.connect(estimated_CTF_4, (ctf_postprocess_4, 0)) inv_CTF_1 = (ctf_postprocess_1, 0) disp_CTF_1 = (ctf_postprocess_1, 1) inv_CTF_2 = (ctf_postprocess_2, 0) disp_CTF_2 = (ctf_postprocess_2, 1) inv_CTF_3 = (ctf_postprocess_3, 0) disp_CTF_3 = (ctf_postprocess_3, 1) inv_CTF_4 = (ctf_postprocess_4, 0) disp_CTF_4 = (ctf_postprocess_4, 1) disp_CTF_RX0 = blocks.add_ff(total_subc / 2) disp_CTF_RX1 = blocks.add_ff(total_subc / 2) self.connect(disp_CTF_1, (disp_CTF_RX0, 0)) self.connect(disp_CTF_2, (disp_CTF_RX0, 1)) self.connect(disp_CTF_3, (disp_CTF_RX1, 0)) self.connect(disp_CTF_4, (disp_CTF_RX1, 1)) terminate_stream(self, disp_CTF_RX0) terminate_stream(self, disp_CTF_RX1) disp_CTF_RX0 = blocks.null_source(gr.sizeof_float * total_subc) disp_CTF_RX1 = blocks.null_source(gr.sizeof_float * total_subc) ## Channel Equalizer #log_to_file(self, ofdm_blocks, "data/vec_mask.compl") #log_to_file(self, ofdm_blocks2, "data/vec_mask2.compl") nondata_blocks = [] for i in range(config.frame_length): if i in config.training_data.pilotsym_pos: nondata_blocks.append(i) pilot_subc = block_header.pilot_tones pilot_subcarriers = block_header.pilot_subc_sym print "PILOT SUBCARRIERS: ", pilot_subcarriers phase_tracking = ofdm.lms_phase_tracking_03( total_subc, pilot_subc, nondata_blocks, pilot_subcarriers, 0) phase_tracking2 = ofdm.lms_phase_tracking_03( total_subc, pilot_subc, nondata_blocks, pilot_subcarriers, 0) ##phase_tracking = ofdm.LMS_phase_tracking2( total_subc, pilot_subc, ## nondata_blocks ) ##phase_tracking2 = ofdm.LMS_phase_tracking2( total_subc, pilot_subc, ## nondata_blocks ) # self.connect( ofdm_blocks, ( phase_tracking, 0 ) ) # self.connect( ofdm_blocks2, ( phase_tracking, 1 )) # self.connect( inv_CTF_1, ( phase_tracking, 2 ) ) # self.connect( inv_CTF_3, ( phase_tracking, 3 ) ) # self.connect( frame_start, ( phase_tracking, 4 ) ) # self.connect( frame_start2, ( phase_tracking, 5) ) # # self.connect( ofdm_blocks2, ( phase_tracking2, 0 ) ) # self.connect( ofdm_blocks, ( phase_tracking2, 1 )) # self.connect( inv_CTF_3, ( phase_tracking2, 2 ) ) # self.connect( inv_CTF_1, ( phase_tracking2, 3 ) ) # self.connect( frame_start2, ( phase_tracking2, 4 ) ) # self.connect( frame_start, ( phase_tracking2, 5 ) ) self.connect(ofdm_blocks, (phase_tracking, 0)) self.connect(inv_CTF_1, (phase_tracking, 1)) self.connect(frame_start, (phase_tracking, 2)) self.connect(ofdm_blocks2, (phase_tracking2, 0)) self.connect(inv_CTF_3, (phase_tracking2, 1)) self.connect(frame_start2, (phase_tracking2, 2)) #ofdm_blocks = phase_tracking #ofdm_blocks2 = phase_tracking2 self.connect(phase_tracking, blocks.null_sink(gr.sizeof_gr_complex * total_subc)) self.connect(phase_tracking2, blocks.null_sink(gr.sizeof_gr_complex * total_subc)) terminate_stream(self, inv_CTF_2) terminate_stream(self, inv_CTF_4) #terminate_stream(self, inv_CTF_1) #terminate_stream(self, inv_CTF_3) terminate_stream(self, estimated_CTF_3) terminate_stream(self, estimated_CTF_4) ##terminate_stream(self, (phase_tracking,1)) ##terminate_stream(self, (phase_tracking2,1)) '''equalizer = ofdm.channel_equalizer_mimo_2( total_subc ) self.connect( ofdm_blocks, ( equalizer, 0 ) ) self.connect( ofdm_blocks2, ( equalizer, 1 ) ) self.connect( inv_CTF_1, ( equalizer, 2 ) ) self.connect( inv_CTF_2, ( equalizer, 3 ) ) self.connect( inv_CTF_3, ( equalizer, 4 ) ) self.connect( inv_CTF_4, ( equalizer, 5 ) ) self.connect( frame_start, ( equalizer, 6 ) ) self.connect( frame_start2, ( equalizer, 7 ) ) ofdm_blocks = equalizer''' terminate_stream(self, inv_CTF_1) terminate_stream(self, inv_CTF_3) equalizer = ofdm.channel_equalizer_mimo_2(total_subc) self.connect(ofdm_blocks, (equalizer, 0)) self.connect(estimated_CTF_1, (equalizer, 1)) self.connect(estimated_CTF_2, (equalizer, 2)) self.connect(frame_start, (equalizer, 3)) ofdm_blocks = equalizer equalizer2 = ofdm.channel_equalizer_mimo_2(total_subc) self.connect(ofdm_blocks2, (equalizer2, 0)) self.connect(estimated_CTF_3, (equalizer2, 1)) self.connect(estimated_CTF_4, (equalizer2, 2)) self.connect(frame_start2, (equalizer2, 3)) ofdm_blocks2 = equalizer2 #ofdm_blocks = equalizer #ofdm_blocks2 = equalizer2 #log_to_file(self, equalizer,"data/equalizer.compl") #log_to_file(self, ofdm_blocks2,"data/equalizer.compl") #log_to_file(self, ofdm_blocks,"data/equalizer2.compl") ## LMS Phase tracking ## Track residual frequency offset and sampling clock frequency offset ''' nondata_blocks = [] for i in range(config.frame_length): if i in config.training_data.pilotsym_pos: nondata_blocks.append(i) pilot_subc = block_header.pilot_tones phase_tracking = ofdm.LMS_phase_tracking2( total_subc, pilot_subc, nondata_blocks ) self.connect( equalizer, ( phase_tracking, 0 ) ) self.connect( frame_start, ( phase_tracking, 1 ) ) phase_tracking2 = ofdm.LMS_phase_tracking2( total_subc, pilot_subc, nondata_blocks ) self.connect( equalizer2, ( phase_tracking2, 0 ) ) self.connect( frame_start2, ( phase_tracking2, 1 ) ) # if options.scatter_plot_before_phase_tracking: # self.before_phase_tracking = equalizer if options.disable_phase_tracking or options.ideal: terminate_stream(self, phase_tracking) terminate_stream(self, phase_tracking2) print "Disabled phase tracking stage" else: ofdm_blocks = phase_tracking ofdm_blocks2 = phase_tracking2 log_to_file(self,phase_tracking, "data/phase_tracking.compl") ''' combine = blocks.add_cc(config.subcarriers) self.connect(ofdm_blocks, (combine, 0)) self.connect(ofdm_blocks2, (combine, 1)) norm_val = [0.5] * 208 norm = ofdm.multiply_const_vcc(norm_val) self.connect(combine, norm) ofdm_blocks = norm ## div = gr.multiply_cc(config.subcarriers) ## const = blocks.vector_source_c([[0.5+0]*config.subcarriers],True) ## self.connect(ofdm_blocks,div) ## self.connect(const,(div,1)) ## ofdm_blocks=div # log_to_file(self,combine,"data/combine.compl") ## Output connections self.connect(ofdm_blocks, out_ofdm_blocks) self.connect(frame_start, out_frame_start) self.connect(disp_CTF_RX0, out_disp_ctf) self.connect(frame_start2, out_frame_start2) self.connect(disp_CTF_RX1, out_disp_ctf2) else: ## extract channel estimation preamble from frame chest_pre_trigger_11 = blocks.delay(gr.sizeof_char, 1) chest_pre_trigger_12 = blocks.delay(gr.sizeof_char, 2) sampled_chest_preamble_11 = \ ofdm.vector_sampler( gr.sizeof_gr_complex * total_subc, 1 ) sampled_chest_preamble_12 = \ ofdm.vector_sampler( gr.sizeof_gr_complex * total_subc, 1 ) self.connect(frame_start, chest_pre_trigger_11) self.connect(chest_pre_trigger_11, (sampled_chest_preamble_11, 1)) self.connect(ofdm_blocks, (sampled_chest_preamble_11, 0)) self.connect(frame_start, chest_pre_trigger_12) self.connect(chest_pre_trigger_12, (sampled_chest_preamble_12, 1)) self.connect(ofdm_blocks, (sampled_chest_preamble_12, 0)) chest_pre_trigger_21 = blocks.delay(gr.sizeof_char, 1) chest_pre_trigger_22 = blocks.delay(gr.sizeof_char, 2) sampled_chest_preamble_21 = \ ofdm.vector_sampler( gr.sizeof_gr_complex * total_subc, 1 ) sampled_chest_preamble_22 = \ ofdm.vector_sampler( gr.sizeof_gr_complex * total_subc, 1 ) self.connect(frame_start2, chest_pre_trigger_21) self.connect(chest_pre_trigger_21, (sampled_chest_preamble_21, 1)) self.connect(ofdm_blocks2, (sampled_chest_preamble_21, 0)) self.connect(frame_start2, chest_pre_trigger_22) self.connect(chest_pre_trigger_22, (sampled_chest_preamble_22, 1)) self.connect(ofdm_blocks2, (sampled_chest_preamble_22, 0)) # Taking inverse for estimating h11 (h12) inv_preamble_fd_1 = numpy.array(block_header.pilotsym_fd_1[ block_header.channel_estimation_pilot[0]]) #inv_preamble_fd_1 = inv_preamble_fd_1[0::2] # Taking inverse for estimating h21 (h22) inv_preamble_fd_2 = numpy.array(block_header.pilotsym_fd_2[ block_header.channel_estimation_pilot[0] + 1]) #inv_preamble_fd_2 = inv_preamble_fd_2[1::2] inv_preamble_fd_1 = 1. / inv_preamble_fd_1 inv_preamble_fd_2 = 1. / inv_preamble_fd_2 # dd = [] #for i in range (total_subc/2): # dd.extend([i*2]) skip_block_11 = ofdm.int_skip(total_subc, 2, 0) skip_block_111 = ofdm.int_skip(total_subc, 2, 0) skip_block_12 = ofdm.int_skip(total_subc, 2, 1) # inta_estim_1 = ofdm.interpolator(total_subc,2,dd) # inta_estim_2 = ofdm.interpolator(total_subc,2,dd) LS_channel_estimator_11 = ofdm.multiply_const_vcc( list(inv_preamble_fd_1)) LS_channel_estimator_12 = ofdm.multiply_const_vcc( list(inv_preamble_fd_2)) self.connect(sampled_chest_preamble_11, LS_channel_estimator_11) #,inta_estim_1 ) self.connect(sampled_chest_preamble_12, LS_channel_estimator_12) #,inta_estim_2 ) estimated_CTF_11 = LS_channel_estimator_11 # h0 estimated_CTF_12 = LS_channel_estimator_12 # h1 skip_block_21 = ofdm.int_skip(total_subc, 2, 0) skip_block_211 = ofdm.int_skip(total_subc, 2, 0) skip_block_22 = ofdm.int_skip(total_subc, 2, 1) # inta_estim_3 = ofdm.interpolator(total_subc,2,dd) # inta_estim_4 = ofdm.interpolator(total_subc,2,dd) LS_channel_estimator_21 = ofdm.multiply_const_vcc( list(inv_preamble_fd_1)) LS_channel_estimator_22 = ofdm.multiply_const_vcc( list(inv_preamble_fd_2)) self.connect(sampled_chest_preamble_21, LS_channel_estimator_21) #,inta_estim_3 ) self.connect(sampled_chest_preamble_22, LS_channel_estimator_22) #,inta_estim_4 ) estimated_CTF_21 = LS_channel_estimator_21 # h2 estimated_CTF_22 = LS_channel_estimator_22 # h3 if not options.disable_ctf_enhancer: # if options.logcir: # ifft1 = fft_blocks.fft_vcc(total_subc,False,[],True) # self.connect( estimated_CTF, ifft1,blocks.null_sink(gr.sizeof_gr_complex*total_subc)) # summ1 = ofdm.vector_sum_vcc(total_subc) # c2m =gr.complex_to_mag(total_subc) # self.connect( estimated_CTF,summ1 ,blocks.null_sink(gr.sizeof_gr_complex)) # self.connect( estimated_CTF, c2m,blocks.null_sink(gr.sizeof_float*total_subc)) # log_to_file( self, ifft1, "data/CIR1.compl" ) # log_to_file( self, summ1, "data/CTFsumm1.compl" ) # log_to_file( self, estimated_CTF, "data/CTF1.compl" ) # log_to_file( self, c2m, "data/CTFmag1.float" ) ## MSE enhancer ctf_mse_enhancer_11 = ofdm.CTF_MSE_enhancer( total_subc, cp_length + cp_length) ctf_mse_enhancer_12 = ofdm.CTF_MSE_enhancer( total_subc, cp_length + cp_length) self.connect(estimated_CTF_11, ctf_mse_enhancer_11) self.connect(estimated_CTF_12, ctf_mse_enhancer_12) ctf_mse_enhancer_21 = ofdm.CTF_MSE_enhancer( total_subc, cp_length + cp_length) ctf_mse_enhancer_22 = ofdm.CTF_MSE_enhancer( total_subc, cp_length + cp_length) self.connect(estimated_CTF_21, ctf_mse_enhancer_21) self.connect(estimated_CTF_22, ctf_mse_enhancer_22) estimated_CTF_11 = ctf_mse_enhancer_11 estimated_CTF_12 = ctf_mse_enhancer_12 estimated_CTF_21 = ctf_mse_enhancer_21 estimated_CTF_22 = ctf_mse_enhancer_22 print "Disabled CTF MSE enhancer" ctf_postprocess_11 = ofdm.postprocess_CTF_estimate(total_subc) self.connect(estimated_CTF_11, (ctf_postprocess_11, 0)) ctf_postprocess_12 = ofdm.postprocess_CTF_estimate(total_subc) self.connect(estimated_CTF_12, (ctf_postprocess_12, 0)) ctf_postprocess_21 = ofdm.postprocess_CTF_estimate(total_subc) self.connect(estimated_CTF_21, (ctf_postprocess_21, 0)) ctf_postprocess_22 = ofdm.postprocess_CTF_estimate(total_subc) self.connect(estimated_CTF_22, (ctf_postprocess_22, 0)) inv_CTF_11 = (ctf_postprocess_11, 0) disp_CTF_11 = (ctf_postprocess_11, 1) inv_CTF_12 = (ctf_postprocess_12, 0) disp_CTF_12 = (ctf_postprocess_12, 1) inv_CTF_21 = (ctf_postprocess_21, 0) disp_CTF_21 = (ctf_postprocess_21, 1) inv_CTF_22 = (ctf_postprocess_22, 0) disp_CTF_22 = (ctf_postprocess_22, 1) #disp_CTF_RX0 = blocks.add_ff(total_subc) #disp_CTF_RX1 = blocks.add_ff(total_subc) #self.connect ( disp_CTF_11, (disp_CTF_RX0, 0) ) #self.connect ( disp_CTF_12, (disp_CTF_RX0, 1) ) #self.connect ( disp_CTF_21, (disp_CTF_RX1, 0) ) #self.connect ( disp_CTF_22, (disp_CTF_RX1, 1) ) terminate_stream(self, disp_CTF_21) terminate_stream(self, disp_CTF_22) disp_CTF_RX0 = disp_CTF_11 disp_CTF_RX1 = disp_CTF_12 ## Channel Equalizer #log_to_file(self, ofdm_blocks, "data/vec_mask.compl") #log_to_file(self, ofdm_blocks2, "data/vec_mask2.compl") nondata_blocks = [] for i in range(config.frame_length): if i in config.training_data.pilotsym_pos: nondata_blocks.append(i) pilot_subc = block_header.pilot_tones pilot_subcarriers = block_header.pilot_subc_sym print "PILOT SUBCARRIERS: ", pilot_subcarriers phase_tracking = ofdm.lms_phase_tracking_03( total_subc, pilot_subc, nondata_blocks, pilot_subcarriers, 0) phase_tracking2 = ofdm.lms_phase_tracking_03( total_subc, pilot_subc, nondata_blocks, pilot_subcarriers, 0) ##phase_tracking = ofdm.LMS_phase_tracking2( total_subc, pilot_subc, ## nondata_blocks ) ##phase_tracking2 = ofdm.LMS_phase_tracking2( total_subc, pilot_subc, ## nondata_blocks ) # self.connect( ofdm_blocks, ( phase_tracking, 0 ) ) # self.connect( ofdm_blocks2, ( phase_tracking, 1 )) # self.connect( inv_CTF_1, ( phase_tracking, 2 ) ) # self.connect( inv_CTF_3, ( phase_tracking, 3 ) ) # self.connect( frame_start, ( phase_tracking, 4 ) ) # self.connect( frame_start2, ( phase_tracking, 5) ) # # self.connect( ofdm_blocks2, ( phase_tracking2, 0 ) ) # self.connect( ofdm_blocks, ( phase_tracking2, 1 )) # self.connect( inv_CTF_3, ( phase_tracking2, 2 ) ) # self.connect( inv_CTF_1, ( phase_tracking2, 3 ) ) # self.connect( frame_start2, ( phase_tracking2, 4 ) ) # self.connect( frame_start, ( phase_tracking2, 5 ) ) self.connect(ofdm_blocks, (phase_tracking, 0)) self.connect(inv_CTF_11, skip_block_111, (phase_tracking, 1)) self.connect(frame_start, (phase_tracking, 2)) self.connect(ofdm_blocks2, (phase_tracking2, 0)) self.connect(inv_CTF_21, skip_block_211, (phase_tracking2, 1)) self.connect(frame_start2, (phase_tracking2, 2)) if options.disable_phase_tracking or options.ideal: terminate_stream(self, phase_tracking) terminate_stream(self, phase_tracking2) print "Disabled phase tracking stage" else: ofdm_blocks = phase_tracking ofdm_blocks2 = phase_tracking2 self.connect(phase_tracking, blocks.null_sink(gr.sizeof_gr_complex * total_subc)) self.connect(phase_tracking2, blocks.null_sink(gr.sizeof_gr_complex * total_subc)) terminate_stream(self, inv_CTF_12) terminate_stream(self, inv_CTF_22) #terminate_stream(self, inv_CTF_1) #terminate_stream(self, inv_CTF_3) #terminate_stream(self, estimated_CTF_21) #terminate_stream(self, estimated_CTF_22) ##terminate_stream(self, (phase_tracking,1)) ##terminate_stream(self, (phase_tracking2,1)) equalizer = ofdm.channel_equalizer_mimo_3(total_subc) self.connect(ofdm_blocks, (equalizer, 0)) self.connect(ofdm_blocks2, (equalizer, 1)) self.connect(estimated_CTF_11, skip_block_11, (equalizer, 2)) self.connect(estimated_CTF_12, skip_block_12, (equalizer, 3)) self.connect(estimated_CTF_21, skip_block_21, (equalizer, 4)) self.connect(estimated_CTF_22, skip_block_22, (equalizer, 5)) self.connect(frame_start, (equalizer, 6)) self.connect(frame_start, (equalizer, 7)) ofdm_blocks = equalizer #terminate_stream(self, inv_CTF_11) #terminate_stream(self, inv_CTF_21) '''equalizer = ofdm.channel_equalizer_mimo_2( total_subc ) self.connect( ofdm_blocks, ( equalizer, 0 ) ) self.connect( estimated_CTF_11, skip_block_11, ( equalizer, 1 ) ) self.connect( estimated_CTF_12, skip_block_12, ( equalizer, 2 ) ) self.connect( frame_start, ( equalizer, 3 ) ) ofdm_blocks = equalizer equalizer2 = ofdm.channel_equalizer_mimo_2( total_subc ) self.connect( ofdm_blocks2, ( equalizer2, 0 ) ) self.connect( estimated_CTF_21, skip_block_21, ( equalizer2, 1 ) ) self.connect( estimated_CTF_22, skip_block_22, ( equalizer2, 2 ) ) self.connect( frame_start2, ( equalizer2, 3 ) ) ofdm_blocks2 = equalizer2''' #ofdm_blocks = equalizer #ofdm_blocks2 = equalizer2 #log_to_file(self, equalizer,"data/equalizer.compl") #log_to_file(self, ofdm_blocks2,"data/equalizer.compl") #log_to_file(self, ofdm_blocks,"data/equalizer2.compl") ## LMS Phase tracking ## Track residual frequency offset and sampling clock frequency offset ''' nondata_blocks = [] for i in range(config.frame_length): if i in config.training_data.pilotsym_pos: nondata_blocks.append(i) pilot_subc = block_header.pilot_tones phase_tracking = ofdm.LMS_phase_tracking2( total_subc, pilot_subc, nondata_blocks ) self.connect( equalizer, ( phase_tracking, 0 ) ) self.connect( frame_start, ( phase_tracking, 1 ) ) phase_tracking2 = ofdm.LMS_phase_tracking2( total_subc, pilot_subc, nondata_blocks ) self.connect( equalizer2, ( phase_tracking2, 0 ) ) self.connect( frame_start2, ( phase_tracking2, 1 ) ) # if options.scatter_plot_before_phase_tracking: # self.before_phase_tracking = equalizer if options.disable_phase_tracking or options.ideal: terminate_stream(self, phase_tracking) terminate_stream(self, phase_tracking2) print "Disabled phase tracking stage" else: ofdm_blocks = phase_tracking ofdm_blocks2 = phase_tracking2 log_to_file(self,phase_tracking, "data/phase_tracking.compl") ''' '''combine = blocks.add_cc(config.subcarriers) self.connect(ofdm_blocks, (combine,0)) self.connect(ofdm_blocks2, (combine,1)) norm_val = [0.5]*config.subcarriers norm = ofdm.multiply_const_vcc( norm_val) self.connect(combine,norm) ofdm_blocks = norm''' ## div = gr.multiply_cc(config.subcarriers) ## const = blocks.vector_source_c([[0.5+0]*config.subcarriers],True) ## self.connect(ofdm_blocks,div) ## self.connect(const,(div,1)) ## ofdm_blocks=div # log_to_file(self,combine,"data/combine.compl") ## Output connections self.connect(ofdm_blocks, out_ofdm_blocks) self.connect(frame_start, out_frame_start) self.connect(disp_CTF_RX0, out_disp_ctf) self.connect(frame_start2, out_frame_start2) self.connect(disp_CTF_RX1, out_disp_ctf2)
def __init__(self, demod_rate, audio_decimation): """ Hierarchical block for demodulating a broadcast FM signal. The input is the downconverted complex baseband signal (gr_complex). The output is two streams of the demodulated audio (float) 0=Left, 1=Right. Args: demod_rate: input sample rate of complex baseband input. (float) audio_decimation: how much to decimate demod_rate to get to audio. (integer) """ gr.hier_block2.__init__( self, "wfm_rcv_pll", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(2, 2, gr.sizeof_float)) # Output signature bandwidth = 250e3 audio_rate = demod_rate / audio_decimation # We assign to self so that outsiders can grab the demodulator # if they need to. E.g., to plot its output. # # input: complex; output: float loop_bw = 2 * math.pi / 100.0 max_freq = 2.0 * math.pi * 90e3 / demod_rate self.fm_demod = analog.pll_freqdet_cf(loop_bw, max_freq, -max_freq) # input: float; output: float self.deemph_Left = fm_deemph(audio_rate) self.deemph_Right = fm_deemph(audio_rate) # compute FIR filter taps for audio filter width_of_transition_band = audio_rate / 32 audio_coeffs = filter.firdes.low_pass( 1.0, # gain demod_rate, # sampling rate 15000, width_of_transition_band, filter.firdes.WIN_HAMMING) # input: float; output: float self.audio_filter = filter.fir_filter_fff(audio_decimation, audio_coeffs) if 1: # Pick off the stereo carrier/2 with this filter. It attenuated 10 dB so apply 10 dB gain # We pick off the negative frequency half because we want to base band by it! ## NOTE THIS WAS HACKED TO OFFSET INSERTION LOSS DUE TO DEEMPHASIS stereo_carrier_filter_coeffs = \ filter.firdes.complex_band_pass(10.0, demod_rate, -19020, -18980, width_of_transition_band, filter.firdes.WIN_HAMMING) #print "len stereo carrier filter = ",len(stereo_carrier_filter_coeffs) #print "stereo carrier filter ", stereo_carrier_filter_coeffs #print "width of transition band = ",width_of_transition_band, " audio rate = ", audio_rate # Pick off the double side band suppressed carrier Left-Right audio. It is attenuated 10 dB so apply 10 dB gain stereo_dsbsc_filter_coeffs = \ filter.firdes.complex_band_pass(20.0, demod_rate, 38000-15000/2, 38000+15000/2, width_of_transition_band, filter.firdes.WIN_HAMMING) #print "len stereo dsbsc filter = ",len(stereo_dsbsc_filter_coeffs) #print "stereo dsbsc filter ", stereo_dsbsc_filter_coeffs # construct overlap add filter system from coefficients for stereo carrier self.stereo_carrier_filter = \ filter.fir_filter_fcc(audio_decimation, stereo_carrier_filter_coeffs) # carrier is twice the picked off carrier so arrange to do a commplex multiply self.stereo_carrier_generator = blocks.multiply_cc() # Pick off the rds signal stereo_rds_filter_coeffs = \ filter.firdes.complex_band_pass(30.0, demod_rate, 57000 - 1500, 57000 + 1500, width_of_transition_band, filter.firdes.WIN_HAMMING) #print "len stereo dsbsc filter = ",len(stereo_dsbsc_filter_coeffs) #print "stereo dsbsc filter ", stereo_dsbsc_filter_coeffs # construct overlap add filter system from coefficients for stereo carrier self.rds_signal_filter = \ filter.fir_filter_fcc(audio_decimation, stereo_rds_filter_coeffs) self.rds_carrier_generator = blocks.multiply_cc() self.rds_signal_generator = blocks.multiply_cc() self_rds_signal_processor = blocks.null_sink(gr.sizeof_gr_complex) loop_bw = 2 * math.pi / 100.0 max_freq = -2.0 * math.pi * 18990 / audio_rate min_freq = -2.0 * math.pi * 19010 / audio_rate self.stereo_carrier_pll_recovery = \ analog.pll_refout_cc(loop_bw, max_freq, min_freq) #self.stereo_carrier_pll_recovery.squelch_enable(False) #pll_refout does not have squelch yet, so disabled for now # set up mixer (multiplier) to get the L-R signal at baseband self.stereo_basebander = blocks.multiply_cc() # pick off the real component of the basebanded L-R signal. The imaginary SHOULD be zero self.LmR_real = blocks.complex_to_real() self.Make_Left = blocks.add_ff() self.Make_Right = blocks.sub_ff() self.stereo_dsbsc_filter = \ filter.fir_filter_fcc(audio_decimation, stereo_dsbsc_filter_coeffs) if 1: # send the real signal to complex filter to pick off the carrier and then to one side of a multiplier self.connect(self, self.fm_demod, self.stereo_carrier_filter, self.stereo_carrier_pll_recovery, (self.stereo_carrier_generator, 0)) # send the already filtered carrier to the otherside of the carrier self.connect(self.stereo_carrier_pll_recovery, (self.stereo_carrier_generator, 1)) # the resulting signal from this multiplier is the carrier with correct phase but at -38000 Hz. # send the new carrier to one side of the mixer (multiplier) self.connect(self.stereo_carrier_generator, (self.stereo_basebander, 0)) # send the demphasized audio to the DSBSC pick off filter, the complex # DSBSC signal at +38000 Hz is sent to the other side of the mixer/multiplier self.connect(self.fm_demod, self.stereo_dsbsc_filter, (self.stereo_basebander, 1)) # the result is BASEBANDED DSBSC with phase zero! # Pick off the real part since the imaginary is theoretically zero and then to one side of a summer self.connect(self.stereo_basebander, self.LmR_real, (self.Make_Left, 0)) #take the same real part of the DSBSC baseband signal and send it to negative side of a subtracter self.connect(self.LmR_real, (self.Make_Right, 1)) # Make rds carrier by taking the squared pilot tone and multiplying by pilot tone self.connect(self.stereo_basebander, (self.rds_carrier_generator, 0)) self.connect(self.stereo_carrier_pll_recovery, (self.rds_carrier_generator, 1)) # take signal, filter off rds, send into mixer 0 channel self.connect(self.fm_demod, self.rds_signal_filter, (self.rds_signal_generator, 0)) # take rds_carrier_generator output and send into mixer 1 channel self.connect(self.rds_carrier_generator, (self.rds_signal_generator, 1)) # send basebanded rds signal and send into "processor" which for now is a null sink self.connect(self.rds_signal_generator, self_rds_signal_processor) if 1: # pick off the audio, L+R that is what we used to have and send it to the summer self.connect(self.fm_demod, self.audio_filter, (self.Make_Left, 1)) # take the picked off L+R audio and send it to the PLUS side of the subtractor self.connect(self.audio_filter, (self.Make_Right, 0)) # The result of Make_Left gets (L+R) + (L-R) and results in 2*L # The result of Make_Right gets (L+R) - (L-R) and results in 2*R self.connect(self.Make_Left, self.deemph_Left, (self, 0)) self.connect(self.Make_Right, self.deemph_Right, (self, 1))
def __init__(self, type, sat_name, mode_name, audio_fname, frequency, line1, line2, lat, lon, alt, when, port = 0, pipe_fname = None, sample_rate=2048000, frequency_offset = 0, filename_raw = 'pants_raw_ssb.dat', audio = True): grc_wxgui.top_block_gui.__init__(self, title = str(type)+" Channel "+sat_name) _icon_path = "/usr/local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) print 'Trying to connect source to port', port, 'in SSB_RX_Chan' self.tcp_source = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex*1, addr="127.0.0.1", port=port, server=False, ) self.gr_throttle = blocks.throttle(gr.sizeof_gr_complex*1, sample_rate) freq_sizer = wx.BoxSizer(wx.HORIZONTAL) self.freq_offset = 0.0 self.freq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=freq_sizer, value=self.freq_offset, callback=self.set_freq, label="Fine Frequency Offset", converter=forms.float_converter(), proportion=0) self.freq_slider = forms.slider( parent=self.GetWin(), sizer=freq_sizer, value=self.freq_offset, callback=self.set_freq, minimum=-5000, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1) self.GridAdd(freq_sizer, 0, 0, 1, 3) #self.Add(self.freq_slider) row = 1 if audio: self.volume = 0.3 vol_sizer = wx.BoxSizer(wx.HORIZONTAL) self.vol_text_box = forms.text_box( parent=self.GetWin(), sizer=vol_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0) self.vol_slider = forms.slider( parent=self.GetWin(), sizer=vol_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=5, num_steps=500, style=wx.SL_HORIZONTAL, cast=float, proportion=1) #self.Add(self.vol_slider) self.GridAdd(vol_sizer, row, 0, 1, 3) row += 1 self.chandown = ChannelDownsample(self.GetWin(), sat_name, mode_name, sample_rate, frequency_offset, filename_raw, frequency, line1, line2, lat, lon, alt, when) self.GridAdd(self.chandown.wxgui_fftsink0.win, row, 0, 1, 3) row += 1 if type == 'SSB': self.demod = ChannelDemodSSB(self.GetWin(), sat_name, mode_name) else: self.demod = ChannelDemodFM(self.GetWin(), sat_name, mode_name) self.GridAdd(self.demod.fftsink_audio.win, row, 0, 1, 3) if audio: self.audio = ChannelAudio(self.GetWin(), sat_name, audio_fname, pipe_fname) else: self.audio = blocks.null_sink(gr.sizeof_gr_complex*1) self.connect(self.tcp_source, self.gr_throttle) self.connect(self.gr_throttle, self.chandown) self.connect(self.chandown, self.demod) self.connect(self.demod, self.audio)
def __init__(self): gr.top_block.__init__(self, "Lang Rx") ################################################## # Variables ################################################## plutoip=os.environ.get('PLUTO_IP') if plutoip==None : plutoip='pluto.local' plutoip='ip:' + plutoip self.SQL = SQL = 50 self.RxOffset = RxOffset = 0 self.Mute = Mute = False self.Mode = Mode = 3 self.Filt_Low = Filt_Low = 300 self.Filt_High = Filt_High = 3000 self.FFTEn = FFTEn = 0 self.AFGain = AFGain = 20 ################################################## # Blocks ################################################## self.pluto_source_0 = iio.pluto_source(plutoip, 1000000000, 528000, 2000000, 0x800, True, True, True, "slow_attack", 64.0, '', True) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=48000, fft_size=512, ref_scale=2, frame_rate=15, avg_alpha=0.9, average=True, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(11, (firdes.low_pass(1,529200,23000,2000)), RxOffset, 528000) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*512) self.blocks_multiply_const_vxx_2_1 = blocks.multiply_const_vff((Mode==5, )) self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((Mode==4, )) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((Mode<4, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(((AFGain/100.0) * (not Mute), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*512, '/tmp/langstonefft', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_xx_1_0 = blocks.add_vff(1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_float*512, num_inputs=1, num_outputs=2, input_index=0, output_index=FFTEn, ) self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, 48000, Filt_Low, Filt_High, 100, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(48000, "hw:CARD=Device,DEV=0", False) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(SQL-100, 0.001, 0, False) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5e3, ) self.blocks_multiply_const_vxx_6 = blocks.multiply_const_vff((Mode==6, )) self.dsd_block_ff_0 = dsd.dsd_block_ff(dsd.dsd_FRAME_DMR_MOTOTRBO,dsd.dsd_MOD_AUTO_SELECT,3,False,0) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=6, decimation=1, taps=None, fractional_bw=None, ) self.analog_agc3_xx_0 = analog.agc3_cc(1e-2, 5e-7, 0.1, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(1000) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blks2_selector_0, 1), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_add_xx_1_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_2_1, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_add_xx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_6, 0)) self.connect((self.blocks_multiply_const_vxx_6, 0), (self.dsd_block_ff_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_add_xx_1, 2)) self.connect((self.blocks_multiply_const_vxx_2_1, 0), (self.blocks_add_xx_1_0, 1)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blks2_selector_0, 0)) self.connect((self.pluto_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.num_streams = num_streams = 4 self.num_elements = num_elements = 1024 self.long_seq = long_seq = [ 0.1562 - 0.0j, -0.0051 + 0.1203j, 0.0397 + 0.1112j, 0.0968 - 0.0828j, 0.0211 - 0.0279j, 0.0598 + 0.0877j, -0.1151 + 0.0552j, -0.0383 + 0.1062j, 0.0975 + 0.0259j, 0.0533 - 0.0041j, 0.0010 + 0.115j, -0.1368 + 0.0474j, 0.0245 + 0.0585j, 0.0587 + 0.0149j, -0.0225 - 0.1607j, 0.1192 + 0.0041j, 0.0625 + 0.0625j, 0.0369 - 0.0983j, -0.0572 - 0.0393j, -0.1313 - 0.0652j, 0.0822 - 0.0924j, 0.0696 - 0.0141j, -0.0603 - 0.0813j, -0.0565 + 0.0218j, -0.0350 + 0.1509j, -0.1219 + 0.0166j, -0.1273 + 0.0205j, 0.0751 + 0.074j, -0.0028 - 0.0538j, -0.0919 - 0.1151j, 0.0917 - 0.1059j, 0.0123 - 0.0976j, -0.1562 - 0.0j, 0.0123 + 0.0976j, 0.0917 + 0.1059j, -0.0919 + 0.1151j, -0.0028 + 0.0538j, 0.0751 - 0.074j, -0.1273 - 0.0205j, -0.1219 - 0.0166j, -0.0350 - 0.1509j, -0.0565 - 0.0218j, -0.0603 + 0.0813j, 0.0696 + 0.0141j, 0.0822 + 0.0924j, -0.1313 + 0.0652j, -0.0572 + 0.0393j, 0.0369 + 0.0983j, 0.0625 - 0.0625j, 0.1192 - 0.0041j, -0.0225 + 0.1607j, 0.0587 - 0.0149j, 0.0245 - 0.0585j, -0.1368 - 0.0474j, 0.0010 - 0.115j, 0.0533 + 0.0041j, 0.0975 - 0.0259j, -0.0383 - 0.1062j, -0.1151 - 0.0552j, 0.0598 - 0.0877j, 0.0211 + 0.0279j, 0.0968 + 0.0828j, 0.0397 - 0.1112j, -0.0051 - 0.1203j ] + 1000 * [0] ################################################## # Blocks ################################################## self.fft_filter_xxx_0_4_0_0_0 = filter.fft_filter_ccc( 1, (long_seq[::-1]), 1) self.fft_filter_xxx_0_4_0_0_0.declare_sample_delay(0) self.fft_filter_xxx_0_4_0_0 = filter.fft_filter_ccc( 1, (long_seq[::-1]), 1) self.fft_filter_xxx_0_4_0_0.declare_sample_delay(0) self.fft_filter_xxx_0_4_0 = filter.fft_filter_ccc( 1, (long_seq[::-1]), 1) self.fft_filter_xxx_0_4_0.declare_sample_delay(0) self.fft_filter_xxx_0_4 = filter.fft_filter_ccc(1, (long_seq[::-1]), 1) self.fft_filter_xxx_0_4.declare_sample_delay(0) self.devsync_rms_normalization_0 = devsync.rms_normalization( num_streams, num_elements) self.devsync_peak_detector_0 = devsync.peak_detector( num_streams, 100, 1, 0, 100) self.devsync_alligner_0 = devsync.alligner(num_streams) self.blocks_vector_to_stream_1_2 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, num_elements) self.blocks_vector_to_stream_1_1 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, num_elements) self.blocks_vector_to_stream_1_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, num_elements) self.blocks_vector_to_stream_1 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, num_elements) self.blocks_vector_source_x_1 = blocks.vector_source_c( numpy.conj(long_seq), True, 1, []) self.blocks_stream_to_vector_0_3_1 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 1024) self.blocks_stream_to_vector_0_0_0_1 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 1024) self.blocks_stream_to_vector_0_0_0_0_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 1024) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 1024) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) ################################################## # Connections ################################################## self.msg_connect((self.devsync_peak_detector_0, 'shifts_out'), (self.devsync_alligner_0, 'phase_init')) self.connect((self.blocks_null_source_0, 0), (self.devsync_alligner_0, 0)) self.connect((self.blocks_null_source_0, 1), (self.devsync_alligner_0, 1)) self.connect((self.blocks_null_source_0, 2), (self.devsync_alligner_0, 2)) self.connect((self.blocks_null_source_0, 3), (self.devsync_alligner_0, 3)) self.connect((self.blocks_null_source_0, 0), (self.fft_filter_xxx_0_4, 0)) self.connect((self.blocks_null_source_0, 2), (self.fft_filter_xxx_0_4_0, 0)) self.connect((self.blocks_null_source_0, 1), (self.fft_filter_xxx_0_4_0_0, 0)) self.connect((self.blocks_null_source_0, 3), (self.fft_filter_xxx_0_4_0_0_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.devsync_rms_normalization_0, 1)) self.connect((self.blocks_stream_to_vector_0_0_0_0_0, 0), (self.devsync_rms_normalization_0, 3)) self.connect((self.blocks_stream_to_vector_0_0_0_1, 0), (self.devsync_rms_normalization_0, 2)) self.connect((self.blocks_stream_to_vector_0_3_1, 0), (self.devsync_rms_normalization_0, 0)) self.connect((self.blocks_vector_source_x_1, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.devsync_peak_detector_0, 0)) self.connect((self.blocks_vector_to_stream_1_0, 0), (self.devsync_peak_detector_0, 2)) self.connect((self.blocks_vector_to_stream_1_1, 0), (self.devsync_peak_detector_0, 3)) self.connect((self.blocks_vector_to_stream_1_2, 0), (self.devsync_peak_detector_0, 1)) self.connect((self.devsync_alligner_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.devsync_alligner_0, 1), (self.blocks_null_sink_1, 1)) self.connect((self.devsync_alligner_0, 2), (self.blocks_null_sink_1, 2)) self.connect((self.devsync_alligner_0, 3), (self.blocks_null_sink_1, 3)) self.connect((self.devsync_rms_normalization_0, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.devsync_rms_normalization_0, 2), (self.blocks_vector_to_stream_1_0, 0)) self.connect((self.devsync_rms_normalization_0, 3), (self.blocks_vector_to_stream_1_1, 0)) self.connect((self.devsync_rms_normalization_0, 1), (self.blocks_vector_to_stream_1_2, 0)) self.connect((self.fft_filter_xxx_0_4, 0), (self.blocks_stream_to_vector_0_3_1, 0)) self.connect((self.fft_filter_xxx_0_4_0, 0), (self.blocks_stream_to_vector_0_0_0_1, 0)) self.connect((self.fft_filter_xxx_0_4_0_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.fft_filter_xxx_0_4_0_0_0, 0), (self.blocks_stream_to_vector_0_0_0_0_0, 0))
class Follow_with_single_usrp(gr.top_block): def __init__(self, FH_seq): gr.top_block.__init__(self, "Test2") ################################################## # Variables ################################################## self.sql_on = sql_on = 0 self.samp_rate = samp_rate = 2e6 self.curr_chann_idx = 0 self.FH_seq = FH_seq ################################################## # Blocks ################################################## #self.analog_noise_source = analog.noise_source_c(analog.GR_GAUSSIAN, 0) self.cosine_source = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) self.analog_pwr_squelch_xx_1 = analog.pwr_squelch_cc(-30, 1, 25, False) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="addr=192.168.30.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:0", 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(2.43665e9, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_sink = uhd.usrp_sink( device_addr="addr=192.168.30.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink.set_subdev_spec("A:0", 0) self.uhd_usrp_sink.set_samp_rate(samp_rate) self.uhd_usrp_sink.set_center_freq(2.43665e9, 0) self.uhd_usrp_sink.set_gain(31.5, 0) self.uhd_usrp_sink.set_antenna("TX/RX", 0) def _sql_on_probe(): while True: val = self.analog_pwr_squelch_xx_1.unmuted() try: self.set_sql_on(val) except AttributeError, e: pass time.sleep((0.001)) _sql_on_thread = threading.Thread(target=_sql_on_probe) _sql_on_thread.daemon = True _sql_on_thread.start() #self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (2.337093355240479e-18, 0.001956143882125616, -0.004504681099206209, 0.005366003606468439, -9.056237216845951e-18, -0.01352460216730833, 0.028625724837183952, -0.029645023867487907, 2.2494524940056896e-17, 0.06486776471138, -0.1492309421300888, 0.22137974202632904, 0.7494196891784668, 0.22137974202632904, -0.1492309421300888, 0.06486776471138, 2.2494524940056896e-17, -0.029645023867487907, 0.028625724837183952, -0.01352460216730833, -9.056237216845951e-18, 0.005366003606468439, -0.004504681099206209, 0.001956143882125616, 2.337093355240479e-18)) self.fir_filter_xxx_0 = filter.fir_filter_ccc( 1, firdes.low_pass(1, samp_rate, 750000, 1000000, firdes.WIN_HAMMING, 6.76)) self.fir_filter_xxx_0.declare_sample_delay(0) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_1, 0)) self.connect((self.analog_pwr_squelch_xx_1, 0), (self.blocks_null_sink_0, 0)) self.connect((self.cosine_source, 0), (self.uhd_usrp_sink, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 ################################################## # Blocks ################################################## self.tnc_hdlc_framer_0 = tnc.hdlc_framer(preamble_length=50, postamble_length=7, verbose=False, use_scrambler=False) self.tnc_hdlc_deframer_0 = tnc.hdlc_deframer() self.tnc_ax25_framer_0 = tnc.ax25_framer(mycall="KI4MTT", destcall="KI4MTS", verbose=True) self.tnc_ax25_deframer_0 = tnc.ax25_deframer(mycall="KI4MTT", verbose=True) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=96, decimation=250, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=250, decimation=96, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=10, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_random_pdu_0 = blocks.random_pdu(50, 50, chr(0xFF), 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern("TEST"), 500) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( -200, 0.1, 0, True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.tnc_ax25_framer_0, 'in')) self.msg_connect((self.tnc_ax25_deframer_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.tnc_ax25_framer_0, 'out'), (self.tnc_hdlc_framer_0, 'in')) self.msg_connect((self.tnc_hdlc_deframer_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.tnc_hdlc_deframer_0, 'out'), (self.tnc_ax25_deframer_0, 'in')) self.msg_connect((self.tnc_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.tnc_hdlc_deframer_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_complex_to_mag_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Vv018 Miso") ################################################## # Variables ################################################## self.samp_rate = samp_rate = (8000000.0) * 8 / 7 ################################################## # Blocks ################################################## self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0,buffers=128,buflen=32768" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(429e6, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(18, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(-8, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(8750000, 0) self.dvbt2_pilotgenerator_cc_1 = dvbt2.pilotgenerator_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.PILOT_PP2, dvbt2.GI_1_16, 19, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_MISO, dvbt2.MISO_TX1, dvbt2.EQUALIZATION_ON, dvbt2.BANDWIDTH_8_0_MHZ, 32768) self.dvbt2_pilotgenerator_cc_0 = dvbt2.pilotgenerator_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.PILOT_PP2, dvbt2.GI_1_16, 19, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_MISO, dvbt2.MISO_TX2, dvbt2.EQUALIZATION_ON, dvbt2.BANDWIDTH_8_0_MHZ, 32768) self.dvbt2_p1insertion_cc_0_0 = dvbt2.p1insertion_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.GI_1_16, 19, dvbt2.PREAMBLE_T2_MISO, dvbt2.SHOWLEVELS_OFF, 3.3) self.dvbt2_p1insertion_cc_0 = dvbt2.p1insertion_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.GI_1_16, 19, dvbt2.PREAMBLE_T2_MISO, dvbt2.SHOWLEVELS_OFF, 3.3) self.dvbt2_modulator_bc_0 = dvbt2.modulator_bc(dvbt2.FECFRAME_NORMAL, dvbt2.MOD_256QAM, dvbt2.ROTATION_ON) self.dvbt2_miso_cc_0 = dvbt2.miso_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.PILOT_PP2, dvbt2.GI_1_16, 19, dvbt2.PAPR_OFF, ) self.dvbt2_ldpc_bb_0 = dvbt2.ldpc_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6) self.dvbt2_interleaver_bb_0 = dvbt2.interleaver_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6, dvbt2.MOD_256QAM) self.dvbt2_freqinterleaver_cc_0 = dvbt2.freqinterleaver_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.PILOT_PP2, dvbt2.GI_1_16, 19, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_MISO, ) self.dvbt2_framemapper_cc_0 = dvbt2.framemapper_cc(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6, dvbt2.MOD_256QAM, dvbt2.ROTATION_ON, 61, 1, dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.GI_1_16, dvbt2.L1_MOD_64QAM, dvbt2.PILOT_PP2, 2, 19, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_MISO, dvbt2.INPUTMODE_NORMAL, dvbt2.RESERVED_OFF, dvbt2.L1_SCRAMBLED_OFF, dvbt2.INBAND_OFF) self.dvbt2_cellinterleaver_cc_0 = dvbt2.cellinterleaver_cc(dvbt2.FECFRAME_NORMAL, dvbt2.MOD_256QAM, 61, 1) self.dvbt2_bch_bb_0 = dvbt2.bch_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6) self.dvbt2_bbscrambler_bb_0 = dvbt2.bbscrambler_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6) self.dvbt2_bbheader_bb_0 = dvbt2.bbheader_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6, dvbt2.INPUTMODE_HIEFF, dvbt2.INBAND_OFF, 168, 4000000) self.digital_ofdm_cyclic_prefixer_0_0 = digital.ofdm_cyclic_prefixer(32768, 32768+32768/16, 0, "") self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(32768, 32768+32768/16, 0, "") self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.2, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/run/shm/adv32kmiso.ts", False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dvbt2_bbheader_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.dvbt2_p1insertion_cc_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0_0, 0), (self.dvbt2_p1insertion_cc_0_0, 0)) self.connect((self.dvbt2_bbheader_bb_0, 0), (self.dvbt2_bbscrambler_bb_0, 0)) self.connect((self.dvbt2_bbscrambler_bb_0, 0), (self.dvbt2_bch_bb_0, 0)) self.connect((self.dvbt2_bch_bb_0, 0), (self.dvbt2_ldpc_bb_0, 0)) self.connect((self.dvbt2_cellinterleaver_cc_0, 0), (self.dvbt2_framemapper_cc_0, 0)) self.connect((self.dvbt2_framemapper_cc_0, 0), (self.dvbt2_freqinterleaver_cc_0, 0)) self.connect((self.dvbt2_freqinterleaver_cc_0, 0), (self.dvbt2_miso_cc_0, 0)) self.connect((self.dvbt2_interleaver_bb_0, 0), (self.dvbt2_modulator_bc_0, 0)) self.connect((self.dvbt2_ldpc_bb_0, 0), (self.dvbt2_interleaver_bb_0, 0)) self.connect((self.dvbt2_miso_cc_0, 1), (self.dvbt2_pilotgenerator_cc_0, 0)) self.connect((self.dvbt2_miso_cc_0, 0), (self.dvbt2_pilotgenerator_cc_1, 0)) self.connect((self.dvbt2_modulator_bc_0, 0), (self.dvbt2_cellinterleaver_cc_0, 0)) self.connect((self.dvbt2_p1insertion_cc_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.dvbt2_p1insertion_cc_0_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.dvbt2_pilotgenerator_cc_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.dvbt2_pilotgenerator_cc_1, 0), (self.digital_ofdm_cyclic_prefixer_0_0, 0))
def _do_connect(self): """Do all reconfiguration operations in the proper order.""" if self.__in_reconnect: raise Exception('reentrant reconnect or _do_connect crashed') self.__in_reconnect = True t0 = time.time() if self.source is not self._sources[self.source_name]: self.__log.info('Flow graph: Switching RF device to {device_name}', device_name=self.source_name) self.__needs_reconnect.append(u'switched device') this_source = self._sources[self.source_name] self.source = this_source self.state_changed('source') self.__monitor_rx_driver = this_source.get_rx_driver() monitor_signal_type = self.__monitor_rx_driver.get_output_type() self.monitor.set_signal_type(monitor_signal_type) self.monitor.set_input_center_freq(this_source.get_freq()) self.__clip_probe.set_window_and_reconnect( 0.5 * monitor_signal_type.get_sample_rate()) if self.__needs_reconnect: self.__log.info( u'Flow graph: Rebuilding connections because: {reasons}', reasons=', '.join(self.__needs_reconnect)) self.__needs_reconnect = [] self._recursive_lock() self.disconnect_all() self.connect(self.__monitor_rx_driver, self.monitor) self.connect(self.__monitor_rx_driver, self.__clip_probe) # Filter receivers audio_rs = self.__audio_manager.reconnecting() n_valid_receivers = 0 has_non_audio_receiver = False for key, receiver in six.iteritems(self._receivers): self._receiver_valid[key] = receiver.get_is_valid() if not self._receiver_valid[key]: continue if not self.__audio_manager.validate_destination( receiver.get_audio_destination()): self.__log.info( 'Flow graph: receiver audio destination {audio_destination} is not available', audio_destination=receiver.get_audio_destination()) continue n_valid_receivers += 1 if n_valid_receivers > 6: # Sanity-check to avoid burning arbitrary resources # TODO: less arbitrary constant; communicate this restriction to client self.__log.info( 'Flow graph: Refusing to connect more than 6 receivers' ) break self.connect( self._sources[receiver.get_device_name()].get_rx_driver(), receiver) receiver_output_type = receiver.get_output_type() if receiver_output_type.get_sample_rate() <= 0: # Demodulator has no output, but receiver has a dummy output, so connect it to something to satisfy flow graph structure. self.connect( receiver, blocks.null_sink(gr.sizeof_float * self.__audio_manager.get_channels())) # Note that we have a non-audio receiver which may be useful even if there is no audio output has_non_audio_receiver = True else: assert receiver_output_type.get_kind() == 'STEREO' audio_rs.input(receiver, receiver_output_type.get_sample_rate(), receiver.get_audio_destination()) self.__has_a_useful_receiver = audio_rs.finish_bus_connections() or \ has_non_audio_receiver self._recursive_unlock() # (this is in an if block but it can't not execute if anything else did) self.__log.info('Flow graph: ...done reconnecting ({time_ms} ms).', time_ms=(time.time() - t0) * 1000) self.__start_or_stop_later() self.__in_reconnect = False
def __init__(self): gr.top_block.__init__(self, "USRP FLEX Pager Receiver (Single Channel)") Qt.QWidget.__init__(self) self.setWindowTitle("USRP FLEX Pager Receiver (Single Channel)") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "usrp_rx_flex") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 3200 self.deviation = deviation = 4800 self.decim = decim = 20 self.adc_rate = adc_rate = 64e6 self.sample_rate = sample_rate = adc_rate / decim self.passband = passband = 2 * (deviation + symbol_rate) self.channel_rate = channel_rate = 8 * 3200 self.channel_taps = channel_taps = firdes.low_pass( 10, sample_rate, passband / 2.0, (channel_rate - passband) / 2.0) self.rx_gain = rx_gain = 40 self.rx_freq = rx_freq = 931e6 self.offset = offset = 0 self.nchan_taps = nchan_taps = len(channel_taps) self.ma_ntaps = ma_ntaps = int(channel_rate / symbol_rate) self.demod_k = demod_k = 3 * channel_rate / (2 * math.pi * deviation) self.config_filename = config_filename = os.environ[ "HOME"] + "/.gnuradio/config.conf" self.channel_decim = channel_decim = int(sample_rate / channel_rate) self.bb_interp = bb_interp = 5 self.bb_decim = bb_decim = 8 self.baseband_rate = baseband_rate = 16000 ################################################## # Blocks ################################################## self._rx_gain_tool_bar = Qt.QToolBar(self) self._rx_gain_tool_bar.addWidget(Qt.QLabel('GAIN' + ": ")) self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain)) self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit) self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain( eng_notation.str_to_num( str(self._rx_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 0, 2, 1, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ' + ": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq( eng_notation.str_to_num( str(self._rx_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 0, 1, 1, 1) self._offset_tool_bar = Qt.QToolBar(self) self._offset_tool_bar.addWidget(Qt.QLabel("offset" + ": ")) self._offset_line_edit = Qt.QLineEdit(str(self.offset)) self._offset_tool_bar.addWidget(self._offset_line_edit) self._offset_line_edit.returnPressed.connect(lambda: self.set_offset( eng_notation.str_to_num( str(self._offset_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._offset_tool_bar, 0, 0, 1, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", otw_format='sc16', channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(sample_rate) self.uhd_usrp_source_0.set_center_freq(rx_freq, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=bb_decim, decimation=bb_interp, taps=([ 1.0 / ma_ntaps, ] * ma_ntaps * bb_interp), fractional_bw=None, ) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.pager_slicer_fb_0 = pager.slicer_fb(1e-6) self.pager_flex_sync_0 = pager.flex_sync() self.pager_flex_deinterleave_0_1_0 = pager.flex_deinterleave() self.pager_flex_deinterleave_0_1 = pager.flex_deinterleave() self.pager_flex_deinterleave_0_0 = pager.flex_deinterleave() self.pager_flex_deinterleave_0 = pager.flex_deinterleave() self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( channel_decim, (channel_taps), offset, sample_rate) self.fosphor_glfw_sink_c_0 = fosphor.glfw_sink_c() self.fosphor_glfw_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_glfw_sink_c_0.set_frequency_range(0, sample_rate) self.fm_demod = analog.quadrature_demod_cf(demod_k) self.blocks_null_sink_0_2 = blocks.null_sink(gr.sizeof_int * 1) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_int * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_int * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_int * 1) ################################################## # Connections ################################################## self.connect((self.fm_demod, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fm_demod, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.pager_flex_deinterleave_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.pager_flex_deinterleave_0_0, 0), (self.blocks_null_sink_0_2, 0)) self.connect((self.pager_flex_deinterleave_0_1, 0), (self.blocks_null_sink_0_1, 0)) self.connect((self.pager_flex_deinterleave_0_1_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.pager_flex_sync_0, 0), (self.pager_flex_deinterleave_0, 0)) self.connect((self.pager_flex_sync_0, 3), (self.pager_flex_deinterleave_0_0, 0)) self.connect((self.pager_flex_sync_0, 2), (self.pager_flex_deinterleave_0_1, 0)) self.connect((self.pager_flex_sync_0, 1), (self.pager_flex_deinterleave_0_1_0, 0)) self.connect((self.pager_slicer_fb_0, 0), (self.pager_flex_sync_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.pager_slicer_fb_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.fosphor_glfw_sink_c_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bob") Qt.QWidget.__init__(self) self.setWindowTitle("Bob") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "bob") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952 ] self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 30 self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 52 self.variable_qtgui_check_box_0 = variable_qtgui_check_box_0 = True self.sps = sps = 4 self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.frequencia_usrp = frequencia_usrp = 484e6 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 30, 200) self._variable_qtgui_range_0_1_win = RangeWidget( self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 52, 200) self._variable_qtgui_range_0_0_win = RangeWidget( self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_Jamming', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 3, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) _variable_qtgui_check_box_0_check_box = Qt.QCheckBox('ENABLE JAM') self._variable_qtgui_check_box_0_choices = {True: True, False: False} self._variable_qtgui_check_box_0_choices_inv = dict( (v, k) for k, v in self._variable_qtgui_check_box_0_choices.iteritems()) self._variable_qtgui_check_box_0_callback = lambda i: Qt.QMetaObject.invokeMethod( _variable_qtgui_check_box_0_check_box, "setChecked", Qt.Q_ARG("bool", self._variable_qtgui_check_box_0_choices_inv[i])) self._variable_qtgui_check_box_0_callback( self.variable_qtgui_check_box_0) _variable_qtgui_check_box_0_check_box.stateChanged.connect( lambda i: self.set_variable_qtgui_check_box_0( self._variable_qtgui_check_box_0_choices[bool(i)])) self.top_grid_layout.addWidget(_variable_qtgui_check_box_0_check_box, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("serial=F5EAC0", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F5EAC0", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX JAMMING USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "RX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "RX Treated", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc( 4, ([1, 0, 0, 0])) self.interp_fir_filter_xxx_1.declare_sample_delay(0) self.custom_corr = correlate_and_delay.corr_and_delay( 200 * sps, 0, 0.99, sps) self.bob_hier = bob_hier(samp_rate=samp_rate, ) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink( gr.sizeof_char * 1, '/home/it/Desktop/Trasmited/depois.txt', False) self.blocks_file_sink_0_0_0_0_2.set_unbuffered(False) self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1) self.blocks_copy_0.set_enabled(variable_qtgui_check_box_0) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.analog_noise_source_x_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, -5) self.adapt_lms_filter_xx_0 = adapt.lms_filter_cc( True, 32, 0.0001, 0, 1, True, False, False) ################################################## # Connections ################################################## self.connect((self.adapt_lms_filter_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.bob_hier, 0)) self.connect((self.analog_noise_source_x_0_0, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_copy_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_copy_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.custom_corr, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.bob_hier, 1), (self.blocks_char_to_float_1_0_1, 0)) self.connect((self.bob_hier, 1), (self.blocks_file_sink_0_0_0_0_2, 0)) self.connect((self.bob_hier, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.custom_corr, 0), (self.adapt_lms_filter_xx_0, 1)) self.connect((self.custom_corr, 1), (self.adapt_lms_filter_xx_0, 0)) self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.vec_len = vec_len = 63 self.short_field_preamble = short_field_preamble = [(0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (1.472, 1.472j), (0, 0), (0, 0), (0, 0), (-1.472, -1.472j), (0, 0), (0, 0), (0, 0), (1.472, 1.472j), (0, 0), (0, 0), (0, 0), (-1.472, -1.472j), (0, 0), (0, 0), (0, 0), (-1.472, -1.472j), (0, 0), (0, 0), (0, 0), (1.472, 1.472j), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (-1.472, -1.472j), (0, 0), (0, 0), (0, 0), (-1.472, -1.472j), (0, 0), (0, 0), (0, 0), (1.472, 1.472j), (0, 0), (0, 0), (0, 0), (1.472, 1.472j), (0, 0), (0, 0), (0, 0), (1.472, 1.472j), (0, 0), (0, 0), (0, 0), (1.472, 1.472j), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0)] self.samp_rate = samp_rate = 100e3 ################################################## # Blocks ################################################## self.satcom_gmu_short_field_preamble_0 = satcom_gmu.short_field_preamble( ) self.blocks_vector_source_x_0 = blocks.vector_source_f( (0, 0, 1, 0, 0, 0, 0, 0, 0, 0), False, 1, []) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, 2, "packet_len") self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) ################################################## # Connections ################################################## self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.satcom_gmu_short_field_preamble_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.satcom_gmu_short_field_preamble_0, 0), (self.blocks_null_sink_0, 0))