def __init__(self, ansibleFreqRx=2.4555e9, ansibleFreqTx=2.4505e9, ansibleID='1', ansibleIP='notValid', bw=250e3, offset=-250e3): gr.top_block.__init__(self, "Ansible Hydra Gr Client 1Tx 1Rx") ################################################## # Parameters ################################################## self.ansibleFreqRx = ansibleFreqRx self.ansibleFreqTx = ansibleFreqTx self.ansibleID = ansibleID self.ansibleIP = ansibleIP self.bw = bw self.offset = offset ################################################## # Variables ################################################## self.spreading_factor = spreading_factor = 8 self.samp_rate = samp_rate = 1e6 self.ldr = ldr = True self.header = header = False self.code_rate = code_rate = 4 ################################################## # Blocks ################################################## self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf( bw/samp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samp_rate/bw, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.lora_mod_0 = lora.mod(spreading_factor, 0x12) self.lora_encode_0 = lora.encode(spreading_factor, code_rate, ldr, header) self.lora_demod_0 = lora.demod(spreading_factor, ldr, 25.0, 2) self.lora_decode_0 = lora.decode(spreading_factor, code_rate, ldr, header) self.hydra_gr_sink_0 = hydra.hydra_gr_client_sink(int(ansibleID), ansibleIP, 5000) self.hydra_gr_sink_0.start_client(ansibleFreqTx + samp_rate/2 + (samp_rate * int(ansibleID)), samp_rate, 1000) self.hydra_gr__source_0 = hydra.hydra_gr_client_source(int(ansibleID), ansibleIP, ansibleIP, 5000) self.hydra_gr__source_0.start_client(ansibleFreqRx + samp_rate/2 + (samp_rate * int(ansibleID)), samp_rate, 1000) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu('tap0', 1000, False) self.blocks_message_debug_0_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.lora_encode_0, 'in')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_tuntap_pdu_0, 'pdus')) self.msg_connect((self.lora_demod_0, 'out'), (self.lora_decode_0, 'in')) self.msg_connect((self.lora_encode_0, 'out'), (self.lora_mod_0, 'in')) self.connect((self.hydra_gr__source_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) self.connect((self.lora_mod_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.hydra_gr_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.lora_demod_0, 0))
def __init__(self, inputFile, outputFile, samp_rate): gr.top_block.__init__(self, "Wavtobin") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.chip_rate = chip_rate = 64e3 ################################################## # Blocks ################################################## self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(chip_rate / samp_rate, taps=None, flt_size=32) self.blocks_wavfile_source_0 = blocks.wavfile_source(inputFile, False) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, outputFile, False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_file_sink_0, 0))
def __init__(self, inputFile, outputFile, samp_rate): gr.top_block.__init__(self, "Wavtobin") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.chip_rate = chip_rate = 64e3 ################################################## # Blocks ################################################## self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(chip_rate/samp_rate, taps=None, flt_size=32) self.blocks_wavfile_source_0 = blocks.wavfile_source(inputFile, False) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, outputFile, False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_file_sink_0, 0))
def __init__(self, fft_len, freq_sample_delay_samps, freq_samps_to_avg, mag_samps_to_avg, thresh): gr.hier_block2.__init__(self, "Coarse Dehopper", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1)) ''' Constructor @param fft_len - @param freq_sample_delay_samps - @param freq_samps_to_avg - @param mag_samps_to_avg - @param thresh - ''' ################################################## # Parameters ################################################## self.fft_len = fft_len self.freq_sample_delay_samps = freq_sample_delay_samps self.freq_samps_to_avg = freq_samps_to_avg self.mag_samps_to_avg = mag_samps_to_avg self.thresh = thresh ################################################## # Blocks ################################################## self.s_and_h_detector = s_and_h_detector( freq_sample_delay_samps=freq_sample_delay_samps, freq_samps_to_avg=freq_samps_to_avg, mag_samps_to_avg=mag_samps_to_avg, thresh=thresh, ) self.resamp = pfb.arb_resampler_ccf(1.0 / (fft_len / 4.0), taps=None, flt_size=32) self.resamp.declare_sample_delay(0) self.fir = filter.fir_filter_ccc(2, (firdes.low_pass_2(1,1,.30,.05,60))) self.fir.declare_sample_delay(0) self.fft_peak = fft_peak(fft_len=fft_len) self.vco = blocks.vco_c(1, 2.0 * pi / fft_len, 1) self.mult_conj = blocks.multiply_conjugate_cc(1) self.delay = blocks.delay(gr.sizeof_gr_complex*1, int(freq_samps_to_avg) + freq_sample_delay_samps) self.c2mag = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.connect((self.c2mag, 0), (self.s_and_h_detector, 0)) self.connect((self.delay, 0), (self.mult_conj, 0)) self.connect((self.mult_conj, 0), (self.fir, 0)) self.connect((self.vco, 0), (self.mult_conj, 1)) self.connect((self.fft_peak, 0), (self.s_and_h_detector, 1)) self.connect((self.fir, 0), (self.resamp, 0)) self.connect((self, 0), (self.c2mag, 0)) self.connect((self, 0), (self.delay, 0)) self.connect((self, 0), (self.fft_peak, 0)) self.connect((self.resamp, 0), (self, 0)) self.connect((self.s_and_h_detector, 0), (self.vco, 0))
def __init__(self, RIC=1006370, SubRIC=0, Text='pRIWET'): gr.top_block.__init__(self, "POCSAG Sender via HackRF") ################################################## # Parameters ################################################## self.RIC = RIC self.SubRIC = SubRIC self.Text = Text ################################################## # Variables ################################################## self.tx_gain = tx_gain = 47 self.symrate = symrate = 38400 self.samp_rate = samp_rate = 12000000 self.pocsagbitrate = pocsagbitrate = 1200 self.pagerfreq = pagerfreq = 473325000 self.max_deviation = max_deviation = 4500.0 self.af_gain = af_gain = 190 ################################################## # Blocks ################################################## self.pocsag_generator = pocsag_generator.pocsagsender(number=RIC, source=SubRIC, sleeptime=5, text=Text) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( float(samp_rate)/float(symrate), taps=None, flt_size=16) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + 'hackrf' ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(pagerfreq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(0, 0) self.osmosdr_sink_0.set_if_gain(tx_gain, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna('', 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, symrate/pocsagbitrate) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((af_gain/100, )) self.blocks_char_to_float_0 = blocks.char_to_float(1, af_gain*0.7/1000) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2.0 * math.pi * max_deviation / float(symrate)) ################################################## # Connections ################################################## self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.pocsag_generator, 0), (self.blocks_repeat_0, 0))
def __init__(self, bias, freq_sample_delay_samps, freq_samps_to_avg, mag_samps_to_avg, resamp_rate, thresh): gr.hier_block2.__init__(self, "Fine Dehopper", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1)) ################################################## # Parameters ################################################## self.bias = bias self.freq_sample_delay_samps = freq_sample_delay_samps self.freq_samps_to_avg = freq_samps_to_avg self.mag_samps_to_avg = mag_samps_to_avg self.resamp_rate = resamp_rate self.thresh = thresh ################################################## # Blocks ################################################## self.s_and_h_detector = s_and_h_detector( freq_sample_delay_samps=freq_sample_delay_samps, freq_samps_to_avg=freq_samps_to_avg, mag_samps_to_avg=mag_samps_to_avg, thresh=thresh, ) self.resamp = pfb.arb_resampler_ccf(resamp_rate * 2.0, taps=None, flt_size=32) self.resamp.declare_sample_delay(0) self.fir = filter.fir_filter_ccc(2, (firdes.low_pass_2(1,1,.25,.05,60))) self.fir.declare_sample_delay(0) self.vco = blocks.vco_c(1, 1, 1) self.mult_conj = blocks.multiply_conjugate_cc(1) self.delay = blocks.delay(gr.sizeof_gr_complex*1, int(freq_samps_to_avg) + freq_sample_delay_samps) self.c2mag = blocks.complex_to_mag(1) self.add_const = blocks.add_const_vff((-1.0 * bias * (resamp_rate), )) self.demod = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.demod, 0), (self.s_and_h_detector, 1)) self.connect((self.add_const, 0), (self.vco, 0)) self.connect((self.c2mag, 0), (self.s_and_h_detector, 0)) self.connect((self.delay, 0), (self.mult_conj, 0)) self.connect((self.mult_conj, 0), (self.fir, 0)) self.connect((self.vco, 0), (self.mult_conj, 1)) self.connect((self.fir, 0), (self.resamp, 0)) self.connect((self, 0), (self.demod, 0)) self.connect((self, 0), (self.c2mag, 0)) self.connect((self, 0), (self.delay, 0)) self.connect((self.resamp, 0), (self, 0)) self.connect((self.s_and_h_detector, 0), (self.add_const, 0))
def __init__(self, sps, gain_mu): gr.hier_block2.__init__(self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature self._sps = float(sps) self._gain_mu = gain_mu # for the clock recovery block self._mu = 0.5 self._omega_relative_limit = 0.35 #first bring that input stream down to a manageable level self._clockrec_oversample = 3.0 self._decim = self._sps / self._clockrec_oversample print "Demodulator decimation: %f" % self._decim self._downsampletaps = filter.firdes.low_pass(1.0/self._decim, 1.0, 0.4, 0.05, filter.firdes.WIN_HANN) # self._downsample = filter.fft_filter_ccc(self._decim, # self._downsampletaps) #sure this works but it's a little heavy on the CPU at high rates self._downsample = pfb.arb_resampler_ccf(1/self._decim) self._clockrec_sps = self._sps / self._decim #using a pll to demod gets you a nice IIR LPF response for free self._demod = analog.pll_freqdet_cf(2.0 / self._clockrec_sps, #gain alpha, rad/samp 2*pi/self._clockrec_sps, #max freq, rad/samp -2*pi/self._clockrec_sps) #min freq, rad/samp #band edge filter FLL with a low bandwidth is very good #at synchronizing to continuous FSK signals self._carriertrack = digital.fll_band_edge_cc(self._clockrec_sps, 0.6, #rolloff factor 64, #taps 1.0) #loop bandwidth print "Samples per symbol: %f" % (self._clockrec_sps,) self._softbits = digital.clock_recovery_mm_ff(self._clockrec_sps, 0.25*self._gain_mu*self._gain_mu, #gain omega, = mu/2 * mu_gain^2 self._mu, #mu (decision threshold) self._gain_mu, #mu gain self._omega_relative_limit) #omega relative limit self._slicer = digital.binary_slicer_fb() if self._decim > 1: self.connect(self, self._downsample, self._carriertrack, self._demod, self._softbits, self._slicer, self) else: self.connect(self, self._carriertrack, self._demod, self._softbits, self._slicer, self)
def __init__(self, options, context): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._queue = gr.msg_queue() self._rate = int(options.rate) self._resample = None self._setup_source(options) if self._rate < 4e6: self._resample = pfb.arb_resampler_ccf(4.e6 / self._rate) self._rx_rate = 4e6 else: self._rx_rate = self._rate self._rx_path = air_modes.rx_path(self._rx_rate, options.threshold, self._queue, options.pmf, options.dcblock) #now subscribe to set various options via pubsub self.subscribe("freq", self.set_freq) self.subscribe("gain", self.set_gain) self.subscribe("rate", self.set_rate) self.subscribe("rate", self._rx_path.set_rate) self.subscribe("threshold", self._rx_path.set_threshold) self.subscribe("pmf", self._rx_path.set_pmf) self.publish("freq", self.get_freq) self.publish("gain", self.get_gain) self.publish("rate", self.get_rate) self.publish("threshold", self._rx_path.get_threshold) self.publish("pmf", self._rx_path.get_pmf) if self._resample is not None: self.connect(self._u, self._resample, self._rx_path) else: self.connect(self._u, self._rx_path) #Publish messages when they come back off the queue server_addr = ["inproc://modes-radio-pub"] if options.tcp is not None: server_addr += ["tcp://*:%i" % options.tcp] self._sender = air_modes.zmq_pubsub_iface(context, subaddr=None, pubaddr=server_addr) self._async_sender = gru.msgq_runner(self._queue, self.send)
def __init__(self, channels, resamp_rate, fc, band, samp_rate, input_file, dest_dir, data_type="complex"): gr.top_block.__init__(self, "grgsm_channelize") ################################################## # Parameters ################################################## self.channels = channels self.resamp_rate = resamp_rate self.fc = fc self.band = band self.samp_rate = samp_rate self.blocks_resamplers = {} self.blocks_rotators = {} self.blocks_file_sinks = {} ################################################## # Blocks and connections ################################################## self.source = None if data_type == "ishort": self.blocks_file_source = blocks.file_source(gr.sizeof_short, input_file, False) self.source = blocks.interleaved_short_to_complex(False, False) self.connect((self.blocks_file_source, 0), (self.source, 0)) elif data_type == "complex": self.source = blocks.file_source(gr.sizeof_gr_complex, input_file, False) fc_str = eng_notation.num_to_str(fc) print("Extracting channels %s, given center frequency at %sHz (ARFCN %d)" % (str(ca), fc_str, center_arfcn)) for channel in channels: channel_freq = arfcn.arfcn2downlink(channel, band) if channel_freq is None: print("Warning: invalid ARFCN %d for band %s" % (channel, band)) continue freq_diff = channel_freq - fc freq_diff_str = "+" if 0 <= freq_diff else "" freq_diff_str += eng_notation.num_to_str(freq_diff) print("ARFCN %d is at %sHz %sHz" % (channel, fc_str, freq_diff_str)) self.blocks_resamplers[channel] = pfb.arb_resampler_ccf( resamp_rate, taps=None, flt_size=32) self.blocks_rotators[channel] = blocks.rotator_cc(-2*math.pi*(freq_diff)/samp_rate) self.connect( (self.source, 0), (self.blocks_rotators[channel], 0) ) self.connect( (self.blocks_rotators[channel], 0), (self.blocks_resamplers[channel], 0) ) self.blocks_file_sinks[channel] = blocks.file_sink(gr.sizeof_gr_complex, dest_dir+"/out_" + str(channel) + ".cfile", False) self.blocks_file_sinks[channel].set_unbuffered(False) self.connect((self.blocks_resamplers[channel], 0), (self.blocks_file_sinks[channel], 0))
def __init__(self, capcode, message): gr.top_block.__init__(self, "Pocsagtx") ################################################## # Variables ################################################## self.symrate = symrate = 38400 self.samp_rate = samp_rate = 5000000 ### Set the frequency! #self.pagerfreq = pagerfreq = 421000000 raise Exception("Make sure you're legal!") ### Set to 2500.0 for narrowband self.max_deviation = max_deviation = 4500.0 ################################################## # Blocks ################################################## self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( float(samp_rate)/float(symrate), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1)) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(pagerfreq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(10, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.mixalot_pocencode_0 = mixalot.pocencode(1, 512, capcode, message, symrate) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.7, )) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2.0 * math.pi * max_deviation / float(symrate)) ################################################## # Connections ################################################## self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.mixalot_pocencode_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 500e3 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0_2 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=True, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0_2.win) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( 4, taps=(firdes.root_raised_cosine(32, 32, 1.0, 0.4, 11 * 32 * 4)), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (((1 - 1j), (1 + 1j), (-1 + 1j), (-1 - 1j))), 1) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 4, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.wxgui_scopesink2_0_2, 0))
def __init__(self, options, context): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._queue = gr.msg_queue() self._rate = int(options.rate) self._resample = None self._setup_source(options) if self._rate < 4e6: self._resample = pfb.arb_resampler_ccf(4.e6/self._rate) self._rx_rate = 4e6 else: self._rx_rate = self._rate self._rx_path = air_modes.rx_path(self._rx_rate, options.threshold, self._queue, options.pmf, options.dcblock) #now subscribe to set various options via pubsub self.subscribe("freq", self.set_freq) self.subscribe("gain", self.set_gain) self.subscribe("rate", self.set_rate) self.subscribe("rate", self._rx_path.set_rate) self.subscribe("threshold", self._rx_path.set_threshold) self.subscribe("pmf", self._rx_path.set_pmf) self.publish("freq", self.get_freq) self.publish("gain", self.get_gain) self.publish("rate", self.get_rate) self.publish("threshold", self._rx_path.get_threshold) self.publish("pmf", self._rx_path.get_pmf) if self._resample is not None: self.connect(self._u, self._resample, self._rx_path) else: self.connect(self._u, self._rx_path) #Publish messages when they come back off the queue server_addr = ["inproc://modes-radio-pub"] if options.tcp is not None: server_addr += ["tcp://*:%i" % options.tcp] self._sender = air_modes.zmq_pubsub_iface(context, subaddr=None, pubaddr=server_addr) self._async_sender = gru.msgq_runner(self._queue, self.send)
def __init__(self, params, filename): # Super gr.hier_block2.__init__( self, "PFBOutputBranch", gr.io_signature(params.width, params.width, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) prev = self # Synthesizer if params.width > 1: self.synth = filter.pfb_synthesizer_ccf( params.width_synth, params.taps_synth, True # 2x oversample ) for i in range(params.width): self.connect((prev, i), (self.synth, i)) prev = self.synth # Delay if params.delay: self.delay = blocks.delay( gr.sizeof_gr_complex, int(round(params.delay * params.width_synth)), ) self.connect((prev, 0), (self.delay, 0)) prev = self.delay # Post synth rotation if params.rotation != 0: self.rotator = blocks.rotator_cc(params.rotation) self.connect((prev, 0), (self.rotator, 0)) prev = self.rotator # PFB Arb Resampler if params.resamp != 1: self.resamp = pfb.arb_resampler_ccf(params.resamp, params.taps_resamp, flt_size=32) self.connect((prev, 0), (self.resamp, 0)) prev = self.resamp # Output file self.sink = blocks.file_sink(gr.sizeof_gr_complex, filename, False) self.connect((prev, 0), (self.sink, 0))
def __init__(self, filename): gr.top_block.__init__(self, "Spritedemodnogui") ################################################## # Variables ################################################## self.chip_rate = chip_rate = 64e3 ################################################## # Blocks ################################################## self.sprite_sprite_decoder_f_0 = sprite.sprite_decoder_f() self.sprite_peak_decimator_ff_0 = sprite.peak_decimator_ff() self.sprite_correlator_cf_1 = sprite.correlator_cf(2) self.sprite_correlator_cf_0 = sprite.correlator_cf(3) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(.256, taps=None, flt_size=32) self.blocks_wavfile_source_0 = blocks.wavfile_source(filename, False) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) ################################################## # Connections ################################################## self.connect((self.blocks_sub_xx_0, 0), (self.sprite_peak_decimator_ff_0, 0)) self.connect((self.sprite_correlator_cf_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.sprite_correlator_cf_1, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.sprite_correlator_cf_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.sprite_correlator_cf_1, 0)) self.connect((self.sprite_peak_decimator_ff_0, 0), (self.sprite_sprite_decoder_f_0, 0))
def __init__(self, input_rate=48000, output_rate=48000): gr.hier_block2.__init__( self, "Arbitrary Resampler", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.input_rate = input_rate self.output_rate = output_rate ################################################## # Variables ################################################## self.decimation = decimation = int(input_rate / output_rate) self.resampled_rate = resampled_rate = float(input_rate) / float(decimation) self.rel_freq = rel_freq = 0 ################################################## # Blocks ################################################## self.osc = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, rel_freq, 1, 0) self.mixer = blocks.multiply_vcc(1) self.lpf = filter.fir_filter_ccf(decimation, (filter.firdes.low_pass(1.0, input_rate, 7250, 725, filter.firdes.WIN_HANN))) self.lpf.declare_sample_delay(0) self.arb_resampler = pfb.arb_resampler_ccf( float(output_rate) / resampled_rate, taps=None, flt_size=32) self.arb_resampler.declare_sample_delay(0) ################################################## # Connections ################################################## self.connect((self.arb_resampler, 0), (self, 0)) self.connect((self.lpf, 0), (self.arb_resampler, 0)) self.connect((self.mixer, 0), (self.lpf, 0)) self.connect((self.osc, 0), (self.mixer, 1)) self.connect((self, 0), (self.mixer, 0))
def __init__(self, params, freq, filename): # Super gr.hier_block2.__init__(self, "DirectOutputBranch", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) prev = self # Delay if params.delay: self.delay = blocks.delay( gr.sizeof_gr_complex, int(round(params.delay)), ) self.connect((prev, 0), (self.delay, 0)) prev = self.delay # Freq xlating filter if params.decim1 > 1: self.filt1 = filter.freq_xlating_fir_filter_ccc( params.decim1, params.taps1, freq, params.samp_rate) self.connect((prev, 0), (self.filt1, 0)) prev = self.filt1 # Decimating FIR filter if params.decim2 > 1: self.filt2 = filter.fir_filter_ccc(params.decim2, params.taps2) self.connect((prev, 0), (self.filt2, 0)) prev = self.filt2 # PFB Arb Resampler if params.resamp != 1: self.resamp = pfb.arb_resampler_ccf(params.resamp, params.taps_resamp, flt_size=32) self.connect((prev, 0), (self.resamp, 0)) prev = self.resamp # Output file self.sink = blocks.file_sink(gr.sizeof_gr_complex, filename, False) self.connect((prev, 0), (self.sink, 0))
def __init__(self, inmessage, incapcode): gr.top_block.__init__(self, "Pocsagtx Hackrf") ################################################## # Variables ################################################## self.symrate = symrate = 38400 self.samp_rate = samp_rate = 8000000 self.pagerfreq = pagerfreq = 920612500 self.max_deviation = max_deviation = 4500.0 ################################################## # Blocks ################################################## self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( float(samp_rate)/float(symrate), taps=None, flt_size=16) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "hackrf=0" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(pagerfreq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(15, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.mixalot_pocencode_0 = mixalot.pocencode(1, 512, incapcode, inmessage, symrate) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2.0 * math.pi * max_deviation / float(symrate)) ################################################## # Connections ################################################## self.connect((self.mixalot_pocencode_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self, filename): gr.top_block.__init__(self, "Spritedemodnogui") ################################################## # Variables ################################################## self.chip_rate = chip_rate = 64e3 ################################################## # Blocks ################################################## self.sprite_sprite_decoder_f_0 = sprite.sprite_decoder_f() self.sprite_peak_decimator_ff_0 = sprite.peak_decimator_ff() self.sprite_correlator_cf_1 = sprite.correlator_cf(2) self.sprite_correlator_cf_0 = sprite.correlator_cf(3) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( .256, taps=None, flt_size=32) self.blocks_wavfile_source_0 = blocks.wavfile_source(filename, False) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) ################################################## # Connections ################################################## self.connect((self.blocks_sub_xx_0, 0), (self.sprite_peak_decimator_ff_0, 0)) self.connect((self.sprite_correlator_cf_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.sprite_correlator_cf_1, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.sprite_correlator_cf_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.sprite_correlator_cf_1, 0)) self.connect((self.sprite_peak_decimator_ff_0, 0), (self.sprite_sprite_decoder_f_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 5 Task 3a") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 5 Task 3a") 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", "lab5_task3a") 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.sps = sps = 4 self.nfilts = nfilts = 32 self.ntaps = ntaps = 11 * nfilts * sps self.excess_bw = excess_bw = 0.45 self.timing_bw = timing_bw = 2 * pi / 100 self.samp_rate = samp_rate = 25000 self.rx_taps = rx_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, excess_bw, ntaps) self.freq_bw = freq_bw = 2 * pi / 100 self.fll_ntaps = fll_ntaps = 55 ################################################## # Blocks ################################################## self.tab_widget = Qt.QTabWidget() self.tab_widget_widget_0 = Qt.QWidget() self.tab_widget_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_widget_0) self.tab_widget_grid_layout_0 = Qt.QGridLayout() self.tab_widget_layout_0.addLayout(self.tab_widget_grid_layout_0) self.tab_widget.addTab(self.tab_widget_widget_0, 'Complex Baseband') self.tab_widget_widget_1 = Qt.QWidget() self.tab_widget_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_widget_1) self.tab_widget_grid_layout_1 = Qt.QGridLayout() self.tab_widget_layout_1.addLayout(self.tab_widget_grid_layout_1) self.tab_widget.addTab(self.tab_widget_widget_1, 'Before Costas') self.tab_widget_widget_2 = Qt.QWidget() self.tab_widget_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_widget_2) self.tab_widget_grid_layout_2 = Qt.QGridLayout() self.tab_widget_layout_2.addLayout(self.tab_widget_grid_layout_2) self.tab_widget.addTab(self.tab_widget_widget_2, 'After Costas') self.top_grid_layout.addWidget(self.tab_widget) self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Output of Pulse Shape Filter', #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0_0_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0_0_0_0.enable_rf_freq(False) self.tab_widget_layout_2.addWidget(self._qtgui_sink_x_0_0_0_0_win) self.qtgui_sink_x_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Output of Pulse Shape Filter', #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0_0_0.enable_rf_freq(False) self.tab_widget_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate * sps, #bw 'Output of Pulse Shape Filter', #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0_0.enable_rf_freq(False) self.tab_widget_layout_0.addWidget(self._qtgui_sink_x_0_0_win) self.pfb_arb_resampler_xxx_0_0_0 = pfb.arb_resampler_ccf(sps, taps=rx_taps, flt_size=32) self.pfb_arb_resampler_xxx_0_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(sps, taps=rx_taps, flt_size=32) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.low_pass_filter_1 = filter.fir_filter_fff( 5, firdes.low_pass(1, 500000, 100000, 10000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff( 5, firdes.low_pass(1, 500000, 100000, 10000, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( 4, timing_bw, rx_taps, 32, 16, 1.5, 1) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( freq_bw, 4, False) self.blocks_throttle_0_0_0_1 = blocks.throttle( gr.sizeof_gr_complex * 1, samp_rate * sps, True) self.blocks_throttle_0_0_0_0 = blocks.throttle( gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_throttle_0_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_float * 1, '/home/ipsit/Documents/EE 340/Lab 5/input2.bin', True, 0, 0) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.analog_sig_source_x_0_0 = analog.sig_source_f( 500000, analog.GR_SIN_WAVE, 1000, 1, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_f( 500000, analog.GR_COS_WAVE, 1000, 1, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0_0_0_1, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_throttle_0_0_0, 0), (self.qtgui_sink_x_0_0_0, 0)) self.connect((self.blocks_throttle_0_0_0_0, 0), (self.qtgui_sink_x_0_0_0_0, 0)) self.connect((self.blocks_throttle_0_0_0_1, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.pfb_arb_resampler_xxx_0_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.blocks_throttle_0_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0_0, 0), (self.blocks_throttle_0_0_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="Stereo FM receiver and RDS Decoder") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.freq_offset = freq_offset = 250000 self.freq = freq = 95.8e6 self.volume = volume = -3 self.samp_rate = samp_rate = 1e6 self.gain = gain = 20 self.freq_tune = freq_tune = freq - freq_offset self.capture_base_freq = capture_base_freq = 88e6 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='Volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=-20, maximum=10, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_volume_sizer, 0, 1, 1, 1) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Const") self.nb.AddPage(grc_wxgui.Panel(self.nb), "x") self.nb.AddPage(grc_wxgui.Panel(self.nb), "y") self.GridAdd(self.nb, 2, 0, 1, 2) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label='Freq', converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=88e6, maximum=108e6, num_steps=800, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_freq_sizer, 1, 0, 1, 2) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(8).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='Waterfall Plot', ) self.nb.GetPage(8).Add(self.wxgui_waterfallsink2_1.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f( self.nb.GetPage(2).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=250000, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title='Waterfall Plot', ) self.nb.GetPage(2).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(6).GetWin(), title='Scope Plot', sample_rate=2375 * 4, v_scale=0.4, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.nb.GetPage(6).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_1 = fftsink2.fft_sink_c( self.nb.GetPage(7).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='FFT Plot', peak_hold=False, ) self.nb.GetPage(7).Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c( self.nb.GetPage(5).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=19000, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='RDS', peak_hold=False, ) self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win) self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f( self.nb.GetPage(4).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=48000, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='L-R', peak_hold=False, ) self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win) self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(3).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=48000, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='L+R', peak_hold=False, ) self.nb.GetPage(3).Add(self.wxgui_fftsink2_0_0_0.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=250000, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title='FM Demod', peak_hold=False, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-30, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title='Baseband', peak_hold=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 2, firdes.root_raised_cosine(1, 19000, 2375, .35, 100)) self.pfb_arb_resampler_xxx_1 = pfb.arb_resampler_fff(240000.0 / 250000, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_1.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(19000 / 250e3, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.gr_rds_parser_0 = rds.parser(True, False, 0) self.gr_rds_panel_0 = rds.rdsPanel(freq, self.GetWin()) self.Add(self.gr_rds_panel_0.panel) self.gr_rds_decoder_0 = rds.decoder(False, False) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='RF Gain', converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=49.6, num_steps=124, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 0, 0, 1, 1) self.freq_xlating_fir_filter_xxx_2 = filter.freq_xlating_fir_filter_fcf( 5, (firdes.low_pass(1.0, 240000, 13e3, 3e3, firdes.WIN_HAMMING)), 38000, 240000) self.freq_xlating_fir_filter_xxx_1_0 = filter.freq_xlating_fir_filter_fcc( 1, (firdes.low_pass(2500.0, 250000, 2.6e3, 2e3, firdes.WIN_HAMMING)), 57e3, 250000) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (firdes.low_pass(1, samp_rate, 80000, 20000)), freq_offset, samp_rate) self.fir_filter_xxx_1 = filter.fir_filter_fff( 5, (firdes.low_pass(1.0, 240000, 13e3, 3e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_1.declare_sample_delay(0) self.digital_psk_demod_0 = digital.psk.psk_demod( constellation_points=2, differential=False, samples_per_symbol=4, excess_bw=0.35, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False, ) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff( (10**(1. * (volume) / 10), )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (10**(1. * (volume) / 10), )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_char * 1, 2) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/deepstar/Projects/OverTheWire/advent2019/advent2019/steven/northpole-airwaves/northpole-airwaves.wav', True) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate, audio_decimation=int(samp_rate / (250e3)), ) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freq - capture_base_freq, 1, 0) self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=48000, tau=75e-6) self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=48000, tau=75e-6) ################################################## # Connections ################################################## self.msg_connect((self.gr_rds_decoder_0, 'out'), (self.gr_rds_parser_0, 'in')) self.msg_connect((self.gr_rds_parser_0, 'out'), (self.gr_rds_panel_0, 'in')) self.connect((self.analog_fm_deemph_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.analog_fm_deemph_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_wfm_rcv_0, 0), (self.freq_xlating_fir_filter_xxx_1_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.pfb_arb_resampler_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.wxgui_fftsink2_0_0_0_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_decoder_0, 0)) self.connect((self.digital_psk_demod_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_2, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_1, 0)) self.connect((self.pfb_arb_resampler_xxx_1, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.pfb_arb_resampler_xxx_1, 0), (self.freq_xlating_fir_filter_xxx_2, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_psk_demod_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.wxgui_scopesink2_1, 0))
def __init__(self, bind_addr="0.0.0.0", dest_addr="127.0.0.1", lo_offset=100e3, recv_port=16886, rx_sdr_device="usrpb200", send_port=5022, tx_sdr_device="usrpb200", wod_port=5023): gr.top_block.__init__(self, "UPSat Tranceiver") ################################################## # Parameters ################################################## self.bind_addr = bind_addr self.dest_addr = dest_addr self.lo_offset = lo_offset self.recv_port = recv_port self.rx_sdr_device = rx_sdr_device self.send_port = send_port self.tx_sdr_device = tx_sdr_device self.wod_port = wod_port ################################################## # Variables ################################################## self.samples_per_symbol_tx = samples_per_symbol_tx = 4*8 self.sq_wave = sq_wave = (1.0, ) * samples_per_symbol_tx self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[rx_sdr_device]['samp_rate'] self.gaussian_taps = gaussian_taps = filter.firdes.gaussian(1.0, samples_per_symbol_tx, 1.0, 4*samples_per_symbol_tx) self.deviation = deviation = 3.9973e3 self.decimation_rx = decimation_rx = 20 self.baud_rate_uplink = baud_rate_uplink = 1200 self.baud_rate_downlink = baud_rate_downlink = 9600 self.tx_frequency = tx_frequency = 145.835e6 self.taps = taps = firdes.low_pass(1.0, samp_rate_rx, 20000, 60000, firdes.WIN_HAMMING, 6.76) self.samp_rate_tx = samp_rate_tx = satnogs.hw_tx_settings[rx_sdr_device]['samp_rate'] self.rx_frequency = rx_frequency = 435.765e6 self.modulation_index_uplink = modulation_index_uplink = deviation / (baud_rate_uplink / 2.0) self.modulation_index_downlink = modulation_index_downlink = deviation / (baud_rate_downlink / 2.0) self.interp_taps = interp_taps = numpy.convolve(numpy.array(gaussian_taps), numpy.array(sq_wave)) self.first_stage_samp_rate_rx = first_stage_samp_rate_rx = samp_rate_rx / decimation_rx ################################################## # Blocks ################################################## self.satnogs_upsat_fsk_frame_encoder_0 = satnogs.upsat_fsk_frame_encoder([0x33]*8 , [0x7A, 0x0E], False, False, False, True, True, "ABCD", 0, "ON02GR", 0, 64) self.satnogs_udp_msg_source_0 = satnogs.udp_msg_source(bind_addr, recv_port, 1500) self.satnogs_udp_msg_sink_0_0_0 = satnogs.udp_msg_sink(dest_addr, wod_port, 1500) self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(dest_addr, send_port, 1500) self.satnogs_qb50_deframer_0 = satnogs.qb50_deframer(0xe) self.satnogs_multi_format_msg_sink_0 = satnogs.multi_format_msg_sink(1) self.satnogs_ax25_decoder_bm_0 = satnogs.ax25_decoder_bm('GND', 0, False, True, 256, 3) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samp_rate_tx / (baud_rate_uplink * samples_per_symbol_tx), taps=(firdes.low_pass_2(32, 32, 0.8, 0.1, 60)), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.hw_rx_settings[rx_sdr_device]['dev_arg'] ) self.osmosdr_source_0.set_sample_rate(samp_rate_rx) self.osmosdr_source_0.set_center_freq(rx_frequency - lo_offset, 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(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(satnogs.hw_rx_settings[rx_sdr_device]['rf_gain'], 0) self.osmosdr_source_0.set_if_gain(satnogs.hw_rx_settings[rx_sdr_device]['if_gain'], 0) self.osmosdr_source_0.set_bb_gain(satnogs.hw_rx_settings[rx_sdr_device]['bb_gain'], 0) self.osmosdr_source_0.set_antenna(satnogs.hw_rx_settings[rx_sdr_device]['antenna'], 0) self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + satnogs.hw_tx_settings[rx_sdr_device]['dev_arg'] ) self.osmosdr_sink_0.set_sample_rate(samp_rate_tx) self.osmosdr_sink_0.set_center_freq(tx_frequency - lo_offset, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(satnogs.hw_tx_settings[tx_sdr_device]['rf_gain'], 0) self.osmosdr_sink_0.set_if_gain(satnogs.hw_tx_settings[tx_sdr_device]['if_gain'], 0) self.osmosdr_sink_0.set_bb_gain(satnogs.hw_tx_settings[tx_sdr_device]['bb_gain'], 0) self.osmosdr_sink_0.set_antenna(satnogs.hw_tx_settings[tx_sdr_device]['antenna'], 0) self.osmosdr_sink_0.set_bandwidth(samp_rate_tx, 0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(samples_per_symbol_tx, (interp_taps)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decimation_rx, (taps), lo_offset, samp_rate_rx) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(first_stage_samp_rate_rx/baud_rate_downlink, 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate_tx, analog.GR_COS_WAVE, lo_offset , 1, 0) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(((first_stage_samp_rate_rx) / baud_rate_downlink)/(math.pi*modulation_index_downlink)) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc((math.pi*modulation_index_uplink) / samples_per_symbol_tx) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'failed_pdu'), (self.satnogs_multi_format_msg_sink_0, 'in')) self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_qb50_deframer_0, 'in')) self.msg_connect((self.satnogs_qb50_deframer_0, 'out'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_qb50_deframer_0, 'wod'), (self.satnogs_udp_msg_sink_0_0_0, 'in')) self.msg_connect((self.satnogs_udp_msg_source_0, 'msg'), (self.satnogs_upsat_fsk_frame_encoder_0, 'pdu')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satnogs_ax25_decoder_bm_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.satnogs_upsat_fsk_frame_encoder_0, 0), (self.interp_fir_filter_xxx_0, 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.sps = sps = 4 self.ntaps = ntaps = 1408 self.nfilts = nfilts = 32 self.excess_bw = excess_bw = 0.45 self.timing_bw = timing_bw = 2 * pi / 100 self.sr2 = sr2 = 300000 self.samp_rate_0 = samp_rate_0 = 32000 self.samp_rate = samp_rate = 100000 self.s = s = 0.01 self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(nfilts, nfilts * sps, 1.0, excess_bw, ntaps) self.freq_bw = freq_bw = 2 * pi / 100 self.fll_ntaps = fll_ntaps = 55 ################################################## # Blocks ################################################## self.n = self.n = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.n.AddPage(grc_wxgui.Panel(self.n), "tab1") self.n.AddPage(grc_wxgui.Panel(self.n), "tab2") self.n.AddPage(grc_wxgui.Panel(self.n), "tab3") self.Add(self.n) self.wxgui_scopesink2_2 = scopesink2.scope_sink_c( self.n.GetPage(1).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.n.GetPage(1).Add(self.wxgui_scopesink2_2.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_f( self.n.GetPage(0).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.n.GetPage(0).Add(self.wxgui_scopesink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.n.GetPage(2).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.n.GetPage(2).Add(self.wxgui_scopesink2_0.win) _s_sizer = wx.BoxSizer(wx.VERTICAL) self._s_text_box = forms.text_box( parent=self.GetWin(), sizer=_s_sizer, value=self.s, callback=self.set_s, label="s", converter=forms.float_converter(), proportion=0, ) self._s_slider = forms.slider( parent=self.GetWin(), sizer=_s_sizer, value=self.s, callback=self.set_s, minimum=-5, maximum=5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_s_sizer) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( 4, taps=(firdes.root_raised_cosine(32, 32, 1.0, 0.45, 1408)), flt_size=32 ) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.iir_filter_xxx_0_0 = filter.iir_filter_ffd(([1.0001, -1]), ([-1, 1]), True) self.iir_filter_xxx_0 = filter.iir_filter_ffd((0.01,), ([-1, 0.99]), True) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(4, 2 * pi / 100, (rx_taps), 32, 16, 1.5, 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (((1 + 1j), (1 - 1j), (-1 + 1j), (-1 - 1j))), 1 ) self.blocks_vco_c_0 = blocks.vco_c(samp_rate, -5, 1) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.001, 0.001, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.001, 0.001, 0) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((1,)) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1.413,)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1.413,)) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1000) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-0.5,)) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5,)) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, 10, 1, 0) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 4, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_delay_0, 0), (self.iir_filter_xxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_0, 2)) self.connect((self.blocks_vco_c_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_vco_c_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self, puncpat='11'): 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()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 5 * sps * nfilts) self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts self.samp_rate_array_MCR = samp_rate_array_MCR = [ 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952 ] self.rate = rate = 2 self.polys = polys = [109, 79] self.k = k = 7 self.vector = vector = [int(random.random() * 4) for i in range(49600)] self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 39 self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50 self.samp_rate = samp_rate = samp_rate_array_MCR[2] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.pld_enc = pld_enc = map( (lambda a: fec.cc_encoder_make(440, k, rate, (polys), 0, fec.CC_TERMINATED, True) ), range(0, 8)) self.pld_dec = pld_dec = map((lambda a: fec.cc_decoder.make( 440, k, rate, (polys), 0, -1, fec.CC_TERMINATED, True)), range(0, 4)) 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.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 39, 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_range = Range(0, 90, 1, 50, 200) self._variable_qtgui_range_0_win = RangeWidget( self._variable_qtgui_range_0_range, self.set_variable_qtgui_range_0, 'Gain_TX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_win, 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 = uhd.usrp_source( ",".join(("serial=F5EAC0", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("serial=F5EAE1", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.qtgui_time_sink_x_2_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "After CAC", #name 1 #number of inputs ) self.qtgui_time_sink_x_2_0.set_update_time(0.10) self.qtgui_time_sink_x_2_0.set_y_axis(0, 1.5) self.qtgui_time_sink_x_2_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2_0.enable_tags(-1, True) self.qtgui_time_sink_x_2_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2_0.enable_autoscale(False) self.qtgui_time_sink_x_2_0.enable_grid(True) self.qtgui_time_sink_x_2_0.enable_axis_labels(True) self.qtgui_time_sink_x_2_0.enable_control_panel(False) self.qtgui_time_sink_x_2_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_2_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_2_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_0_win = sip.wrapinstance( self.qtgui_time_sink_x_2_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_win, 2, 4, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Defore CAC", #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(0, 1.5) 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(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) self.qtgui_time_sink_x_2.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_2.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_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_grid_layout.addWidget(self._qtgui_time_sink_x_2_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_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, 4, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX USRP", #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(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: 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, 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, 5, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Tx Data', #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, 256) 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, 'packet_length_tag_key') self.qtgui_time_sink_x_0_0.enable_autoscale(False) 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(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_grid_layout.addWidget(self._qtgui_time_sink_x_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_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_0 = qtgui.const_sink_c( 1024, #size "TX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_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_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_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 = 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.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=(tx_rrc_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay) self.fec_extended_encoder_0 = fec.extended_encoder( encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat) self.fec_extended_decoder_0_0_1_0_1_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 / 400.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_map_bb_1_0 = digital.map_bb((pld_const.pre_diff_code())) self.digital_map_bb_0_0_0_0_0 = digital.map_bb(([-1, 1])) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(4) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 200.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, 1, 'packet_len') self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( pld_const) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (pld_const.points()), 1) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_vector_insert_x_0 = blocks.vector_insert_b((vector), 496000000, 0) self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 992, "packet_len") self.blocks_stream_mux_0_1_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 896)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (892, 4)) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char * 1, (440, 2)) self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb( 8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb( 1, 2, "packet_len", False, gr.GR_MSB_FIRST) 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( 2, 1, '', False, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, )) 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 = blocks.keep_m_in_n( gr.sizeof_char, 892, 896, 0) self.blocks_file_source_0_0_1_0_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Downloads/lion-sample.mts', False) self.blocks_file_source_0_0_1_0_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/andre/Desktop/transmitido/depois.mts', False) self.blocks_file_sink_0_0_0_0_0.set_unbuffered(False) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_2_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.acode_1104 = blocks.vector_source_b([ 0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0 ], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_2_0, 0)) self.connect((self.blocks_char_to_float_0_2_0_0, 0), (self.fec_extended_decoder_0_0_1_0_1_0, 0)) self.connect((self.blocks_char_to_float_1_0_0, 0), (self.qtgui_time_sink_x_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_file_source_0_0_1_0_0, 0), (self.blocks_char_to_float_1_0_0, 0)) self.connect((self.blocks_file_source_0_0_1_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_keep_m_in_n_0_0_2_0, 0), (self.digital_map_bb_0_0_0_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0_1_1_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_char_to_float_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_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0), (self.blocks_vector_insert_x_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.blocks_stream_mux_0_1_0, 1)) self.connect((self.blocks_stream_mux_0_1_0, 0), (self.blocks_stream_to_tagged_stream_0_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_0, 0)) self.connect((self.blocks_vector_insert_x_0, 0), (self.digital_map_bb_1_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_arb_resampler_xxx_0, 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_char_to_float_0_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)) 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_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_map_bb_0_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0_0, 0)) self.connect((self.digital_map_bb_1_0, 0), (self.digital_diff_encoder_bb_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), (self.blocks_keep_m_in_n_0_1_1_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_stream_mux_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Tutorial") Qt.QWidget.__init__(self) self.setWindowTitle("Tutorial") 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", "tutorial_10") 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.H = H = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.vector = vector = [int(random.random() * 4) for i in range(49600)] self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 11 * sps * nfilts) 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_enc = pld_enc = map( (lambda a: fec.ldpc_par_mtrx_encoder_make_H(H)), range(0, 4)) 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) ################################################## # Blocks ################################################## self.scrambler_cpp_additive_scrambler_0 = scrambler_cpp.additive_scrambler( 0x8A, 0x7F, 7, 440 - 32) self.scrambler_cpp_additive_descrambler_0 = scrambler_cpp.additive_descrambler( 0x8A, 0x7F, 7, 440 - 32) 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_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "LMS IN/OUT", #name 3 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(False) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = [ 'Signal MIXED', 'ERROR', 'OUT', 'Error', 'MIX', '', '', '', '', '' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "black", "red", "green", "cyan", "magenta", "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(3): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 5, 1, 1, 3) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0_1_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "ORIGINAL/RECOVERED", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0_1_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_1_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_1_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_1_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_1_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_1_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_1_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0_1_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_1_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0_1_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_1_0_0.set_plot_pos_half(not True) labels = [ 'After Chunks to symbols', 'After Treated', 'Error LMS', '', '', '', '', '', '', '' ] 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_0_1_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_1_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_1_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_1_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_1_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_1_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_1_0_0_win, 7, 1, 1, 3) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "TX/OUT LMS", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_1_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_1_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_1_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_1_0.set_plot_pos_half(not True) labels = [ 'After TX RRC', 'ERROR LMS', 'Error LMS', '', '', '', '', '', '', '' ] 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_0_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_1_0_win, 6, 1, 1, 3) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "RX Frequency", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_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_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Jamming", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_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_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "TX Frequency", #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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_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_0 = qtgui.const_sink_c( 1024, #size "RX Treated Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_1_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_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_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.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c( 1024, #size "TX Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_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_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_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.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf( sps, taps=(tx_rrc_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_1_0 = filter.interp_fir_filter_ccc( 4, ([1, 0, 0, 0])) self.interp_fir_filter_xxx_1_0.declare_sample_delay(0) self.insert_vec_cpp_new_vec_0_0 = insert_vec_cpp.new_vec((vector)) self.fec_extended_encoder_0 = fec.extended_encoder( encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat) 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, 2) self.digital_map_bb_0_0_0_0_0_0 = digital.map_bb(([-1, 1])) self.digital_diff_encoder_bb_0_0 = digital.diff_encoder_bb( pld_const.arity()) 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.digital_cma_equalizer_cc_0_0 = digital.cma_equalizer_cc( 15, 1, 0.01, 2) self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bc( (pld_const.points()), 1) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_mux_0_1_0_0_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 1104)) self.blocks_stream_mux_0_0_0 = blocks.stream_mux( gr.sizeof_char * 1, (1100, 4)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (440, 2)) self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb( 8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1_0_0_0_0 = blocks.repack_bits_bb( 1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST) 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_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, )) 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_source_0_0_1_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/Files_To_Transmit/trasmit_10_mb.txt', False) self.blocks_file_source_0_0_1_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0_2 = blocks.file_sink( gr.sizeof_char * 1, '/home/andre/Desktop/Trasmited/depois.txt', False) self.blocks_file_sink_0_0_0_2.set_unbuffered(False) 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.blocks_add_xx_0 = blocks.add_vcc(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) self.acode_1104_0_0 = blocks.vector_source_b([ 0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0 ], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104_0_0, 0), (self.blocks_stream_mux_0_1_0_0_0, 0)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.qtgui_freq_sink_x_0_0_1_0, 1)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.qtgui_freq_sink_x_1_0, 1)) self.connect((self.adapt_lms_filter_xx_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.analog_noise_source_x_0_0, 0), (self.interp_fir_filter_xxx_1_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.adapt_lms_filter_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_1_0, 2)) 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_file_source_0_0_1_0, 0), (self.blocks_repack_bits_bb_1_0_0_1, 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_additive_descrambler_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.adapt_lms_filter_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_freq_sink_x_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_2, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_0_0, 0), (self.insert_vec_cpp_new_vec_0_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0), (self.scrambler_cpp_additive_scrambler_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.blocks_stream_mux_0_1_0_0_0, 1)) self.connect((self.blocks_stream_mux_0_1_0_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_0_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_0_0_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0), (self.qtgui_freq_sink_x_0_0_1_0_0, 0)) self.connect((self.digital_cma_equalizer_cc_0_0, 0), (self.digital_costas_loop_cc_0_0, 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_1_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_freq_sink_x_0_0_1_0_0, 1)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_diff_encoder_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0_0_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_cma_equalizer_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.fec_extended_encoder_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.insert_vec_cpp_new_vec_0_0, 0), (self.digital_diff_encoder_bb_0_0, 0)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0_0_1_0, 0)) self.connect((self.scrambler_cpp_additive_descrambler_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0)) self.connect((self.scrambler_cpp_additive_scrambler_0, 0), (self.blocks_stream_mux_0_0, 0))
def __init__(self, antenna=satnogs.not_set_antenna, baudrate=9600.0, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/tmp/.satnogs/data/data', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=1000, enable_iq_dump=0, file_path='test.wav', if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, mark_frequency=2200.0, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=100e6, rx_sdr_device='usrpb200', samp_rate_rx=satnogs.not_set_samp_rate_rx, space_frequency=1200.0, udp_IP='127.0.0.1', udp_port=16887, waterfall_file_path='/tmp/waterfall.dat'): gr.top_block.__init__(self, "AFSK1200 AX.25 decoder ") ################################################## # Parameters ################################################## self.antenna = antenna self.baudrate = baudrate self.bb_gain = bb_gain self.decoded_data_file_path = decoded_data_file_path self.dev_args = dev_args self.doppler_correction_per_sec = doppler_correction_per_sec self.enable_iq_dump = enable_iq_dump self.file_path = file_path self.if_gain = if_gain self.iq_file_path = iq_file_path self.lo_offset = lo_offset self.mark_frequency = mark_frequency self.ppm = ppm self.rf_gain = rf_gain self.rigctl_port = rigctl_port self.rx_freq = rx_freq self.rx_sdr_device = rx_sdr_device self.samp_rate_rx = samp_rate_rx self.space_frequency = space_frequency self.udp_IP = udp_IP self.udp_port = udp_port self.waterfall_file_path = waterfall_file_path ################################################## # Variables ################################################## self.max_modulation_freq = max_modulation_freq = 3000 self.deviation = deviation = 5000 self.baud_rate = baud_rate = 1200 self.audio_samp_rate = audio_samp_rate = 48000 ################################################## # Blocks ################################################## self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink( audio_samp_rate, 0.0, 10, 1024, waterfall_file_path, 1) self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink( udp_IP, udp_port, 1500) self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source( "127.0.0.1", rigctl_port, False, 1000, 1500) self.satnogs_quad_demod_filter_ff_0 = satnogs.quad_demod_filter_ff( ((audio_samp_rate / 10) / baud_rate) / (math.pi * 1)) self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder( file_path, audio_samp_rate, 1.0) self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump) self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink( decoded_data_file_path, 0) self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc( rx_freq, satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx)) self.satnogs_ax25_decoder_bm_0_0 = satnogs.ax25_decoder_bm( 'GND', 0, True, True, 1024) self.satnogs_ax25_decoder_bm_0 = satnogs.ax25_decoder_bm( 'GND', 0, True, False, 1024) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( audio_samp_rate / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args)) self.osmosdr_source_0.set_sample_rate( satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx)) self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0) self.osmosdr_source_0.set_freq_corr(ppm, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain( satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0) self.osmosdr_source_0.set_if_gain( satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0) self.osmosdr_source_0.set_bb_gain( satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0) self.osmosdr_source_0.set_antenna( satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0) self.osmosdr_source_0.set_bandwidth( satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), 0) self.low_pass_filter_1 = filter.fir_filter_ccf( 10, firdes.low_pass(10, audio_samp_rate, (mark_frequency - space_frequency) / 2.0, 1000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, audio_samp_rate, deviation + max_modulation_freq, 3000, firdes.WIN_HAMMING, 6.76)) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( (48e3 / 10) / baud_rate, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True) self.blocks_rotator_cc_0 = blocks.rotator_cc( -2.0 * math.pi * (lo_offset / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx))) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.analog_sig_source_x_0 = analog.sig_source_c( audio_samp_rate, analog.GR_COS_WAVE, -(1200 + 2200) / 2, 1, 0) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf( (2 * math.pi * deviation) / audio_samp_rate) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( ((audio_samp_rate / 10) / baud_rate) / (math.pi * 1)) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_ax25_decoder_bm_0_0, 'pdu'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_ax25_decoder_bm_0_0, 'pdu'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq')) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.satnogs_ogg_encoder_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satnogs_ax25_decoder_bm_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satnogs_ax25_decoder_bm_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.satnogs_quad_demod_filter_ff_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_iq_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_waterfall_sink_0, 0)) self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.satnogs_quad_demod_filter_ff_0, 0), (self.digital_binary_slicer_fb_0, 0))
def create_block(self, taps): return pfb.arb_resampler_ccf(self.resample_rate) # TODO explicitly compute taps
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage3") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage3") 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", "mpsk_stage3") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 8 self.payload = payload = range(256) self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.taps = taps = [1.0 + 0.0j, ] self.samp_rate = samp_rate = 250e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts) self.qpsk_const = qpsk_const = digital.constellation_rect(([-1, +1]), ([0, 1]), 1, 2, 1, 1, 1).base() self.payload_str = payload_str = ''.join(map(lambda x: "{0:08b}".format(x), payload)) self.gain = gain = 50 self.freq = freq = 2.3e9 self.excess_bw = excess_bw = 0.35 self.delay = delay = 32 self.decim = decim = 1 self.arity = arity = 2 self.access_code_str = access_code_str = "1111100110101" self.access_code = access_code = [31, 53] ################################################## # Blocks ################################################## self._delay_layout = Qt.QVBoxLayout() self._delay_tool_bar = Qt.QToolBar(self) self._delay_layout.addWidget(self._delay_tool_bar) self._delay_tool_bar.addWidget(Qt.QLabel("delay"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._delay_counter = qwt_counter_pyslot() self._delay_counter.setRange(0, 100, 1) self._delay_counter.setNumButtons(2) self._delay_counter.setValue(self.delay) self._delay_tool_bar.addWidget(self._delay_counter) self._delay_counter.valueChanged.connect(self.set_delay) self._delay_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._delay_slider.setRange(0, 100, 1) self._delay_slider.setValue(self.delay) self._delay_slider.setMinimumWidth(200) self._delay_slider.valueChanged.connect(self.set_delay) self._delay_layout.addWidget(self._delay_slider) self.top_layout.addLayout(self._delay_layout) self.west_stream_trigged_pdu_0 = west.stream_trigged_pdu("start_payload", 2048) self.west_ber_pdu_0 = west.ber_pdu(payload_str) self._timing_loop_bw_layout = Qt.QVBoxLayout() self._timing_loop_bw_label = Qt.QLabel("Time: BW") self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005) self._timing_loop_bw_slider.setValue(self.timing_loop_bw) self._timing_loop_bw_slider.setMinimumWidth(200) self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw) self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider) self.top_grid_layout.addLayout(self._timing_loop_bw_layout, 3,1,1,1) 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(-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) 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.qtgui_const_sink_x_1_0 = qtgui.const_sink_c( 1024, #size "Equalizer", #name 1 #number of inputs ) self.qtgui_const_sink_x_1_0.set_update_time(0.10) self.qtgui_const_sink_x_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1_0.enable_autoscale(False) self.qtgui_const_sink_x_1_0.enable_grid(False) 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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_0_win = sip.wrapinstance(self.qtgui_const_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "Clock Sync Output", #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) 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.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 2048, #size "Costas Loop Output", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) 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(False) 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.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,1,1,1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( 1, taps=(rrc_taps[:-1]), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("RF gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 90, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 90, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.015, 2) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb(access_code_str, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) (self.digital_constellation_modulator_0).set_processor_affinity([2]) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk_const) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(16, 1, 0.15/100., 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(sps*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([135, 201]*5000 + access_code + payload*100000, False, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.0001, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, int(delay)) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 0.3, 0, 8192) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.west_stream_trigged_pdu_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.west_stream_trigged_pdu_0, "pdus", self.west_ber_pdu_0, "pdus")
def __init__(self, name='Multistage Channel Filter', input_rate=None, output_rate=None, cutoff_freq=None, transition_width=None): gr.hier_block2.__init__( self, name, gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) total_decimation = max(1, input_rate // output_rate) stage_decimations = _factorize(total_decimation) stage_decimations.reverse() if len(stage_decimations) == 0: # We need at least one filter to do the frequency shift stage_decimations = [1] prev_block = self stage_input_rate = input_rate for i, stage_decimation in enumerate(stage_decimations): first = i == 0 last = i == len(stage_decimations) - 1 next_rate = stage_input_rate / stage_decimation # filter taps if last: taps = firdes.low_pass( 1.0, stage_input_rate, cutoff_freq, transition_width, firdes.WIN_HAMMING) else: # TODO check for collision with user filter user_inner = cutoff_freq - transition_width / 2 limit = next_rate / 2 taps = firdes.low_pass( 1.0, stage_input_rate, (user_inner + limit) / 2, limit - user_inner, firdes.WIN_HAMMING) #print 'Stage %i decimation %i rate %i taps %i' % (i, stage_decimation, stage_input_rate, len(taps)) # filter block if first: stage_filter = grfilter.freq_xlating_fir_filter_ccc( stage_decimation, taps, 0, # default frequency stage_input_rate) self.freq_filter_block = stage_filter else: stage_filter = grfilter.fir_filter_ccc(stage_decimation, taps) self.connect(prev_block, stage_filter) prev_block = stage_filter stage_input_rate = next_rate # final connection and resampling if stage_input_rate == output_rate: # exact multiple, no fractional resampling needed #print 'direct connect %s/%s' % (output_rate, stage_input_rate) self.connect(prev_block, self) else: # TODO: combine resampler with final filter stage # TODO: cache filter computation as optfir is used and takes a noticeable time self.connect( prev_block, pfb.arb_resampler_ccf(float(output_rate) / stage_input_rate), self)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") options = get_options() self.ifreq = options.frequency self.rfgain = options.gain self.src = osmosdr.source(options.args) self.src.set_center_freq(self.ifreq) self.src.set_sample_rate(int(options.sample_rate)) if self.rfgain is None: self.src.set_gain_mode(1) self.iagc = 1 self.rfgain = 0 else: self.iagc = 0 self.src.set_gain_mode(0) self.src.set_gain(self.rfgain) # may differ from the requested rate sample_rate = self.src.get_sample_rate() sys.stderr.write("sample rate: %d\n" % (sample_rate)) symbol_rate = 18000 sps = 2 # output rate will be 36,000 out_sample_rate = symbol_rate * sps options.low_pass = options.low_pass / 2.0 if sample_rate == 96000: # FunCube Dongle first_decim = 2 else: first_decim = 10 self.offset = 0 taps = filter.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.2, filter.firdes.WIN_HANN) self.tuner = filter.freq_xlating_fir_filter_ccf(first_decim, taps, self.offset, sample_rate) self.demod = cqpsk.cqpsk_demod( samples_per_symbol = sps, excess_bw=0.35, costas_alpha=0.03, gain_mu=0.05, mu=0.05, omega_relative_limit=0.05, log=options.log, verbose=options.verbose) self.output = blocks.file_sink(gr.sizeof_float, options.output_file) rerate = float(sample_rate / float(first_decim)) / float(out_sample_rate) sys.stderr.write("resampling factor: %f\n" % rerate) if rerate.is_integer(): sys.stderr.write("using pfb decimator\n") self.resamp = pfb.decimator_ccf(int(rerate)) else: sys.stderr.write("using pfb resampler\n") self.resamp = pfb.arb_resampler_ccf(1 / rerate) self.connect(self.src, self.tuner, self.resamp, self.demod, self.output) self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "Wideband Spectrum") self.Main.AddPage(grc_wxgui.Panel(self.Main), "Channel Spectrum") self.Main.AddPage(grc_wxgui.Panel(self.Main), "Soft Bits") def set_ifreq(ifreq): self.ifreq = ifreq self._ifreq_text_box.set_value(self.ifreq) self.src.set_center_freq(self.ifreq) self._ifreq_text_box = forms.text_box( parent=self.GetWin(), value=self.ifreq, callback=set_ifreq, label="Center Frequency", converter=forms.float_converter(), ) self.Add(self._ifreq_text_box) def set_iagc(iagc): self.iagc = iagc self._agc_check_box.set_value(self.iagc) self.src.set_gain_mode(self.iagc, 0) self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0) self._agc_check_box = forms.check_box( parent=self.GetWin(), value=self.iagc, callback=set_iagc, label="Automatic Gain", true=1, false=0, ) self.Add(self._agc_check_box) def set_rfgain(rfgain): self.rfgain = rfgain self._rfgain_slider.set_value(self.rfgain) self._rfgain_text_box.set_value(self.rfgain) self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0) _rfgain_sizer = wx.BoxSizer(wx.VERTICAL) self._rfgain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=set_rfgain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._rfgain_slider = forms.slider( parent=self.GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=set_rfgain, minimum=0, maximum=50, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_rfgain_sizer) self.Add(self.Main) def fftsink2_callback(x, y): if abs(x / (sample_rate / 2)) > 0.9: set_ifreq(self.ifreq + x / 2) else: sys.stderr.write("coarse tuned to: %d Hz\n" % x) self.offset = x self.tuner.set_center_freq(self.offset) self.scope = fftsink2.fft_sink_c(self.Main.GetPage(0).GetWin(), title="Wideband Spectrum (click to coarse tune)", fft_size=1024, sample_rate=sample_rate, ref_scale=2.0, ref_level=0, y_divs=10, fft_rate=10, average=False, avg_alpha=0.6) self.Main.GetPage(0).Add(self.scope.win) self.scope.set_callback(fftsink2_callback) self.connect(self.src, self.scope) def fftsink2_callback2(x, y): self.offset = self.offset - (x / 10) sys.stderr.write("fine tuned to: %d Hz\n" % self.offset) self.tuner.set_center_freq(self.offset) self.scope2 = fftsink2.fft_sink_c(self.Main.GetPage(1).GetWin(), title="Channel Spectrum (click to fine tune)", fft_size=1024, sample_rate=out_sample_rate, ref_scale=2.0, ref_level=-20, y_divs=10, fft_rate=10, average=False, avg_alpha=0.6) self.Main.GetPage(1).Add(self.scope2.win) self.scope2.set_callback(fftsink2_callback2) self.connect(self.resamp, self.scope2) self.scope3 = scopesink2.scope_sink_f( self.Main.GetPage(2).GetWin(), title="Soft Bits", sample_rate=out_sample_rate, v_scale=0, v_offset=0, t_scale=0.001, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Main.GetPage(2).Add(self.scope3.win) self.connect(self.demod, self.scope3)
def __init__(self, antenna=satnogs.not_set_antenna, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/tmp/.satnogs/data/data', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=20, enable_iq_dump=0, file_path='test.ogg', if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=100e6, rx_sdr_device='usrpb200', waterfall_file_path='/tmp/waterfall.dat'): gr.top_block.__init__(self, "METEOR Demodulation") ################################################## # Parameters ################################################## self.antenna = antenna self.bb_gain = bb_gain self.decoded_data_file_path = decoded_data_file_path self.dev_args = dev_args self.doppler_correction_per_sec = doppler_correction_per_sec self.enable_iq_dump = enable_iq_dump self.file_path = file_path self.if_gain = if_gain self.iq_file_path = iq_file_path self.lo_offset = lo_offset self.ppm = ppm self.rf_gain = rf_gain self.rigctl_port = rigctl_port self.rx_freq = rx_freq self.rx_sdr_device = rx_sdr_device self.waterfall_file_path = waterfall_file_path ################################################## # Variables ################################################## self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[rx_sdr_device]['samp_rate'] self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate_rx, 80000, 25000, firdes.WIN_HAMMING, 6.76) self.filter_rate = filter_rate = 2*80000.0 ################################################## # Blocks ################################################## self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(filter_rate, 0.0, 5, 1024, waterfall_file_path, 1) self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, 1000/doppler_correction_per_sec, 1500) self.satnogs_iq_sink_0 = satnogs.iq_sink(32767, iq_file_path, False, enable_iq_dump) self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( filter_rate / int(samp_rate_rx / int(samp_rate_rx/filter_rate)), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args) ) self.osmosdr_source_0.set_sample_rate(samp_rate_rx) self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0) self.osmosdr_source_0.set_freq_corr(ppm, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0) self.osmosdr_source_0.set_if_gain(satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0) self.osmosdr_source_0.set_bb_gain(satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0) self.osmosdr_source_0.set_antenna(satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0) self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate_rx/filter_rate), (xlate_filter_taps), lo_offset, samp_rate_rx) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq')) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_iq_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_waterfall_sink_0, 0)) self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self, antenna="", baudrate=9600.0, bb_freq=0.0, bw=0.0, dc_removal="False", decoded_data_file_path="/tmp/.satnogs/data/data", dev_args="", doppler_correction_per_sec=20, enable_iq_dump=0, excess_bw=0.5, file_path="test.wav", framing="ax25", gain=0.0, gain_mode="Overall", iq_file_path="/tmp/iq.dat", lo_offset=100e3, max_cfo=2000.0, other_settings="", ppm=0, rigctl_port=4532, rx_freq=100e6, samp_rate_rx=0.0, soapy_rx_device="driver=invalid", stream_args="", tune_args="", udp_IP="127.0.0.1", udp_port=16887, waterfall_file_path="/tmp/waterfall.dat"): gr.top_block.__init__(self, "satnogs_bpsk UDP") ################################################## # Parameters ################################################## self.antenna = antenna self.baudrate = baudrate self.bb_freq = bb_freq self.bw = bw self.dc_removal = dc_removal self.decoded_data_file_path = decoded_data_file_path self.dev_args = dev_args self.doppler_correction_per_sec = doppler_correction_per_sec self.enable_iq_dump = enable_iq_dump self.excess_bw = excess_bw self.file_path = file_path self.framing = framing self.gain = gain self.gain_mode = gain_mode self.iq_file_path = iq_file_path self.lo_offset = lo_offset self.max_cfo = max_cfo self.other_settings = other_settings self.ppm = ppm self.rigctl_port = rigctl_port self.rx_freq = rx_freq self.samp_rate_rx = samp_rate_rx self.soapy_rx_device = soapy_rx_device self.stream_args = stream_args self.tune_args = tune_args self.udp_IP = udp_IP self.udp_port = udp_port self.waterfall_file_path = waterfall_file_path ################################################## # Variables ################################################## self.variable_ax25_decoder_0 = variable_ax25_decoder_0 = satnogs.ax25_decoder_make( 'GND', 0, True, True, True, 1024) self.sps = sps = 4 self.nfilts = nfilts = 32 self.audio_samp_rate = audio_samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), excess_bw, 11 * sps * nfilts) self.if_freq = if_freq = 12000 self.decimation = decimation = satnogs.find_decimation( baudrate, 2, audio_samp_rate, sps) self.bpsk_constellation = bpsk_constellation = digital.constellation_bpsk( ).base() self.available_framings = available_framings = { 'ax25': variable_ax25_decoder_0 } ################################################## # Blocks ################################################## self.soapy_source_0 = None # Make sure that the gain mode is valid if (gain_mode not in ['Overall', 'Specific', 'Settings Field']): raise ValueError( "Wrong gain mode on channel 0. Allowed gain modes: " "['Overall', 'Specific', 'Settings Field']") dev = soapy_rx_device # Stream arguments for every activated stream tune_args = [tune_args] settings = [other_settings] # Setup the device arguments dev_args = dev_args self.soapy_source_0 = soapy.source(1, dev, dev_args, stream_args, tune_args, settings, samp_rate_rx, "fc32") self.soapy_source_0.set_dc_removal( 0, bool(distutils.util.strtobool(dc_removal))) # Set up DC offset. If set to (0, 0) internally the source block # will handle the case if no DC offset correction is supported self.soapy_source_0.set_dc_offset(0, 0) # Setup IQ Balance. If set to (0, 0) internally the source block # will handle the case if no IQ balance correction is supported self.soapy_source_0.set_iq_balance(0, 0) self.soapy_source_0.set_agc(0, False) # generic frequency setting should be specified first self.soapy_source_0.set_frequency(0, rx_freq - lo_offset) self.soapy_source_0.set_frequency(0, "BB", bb_freq) # Setup Frequency correction. If set to 0 internally the source block # will handle the case if no frequency correction is supported self.soapy_source_0.set_frequency_correction(0, ppm) self.soapy_source_0.set_antenna(0, antenna) self.soapy_source_0.set_bandwidth(0, bw) if (gain_mode != 'Settings Field'): # pass is needed, in case the template does not evaluare anything pass self.soapy_source_0.set_gain(0, gain) self.satnogs_waterfall_sink_0_0 = satnogs.waterfall_sink( baudrate * decimation, rx_freq, 10, 1024, waterfall_file_path, 1) self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink( udp_IP, udp_port, 1500) self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source( "127.0.0.1", rigctl_port, False, int(1000.0 / doppler_correction_per_sec) + 1, 1500) self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder( file_path, audio_samp_rate, 1.0) self.satnogs_json_converter_0 = satnogs.json_converter() self.satnogs_iq_sink_0_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump) self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink( decoded_data_file_path, 0) self.satnogs_frame_decoder_0_0 = satnogs.frame_decoder( available_framings[framing], 1 * 1) self.satnogs_doppler_compensation_0 = satnogs.doppler_compensation( samp_rate_rx, rx_freq, lo_offset, baudrate * decimation, 1, 0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( audio_samp_rate / (baudrate * decimation), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, audio_samp_rate, 0.42 * audio_samp_rate / 2.0, 0.05 * audio_samp_rate, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( decimation // sps, firdes.low_pass( 1, baudrate * decimation, baudrate / 2 + excess_bw * baudrate / 2 + abs(max_cfo), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 2.0 * math.pi / 100.0, rrc_taps, nfilts, nfilts / 2, 1.5, 1) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( bpsk_constellation, 2.0 * math.pi / 100.0, -0.25, 0.25) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1, udp_IP, 7355, 1472, True) self.blocks_rotator_cc_0_0 = blocks.rotator_cc( 2.0 * math.pi * (if_freq / audio_samp_rate)) self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-3, 0.5, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_frame_decoder_0_0, 'out'), (self.satnogs_json_converter_0, 'in')) self.msg_connect((self.satnogs_json_converter_0, 'out'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_json_converter_0, 'out'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_doppler_compensation_0, 'doppler')) self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.satnogs_ogg_encoder_0, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_rotator_cc_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.satnogs_frame_decoder_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_rotator_cc_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.satnogs_doppler_compensation_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.satnogs_doppler_compensation_0, 0), (self.satnogs_iq_sink_0_0, 0)) self.connect((self.satnogs_doppler_compensation_0, 0), (self.satnogs_waterfall_sink_0_0, 0)) self.connect((self.soapy_source_0, 0), (self.satnogs_doppler_compensation_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Usb Demod Rtlsdr") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 self.rf_gain = rf_gain = 25 self.if_gain = if_gain = 25 self.freq = freq = 440.980e6 self.bb_gain = bb_gain = 25 ################################################## # Blocks ################################################## _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rf_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, label="RF Gain", converter=forms.int_converter(), proportion=0, ) self._rf_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, minimum=0, maximum=50, num_steps=125, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_rf_gain_sizer) _if_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._if_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, label="IF Gain", converter=forms.int_converter(), proportion=0, ) self._if_gain_slider = forms.slider( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, minimum=0, maximum=50, num_steps=125, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_if_gain_sizer) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=435e6, maximum=445e6, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) _bb_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._bb_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, label="BB Gain", converter=forms.int_converter(), proportion=0, ) self._bb_gain_slider = forms.slider( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, minimum=0, maximum=50, num_steps=125, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_bb_gain_sizer) self.wxgui_fftsink2_1 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate/4, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="SSB Demod", peak_hold=False, ) self.Add(self.wxgui_fftsink2_1.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=5, average=False, avg_alpha=None, title="Spectrum", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( 0.923096, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 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(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(rf_gain, 0) self.osmosdr_source_0.set_if_gain(if_gain, 0) self.osmosdr_source_0.set_bb_gain(bb_gain, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.blocks_float_to_short_0 = blocks.float_to_short(1, 25000) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_short*1, addr="127.0.0.1", port=9898, server=True, ) self.band_pass_filter_0 = filter.fir_filter_ccc(2, firdes.complex_band_pass( 1, samp_rate, 50000, 450000, 50000, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.band_pass_filter_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Tx No Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Tx No Gui") 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", "tx_no_gui") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 11 * sps * nfilts) self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts 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.rate = rate = 2 self.polys = polys = [109, 79] self.k = k = 7 self.vector = vector = [int(random.random() * 4) for i in range(49600)] self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 50 self.samp_rate = samp_rate = samp_rate_array_MCR[3] self.pld_enc = pld_enc = map((lambda a: fec.cc_encoder_make( 440, k, rate, (polys), 0, fec.CC_TERMINATED, False)), 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.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 50, 200) self._variable_qtgui_range_0_0_win = RangeWidget( self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_TX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 2, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("serial=F5EAE1", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.scrambler_cpp_additive_scrambler_0 = scrambler_cpp.additive_scrambler( 0x8A, 0x7F, 7, 440 - 32) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=(tx_rrc_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay) self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector)) self.fec_extended_encoder_0 = fec.extended_encoder( encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb( pld_const.arity()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (pld_const.points()), 1) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_stream_mux_0_1_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 896)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (892, 4)) self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb( 8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb( 1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, )) self.blocks_file_source_0_0_1_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/Files_To_Transmit/trasmit_10_mb.txt', False) self.blocks_file_source_0_0_1_0.set_begin_tag(pmt.PMT_NIL) self.acode_1104 = blocks.vector_source_b([ 0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0 ], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0)) self.connect((self.blocks_file_source_0_0_1_0, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0), (self.insert_vec_cpp_new_vec_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0), (self.scrambler_cpp_additive_scrambler_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.blocks_stream_mux_0_1_0, 1)) self.connect((self.blocks_stream_mux_0_1_0, 0), (self.blocks_repack_bits_bb_1_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_stream_mux_0_0, 0)) self.connect((self.insert_vec_cpp_new_vec_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.scrambler_cpp_additive_scrambler_0, 0), (self.fec_extended_encoder_0, 0))
def __init__(self, antenna=satnogs.not_set_antenna, baudrate=9600.0, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/tmp/.satnogs/data/data', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=20, enable_iq_dump=0, file_path='test.ogg', if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=100e6, rx_sdr_device='usrpb200', samp_rate_rx=satnogs.not_set_samp_rate_rx, udp_IP='127.0.0.1', udp_port=16887, waterfall_file_path='/tmp/waterfall.dat'): gr.top_block.__init__(self, "AMSAT FOX DUV Decoder") ################################################## # Parameters ################################################## self.antenna = antenna self.baudrate = baudrate self.bb_gain = bb_gain self.decoded_data_file_path = decoded_data_file_path self.dev_args = dev_args self.doppler_correction_per_sec = doppler_correction_per_sec self.enable_iq_dump = enable_iq_dump self.file_path = file_path self.if_gain = if_gain self.iq_file_path = iq_file_path self.lo_offset = lo_offset self.ppm = ppm self.rf_gain = rf_gain self.rigctl_port = rigctl_port self.rx_freq = rx_freq self.rx_sdr_device = rx_sdr_device self.samp_rate_rx = samp_rate_rx self.udp_IP = udp_IP self.udp_port = udp_port self.waterfall_file_path = waterfall_file_path ################################################## # Variables ################################################## self.max_modulation_freq = max_modulation_freq = 3000 self.deviation = deviation = 5000 self.audio_samp_rate = audio_samp_rate = 48000 ################################################## # Blocks ################################################## self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink( audio_samp_rate, 0.0, 10, 1024, waterfall_file_path, 1) self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink( udp_IP, udp_port, 1500) self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source( "127.0.0.1", rigctl_port, False, 1000, 1500) self.satnogs_quad_demod_filter_ff_0 = satnogs.quad_demod_filter_ff(1.2) self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder( file_path, audio_samp_rate, 1.0) self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump) self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink( decoded_data_file_path, 0) self.satnogs_fox_telem_mm_0 = satnogs.fox_telem_mm() self.satnogs_decoder_8b10b_0 = satnogs.decoder_8b10b('0011111010', 960) self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc( rx_freq, satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx)) self.satnogs_ccsds_rs_decoder_mm_0 = satnogs.ccsds_rs_decoder_mm() self.root_raised_cosine_filter_0 = filter.fir_filter_fff( 1, firdes.root_raised_cosine(1, 1, 2.4, 0.5, 512)) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( audio_samp_rate / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args)) self.osmosdr_source_0.set_sample_rate( satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx)) self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0) self.osmosdr_source_0.set_freq_corr(ppm, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain( satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0) self.osmosdr_source_0.set_if_gain( satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0) self.osmosdr_source_0.set_bb_gain( satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0) self.osmosdr_source_0.set_antenna( satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0) self.osmosdr_source_0.set_bandwidth( satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), 0) self.low_pass_filter_1 = filter.fir_filter_fff( 100, firdes.low_pass(1, audio_samp_rate, 195, 10, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, audio_samp_rate, deviation + max_modulation_freq, 3000, firdes.WIN_HAMMING, 6.76)) self.digital_clock_recovery_mm_xx_0_0_0 = digital.clock_recovery_mm_ff( (audio_samp_rate / 100.0) / 200, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True) self.blocks_rotator_cc_0 = blocks.rotator_cc( -2.0 * math.pi * (lo_offset / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx))) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(1.2) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.0) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_ccsds_rs_decoder_mm_0, 'pdu'), (self.satnogs_fox_telem_mm_0, 'in')) self.msg_connect((self.satnogs_decoder_8b10b_0, 'pdu'), (self.satnogs_ccsds_rs_decoder_mm_0, 'in')) self.msg_connect((self.satnogs_fox_telem_mm_0, 'raw'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_fox_telem_mm_0, 'raw'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq')) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.satnogs_ogg_encoder_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.satnogs_decoder_8b10b_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0_0_0, 0), (self.satnogs_quad_demod_filter_ff_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_iq_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_waterfall_sink_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_clock_recovery_mm_xx_0_0_0, 0)) self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.satnogs_quad_demod_filter_ff_0, 0), (self.digital_binary_slicer_fb_0_0, 0))
def __init__(self, rx_freq): gr.top_block.__init__(self, "FM RDS receiver and decoder") ################################################## # Variables ################################################## self.freq_offset = freq_offset = 250000 self.freq = freq = rx_freq self.samp_rate = samp_rate = 2000000 self.gain = gain = 20 self.freq_tune = freq_tune = freq - freq_offset ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 2, firdes.root_raised_cosine(1, 19000, 2375, .35, 100)) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(19000 / 250e3, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'hackrf') self.osmosdr_source_0.set_clock_source('gpsdo', 0) self.osmosdr_source_0.set_time_source('gpsdo', 0) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq_tune, 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(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(14, 0) self.osmosdr_source_0.set_if_gain(24, 0) self.osmosdr_source_0.set_bb_gain(gain, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.gr_rds_parser_0 = rds.parser(True, False, 0) self.gr_rds_decoder_0 = rds.decoder(False, False) self.freq_xlating_fir_filter_xxx_1_0 = filter.freq_xlating_fir_filter_fcc( 1, (firdes.low_pass(2500.0, 250000, 2.6e3, 2e3, firdes.WIN_HAMMING)), 57e3, 250000) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (firdes.low_pass(1, samp_rate, 80000, 20000)), freq_offset, samp_rate) self.digital_psk_demod_0 = digital.psk.psk_demod( constellation_points=2, differential=False, samples_per_symbol=4, excess_bw=0.35, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False, ) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_char * 1, 2) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate, audio_decimation=8, ) self.rds_buffer_0 = rds_buffer() ################################################## # Connections ################################################## self.msg_connect((self.gr_rds_decoder_0, 'out'), (self.gr_rds_parser_0, 'in')) self.connect((self.analog_wfm_rcv_0, 0), (self.freq_xlating_fir_filter_xxx_1_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_decoder_0, 0)) self.connect((self.digital_psk_demod_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_psk_demod_0, 0)) self.msg_connect((self.gr_rds_parser_0, 'out'), (self.rds_buffer_0, 'in'))
def __init__(self): gr.top_block.__init__(self, "Files Loopback") Qt.QWidget.__init__(self) self.setWindowTitle("Files Loopback") 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", "files_loopback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.snr = snr = 15 self.pdu_length = pdu_length = 500 self.out_buf_size = out_buf_size = 96000 self.interval = interval = 10 self.epsilon = epsilon = 0 self.chan_est = chan_est = 1 ################################################## # Blocks ################################################## self._snr_range = Range(-15, 30, 0.1, 15, 200) self._snr_win = RangeWidget(self._snr_range, self.set_snr, "snr", "counter_slider", float) self.top_layout.addWidget(self._snr_win) self._pdu_length_range = Range(0, 1500, 1, 500, 200) self._pdu_length_win = RangeWidget(self._pdu_length_range, self.set_pdu_length, "pdu_length", "counter_slider", int) self.top_layout.addWidget(self._pdu_length_win) self._epsilon_range = Range(-20e-6, 20e-6, 1e-6, 0, 200) self._epsilon_win = RangeWidget(self._epsilon_range, self.set_epsilon, "epsilon", "counter_slider", float) self.top_layout.addWidget(self._epsilon_win) self._chan_est_options = [0, 1, 3, 2] self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"] self._chan_est_group_box = Qt.QGroupBox("chan_est") self._chan_est_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._chan_est_button_group = variable_chooser_button_group() self._chan_est_group_box.setLayout(self._chan_est_box) for i, label in enumerate(self._chan_est_labels): radio_button = Qt.QRadioButton(label) self._chan_est_box.addWidget(radio_button) self._chan_est_button_group.addButton(radio_button, i) self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod( self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i))) self._chan_est_callback(self.chan_est) self._chan_est_button_group.buttonClicked[int].connect( lambda i: self.set_chan_est(self._chan_est_options[i])) self.top_layout.addWidget(self._chan_est_group_box) self.wifi_freq_adap_phy_hier_0 = wifi_freq_adap_phy_hier( bandwidth=10e6, chan_est=0, debug_encoding=[0, 1, 1, 0, 0], delay_file="/tmp/symbols_delay.csv", frequency=5.89e9, sensitivity=0.56, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size 300000, #samp_rate "Data Received", #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(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.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 = ['Error Rate', '', '', '', '', '', '', '', '', ''] units = ['Percent', '', '', '', '', '', '', '', '', ''] 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_const_sink_x_0 = qtgui.const_sink_c( 48 * 10, #size "", #name 4 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['RB1', 'RB2', 'RB3', 'RB4', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "yellow", "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(4): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(1 + epsilon, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self._interval_range = Range(1, 1000, 1, 10, 200) self._interval_win = RangeWidget(self._interval_range, self.set_interval, "interval", "counter_slider", int) self.top_layout.addWidget(self._interval_win) self.frequencyAdaptiveOFDM_write_frame_data_1 = frequencyAdaptiveOFDM.write_frame_data( '/tmp/freq_snr.csv', '/tmp/freq_encoding.csv', '/tmp/freq_wifi_frame_delay.csv', False) self.frequencyAdaptiveOFDM_rb_const_demux_stream_0 = frequencyAdaptiveOFDM.rb_const_demux_stream( 'packet_len') self.frequencyAdaptiveOFDM_mac_and_parse_0 = frequencyAdaptiveOFDM.mac_and_parse( ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]), False, False, '/tmp/freq_tx_packets.csv', '/tmp/freq_rx_packets.csv') self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 500, 0) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() 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 = blocks.pdu_to_tagged_stream( blocks.float_t, 'packet_len') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( ((10**(snr / 10.0))**.5, )) self.blocks_message_strobe_0_0 = blocks.message_strobe( pmt.intern("".join("X" for i in range(pdu_length))), 20) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, '/tmp/prueba_rx.txt', False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.msg_connect( (self.blocks_message_strobe_0_0, 'strobe'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app in')) self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect( (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus')) self.msg_connect( (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'frame data'), (self.frequencyAdaptiveOFDM_write_frame_data_1, 'frame data')) self.msg_connect( (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'phy out'), (self.wifi_freq_adap_phy_hier_0, 'mac_in')) self.msg_connect( (self.wifi_freq_adap_phy_hier_0, 'mac_out'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'phy in')) self.msg_connect( (self.wifi_freq_adap_phy_hier_0, 'carrier'), (self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 'symbols_in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) 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_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 1), (self.qtgui_const_sink_x_0, 1)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 2), (self.qtgui_const_sink_x_0, 2)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 3), (self.qtgui_const_sink_x_0, 3)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.wifi_freq_adap_phy_hier_0, 0)) self.connect((self.wifi_freq_adap_phy_hier_0, 0), (self.foo_packet_pad2_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Tx No Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Tx No Gui") 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", "tx_no_gui") 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, 200000 ] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.H = H = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.vector = vector = [int(random.random() * 4) for i in range(49600)] self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 43 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 11 * sps * nfilts) self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.pld_enc = pld_enc = map( (lambda a: fec.ldpc_par_mtrx_encoder_make_H(H)), range(0, 4)) 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_0_range = Range(0, 90, 1, 43, 200) self._variable_qtgui_range_0_0_win = RangeWidget( self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_TX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_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.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("serial=F5EAE1", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.scrambler_cpp_additive_scrambler_0 = scrambler_cpp.additive_scrambler( 0x8A, 0x7F, 7, 440 - 32) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX USRP", #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(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: 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, 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_freq_sink_x_0 = 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_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_grid_layout.addWidget(self._qtgui_freq_sink_x_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) self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c( 1024, #size "TX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_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_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_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.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=(tx_rrc_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector)) self.fec_extended_encoder_0 = fec.extended_encoder( encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb( pld_const.arity()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (pld_const.points()), 1) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_stream_mux_0_1_0_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 1104)) self.blocks_stream_mux_0_0_0 = blocks.stream_mux( gr.sizeof_char * 1, (1100, 4)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (440, 2)) self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb( 8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb( 1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, )) self.blocks_file_source_0_0_1_0_0_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/Files_To_Transmit/video_lion.mpeg', False) self.blocks_file_source_0_0_1_0_0_0.set_begin_tag(pmt.PMT_NIL) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 500000) self.acode_1104_0 = blocks.vector_source_b([ 0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0 ], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104_0, 0), (self.blocks_stream_mux_0_1_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_delay_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_file_source_0_0_1_0_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0), (self.insert_vec_cpp_new_vec_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0), (self.scrambler_cpp_additive_scrambler_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.blocks_stream_mux_0_1_0_0, 1)) self.connect((self.blocks_stream_mux_0_1_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_0_0_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.insert_vec_cpp_new_vec_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.scrambler_cpp_additive_scrambler_0, 0), (self.blocks_stream_mux_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Wifi Loopback") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Loopback") 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", "wifi_loopback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.snr = snr = 15 self.pdu_length = pdu_length = 500 self.out_buf_size = out_buf_size = 96000 self.interval = interval = 300 self.epsilon = epsilon = 0 self.encoding = encoding = 0 self.chan_est = chan_est = 0 ################################################## # Blocks ################################################## self._snr_range = Range(-15, 30, 0.1, 15, 200) self._snr_win = RangeWidget(self._snr_range, self.set_snr, "snr", "counter_slider", float) self.top_grid_layout.addWidget(self._snr_win, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._pdu_length_range = Range(0, 1500, 1, 500, 200) self._pdu_length_win = RangeWidget(self._pdu_length_range, self.set_pdu_length, "pdu_length", "counter_slider", int) self.top_grid_layout.addWidget(self._pdu_length_win, 3, 0, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._epsilon_range = Range(-20e-6, 20e-6, 1e-6, 0, 200) self._epsilon_win = RangeWidget(self._epsilon_range, self.set_epsilon, "epsilon", "counter_slider", float) self.top_grid_layout.addWidget(self._epsilon_win, 3, 1, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._encoding_options = [0, 1, 2, 3, 4, 5, 6, 7] self._encoding_labels = [ "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4" ] self._encoding_tool_bar = Qt.QToolBar(self) self._encoding_tool_bar.addWidget(Qt.QLabel("encoding" + ": ")) self._encoding_combo_box = Qt.QComboBox() self._encoding_tool_bar.addWidget(self._encoding_combo_box) for label in self._encoding_labels: self._encoding_combo_box.addItem(label) self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod( self._encoding_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._encoding_options.index(i))) self._encoding_callback(self.encoding) self._encoding_combo_box.currentIndexChanged.connect( lambda i: self.set_encoding(self._encoding_options[i])) self.top_grid_layout.addWidget(self._encoding_tool_bar, 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._chan_est_options = [ ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB ] self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"] self._chan_est_tool_bar = Qt.QToolBar(self) self._chan_est_tool_bar.addWidget(Qt.QLabel("chan_est" + ": ")) self._chan_est_combo_box = Qt.QComboBox() self._chan_est_tool_bar.addWidget(self._chan_est_combo_box) for label in self._chan_est_labels: self._chan_est_combo_box.addItem(label) self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod( self._chan_est_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._chan_est_options.index(i))) self._chan_est_callback(self.chan_est) self._chan_est_combo_box.currentIndexChanged.connect( lambda i: self.set_chan_est(self._chan_est_options[i])) self.top_grid_layout.addWidget(self._chan_est_tool_bar, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.wifi_phy_hier_0 = wifi_phy_hier( bandwidth=10e6, chan_est=chan_est, encoding=encoding, frequency=5.89e9, sensitivity=0.56, ) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0.05, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['Error Rate', '', '', '', '', '', '', '', '', ''] units = ['Percent', '', '', '', '', '', '', '', '', ''] 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_grid_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 48 * 10, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_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.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 0, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(1 + epsilon, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self._interval_range = Range(10, 1000, 1, 300, 200) self._interval_win = RangeWidget(self._interval_range, self.set_interval, "interval", "counter_slider", int) self.top_grid_layout.addWidget(self._interval_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.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, True) self.ieee802_11_mac_0 = ieee802_11.mac( ([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 500, 0) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.channels_channel_model_0 = channels.channel_model( noise_voltage=1, frequency_offset=epsilon * 5.89e9 / 10e6, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len') self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, pdu_length, "packet_len") self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.complex_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.float_t, 'packet_len') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( ((10**(snr / 10.0))**.5, )) self.Input_file_source = blocks.file_source( gr.sizeof_char * 1, '/home/meid/Desktop/input.txt', True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.ieee802_11_mac_0, 'app in')) self.msg_connect((self.ieee802_11_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) self.msg_connect((self.ieee802_11_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.wifi_phy_hier_0, 'carrier'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_parse_mac_0, 'in')) self.connect((self.Input_file_source, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0)) 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, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0))
def __init__(self, name='Multistage Channel Filter', input_rate=0, output_rate=0, cutoff_freq=0, transition_width=0, center_freq=0): assert input_rate > 0 assert output_rate > 0 assert cutoff_freq > 0 assert transition_width > 0 gr.hier_block2.__init__( self, name, gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) self.cutoff_freq = cutoff_freq self.transition_width = transition_width total_decimation = max(1, input_rate // output_rate) stage_decimations = _factorize(total_decimation) stage_decimations.reverse() if len(stage_decimations) == 0: # We need at least one filter to do the frequency shift and to apply the user-specified LPF stage_decimations = [1] self.stages = [] placeholder_taps = [0] prev_block = self stage_input_rate = input_rate for i, stage_decimation in enumerate(stage_decimations): next_rate = stage_input_rate / stage_decimation if i == 0: stage_filter = grfilter.freq_xlating_fir_filter_ccc( stage_decimation, placeholder_taps, center_freq, stage_input_rate) self.freq_filter_block = stage_filter else: stage_filter = grfilter.fir_filter_ccc(stage_decimation, placeholder_taps) self.stages.append((stage_filter, stage_input_rate, next_rate)) self.connect(prev_block, stage_filter) prev_block = stage_filter stage_input_rate = next_rate # final connection and resampling if stage_input_rate == output_rate: # exact multiple, no fractional resampling needed #print 'direct connect %s/%s' % (output_rate, stage_input_rate) self.connect(prev_block, self) else: # TODO: combine resampler with final filter stage # TODO: cache filter computation as optfir is used and takes a noticeable time self.connect( prev_block, pfb.arb_resampler_ccf(float(output_rate) / stage_input_rate), self) #print 'resampling %s/%s = %s' % (output_rate, stage_input_rate, float(output_rate) / stage_input_rate) self.__do_taps()
def create_block(self, taps): return pfb.arb_resampler_ccf( self.resample_rate) # TODO explicitly compute taps
def __init__(self, samp_rate=80e6): gr.top_block.__init__(self, "Inmarsat Cband Playback") Qt.QWidget.__init__(self) self.setWindowTitle("Inmarsat Cband Playback") 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", "inmarsat_cband_playback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.samp_rate = samp_rate ################################################## # Variables ################################################## self.rf_freq = rf_freq = 3627.5e6 self.hs_lo = hs_lo = 5150e6 self.xpndr_4_offset = xpndr_4_offset = 23e6 self.xpndr_3_offset = xpndr_3_offset = 7.5e6 self.xpndr_2_offset = xpndr_2_offset = -7.5e6 self.xpndr_1_offset = xpndr_1_offset = -23e6 self.if_freq = if_freq = hs_lo - rf_freq self.xpndr4_lbl = xpndr4_lbl = xpndr_4_offset self.xpndr3_lbl = xpndr3_lbl = xpndr_3_offset self.xpndr2_lbl = xpndr2_lbl = xpndr_2_offset self.xpndr1_lbl = xpndr1_lbl = xpndr_1_offset self.rf_freq_lbl = rf_freq_lbl = rf_freq self.resamp_rate = resamp_rate = 0.175 self.if_freq_lbl = if_freq_lbl = if_freq ################################################## # Blocks ################################################## self._xpndr4_lbl_tool_bar = Qt.QToolBar(self) if None: self._xpndr4_lbl_formatter = None else: self._xpndr4_lbl_formatter = lambda x: eng_notation.num_to_str(x) self._xpndr4_lbl_tool_bar.addWidget(Qt.QLabel('Transponder 4' + ": ")) self._xpndr4_lbl_label = Qt.QLabel( str(self._xpndr4_lbl_formatter(self.xpndr4_lbl))) self._xpndr4_lbl_tool_bar.addWidget(self._xpndr4_lbl_label) self.top_grid_layout.addWidget(self._xpndr4_lbl_tool_bar, 9, 6, 1, 2) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self._xpndr3_lbl_tool_bar = Qt.QToolBar(self) if None: self._xpndr3_lbl_formatter = None else: self._xpndr3_lbl_formatter = lambda x: eng_notation.num_to_str(x) self._xpndr3_lbl_tool_bar.addWidget(Qt.QLabel('Transponder 3' + ": ")) self._xpndr3_lbl_label = Qt.QLabel( str(self._xpndr3_lbl_formatter(self.xpndr3_lbl))) self._xpndr3_lbl_tool_bar.addWidget(self._xpndr3_lbl_label) self.top_grid_layout.addWidget(self._xpndr3_lbl_tool_bar, 9, 2, 1, 2) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._xpndr2_lbl_tool_bar = Qt.QToolBar(self) if None: self._xpndr2_lbl_formatter = None else: self._xpndr2_lbl_formatter = lambda x: eng_notation.num_to_str(x) self._xpndr2_lbl_tool_bar.addWidget(Qt.QLabel('Transponder 2' + ": ")) self._xpndr2_lbl_label = Qt.QLabel( str(self._xpndr2_lbl_formatter(self.xpndr2_lbl))) self._xpndr2_lbl_tool_bar.addWidget(self._xpndr2_lbl_label) self.top_grid_layout.addWidget(self._xpndr2_lbl_tool_bar, 4, 6, 1, 2) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self._xpndr1_lbl_tool_bar = Qt.QToolBar(self) if None: self._xpndr1_lbl_formatter = None else: self._xpndr1_lbl_formatter = lambda x: eng_notation.num_to_str(x) self._xpndr1_lbl_tool_bar.addWidget(Qt.QLabel('Transponder 1' + ": ")) self._xpndr1_lbl_label = Qt.QLabel( str(self._xpndr1_lbl_formatter(self.xpndr1_lbl))) self._xpndr1_lbl_tool_bar.addWidget(self._xpndr1_lbl_label) self.top_grid_layout.addWidget(self._xpndr1_lbl_tool_bar, 4, 2, 1, 2) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._rf_freq_lbl_tool_bar = Qt.QToolBar(self) if None: self._rf_freq_lbl_formatter = None else: self._rf_freq_lbl_formatter = lambda x: eng_notation.num_to_str(x) self._rf_freq_lbl_tool_bar.addWidget(Qt.QLabel('RF' + ": ")) self._rf_freq_lbl_label = Qt.QLabel( str(self._rf_freq_lbl_formatter(self.rf_freq_lbl))) self._rf_freq_lbl_tool_bar.addWidget(self._rf_freq_lbl_label) self.top_grid_layout.addWidget(self._rf_freq_lbl_tool_bar, 10, 0, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.pfb_arb_resampler_xxx_0_1 = pfb.arb_resampler_ccf(resamp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0_1.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0_0_0 = pfb.arb_resampler_ccf(resamp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(resamp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(resamp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self._if_freq_lbl_tool_bar = Qt.QToolBar(self) if None: self._if_freq_lbl_formatter = None else: self._if_freq_lbl_formatter = lambda x: eng_notation.num_to_str(x) self._if_freq_lbl_tool_bar.addWidget(Qt.QLabel('IF' + ": ")) self._if_freq_lbl_label = Qt.QLabel( str(self._if_freq_lbl_formatter(self.if_freq_lbl))) self._if_freq_lbl_tool_bar.addWidget(self._if_freq_lbl_label) self.top_grid_layout.addWidget(self._if_freq_lbl_tool_bar, 10, 1, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.fosphor_qt_sink_c_0_1 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0_1.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0_1.set_frequency_range( rf_freq + xpndr_3_offset, samp_rate * resamp_rate) self._fosphor_qt_sink_c_0_1_win = sip.wrapinstance( self.fosphor_qt_sink_c_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_1_win, 5, 0, 4, 4) for r in range(5, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.fosphor_qt_sink_c_0_0_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0_0_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0_0_0.set_frequency_range( rf_freq + xpndr_4_offset, samp_rate * resamp_rate) self._fosphor_qt_sink_c_0_0_0_win = sip.wrapinstance( self.fosphor_qt_sink_c_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_0_0_win, 5, 4, 4, 4) for r in range(5, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.fosphor_qt_sink_c_0_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0_0.set_frequency_range( rf_freq + xpndr_2_offset, samp_rate * resamp_rate) self._fosphor_qt_sink_c_0_0_win = sip.wrapinstance( self.fosphor_qt_sink_c_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_0_win, 0, 4, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range(rf_freq + xpndr_1_offset, samp_rate * resamp_rate) self._fosphor_qt_sink_c_0_win = sip.wrapinstance( self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_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.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(rf_freq, samp_rate) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, )) self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex( False, False) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_1 = blocks.file_source( gr.sizeof_short * 1, '/data1/captures/inmarsat_c/4F3_F5BE35_20180903_043333.872099_UTC_80M.short', True) self.blocks_file_source_1.set_begin_tag(pmt.PMT_NIL) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.analog_sig_source_x_0_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1 * xpndr_3_offset, 1, 0) self.analog_sig_source_x_0_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1 * xpndr_4_offset, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1 * xpndr_2_offset, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1 * xpndr_1_offset, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_file_source_1, 0), (self.blocks_interleaved_short_to_complex_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.fosphor_glfw_sink_c_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.pfb_arb_resampler_xxx_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.pfb_arb_resampler_xxx_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.fosphor_qt_sink_c_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0_0, 0), (self.fosphor_qt_sink_c_0_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_1, 0), (self.fosphor_qt_sink_c_0_1, 0))
def __init__(self, bind_addr='0.0.0.0', dest_addr='127.0.0.1', lo_offset=100e3, recv_port=16886, rx_sdr_device='usrpb200', send_port=5022, tx_sdr_device='usrpb200', wod_port=5023): gr.top_block.__init__(self, "UPSat Transceiver QT") Qt.QWidget.__init__(self) self.setWindowTitle("UPSat Transceiver QT") 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", "upsat_transceiver_qt") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.bind_addr = bind_addr self.dest_addr = dest_addr self.lo_offset = lo_offset self.recv_port = recv_port self.rx_sdr_device = rx_sdr_device self.send_port = send_port self.tx_sdr_device = tx_sdr_device self.wod_port = wod_port ################################################## # Variables ################################################## self.samples_per_symbol_tx = samples_per_symbol_tx = 4*8 self.sq_wave = sq_wave = (1.0, ) * samples_per_symbol_tx self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[rx_sdr_device]['samp_rate'] self.gaussian_taps = gaussian_taps = filter.firdes.gaussian(1.0, samples_per_symbol_tx, 1.0, 4*samples_per_symbol_tx) self.deviation = deviation = 3.9973e3 self.decimation_rx = decimation_rx = 20 self.baud_rate_uplink = baud_rate_uplink = 1200 self.baud_rate_downlink = baud_rate_downlink = 9600 self.tx_frequency = tx_frequency = 145.835e6 self.taps = taps = firdes.low_pass(1.0, samp_rate_rx, 20000, 60000, firdes.WIN_HAMMING, 6.76) self.samp_rate_tx = samp_rate_tx = satnogs.hw_tx_settings[rx_sdr_device]['samp_rate'] self.rx_frequency = rx_frequency = 435.765e6 self.modulation_index_uplink = modulation_index_uplink = deviation / (baud_rate_uplink / 2.0) self.modulation_index_downlink = modulation_index_downlink = deviation / (baud_rate_downlink / 2.0) self.interp_taps = interp_taps = numpy.convolve(numpy.array(gaussian_taps), numpy.array(sq_wave)) self.first_stage_samp_rate_rx = first_stage_samp_rate_rx = samp_rate_rx / decimation_rx ################################################## # Blocks ################################################## self.satnogs_upsat_fsk_frame_encoder_0 = satnogs.upsat_fsk_frame_encoder([0x33]*8 , [0x7A, 0x0E], False, False, False, True, True, 'ABCD', 0, 'ON02GR', 0, 64) self.satnogs_udp_msg_source_0 = satnogs.udp_msg_source(bind_addr, recv_port, 1500, 0) self.satnogs_udp_msg_sink_0_0_0 = satnogs.udp_msg_sink(dest_addr, wod_port, 1500) self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(dest_addr, send_port, 1500) self.satnogs_qb50_deframer_0 = satnogs.qb50_deframer(0xe) self.satnogs_multi_format_msg_sink_0 = satnogs.multi_format_msg_sink(1, False, True, '') self.satnogs_ax25_decoder_bm_0 = satnogs.ax25_decoder_bm('GND', 0, False, True, 256, 3) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 50e3, #bw "", #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 samp_rate_rx/decimation_rx, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.01) self.qtgui_freq_sink_x_0.set_y_axis(-140, 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(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(True) 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_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samp_rate_tx / (baud_rate_uplink * samples_per_symbol_tx), taps=(firdes.low_pass_2(32, 32, 0.8, 0.1, 60)), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.hw_rx_settings[rx_sdr_device]['dev_arg'] ) self.osmosdr_source_0.set_sample_rate(samp_rate_rx) self.osmosdr_source_0.set_center_freq(rx_frequency - lo_offset, 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(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(satnogs.hw_rx_settings[rx_sdr_device]['rf_gain'], 0) self.osmosdr_source_0.set_if_gain(satnogs.hw_rx_settings[rx_sdr_device]['if_gain'], 0) self.osmosdr_source_0.set_bb_gain(satnogs.hw_rx_settings[rx_sdr_device]['bb_gain'], 0) self.osmosdr_source_0.set_antenna(satnogs.hw_rx_settings[rx_sdr_device]['antenna'], 0) self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + satnogs.hw_tx_settings[rx_sdr_device]['dev_arg'] ) self.osmosdr_sink_0.set_sample_rate(samp_rate_tx) self.osmosdr_sink_0.set_center_freq(tx_frequency - lo_offset, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(satnogs.hw_tx_settings[tx_sdr_device]['rf_gain'], 0) self.osmosdr_sink_0.set_if_gain(satnogs.hw_tx_settings[tx_sdr_device]['if_gain'], 0) self.osmosdr_sink_0.set_bb_gain(satnogs.hw_tx_settings[tx_sdr_device]['bb_gain'], 0) self.osmosdr_sink_0.set_antenna(satnogs.hw_tx_settings[tx_sdr_device]['antenna'], 0) self.osmosdr_sink_0.set_bandwidth(samp_rate_tx, 0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(samples_per_symbol_tx, (interp_taps)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decimation_rx, (taps), lo_offset, samp_rate_rx) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(first_stage_samp_rate_rx/baud_rate_downlink, 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate_tx, analog.GR_COS_WAVE, lo_offset , 1, 0) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(((first_stage_samp_rate_rx) / baud_rate_downlink)/(math.pi*modulation_index_downlink)) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc((math.pi*modulation_index_uplink) / samples_per_symbol_tx) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'failed_pdu'), (self.satnogs_multi_format_msg_sink_0, 'in')) self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_qb50_deframer_0, 'in')) self.msg_connect((self.satnogs_qb50_deframer_0, 'out'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_qb50_deframer_0, 'wod'), (self.satnogs_udp_msg_sink_0_0_0, 'in')) self.msg_connect((self.satnogs_udp_msg_source_0, 'msg'), (self.satnogs_upsat_fsk_frame_encoder_0, 'pdu')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satnogs_ax25_decoder_bm_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0_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.interp_fir_filter_xxx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.satnogs_upsat_fsk_frame_encoder_0, 0), (self.interp_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 6 Task 1") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 6 Task 1") 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", "lab6_task1") 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.sps = sps = 4 self.nfilts = nfilts = 32 self.ntaps = ntaps = 11*nfilts*sps self.tx_taps = tx_taps = firdes.root_raised_cosine(nfilts,nfilts,1.0,0.4,ntaps) self.timing_bw = timing_bw = 2*pi/100 self.samp_rate = samp_rate = 32000 self.rx_taps = rx_taps = firdes.root_raised_cosine(nfilts,nfilts*sps,1.0,0.4,ntaps) ################################################## # 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, 'Before Multipath') 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, 'After Multipath') self.top_grid_layout.addWidget(self.tab) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) 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(False) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) 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 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.tab_layout_1.addWidget(self._qtgui_const_sink_x_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) 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 range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=tx_taps, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.iir_filter_xxx_0 = filter.iir_filter_ccf([1, 1], [1], True) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(8, timing_bw, rx_taps, 32, 16, 1.5, 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(((-0.707-0.707j),(-1-0j),(-0.707+0.707j),(0+1j),(0.707+0.707j),(1+0j),(0.707-0.707j),(0-1j)), 1) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 8, 1000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
def __init__(self, antenna=satnogs.not_set_antenna, baudrate=9600.0, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/tmp/.satnogs/data/data', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=1000, enable_iq_dump=0, excess_bw=0.35, file_path='test.wav', if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, max_cfo=1000.0, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=100e6, rx_sdr_device='usrpb200', samp_rate_rx=satnogs.not_set_samp_rate_rx, udp_IP='127.0.0.1', udp_port=16887, waterfall_file_path='/tmp/waterfall.dat'): gr.top_block.__init__(self, "satnogs_bpsk_ax25") ################################################## # Parameters ################################################## self.antenna = antenna self.baudrate = baudrate self.bb_gain = bb_gain self.decoded_data_file_path = decoded_data_file_path self.dev_args = dev_args self.doppler_correction_per_sec = doppler_correction_per_sec self.enable_iq_dump = enable_iq_dump self.excess_bw = excess_bw self.file_path = file_path self.if_gain = if_gain self.iq_file_path = iq_file_path self.lo_offset = lo_offset self.max_cfo = max_cfo self.ppm = ppm self.rf_gain = rf_gain self.rigctl_port = rigctl_port self.rx_freq = rx_freq self.rx_sdr_device = rx_sdr_device self.samp_rate_rx = samp_rate_rx self.udp_IP = udp_IP self.udp_port = udp_port self.waterfall_file_path = waterfall_file_path ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), excess_bw, 11 * sps * nfilts) self.bpsk_constellation = bpsk_constellation = digital.constellation_bpsk( ).base() self.audio_samp_rate = audio_samp_rate = 48000 ################################################## # Blocks ################################################## self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink( audio_samp_rate, 0.0, 10, 1024, waterfall_file_path, 1) self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink( udp_IP, udp_port, 1500) self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source( "127.0.0.1", rigctl_port, False, 1000, 1500) self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder( file_path, audio_samp_rate, 1.0) self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump) self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink( decoded_data_file_path, 0) self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc( rx_freq, satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx)) self.satnogs_ax25_decoder_bm_0_0 = satnogs.ax25_decoder_bm( 'GND', 0, True, False, 1024) self.satnogs_ax25_decoder_bm_0 = satnogs.ax25_decoder_bm( 'GND', 0, True, True, 1024) self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf( (1.0 * sps * baudrate) / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( audio_samp_rate / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args)) self.osmosdr_source_0.set_sample_rate( satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx)) self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0) self.osmosdr_source_0.set_freq_corr(ppm, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain( satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0) self.osmosdr_source_0.set_if_gain( satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0) self.osmosdr_source_0.set_bb_gain( satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0) self.osmosdr_source_0.set_antenna( satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0) self.osmosdr_source_0.set_bandwidth( satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), 0) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, audio_samp_rate, ((1.0 + excess_bw) * baudrate / 2.0) + min(baudrate, abs(max_cfo)), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, sps * baudrate, ((1.0 + excess_bw) * baudrate / 2.0) + min(baudrate, abs(max_cfo)), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 2.0 * math.pi / 100.0, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 2.0 * math.pi / 100.0, 2, True) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( bpsk_constellation, 2.0 * math.pi / 100.0, -0.25, 0.25) self.blocks_rotator_cc_0_0 = blocks.rotator_cc( 2.0 * math.pi * (1200.0 / audio_samp_rate)) self.blocks_rotator_cc_0 = blocks.rotator_cc( -2.0 * math.pi * (lo_offset / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx))) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-3, 0.5, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_ax25_decoder_bm_0_0, 'pdu'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_ax25_decoder_bm_0_0, 'pdu'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq')) self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.satnogs_ogg_encoder_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0)) self.connect((self.blocks_rotator_cc_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.satnogs_ax25_decoder_bm_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.satnogs_ax25_decoder_bm_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_rotator_cc_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_iq_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_waterfall_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
def __init__(self, name='Multistage Channel Filter', input_rate=0, output_rate=0, cutoff_freq=0, transition_width=0, center_freq=0): assert input_rate > 0 assert output_rate > 0 assert cutoff_freq > 0 assert transition_width > 0 # cf. firdes.sanity_check_1f (which is private) # TODO better errors for other cases if cutoff_freq > output_rate / 2: # early check for better errors since our cascaded filters might be cryptically nonsense raise ValueError('cutoff_freq (%s) is too high for output_rate (%s)' % (cutoff_freq, output_rate)) gr.hier_block2.__init__( self, name, gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) self.cutoff_freq = cutoff_freq self.transition_width = transition_width total_decimation = max(1, int(input_rate // output_rate)) using_rational_resampler = _use_rational_resampler and input_rate % 1 == 0 and output_rate % 1 == 0 if using_rational_resampler: # If using rational resampler, don't decimate to the point that we get a fractional rate, if possible. input_rate = int(input_rate) output_rate = int(output_rate) if input_rate > output_rate: total_decimation = input_rate // small_factor_at_least(input_rate, output_rate) # print input_rate / total_decimation, total_decimation, input_rate, output_rate, input_rate // gcd(input_rate, output_rate) # TODO: Don't re-factorize unnecessarily stage_decimations = factorize(total_decimation) stage_decimations.reverse() self.stages = [] # loop variables prev_block = self stage_input_rate = input_rate last_index = len(stage_decimations) - 1 if len(stage_decimations) == 0: # interpolation or nothing -- don't put it in the stages # TODO: consider using rotator block instead (has different API) self.freq_filter_block = grfilter.freq_xlating_fir_filter_ccc( 1, [1], center_freq, stage_input_rate) self.connect(prev_block, self.freq_filter_block) prev_block = self.freq_filter_block else: # decimation for i, stage_decimation in enumerate(stage_decimations): next_rate = stage_input_rate / stage_decimation if i == 0: stage_filter = grfilter.freq_xlating_fir_filter_ccc( stage_decimation, [0], # placeholder center_freq, stage_input_rate) self.freq_filter_block = stage_filter else: taps = self.__stage_taps(i == last_index, stage_input_rate, next_rate) if len(taps) > 10: stage_filter = grfilter.fft_filter_ccc(stage_decimation, taps, 1) else: stage_filter = grfilter.fir_filter_ccc(stage_decimation, taps) self.stages.append((stage_filter, stage_input_rate, next_rate)) self.connect(prev_block, stage_filter) prev_block = stage_filter stage_input_rate = next_rate # final connection and resampling if stage_input_rate == output_rate: # exact multiple, no fractional resampling needed self.connect(prev_block, self) self.__resampler_explanation = 'No final resampler stage.' else: # TODO: systematically combine resampler with final filter stage if using_rational_resampler: if stage_input_rate % 1 != 0: raise Exception("shouldn't happen", stage_input_rate) stage_input_rate = int(stage_input_rate) # because of float division above common = gcd(output_rate, stage_input_rate) interpolation = output_rate // common decimation = stage_input_rate // common self.__resampler_explanation = 'rational_resampler by %s/%s (stage rates %s/%s)' % (interpolation, decimation, output_rate, stage_input_rate) resampler = rational_resampler.rational_resampler_ccf( interpolation=interpolation, decimation=decimation) else: # TODO: cache filter computation as optfir is used and takes a noticeable time self.__resampler_explanation = 'arb_resampler %s/%s = %s' % (output_rate, stage_input_rate, float(output_rate) / stage_input_rate) resampler = pfb.arb_resampler_ccf(float(output_rate) / stage_input_rate) self.connect( prev_block, resampler, self) # TODO: Shouldn't be necessary since we compute the taps in the loop above... self.__do_taps()