Beispiel #1
0
    def __init__(self, samp_per_sym=4):
        gr.hier_block2.__init__(
            self, "PSK31 Modulator",
            gr.io_signature(1, 1, gr.sizeof_char*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

        self.samp_per_sym = samp_per_sym

        self.connect(
            self,

            # PSK31 defines 0 as a phase change, opposite the usual
            # differential encoding which is: out = (next - prev) % 2
            blocks.not_bb(),
            blocks.and_const_bb(1),

            digital.diff_encoder_bb(2),
            blocks.char_to_float(1, 1),
            blocks.add_const_vff((-0.5, )),
            blocks.multiply_const_vff((2, )),
            interp_fir_filter_fff(samp_per_sym, self._envelope_taps()),
            blocks.float_to_complex(1),
            self,
        )
Beispiel #2
0
    def __init__(self, EbN0):
        gr.top_block.__init__(self)
        self.const = digital.bpsk_constellation()
        # Source is N_BITS bits, non-repeated

        #print("BITS PER SYMBOL: ", self.const.bits_per_symbol())
        #print("arity: ", self.const.arity())

        data = map(
            int,
            numpy.random.randint(0, self.const.arity(),
                                 int(N_BITS / self.const.bits_per_symbol())))
        src = blocks.vector_source_b(data, False)
        mod = digital.chunks_to_symbols_bc((self.const.points()), 1)
        add = blocks.add_vcc()
        diff_enc = digital.diff_encoder_bb(2)
        diff_dec = digital.diff_decoder_bb(2)

        #print("Gaussian amplitude: ", self.EbN0_to_noise_voltage(EbN0))

        noise = analog.noise_source_c(analog.GR_GAUSSIAN,
                                      self.EbN0_to_noise_voltage(EbN0),
                                      RAND_SEED)
        demod = digital.constellation_decoder_cb(self.const.base())
        ber = BitErrors(self.const.bits_per_symbol())
        self.sink = blocks.vector_sink_f()
        self.connect(src, diff_enc, mod, add, demod, diff_dec, ber, self.sink)
        self.connect(noise, (add, 1))
        self.connect(src, (ber, 1))
Beispiel #3
0
    def __init__(self, constellation, differential, rotation):
        if constellation.arity() > 256:
            # If this becomes limiting some of the blocks should be generalised so
            # that they can work with shorts and ints as well as chars.
            raise ValueError("Constellation cannot contain more than 256 points.")

        gr.hier_block2.__init__(
            self,
            "mod_demod",
            gr.io_signature(1, 1, gr.sizeof_char),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_char),
        )  # Output signature

        arity = constellation.arity()

        # TX
        self.constellation = constellation
        self.differential = differential
        import weakref

        self.blocks = [weakref.proxy(self)]
        # We expect a stream of unpacked bits.
        # First step is to pack them.
        self.blocks.append(blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST))
        # Second step we unpack them such that we have k bits in each byte where
        # each constellation symbol hold k bits.
        self.blocks.append(blocks.packed_to_unpacked_bb(self.constellation.bits_per_symbol(), gr.GR_MSB_FIRST))
        # Apply any pre-differential coding
        # Gray-coding is done here if we're also using differential coding.
        if self.constellation.apply_pre_diff_code():
            self.blocks.append(digital.map_bb(self.constellation.pre_diff_code()))
        # Differential encoding.
        if self.differential:
            self.blocks.append(digital.diff_encoder_bb(arity))
        # Convert to constellation symbols.
        self.blocks.append(
            digital.chunks_to_symbols_bc(self.constellation.points(), self.constellation.dimensionality())
        )
        # CHANNEL
        # Channel just consists of a rotation to check differential coding.
        if rotation is not None:
            self.blocks.append(blocks.multiply_const_cc(rotation))

        # RX
        # Convert the constellation symbols back to binary values.
        self.blocks.append(digital.constellation_decoder_cb(self.constellation.base()))
        # Differential decoding.
        if self.differential:
            self.blocks.append(digital.diff_decoder_bb(arity))
        # Decode any pre-differential coding.
        if self.constellation.apply_pre_diff_code():
            self.blocks.append(digital.map_bb(mod_codes.invert_code(self.constellation.pre_diff_code())))
        # unpack the k bit vector into a stream of bits
        self.blocks.append(blocks.unpack_k_bits_bb(self.constellation.bits_per_symbol()))
        # connect to block output
        check_index = len(self.blocks)
        self.blocks = self.blocks[:check_index]
        self.blocks.append(weakref.proxy(self))

        self.connect(*self.blocks)
Beispiel #4
0
    def __init__(self, alfa=0.35, samp_per_sym=5, bits_per_sym=2, constellation=[-1-1j,1-1j, 1+1j, -1+1j], len_sym_srrc=7, out_const_mul=0.4):
        gr.hier_block2.__init__(
            self, "Hier Tx",
            gr.io_signature(1, 1, gr.sizeof_char*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.alfa = alfa
        self.samp_per_sym = samp_per_sym
        self.bits_per_sym = bits_per_sym
        self.constellation = constellation
        self.len_sym_srrc = len_sym_srrc
        self.out_const_mul = out_const_mul

        ##################################################
        # Variables
        ##################################################
        self.pulso = pulso = firdes.root_raised_cosine(samp_per_sym,samp_per_sym,1.0,alfa,samp_per_sym*len_sym_srrc)


        ##################################################
        # Blocks
        ##################################################
        self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf(
        	  samp_per_sym,
        	  (pulso),
        	  100)
        	
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2**bits_per_sym)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((constellation), 1)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bits_per_sym, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((out_const_mul, ))
        if DEBUG:
		self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "./file_tx_ini", False)
        	self.blocks_file_sink_0.set_unbuffered(True)
 		self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, "./file_tx_2bits", False)
		self.blocks_file_sink_1.set_unbuffered(True)
 		self.blocks_file_sink_2 = blocks.file_sink(gr.sizeof_gr_complex*1, "./file_tx_out", False)
        	self.blocks_file_sink_2.set_unbuffered(True)
 		self.blocks_file_sink_3 = blocks.file_sink(gr.sizeof_gr_complex*1, "./file_tx_sym", False)
        	self.blocks_file_sink_3.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.pfb_interpolator_ccf_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_interpolator_ccf_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self, 0))
        self.connect((self, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        if DEBUG:
	 	self.connect((self, 0), (self.blocks_file_sink_0, 0))
        	self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_file_sink_1, 0))
		self.connect((self.pfb_interpolator_ccf_0, 0), (self.blocks_file_sink_2, 0))
		self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_file_sink_3, 0))
    def __init__(self, constellation, differential, rotation):
        if constellation.arity() > 256:
            # If this becomes limiting some of the blocks should be generalised so
            # that they can work with shorts and ints as well as chars.
            raise ValueError("Constellation cannot contain more than 256 points.")

        gr.hier_block2.__init__(self, "mod_demod",
                                gr.io_signature(1, 1, gr.sizeof_char),       # Input signature
                                gr.io_signature(1, 1, gr.sizeof_char))       # Output signature

        arity = constellation.arity()

        # TX
        self.constellation = constellation
        self.differential = differential
        import weakref
        self.blocks = [weakref.proxy(self)]
        # We expect a stream of unpacked bits.
        # First step is to pack them.
        self.blocks.append(blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST))
        # Second step we unpack them such that we have k bits in each byte where
        # each constellation symbol hold k bits.
        self.blocks.append(
            blocks.packed_to_unpacked_bb(self.constellation.bits_per_symbol(),
                                         gr.GR_MSB_FIRST))
        # Apply any pre-differential coding
        # Gray-coding is done here if we're also using differential coding.
        if self.constellation.apply_pre_diff_code():
            self.blocks.append(digital.map_bb(self.constellation.pre_diff_code()))
        # Differential encoding.
        if self.differential:
            self.blocks.append(digital.diff_encoder_bb(arity))
        # Convert to constellation symbols.
        self.blocks.append(digital.chunks_to_symbols_bc(self.constellation.points(),
                                                        self.constellation.dimensionality()))
        # CHANNEL
        # Channel just consists of a rotation to check differential coding.
        if rotation is not None:
            self.blocks.append(blocks.multiply_const_cc(rotation))

        # RX
        # Convert the constellation symbols back to binary values.
        self.blocks.append(digital.constellation_decoder_cb(self.constellation.base()))
        # Differential decoding.
        if self.differential:
            self.blocks.append(digital.diff_decoder_bb(arity))
        # Decode any pre-differential coding.
        if self.constellation.apply_pre_diff_code():
            self.blocks.append(digital.map_bb(
                mod_codes.invert_code(self.constellation.pre_diff_code())))
        # unpack the k bit vector into a stream of bits
        self.blocks.append(blocks.unpack_k_bits_bb(
                self.constellation.bits_per_symbol()))
        # connect to block output
        check_index = len(self.blocks)
        self.blocks = self.blocks[:check_index]
        self.blocks.append(weakref.proxy(self))

        self.connect(*self.blocks)
    def test_encode_decode(self):
        """Performs NRZI encode and decode and checks the result"""
        encoder = digital.diff_encoder_bb(2, digital.DIFF_NRZI)
        decoder = digital.diff_decoder_bb(2, digital.DIFF_NRZI)

        self.tb.connect(self.source, encoder, decoder, self.sink)
        self.tb.start()
        self.tb.wait()

        np.testing.assert_equal(
            self.sink.data(), self.data,
            'NRZI encoded and decoded output does not match input')
 def test_diff_encdec_002(self):
     random.seed(0)
     modulus = 8
     src_data = make_random_int_tuple(40000, 0, modulus-1)
     expected_result = src_data
     src = blocks.vector_source_b(src_data)
     enc = digital.diff_encoder_bb(modulus)
     dec = digital.diff_decoder_bb(modulus)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, enc, dec, dst)
     self.tb.run()               # run the graph and wait for it to finish
     actual_result = dst.data()  # fetch the contents of the sink
     self.assertEqual(expected_result, actual_result)
Beispiel #8
0
 def test_diff_encdec_000(self):
     for modulus in (2, 4, 8):
         with self.subTest(modulus=modulus):
             src_data = make_random_int_list(40000, 0, modulus - 1)
             expected_result = src_data
             src = blocks.vector_source_b(src_data)
             enc = digital.diff_encoder_bb(modulus)
             dec = digital.diff_decoder_bb(modulus)
             dst = blocks.vector_sink_b()
             self.tb.connect(src, enc, dec, dst)
             self.tb.run()  # run the graph and wait for it to finish
             actual_result = dst.data()  # fetch the contents of the sink
             self.assertEqual(expected_result, actual_result)
    def test_encode(self):
        """Performs NRZI encode and checks the result"""
        encoder = digital.diff_encoder_bb(2, digital.DIFF_NRZI)

        self.tb.connect(self.source, encoder, self.sink)
        self.tb.start()
        self.tb.wait()

        expected = np.cumsum((1 ^ self.data) & 1) & 1

        np.testing.assert_equal(
            self.sink.data(), expected,
            'NRZI encode output does not match expected result')
Beispiel #10
0
 def test_diff_encdec_001(self):
     random.seed(0)
     modulus = 4
     src_data = make_random_int_tuple(1000, 0, modulus-1)
     expected_result = src_data
     src = blocks.vector_source_b(src_data)
     enc = digital.diff_encoder_bb(modulus)
     dec = digital.diff_decoder_bb(modulus)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, enc, dec, dst)
     self.tb.run()               # run the graph and wait for it to finish
     actual_result = dst.data()  # fetch the contents of the sink
     self.assertEqual(expected_result, actual_result)
    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", "corr_ultimapte_testing")
        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.rate = rate = 2
        self.polys = polys = [109, 79]
        self.nfilts = nfilts = 32
        self.k = k = 7
        self.eb = eb = 0.22
        self.vector = vector = [int(random.random() * 4) for i in range(49600)]
        self.variable_qtgui_range_1_0 = variable_qtgui_range_1_0 = 900
        self.variable_qtgui_range_1 = variable_qtgui_range_1 = 0
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 38
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50

        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[7]

        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, False)), range(0, 4))

        self.pld_dec = pld_dec = map((lambda a: fec.cc_decoder.make(
            440, k, rate, (polys), 0, -1, 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.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_1_range = Range(0, 5000, 1, 0, 200)
        self._variable_qtgui_range_1_win = RangeWidget(
            self._variable_qtgui_range_1_range,
            self.set_variable_qtgui_range_1, 'Delay JAMMING', "counter_slider",
            int)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_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._variable_qtgui_range_1_0_range = Range(0, 5000, 1, 900, 200)
        self._variable_qtgui_range_1_0_win = RangeWidget(
            self._variable_qtgui_range_1_0_range,
            self.set_variable_qtgui_range_1_0, 'Delay SIGNAL',
            "counter_slider", int)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_1_0_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._variable_qtgui_range_0_1_range = Range(0, 73, 1, 38, 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.qtgui_time_sink_x_2_0_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "MAG",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0_1.set_y_axis(-1, 200)

        self.qtgui_time_sink_x_2_0_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_2_0_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_2_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 0, 0, "")
        self.qtgui_time_sink_x_2_0_1.enable_autoscale(False)
        self.qtgui_time_sink_x_2_0_1.enable_grid(False)
        self.qtgui_time_sink_x_2_0_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_2_0_1.enable_control_panel(False)
        self.qtgui_time_sink_x_2_0_1.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_2_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_2_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_2_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_1_win)
        self.qtgui_time_sink_x_2_0_0_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "Without MAG",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2_0_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0_0_1.set_y_axis(-1, 15)

        self.qtgui_time_sink_x_2_0_0_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_2_0_0_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_2_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_2_0_0_1.enable_autoscale(False)
        self.qtgui_time_sink_x_2_0_0_1.enable_grid(False)
        self.qtgui_time_sink_x_2_0_0_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_2_0_0_1.enable_control_panel(False)
        self.qtgui_time_sink_x_2_0_0_1.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_2_0_0_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_2_0_0_1.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_2_0_0_1.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_2_0_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_0_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_0_1_win)
        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, 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_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_freq_sink_x_1 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_1.set_plot_pos_half(not True)

        labels = ['OUT', 'ERROR', 'Output', '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(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 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_1_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Difference Between ORIGINAL/RECOVERED",  #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 chunks to symbols', '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, 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_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,
                                       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_ccc(
            sps, taps=(tx_rrc_taps), flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(sps, ([1]))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector))
        self.digital_pfb_clock_sync_xxx_0_0_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_diff_encoder_bb_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 = digital.costas_loop_cc(
            6.28 / 100, 4, 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_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.custom_corr = correlate_and_delay.corr_and_delay(
            200 * sps, 0, 0.99, sps)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_stream_to_streams_0 = blocks.stream_to_streams(
            gr.sizeof_float * 1, 2)
        self.blocks_stream_mux_1_0 = blocks.stream_mux(gr.sizeof_float * 1,
                                                       (1, 1))
        self.blocks_stream_mux_1 = blocks.stream_mux(gr.sizeof_float * 1,
                                                     (1, 1))
        self.blocks_stream_mux_0_1_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (96, 896))
        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_0_1 = blocks.repack_bits_bb(
            1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_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 = blocks.multiply_const_vcc((0.3, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        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_delay_0_0_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                               variable_qtgui_range_1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 900)
        self.blocks_complex_to_mag_squared_0_1_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        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_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 0)
        self.adapt_lms_filter_xx_0 = adapt.lms_filter_ff(
            True, 32, 0.0001, 0, 1, True, False, False)
        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.adapt_lms_filter_xx_0, 1),
                     (self.blocks_stream_to_streams_0, 0))
        self.connect((self.adapt_lms_filter_xx_0, 1),
                     (self.qtgui_freq_sink_x_1, 1))
        self.connect((self.adapt_lms_filter_xx_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_delay_0_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_complex_to_float_0, 1),
                     (self.blocks_stream_mux_1, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_stream_mux_1, 0))
        self.connect((self.blocks_complex_to_float_0_0, 1),
                     (self.blocks_stream_mux_1_0, 1))
        self.connect((self.blocks_complex_to_float_0_0, 0),
                     (self.blocks_stream_mux_1_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_1_0, 0),
                     (self.qtgui_time_sink_x_2_0_1, 0))
        self.connect((self.blocks_delay_0_0, 0), (self.custom_corr, 1))
        self.connect((self.blocks_delay_0_0_0, 0), (self.custom_corr, 0))
        self.connect((self.blocks_file_source_0_0_1_0, 0),
                     (self.blocks_char_to_float_1_0_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_float_to_complex_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_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_time_sink_x_1, 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),
                     (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.blocks_file_sink_0_0_0_2, 0))
        self.connect((self.blocks_repack_bits_bb_0_1, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0),
                     (self.blocks_stream_mux_0_1_0, 1))
        self.connect((self.blocks_stream_mux_0_1_0, 0),
                     (self.blocks_repack_bits_bb_0_1, 0))
        self.connect((self.blocks_stream_mux_1, 0),
                     (self.adapt_lms_filter_xx_0, 1))
        self.connect((self.blocks_stream_mux_1_0, 0),
                     (self.adapt_lms_filter_xx_0, 0))
        self.connect((self.blocks_stream_to_streams_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_stream_to_streams_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_throttle_0, 0),
                     (self.insert_vec_cpp_new_vec_0, 0))
        self.connect((self.custom_corr, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.custom_corr, 1),
                     (self.blocks_complex_to_float_0_0, 0))
        self.connect((self.custom_corr, 2),
                     (self.blocks_complex_to_mag_squared_0_1_0, 0))
        self.connect((self.custom_corr, 2),
                     (self.qtgui_time_sink_x_2_0_0_1, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.qtgui_freq_sink_x_0_0_1_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_freq_sink_x_0_0_1_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),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.insert_vec_cpp_new_vec_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.blocks_delay_0_0_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
Beispiel #12
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Rds Tx")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.usrp_rate = usrp_rate = 19e3 * 20
        self.stereo_gain = stereo_gain = .3
        self.rt = rt = ""
        self.rds_gain = rds_gain = .27
        self.ps = ps = "Part 3/3"
        self.pilot_gain = pilot_gain = .09
        self.outbuffer = outbuffer = 10
        self.input_gain = input_gain = .3
        self.freq = freq = 87.5e6
        self.fm_max_dev = fm_max_dev = 80e3

        ##################################################
        # Blocks
        ##################################################
        self._rt_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.rt,
            callback=self.set_rt,
            label='RadioText',
            converter=forms.str_converter(),
        )
        self.Add(self._rt_text_box)
        _rds_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rds_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rds_gain_sizer,
            value=self.rds_gain,
            callback=self.set_rds_gain,
            label='rds_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rds_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rds_gain_sizer,
            value=self.rds_gain,
            callback=self.set_rds_gain,
            minimum=0,
            maximum=3,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rds_gain_sizer)
        self._ps_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.ps,
            callback=self.set_ps,
            label='PS',
            converter=forms.str_converter(),
        )
        self.Add(self._ps_text_box)
        _pilot_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pilot_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_pilot_gain_sizer,
            value=self.pilot_gain,
            callback=self.set_pilot_gain,
            label='pilot_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pilot_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_pilot_gain_sizer,
            value=self.pilot_gain,
            callback=self.set_pilot_gain,
            minimum=0,
            maximum=3,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_pilot_gain_sizer)
        _input_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._input_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_input_gain_sizer,
            value=self.input_gain,
            callback=self.set_input_gain,
            label='input_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._input_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_input_gain_sizer,
            value=self.input_gain,
            callback=self.set_input_gain,
            minimum=0,
            maximum=10,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_input_gain_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=20,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=usrp_rate,
            fft_size=1024,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        _stereo_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._stereo_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_stereo_gain_sizer,
            value=self.stereo_gain,
            callback=self.set_stereo_gain,
            label='stereo_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._stereo_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_stereo_gain_sizer,
            value=self.stereo_gain,
            callback=self.set_stereo_gain,
            minimum=0,
            maximum=3,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_stereo_gain_sizer)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1000,
            decimation=380,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=380,
            decimation=16,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=380,
            decimation=16,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0_0_0 = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(1, usrp_rate, 2.5e3, .5e3, firdes.WIN_HAMMING,
                            6.76))
        (self.low_pass_filter_0).set_max_output_buffer(10)
        self.gr_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        (self.gr_unpack_k_bits_bb_0).set_max_output_buffer(10)
        self.gr_sub_xx_0 = blocks.sub_ff(1)
        self.gr_sig_source_x_0_1 = analog.sig_source_f(usrp_rate,
                                                       analog.GR_SIN_WAVE,
                                                       19e3, 1, 0)
        self.gr_sig_source_x_0_0 = analog.sig_source_f(usrp_rate,
                                                       analog.GR_SIN_WAVE,
                                                       57e3, 1, 0)
        self.gr_sig_source_x_0 = analog.sig_source_f(usrp_rate,
                                                     analog.GR_SIN_WAVE, 38e3,
                                                     1, 0)
        self.gr_rds_encoder_0 = rds.encoder(0, 14, True, ps, 89.8e6, True,
                                            False, 6, 1, 147, rt)

        (self.gr_rds_encoder_0).set_max_output_buffer(10)
        self.gr_multiply_xx_1 = blocks.multiply_vff(1)
        self.gr_multiply_xx_0 = blocks.multiply_vff(1)
        (self.gr_multiply_xx_0).set_max_output_buffer(10)
        self.gr_map_bb_1 = digital.map_bb(([1, 2]))
        (self.gr_map_bb_1).set_max_output_buffer(10)
        self.gr_map_bb_0 = digital.map_bb(([-1, 1]))
        (self.gr_map_bb_0).set_max_output_buffer(10)
        self.gr_frequency_modulator_fc_0 = analog.frequency_modulator_fc(
            2 * math.pi * fm_max_dev / usrp_rate)
        (self.gr_frequency_modulator_fc_0).set_max_output_buffer(10)
        self.gr_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        (self.gr_diff_encoder_bb_0).set_max_output_buffer(10)
        self.gr_char_to_float_0 = blocks.char_to_float(1, 1)
        (self.gr_char_to_float_0).set_max_output_buffer(10)
        self.gr_add_xx_1 = blocks.add_vff(1)
        (self.gr_add_xx_1).set_max_output_buffer(10)
        self.gr_add_xx_0 = blocks.add_vff(1)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/deepstar/Projects/OverTheWire/advent2019/advent2019/steven/santa-radio/part3/part3-new.wav',
            False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '', '52001',
                                                     10000, False)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, 160)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff(
            (input_gain, ))
        self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_vff(
            (pilot_gain, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (rds_gain, ))
        (self.blocks_multiply_const_vxx_0_0).set_max_output_buffer(10)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (input_gain, ))
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 1,
            '/home/deepstar/Projects/OverTheWire/advent2019/advent2019/steven/santa-radio/part3/fm3-small.wav',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.audio_sink_0 = audio.sink(16000, '', True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.gr_rds_encoder_0, 'rds in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.gr_add_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_1, 0),
                     (self.gr_add_xx_1, 1))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.gr_add_xx_1, 0),
                     (self.gr_frequency_modulator_fc_0, 0))
        self.connect((self.gr_add_xx_1, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.gr_char_to_float_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0))
        self.connect((self.gr_frequency_modulator_fc_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0))
        self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0))
        self.connect((self.gr_multiply_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.gr_multiply_xx_1, 0), (self.gr_add_xx_1, 2))
        self.connect((self.gr_rds_encoder_0, 0),
                     (self.gr_diff_encoder_bb_0, 0))
        self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 0))
        self.connect((self.gr_sig_source_x_0_0, 0), (self.gr_multiply_xx_0, 0))
        self.connect((self.gr_sig_source_x_0_1, 0),
                     (self.blocks_multiply_const_vxx_0_0_1, 0))
        self.connect((self.gr_sub_xx_0, 0), (self.low_pass_filter_0_0_0, 0))
        self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 1))
        self.connect((self.low_pass_filter_0_0, 0), (self.gr_add_xx_1, 3))
        self.connect((self.low_pass_filter_0_0_0, 0),
                     (self.gr_multiply_xx_1, 1))
        self.connect((self.rational_resampler_xxx_0, 0), (self.gr_add_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.gr_sub_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.gr_add_xx_0, 1))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.gr_sub_xx_0, 1))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_file_sink_0, 0))
Beispiel #13
0
    def __init__(self):
        gr.hier_block2.__init__(
            self, "Hier Tx Ch Rx",
            gr.io_signature(1, 1, gr.sizeof_char*1),
            gr.io_signature(1, 1, gr.sizeof_char*1),
        )

        ##################################################
        # Variables
        ##################################################
        self.samp_per_sym = samp_per_sym = 3
        self.n_filts = n_filts = 32
        self.len_sym_srrc = len_sym_srrc = 7
        self.alfa = alfa = 0.35
        self.pulso = pulso = firdes.root_raised_cosine(samp_per_sym,samp_per_sym,1.0,alfa,samp_per_sym*len_sym_srrc)
        self.gain = gain = 15
        self.frec = frec = 850e3
        self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts)
        self.bits_per_sym = bits_per_sym = 2

        ##################################################
        # Blocks
        ##################################################
        self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf(
        	  samp_per_sym,
        	  (pulso),
        	  100)
        	
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, 2*math.pi/100, (filtro_srrc), n_filts, 16, 5, 1)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, math.pi/1600)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2**bits_per_sym)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym)
        self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(2*math.pi/100, 2**bits_per_sym)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base())
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(([-1-1j,1-1j, 1+1j, -1+1j]), 1)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=0.0,
        	frequency_offset=0.0,
        	epsilon=1.00,
        	taps=(1+0.5j, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bits_per_sym, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.4, ))
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=samp_per_sym,
        		bits_per_symbol=bits_per_sym,
        		preamble="",
        		access_code="",
        		pad_for_usrp=True,
        	),
        	payload_length=1,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.pfb_interpolator_ccf_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_interpolator_ccf_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.channels_channel_model_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_packet_decoder_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0), (self, 0))
        self.connect((self, 0), (self.blks2_packet_encoder_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0_0, 0))
Beispiel #14
0
    def __init__(self, address='serial=30AD34D'):
        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.address = address

        ##################################################
        # Variables
        ##################################################
        self.const_type = const_type = 1
        self.bits_per_symbol = bits_per_symbol = int(const_type + 1)
        self.samples_per_symbol = samples_per_symbol = int(2 *
                                                           (bits_per_symbol))
        self.nfilts = nfilts = 32
        self.bitrate = bitrate = 64e3
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = {
            0: 'BPSK',
            1: 'QPSK',
            2: '8-PSK'
        }[const_type] + " - Change const_type for different constellation types!"
        self.tun_gain_tx = tun_gain_tx = 40
        self.tun_freq_tx = tun_freq_tx = 2.39e9
        self.samp_rate = samp_rate = samples_per_symbol * bitrate
        self.ntaps = ntaps = 11 * int(samples_per_symbol * nfilts)
        self.excess_bw = excess_bw = 0.35
        self.constellation = constellation = (digital.constellation_bpsk(),
                                              digital.constellation_qpsk(),
                                              digital.constellation_8psk())
        self.arrity = arrity = pow(2, bits_per_symbol)
        self.ampl = ampl = 0.7

        ##################################################
        # Blocks
        ##################################################
        self._tun_gain_tx_range = Range(0, 80, 1, 40, 200)
        self._tun_gain_tx_win = RangeWidget(self._tun_gain_tx_range,
                                            self.set_tun_gain_tx,
                                            'UHD Tx Gain', "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._tun_gain_tx_win, 1, 0, 1, 1)
        self._tun_freq_tx_range = Range(2.3e9, 2.5e9, 1, 2.39e9, 200)
        self._tun_freq_tx_win = RangeWidget(self._tun_freq_tx_range,
                                            self.set_tun_freq_tx,
                                            'UHD Tx Freq (Hz)',
                                            "counter_slider", float)
        self.top_grid_layout.addWidget(self._tun_freq_tx_win, 0, 0, 1, 1)
        self._const_type_options = (
            0,
            1,
            2,
        )
        self._const_type_labels = (
            'DBPSK',
            'DQPSK',
            'D8PSK',
        )
        self._const_type_tool_bar = Qt.QToolBar(self)
        self._const_type_tool_bar.addWidget(Qt.QLabel("const_type" + ": "))
        self._const_type_combo_box = Qt.QComboBox()
        self._const_type_tool_bar.addWidget(self._const_type_combo_box)
        for label in self._const_type_labels:
            self._const_type_combo_box.addItem(label)
        self._const_type_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._const_type_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._const_type_options.index(i)))
        self._const_type_callback(self.const_type)
        self._const_type_combo_box.currentIndexChanged.connect(
            lambda i: self.set_const_type(self._const_type_options[i]))
        self.top_layout.addWidget(self._const_type_tool_bar)
        self._ampl_range = Range(0, 1, 0.01, 0.7, 200)
        self._ampl_win = RangeWidget(self._ampl_range, self.set_ampl,
                                     'Amplitude', "counter_slider", float)
        self.top_grid_layout.addWidget(self._ampl_win, 2, 0, 1, 1)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_formatter = None
        else:
            self._variable_qtgui_label_0_formatter = lambda x: str(x)

        self._variable_qtgui_label_0_tool_bar.addWidget(
            Qt.QLabel('Constellation Type' + ": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_formatter(
                    self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_label)
        self.top_layout.addWidget(self._variable_qtgui_label_0_tool_bar)

        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join((address, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_subdev_spec('A:B', 0)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(tun_freq_tx, 0)
        self.uhd_usrp_sink_0_0.set_gain(tun_gain_tx, 0)
        self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            samples_per_symbol,
            taps=(firdes.root_raised_cosine(nfilts, nfilts, 1.0, 0.35, ntaps)),
            flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x8A, 0x7F, 7)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(arrity)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (constellation[const_type].points()), 1)
        self.blocks_vector_source_x_0 = blocks.vector_source_b([
            1,
        ], True, 1, [])
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(bits_per_symbol)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((ampl, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.uhd_usrp_sink_0_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_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))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_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):
        grc_wxgui.top_block_gui.__init__(self, title="Packet Encoder Decoder By Aaron")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0
        self.samp_rate_0 = samp_rate_0 = 1000000
        self.samp_rate = samp_rate = 32E3
        self.rx_gain = rx_gain = 0
        self.rfgain = rfgain = 0
        self.code2 = code2 = '11011010110111011000110011110101100010010011110111'
        self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001'
        self.center_freq = center_freq = 1250000
        self.band_w = band_w = 75000

        ##################################################
        # Blocks
        ##################################################
        self.serial_port_0 = grpyserial.serial_port('/dev/ttyUSB0',0,9600,0,1,False)
        _rfgain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rfgain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rfgain_sizer,
        	value=self.rfgain,
        	callback=self.set_rfgain,
        	label='rfgain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rfgain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rfgain_sizer,
        	value=self.rfgain,
        	callback=self.set_rfgain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_rfgain_sizer)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/home/vmatusic/Documents/VLC/gnuradio_codes/CSNDSP/received_data_Aaron.txt', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blks2_packet_encoder_0_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=1,
        		bits_per_symbol=1,
        		preamble='',
        		access_code=code1,
        		pad_for_usrp=False,
        	),
        	payload_length=4,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code=code1,
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.analog_const_source_x_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.serial_port_0, 0))    
        self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blks2_packet_encoder_0_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))    
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blks2_packet_encoder_0_0, 0))    
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blks2_packet_decoder_0, 0))    
        self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_diff_decoder_bb_0, 0))    
        self.connect((self.serial_port_0, 0), (self.blocks_throttle_0, 0))    
    def __init__(self, freq):
        gr.top_block.__init__(self, "Burst Transmitter")

        ##################################################
        # Variables
        ##################################################
        self.tsh = tsh = 0
        self.sps = sps = 4
        self.nfilts = nfilts = 64
        self.eb = eb = .700
        self.usrp_rate = usrp_rate = 500e3

        self.psf_taps = psf_taps = firdes.root_raised_cosine(
            nfilts / 1.5, nfilts, 1.0, eb, 5 * sps * nfilts)

        self.pld_cons = pld_cons = digital.constellation_calcdist(
            ([-1, 1]), ([0, 1]), 4, 1).base()

        self.hdr_cons = hdr_cons = digital.constellation_calcdist(
            ([-1, 1]), ([0, 1]), 2, 1).base()

        self.freq = freq

        self.format_0 = format_0 = digital.header_format_default(
            digital.packet_utils.default_access_code, tsh)

        self.b_ntaps = b_ntaps = 50

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            "packet_len",
        )
        self.uhd_usrp_sink_0.set_samp_rate(usrp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(0, 0)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps,
                                                             taps=(psf_taps),
                                                             flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, usrp_rate, usrp_rate / sps * 1.4, 10e3,
                            firdes.WIN_KAISER, 6.76))
        self.digital_protocol_formatter_async_0 = digital.protocol_formatter_async(
            format_0)
        self.digital_map_bb_0_0 = digital.map_bb((pld_cons.pre_diff_code()))
        self.digital_map_bb_0 = digital.map_bb((hdr_cons.pre_diff_code()))
        self.digital_diff_encoder_bb_0_0 = digital.diff_encoder_bb(
            pld_cons.arity())
        self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (pld_cons.points()), pld_cons.dimensionality())
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (hdr_cons.points()), hdr_cons.dimensionality())
        self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc(
            (firdes.window(firdes.WIN_HANN, b_ntaps, 0)), 10, 20, True,
            "packet_len")
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, "packet_len", 0)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, "packet_len", sps)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '127.0.0.1',
                                                     '52001', 10000, False)
        self.blocks_repack_bits_bb_2 = blocks.repack_bits_bb(
            8, 1, "packet_len", False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb(
            8, 1, "packet_len", False, gr.GR_MSB_FIRST)
        self.blocks_pdu_to_tagged_stream_1_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.digital_crc32_async_bb_0, 'in'))
        self.msg_connect((self.digital_crc32_async_bb_0, 'out'),
                         (self.digital_protocol_formatter_async_0, 'in'))
        self.msg_connect((self.digital_protocol_formatter_async_0, 'payload'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.digital_protocol_formatter_async_0, 'header'),
                         (self.blocks_pdu_to_tagged_stream_1_0, 'pdus'))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.blocks_repack_bits_bb_2, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1_0, 0),
                     (self.blocks_repack_bits_bb_1, 0))
        self.connect((self.blocks_repack_bits_bb_1, 0),
                     (self.digital_map_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_2, 0),
                     (self.digital_map_bb_0_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_burst_shaper_xx_0, 0))
        self.connect((self.digital_burst_shaper_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.digital_diff_encoder_bb_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_map_bb_0_0, 0),
                     (self.digital_diff_encoder_bb_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))
    def __init__(self, principal_gui, options):
        gr.hier_block2.__init__(self, "bpsk_mod",
                                gr.io_signature(1, 1, gr.sizeof_char),       # Input signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
        
        self._samples_per_symbol = options.sps
        self.amplitude = options.amplitude
        self.verbose = options.verbose
        
        self._excess_bw = _def_excess_bw
        self._gray_code = _def_gray_code

        if not isinstance(self._samples_per_symbol, int) or self._samples_per_symbol < 2:
            raise TypeError, ("sample per symbol must be an integer >= 2, is %d" % self._samples_per_symbol)
    

        arity = pow(2,self.bits_per_symbol())
        
        #arity = pow (2, 2)
        # turn bytes into k-bit vectors
        self.packed_to_unpacked_bb = \
            blocks.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)

        if self._gray_code:
            map_param = psk.binary_to_gray[arity]
            self.symbol_mapper = digital.map_bb(map_param)
        else:
            self.symbol_mapper = digital.map_bb(psk.binary_to_ungray[arity])
        self.diff_encoder_bb = digital.diff_encoder_bb(arity)
            
        #This bloc allow to decode the stream
        #self.scrambler = gr.scrambler_bb(0x8A, 0x7F, 7)
        
        #Transform symbols to chips
        self.symbols_to_chips = ieee_868_915.symbols_to_chips_bs()

        #self.chunks2symbols = gr.chunks_to_symbols_ic(psk.constellation[arity])
        self.chunks2symbols = digital.chunks_to_symbols_sc([-1+0j, 1+0j])
        self.chunks2symbols_b = digital.chunks_to_symbols_bc([-1+0j, 1+0j])
        
        # transform chips to symbols
        print "bits_per_symbol", self.bits_per_symbol()
        self.packed_to_unpacked_ss = \
          blocks.packed_to_unpacked_ss(self.bits_per_symbol(), gr.GR_MSB_FIRST)

        ntaps = 11 * self._samples_per_symbol
        # pulse shaping filter
        self.rrc_taps = filter.firdes.root_raised_cosine(
                                                     self._samples_per_symbol,   # gain (samples_per_symbol since we're
                                                                                 # interpolating by samples_per_symbol)
                                                     self._samples_per_symbol,   # sampling rate
                                                     1.0,                # symbol rate
                                                     self._excess_bw,            # excess bandwidth (roll-off factor)
                                                     ntaps)
        self.rrc_filter = filter.interp_fir_filter_ccf(self._samples_per_symbol,
                                                   self.rrc_taps)

        # Connect
        #self.connect(self, self.bytes2chunks, self.symbol_mapper,self.scrambler, self.chunks2symbols, self.rrc_filter, self)
   
        #Modefied for IEEE 802.15.4
        #self.connect(self, self.packed_to_unpacked_bb, self.symbol_mapper, self.diff_encoder_bb, self.symbols_to_chips, self.packed_to_unpacked_ss,  self.chunks2symbols, self.rrc_filter, self)
        
        #For IEEE 802.15.4 915 868 MHz standard 
        self.connect(self, self.packed_to_unpacked_bb, self.symbol_mapper, self.symbols_to_chips, self.packed_to_unpacked_ss,  self.chunks2symbols, self.rrc_filter, self)
        
        
        #self.connect(self, self.symbols_to_chips, self.packed_to_unpacked_ss,  self.chunks2symbols, self.rrc_filter, self)
        #self.connect(self, self.packed_to_unpacked_ss,  self.chunks2symbols, self.rrc_filter, self)
        
        #case when we use a stream of bits
        #self.connect(self, self.chunks2symbols_b, self.rrc_filter, self)


        if self.verbose:
            self._print_verbage()
Beispiel #19
0
    def __init__(self):
        gr.top_block.__init__(self, "Psk Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Psk Rx")
        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", "psk_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 2
        self.samp_rate = samp_rate = 1e6
        self.my_constellation = my_constellation = digital.constellation_calcdist(([-1,1]), ([0, 1]), 2, 1).base()
        self.freq = freq = 2.4e9

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_sink_x_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	freq, #fc
        	samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0/10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)
        
        self.qtgui_sink_x_0.enable_rf_freq(False)
        
        
          
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "hackrf=0x000000000x000000000x457863c80x320c831f" )
        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(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 6.28/100.0, (filter.firdes.root_raised_cosine(32,32*sps,1.0,0.35,11*32*sps)), 32, 16, 1.5, 1)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, 0.35, 55, 6.28/100.0)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(my_constellation, 6.28/100.0, -0.25, 0.25)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/ubuntu/recv.b", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_c(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.analog_agc2_xx_0 = analog.agc2_cc(0.06, 0.001, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0))    
        self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_packet_decoder_0, 0))    
        self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_diff_encoder_bb_0, 0))    
        self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))    
        self.connect((self.digital_fll_band_edge_cc_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.osmosdr_source_0, 0), (self.analog_agc2_xx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_sink_x_0, 0))    
Beispiel #20
0
    def __init__(self):
        gr.top_block.__init__(self, "Psk Low Rate")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Psk Low Rate")
        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", "psk_low_rate")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48e3
        self.baudrate = baudrate = 1200
        self.subcarrier = subcarrier = 1.5e3
        self.sps = sps = int(samp_rate) / baudrate
        self.rx_sps = rx_sps = 2

        self.psk_const = psk_const = digital.constellation_bpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(
            1,
            firdes.root_raised_cosine(1, rx_sps * 1.0, 1.0, 0.35, 64 * rx_sps))
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, sps * 1.0, 1.0, 0.35, 11 * sps))
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=baudrate * rx_sps,
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            baudrate * rx_sps,  #bw
            "",  #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(-80, 0)
        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(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not False:
            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, 1,
                                       1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-100, 0)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1,
                                       2)
        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)

        if not False:
            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,
                                       1)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (1, ), subcarrier, samp_rate)
        self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(
            16, 0.05, 1, psk_const)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            6.28 / 200, 2, False)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(
            rx_sps * (1 + 0.0), 0.25 * 0.02 * 0.02, 0.5, 0.02, 0.005)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (1, -1), 1)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0.2,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(0.5 + 0.5j, ),
            noise_seed=0,
            block_tags=False)
        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_rotator_cc_0 = blocks.rotator_cc(
            (subcarrier / samp_rate) * 2 * math.pi)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, sps)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 256, 1000)), True)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=int(samp_rate),
            quad_rate=int(samp_rate),
            tau=75e-6,
            max_dev=5e3,
            fh=-1.0,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=int(samp_rate),
            quad_rate=int(samp_rate),
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_lms_dd_equalizer_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.root_raised_cosine_filter_1, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.blocks_rotator_cc_0, 0))
        self.connect((self.root_raised_cosine_filter_1, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Not titled yet", catch_exceptions=True)
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Not titled yet")
        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", "TextStreaming")

        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.nfilts = nfilts = 32
        self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0
        self.time_offset = time_offset = 1.00
        self.taps = taps = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j]
        self.samp_rate = samp_rate = 960e3
        self.qpsk = qpsk = digital.constellation_rect(
            [-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j], [0, 1, 2, 3], 4, 2, 2, 1,
            1).base()
        self.noise_volt = noise_volt = 0.0001
        self.freq_offset = freq_offset = 0
        self.RRC_filter_taps = RRC_filter_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, 350e-3, 5 * 40 * 32)

        ##################################################
        # Blocks
        ##################################################
        self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200)
        self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range,
                                               self.set_timing_loop_bw,
                                               'Time: BW', "slider", float,
                                               QtCore.Qt.Horizontal)
        self.top_grid_layout.addWidget(self._timing_loop_bw_win)
        self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range,
                                            self.set_time_offset,
                                            'Timing Offset', "counter_slider",
                                            float, QtCore.Qt.Horizontal)
        self.top_grid_layout.addWidget(self._time_offset_win)
        self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200)
        self._noise_volt_win = RangeWidget(self._noise_volt_range,
                                           self.set_noise_volt,
                                           'Noise Voltage', "counter_slider",
                                           float, QtCore.Qt.Horizontal)
        self.top_grid_layout.addWidget(self._noise_volt_win)
        self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range,
                                            self.set_freq_offset,
                                            'Frequency Offset',
                                            "counter_slider", float,
                                            QtCore.Qt.Horizontal)
        self.top_grid_layout.addWidget(self._freq_offset_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            2,  #number of inputs
            None  # parent
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(0, 300)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        labels = [
            'Tx', 'Rx', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6',
            'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
            1024,  #size
            "Tx",  #name
            1,  #number of inputs
            None  # parent
        )
        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)
        self.qtgui_const_sink_x_1.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_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_grid_layout.addWidget(self._qtgui_const_sink_x_1_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "Rx",  #name
            1,  #number of inputs
            None  # parent
        )
        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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            2, taps=RRC_filter_taps, flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(
            2, timing_loop_bw, RRC_filter_taps, nfilts, nfilts / 2, 1.5, 2)
        self.digital_map_bb_0_0 = digital.map_bb([0, 1, 2, 3])
        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 = digital.costas_loop_cc(
            62.8e-3, 4, False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            qpsk)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, 10e-3, 2)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            [-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j], 1)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise_volt,
            frequency_offset=freq_offset,
            epsilon=time_offset,
            taps=taps,
            noise_seed=0,
            block_tags=False)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            2, gr.GR_MSB_FIRST)
        self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float()
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            2, gr.GR_MSB_FIRST)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, 'C:\\Users\\patri\\Desktop\\test.txt', True, 0,
            0)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, 'C:\\Users\\patri\\Desktop\\txt2.txt', False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_uchar_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_uchar_to_float_0_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.qtgui_const_sink_x_1, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.digital_map_bb_0_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_map_bb_0_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_throttle_0, 0))
Beispiel #22
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, 200000
        ]
        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.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 30
        self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 53
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 43
        self.variable_qtgui_entry_0 = variable_qtgui_entry_0 = 0.5

        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.rate = rate = 2
        self.polys = polys = [109, 79]

        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)
        self.k = k = 7
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 30, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0,
                                       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._variable_qtgui_range_0_0_range = Range(0, 90, 1, 53, 200)
        self._variable_qtgui_range_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_range,
            self.set_variable_qtgui_range_0_0, 'Gain_Jamming',
            "counter_slider", float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0,
                                       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, 43, 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._variable_qtgui_entry_0_tool_bar = Qt.QToolBar(self)
        self._variable_qtgui_entry_0_tool_bar.addWidget(
            Qt.QLabel('mult' + ": "))
        self._variable_qtgui_entry_0_line_edit = Qt.QLineEdit(
            str(self.variable_qtgui_entry_0))
        self._variable_qtgui_entry_0_tool_bar.addWidget(
            self._variable_qtgui_entry_0_line_edit)
        self._variable_qtgui_entry_0_line_edit.returnPressed.connect(
            lambda: self.set_variable_qtgui_entry_0(
                eng_notation.str_to_num(
                    str(self._variable_qtgui_entry_0_line_edit.text().toAscii(
                    )))))
        self.top_grid_layout.addWidget(self._variable_qtgui_entry_0_tool_bar)
        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_unknown_pps(uhd.time_spec())
        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('TX/RX', 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.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAC0", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.scrambler_cpp_custom_scrambler_0 = scrambler_cpp.custom_scrambler(
            0x8A, 0x7F, 7, 440 - 32)
        self.scrambler_cpp_custom_descrambler_0 = scrambler_cpp.custom_descrambler(
            0x8A, 0x7F, 7, 440 - 32)
        self.qtgui_time_sink_x_2_0_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "MAG",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0_1.set_y_axis(-1, 200)

        self.qtgui_time_sink_x_2_0_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_2_0_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_2_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 0, 0, "")
        self.qtgui_time_sink_x_2_0_1.enable_autoscale(False)
        self.qtgui_time_sink_x_2_0_1.enable_grid(False)
        self.qtgui_time_sink_x_2_0_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_2_0_1.enable_control_panel(False)
        self.qtgui_time_sink_x_2_0_1.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_2_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_2_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_2_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_1_win, 7, 1,
                                       1, 1)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_2_0_0_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "Without MAG",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2_0_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0_0_1.set_y_axis(-1, 15)

        self.qtgui_time_sink_x_2_0_0_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_2_0_0_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_2_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_2_0_0_1.enable_autoscale(False)
        self.qtgui_time_sink_x_2_0_0_1.enable_grid(False)
        self.qtgui_time_sink_x_2_0_0_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_2_0_0_1.enable_control_panel(False)
        self.qtgui_time_sink_x_2_0_0_1.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_2_0_0_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_2_0_0_1.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_2_0_0_1.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_2_0_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_0_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_0_1_win, 6,
                                       0, 1, 1)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "RX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_1_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1_1.enable_grid(False)
        self.qtgui_time_sink_x_1_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_1.enable_control_panel(False)
        self.qtgui_time_sink_x_1_1.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_1_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_1.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_1_1.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_1_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_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_time_sink_x_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX JAMMING USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_1_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_0.enable_control_panel(False)
        self.qtgui_time_sink_x_1_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_1_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_1_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX DATA 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, 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_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_0_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_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, 10, 2,
                                       1, 1)
        for r in range(10, 11):
            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 = pfb.arb_resampler_ccc(
            sps, taps=(tx_rrc_taps), flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(
            4, ([1, 0, 0, 0]))
        self.interp_fir_filter_xxx_1.declare_sample_delay(0)
        self.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.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_0_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_map_bb_0_0_0_0_0_0 = digital.map_bb(([-1, 1]))
        self.digital_diff_encoder_bb_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 = digital.costas_loop_cc(
            6.28 / 100, 4, 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_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.custom_corr = correlate_and_delay.corr_and_delay(
            200 * sps, 0, 0.99, sps)
        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_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb(
            1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc(
            (variable_qtgui_entry_0, ))
        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_1 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/andre/Desktop/Files_To_Transmit/book.txt', False)
        self.blocks_file_source_0_0_1_0_1.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_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 500000)
        self.blocks_complex_to_mag_squared_0_1_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_2_0_0_0 = blocks.char_to_float(1, 1)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, -5)
        self.adapt_lms_filter_xx_0_0 = adapt.lms_filter_cc(
            True, 32, 0.0001, 0, 1, True, False, False)
        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.adapt_lms_filter_xx_0_0, 0),
                     (self.blocks_null_sink_0_0, 0))
        self.connect((self.adapt_lms_filter_xx_0_0, 1),
                     (self.digital_pfb_clock_sync_xxx_0_0_0, 0))
        self.connect((self.analog_noise_source_x_0_0, 0),
                     (self.interp_fir_filter_xxx_1, 0))
        self.connect((self.blocks_char_to_float_0_2_0_0_0, 0),
                     (self.fec_extended_decoder_0_0_1_0_1_0_0, 0))
        self.connect((self.blocks_char_to_float_1_0_1, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_1_0, 0),
                     (self.qtgui_time_sink_x_2_0_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_1, 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_custom_descrambler_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_delay_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, 0),
                     (self.custom_corr, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.uhd_usrp_sink_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),
                     (self.insert_vec_cpp_new_vec_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0),
                     (self.scrambler_cpp_custom_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.custom_corr, 0), (self.adapt_lms_filter_xx_0_0, 1))
        self.connect((self.custom_corr, 1), (self.adapt_lms_filter_xx_0_0, 0))
        self.connect((self.custom_corr, 2),
                     (self.blocks_complex_to_mag_squared_0_1_0, 0))
        self.connect((self.custom_corr, 2),
                     (self.qtgui_time_sink_x_2_0_0_1, 0))
        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, 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),
                     (self.digital_constellation_decoder_cb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1_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, 0),
                     (self.blocks_char_to_float_0_2_0_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0_0, 0),
                     (self.digital_costas_loop_cc_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),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.interp_fir_filter_xxx_1, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.scrambler_cpp_custom_descrambler_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0_1_0, 0))
        self.connect((self.scrambler_cpp_custom_scrambler_0, 0),
                     (self.blocks_stream_mux_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.custom_corr, 1))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_time_sink_x_1_1, 0))
Beispiel #23
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[15]

        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.copy = copy = True
        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)
        _copy_check_box = Qt.QCheckBox("copy")
        self._copy_choices = {True: True, False: False}
        self._copy_choices_inv = dict(
            (v, k) for k, v in self._copy_choices.iteritems())
        self._copy_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _copy_check_box, "setChecked",
            Qt.Q_ARG("bool", self._copy_choices_inv[i]))
        self._copy_callback(self.copy)
        _copy_check_box.stateChanged.connect(
            lambda i: self.set_copy(self._copy_choices[bool(i)]))
        self.top_grid_layout.addWidget(_copy_check_box, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_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_unknown_pps(uhd.time_spec())
        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_packets_same_seed_scramble_packetize_0 = scrambler_packets_same_seed.scramble_packetize(
            0x8A, 0x7F, 7, 440)
        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_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_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(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.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1)
        self.blocks_copy_0.set_enabled(copy)
        self.blocks_char_to_float_1_0_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_1_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_copy_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_file_source_0_0_1_0, 0),
                     (self.blocks_char_to_float_1_0_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.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_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_packets_same_seed_scramble_packetize_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_copy_0, 0))
        self.connect(
            (self.scrambler_packets_same_seed_scramble_packetize_0, 0),
            (self.fec_extended_encoder_0, 0))
Beispiel #24
0
    def __init__(self, EbN0, viterbi=False):
        gr.top_block.__init__(self)

        self.sps = 5
        alpha = 0.35

        const = digital.constellation_bpsk().base()
        modulator = digital.generic_mod(
          constellation=const,
          differential=False,
          samples_per_symbol=self.sps,
          pre_diff_code=True,
          excess_bw=alpha,
          verbose=False,
          log=False,
          )
        channel = channels.channel_model(
        	noise_voltage=self.EbN0_to_noise_voltage(EbN0, viterbi),
        	frequency_offset=0,
        	epsilon=1.0,
        	taps=(0, 0, (1+1j)/numpy.sqrt(2), ),
        	noise_seed=RAND_SEED,
        	block_tags=False
        )
        self.sink  = blocks.vector_sink_f()
        biterrors = BitErrors()

        dut = lilacsat1_ber_viterbi() if viterbi else lilacsat1_ber_bpsk()

        pack = blocks.pack_k_bits_bb(8)
        descrambler = digital.descrambler_bb(0x21, 0x00, 16)
        self.connect(blocks.vector_source_b([1], repeat=True),
                     blocks.head(gr.sizeof_char, int(N_BITS)),
                     digital.scrambler_bb(0x21, 0x00, 16),
                     digital.diff_encoder_bb(2),
                     pack)
        self.connect(modulator, channel,
                     blocks.multiply_const_cc(0.1), # we set some amplitude to test the agc # signal amplitude 1 seems very important
                     dut,
                     digital.diff_decoder_bb(2),
                     descrambler)
        self.connect(biterrors, self.sink)
        
        if viterbi:
            deinterleave_viterbi = blocks.deinterleave(gr.sizeof_char)
            interleave_viterbi = blocks.interleave(gr.sizeof_char)
            self.connect(pack,
                         fec.encode_ccsds_27_bb(),
                         deinterleave_viterbi)
            self.connect((deinterleave_viterbi, 0),
                         (interleave_viterbi, 1))
            self.connect((deinterleave_viterbi, 1),
                         blocks.not_bb(),
                         blocks.and_const_bb(1),
                         (interleave_viterbi, 0))
            self.connect(interleave_viterbi,
                         blocks.pack_k_bits_bb(8),
                         modulator)
            descrambler2 = digital.descrambler_bb(0x21, 0x00, 16)
            self.connect((dut, 1),
                        digital.diff_decoder_bb(2),
                        descrambler2)
            or2 = blocks.or_bb()
            self.connect(descrambler, or2)
            self.connect(descrambler2, (or2, 1))
            self.connect(or2, biterrors)
            #self.sinkviterbi1 = blocks.vector_sink_b()
            #self.sinkviterbi2 = blocks.vector_sink_b()
            #self.connect(descrambler, self.sinkviterbi1)
            #self.connect(descrambler2, self.sinkviterbi2)

        else:
            self.connect(pack, modulator)
            self.connect(descrambler, biterrors)            
Beispiel #25
0
    def __init__(self):
        gr.top_block.__init__(self, "Psk Doppler Corr")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Psk Doppler Corr")
        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", "psk_doppler_corr")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate = samp_rate = 32000
        self.offset = offset = 0
        self.cma = cma = -20

        ##################################################
        # 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, 'RF Input')
        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, 'FLL Doppler Corr')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Costas Out')
        self.tab_widget_3 = Qt.QWidget()
        self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_3)
        self.tab_grid_layout_3 = Qt.QGridLayout()
        self.tab_layout_3.addLayout(self.tab_grid_layout_3)
        self.tab.addTab(self.tab_widget_3, 'Tab 3')
        self.top_layout.addWidget(self.tab)
        self._offset_range = Range(-0.5, 0.5, 0.001, 0, 200)
        self._offset_win = RangeWidget(self._offset_range, self.set_offset,
                                       "offset", "counter_slider", float)
        self.top_layout.addWidget(self._offset_win)
        self._cma_range = Range(-40, -10, 1, -20, 200)
        self._cma_win = RangeWidget(self._cma_range, self.set_cma, "cma",
                                    "counter_slider", float)
        self.top_layout.addWidget(self._cma_win)
        self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, sps * 1.0, 1.0, 0.35, 32 * sps))
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, sps * 1.0, 1.0, 0.7, 32 * sps))
        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(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "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.tab_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_win, 0, 1,
                                         1, 1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 0)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(True)
        self.qtgui_freq_sink_x_1.set_fft_average(0.1)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tab_layout_1.addWidget(self._qtgui_freq_sink_x_1_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-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(0.1)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_freq_sink_x_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            2048,  #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 False:
            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 = [2, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [0.4, 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.tab_grid_layout_2.addWidget(self._qtgui_const_sink_x_0_win, 0, 0,
                                         1, 1)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            6.28 / 100, 4, False)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            16, 1.0, pow(10.0, cma / 10.0), 1)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(
            sps * (1 + 0.0), 0.25 * 0.002 * 0.002, 0.5, 0.002, 0.005)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            ([1 + 1j, 1 - 1j, -1 - 1j, -1 + 1j]), 1)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0.1,
            frequency_offset=offset,
            epsilon=1.0,
            taps=(1.0 + 1.0j, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, sps)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            8, 2, "", False, gr.GR_LSB_FIRST)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 256, 1000000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.root_raised_cosine_filter_1, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 1),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.root_raised_cosine_filter_1, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
Beispiel #26
0
    def __init__(self, samp=4):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.samp = samp

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32E3

        ##################################################
        # Blocks
        ##################################################
        self.digital_dxpsk_mod_0 = digital.dqpsk_mod(samples_per_symbol=samp,
                                                     excess_bw=0.35,
                                                     mod_code="gray",
                                                     verbose=False,
                                                     log=False)

        self.digital_dxpsk_demod_0 = digital.dqpsk_demod(
            samples_per_symbol=samp,
            excess_bw=0.35,
            freq_bw=6.28 / 100.0,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            'C:\\Users\\ericj\\Senior-Design\\UMass-Dartmouth.png', False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, 'C:\\Users\\ericj\\Desktop\\out.png', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blks2_packet_encoder_0_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=samp,
                bits_per_symbol=2,
                preamble='',
                access_code='',
                pad_for_usrp=True,
            ),
            payload_length=8,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code='',
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blks2_packet_encoder_0_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blks2_packet_encoder_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_dxpsk_mod_0, 0))
        self.connect((self.digital_dxpsk_demod_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_dxpsk_mod_0, 0),
                     (self.digital_dxpsk_demod_0, 0))
Beispiel #27
0
    def __init__(self):
        gr.top_block.__init__(self, "FM Sender")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("FM Sender")
        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", "fm_transmitter")

        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.osr_rf = osr_rf = 4
        self.osr_mod = osr_mod = 5
        self.fs_file = fs_file = 48000
        self.tx_gain_db = tx_gain_db = 0.8
        self.outbuffer = outbuffer = 10
        self.n_filter_delay = n_filter_delay = 289 // 2
        self.gain_rds = gain_rds = 0.05
        self.gain_pilot = gain_pilot = 0.05
        self.gain_mono = gain_mono = 0.3
        self.gain_lrdiff = gain_lrdiff = 0.5
        self.gain_hinz = gain_hinz = 0.05
        self.fs_rf = fs_rf = fs_file * osr_mod * osr_rf
        self.fs_mod = fs_mod = fs_file * osr_mod
        self.fc_pirate = fc_pirate = 99e6

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_db_range = Range(0, 1, 0.01, 0.8, 200)
        self._tx_gain_db_win = RangeWidget(self._tx_gain_db_range,
                                           self.set_tx_gain_db, 'tx_gain_db',
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_db_win, 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.qtgui_tab_widget_0 = Qt.QTabWidget()
        self.qtgui_tab_widget_0_widget_0 = Qt.QWidget()
        self.qtgui_tab_widget_0_layout_0 = Qt.QBoxLayout(
            Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_0)
        self.qtgui_tab_widget_0_grid_layout_0 = Qt.QGridLayout()
        self.qtgui_tab_widget_0_layout_0.addLayout(
            self.qtgui_tab_widget_0_grid_layout_0)
        self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_0,
                                       'Tab 0')
        self.qtgui_tab_widget_0_widget_1 = Qt.QWidget()
        self.qtgui_tab_widget_0_layout_1 = Qt.QBoxLayout(
            Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_1)
        self.qtgui_tab_widget_0_grid_layout_1 = Qt.QGridLayout()
        self.qtgui_tab_widget_0_layout_1.addLayout(
            self.qtgui_tab_widget_0_grid_layout_1)
        self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_1,
                                       'Tab 1')
        self.qtgui_tab_widget_0_widget_2 = Qt.QWidget()
        self.qtgui_tab_widget_0_layout_2 = Qt.QBoxLayout(
            Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_2)
        self.qtgui_tab_widget_0_grid_layout_2 = Qt.QGridLayout()
        self.qtgui_tab_widget_0_layout_2.addLayout(
            self.qtgui_tab_widget_0_grid_layout_2)
        self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_2,
                                       'Tab 2')
        self.top_grid_layout.addWidget(self.qtgui_tab_widget_0, 5, 0, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._n_filter_delay_range = Range(0, 400, 1, 289 // 2, 200)
        self._n_filter_delay_win = RangeWidget(self._n_filter_delay_range,
                                               self.set_n_filter_delay,
                                               'n_filter_delay',
                                               "counter_slider", int)
        self.top_grid_layout.addWidget(self._n_filter_delay_win, 9, 0, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gain_rds_range = Range(0, 1, 0.05, 0.05, 200)
        self._gain_rds_win = RangeWidget(self._gain_rds_range,
                                         self.set_gain_rds, 'gain_rds',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_rds_win, 8, 0, 1, 1)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gain_pilot_range = Range(0, 1, 0.05, 0.05, 200)
        self._gain_pilot_win = RangeWidget(self._gain_pilot_range,
                                           self.set_gain_pilot, 'gain_pilot',
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_pilot_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._gain_mono_range = Range(0, 1, 0.05, 0.3, 200)
        self._gain_mono_win = RangeWidget(self._gain_mono_range,
                                          self.set_gain_mono, 'gain_mono',
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_mono_win, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gain_lrdiff_range = Range(0, 1, 0.05, 0.5, 200)
        self._gain_lrdiff_win = RangeWidget(self._gain_lrdiff_range,
                                            self.set_gain_lrdiff,
                                            'gain_lrdiff', "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._gain_lrdiff_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._gain_hinz_range = Range(0, 0.5, 0.05, 0.05, 200)
        self._gain_hinz_win = RangeWidget(self._gain_hinz_range,
                                          self.set_gain_hinz, 'gain_hinz',
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_hinz_win, 4, 0, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_sink_1 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
            '',
        )
        self.uhd_usrp_sink_1.set_center_freq(fc_pirate, 0)
        self.uhd_usrp_sink_1.set_normalized_gain(tx_gain_db, 0)
        self.uhd_usrp_sink_1.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_1.set_bandwidth(200e3, 0)
        self.uhd_usrp_sink_1.set_samp_rate(fs_rf)
        self.uhd_usrp_sink_1.set_time_unknown_pps(uhd.time_spec())
        self.rds_encoder_0 = rds.encoder(0, 20, True, 'PIRAT 17', 47.11e6,
                                         True, False, 13, 3, 147,
                                         'SAALFELDEN TESTING')

        self.rational_resampler_xxx_0_0_0_0 = filter.rational_resampler_fff(
            interpolation=osr_mod, decimation=1, taps=None, fractional_bw=None)
        self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff(
            interpolation=osr_mod, decimation=1, taps=None, fractional_bw=None)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=osr_mod, decimation=1, taps=None, fractional_bw=None)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=osr_rf, decimation=1, taps=None, fractional_bw=None)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            4096 * 2,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            fs_mod,  #bw
            "fmChannelData",  #name
            1)
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.1)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        self.qtgui_freq_sink_x_0.set_plot_pos_half(not 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", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.qtgui_tab_widget_0_layout_0.addWidget(
            self._qtgui_freq_sink_x_0_win)
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(
            1, firdes.low_pass(1, fs_mod, 2.5e3, .5e3, firdes.WIN_HAMMING,
                               6.76))
        self.low_pass_filter_0.set_max_output_buffer(10)
        self.gr_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.gr_unpack_k_bits_bb_0.set_max_output_buffer(10)
        self.gr_sig_source_x_0_0 = analog.sig_source_f(fs_mod,
                                                       analog.GR_COS_WAVE,
                                                       57e3, 1, 0, 0)
        self.gr_multiply_xx_0 = blocks.multiply_vff(1)
        self.gr_multiply_xx_0.set_max_output_buffer(10)
        self.gr_map_bb_1 = digital.map_bb([1, 2])
        self.gr_map_bb_1.set_max_output_buffer(10)
        self.gr_map_bb_0 = digital.map_bb([-1, 1])
        self.gr_map_bb_0.set_max_output_buffer(10)
        self.gr_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.gr_diff_encoder_bb_0.set_max_output_buffer(10)
        self.gr_char_to_float_0 = blocks.char_to_float(1, 1)
        self.gr_char_to_float_0.set_max_output_buffer(10)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1,
                                             int(fs_mod / 2.375 / 1000))
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_xx_0_2 = blocks.multiply_const_ff(
            gain_hinz, 1)
        self.blocks_multiply_const_xx_0_0_0 = blocks.multiply_const_ff(
            gain_pilot, 1)
        self.blocks_multiply_const_xx_0_0 = blocks.multiply_const_ff(
            gain_lrdiff, 1)
        self.blocks_multiply_const_xx_0 = blocks.multiply_const_ff(
            gain_mono, 1)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_ff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(gain_rds)
        self.blocks_multiply_const_vxx_0_0.set_max_output_buffer(10)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float * 1,
                                             n_filter_delay)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, n_filter_delay)
        self.blocks_add_xx_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.band_pass_filter_1_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, fs_mod, 30, 15e3, 100, firdes.WIN_HAMMING,
                             6.76))
        self.band_pass_filter_1 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, fs_mod, 30, 15e3, 100, firdes.WIN_HAMMING,
                             6.76))
        self.band_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, fs_mod, 23e3, 53e3, 2e3, firdes.WIN_HAMMING,
                             6.76))
        self.band_pass_filter_0.set_block_alias("filter_bp_lrdiff")
        self.audio_source_0_0 = audio.source(48000, 'pulse_monitor', False)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            fs_mod, analog.GR_COS_WAVE, 19e3, 1, 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            fs_mod, analog.GR_COS_WAVE, 38e3, 1, 0, 0)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(
            75e3 / fs_mod * 2 * math.pi)
        self.analog_fm_preemph_0_0 = analog.fm_preemph(fs=fs_file,
                                                       tau=50e-6,
                                                       fh=-1.0)
        self.analog_fm_preemph_0 = analog.fm_preemph(fs=fs_file,
                                                     tau=50e-6,
                                                     fh=-1.0)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.rational_resampler_xxx_0_0_0_0, 0))
        self.connect((self.analog_fm_preemph_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_fm_preemph_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_fm_preemph_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_fm_preemph_0_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.analog_frequency_modulator_fc_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        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_delay_0, 0))
        self.connect((self.audio_source_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.audio_source_0_0, 1),
                     (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_multiply_const_xx_0_0, 0))
        self.connect((self.band_pass_filter_1, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.band_pass_filter_1_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_const_xx_0_0_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_multiply_const_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.analog_fm_preemph_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_add_xx_0_0, 4))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.analog_fm_preemph_0_0, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_multiply_const_xx_0_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.blocks_multiply_const_xx_0_0_0, 0),
                     (self.blocks_add_xx_0_0, 2))
        self.connect((self.blocks_multiply_const_xx_0_2, 0),
                     (self.blocks_add_xx_0_0, 3))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.rational_resampler_xxx_0_0_0, 0))
        self.connect((self.gr_char_to_float_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0))
        self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0))
        self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0))
        self.connect((self.gr_multiply_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.gr_sig_source_x_0_0, 0), (self.gr_multiply_xx_0, 0))
        self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.uhd_usrp_sink_1, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.band_pass_filter_1, 0))
        self.connect((self.rational_resampler_xxx_0_0_0, 0),
                     (self.band_pass_filter_1_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0, 0),
                     (self.blocks_multiply_const_xx_0_2, 0))
        self.connect((self.rds_encoder_0, 0), (self.gr_diff_encoder_bb_0, 0))
Beispiel #28
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 = 3
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11 * nfilts * sps
        self.excess_bw = excess_bw = 0.4
        self.tx_taps = tx_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.timing_bw = timing_bw = 2 * pi / 100
        self.samp_rate_0 = samp_rate_0 = 20000 * sps
        self.samp_rate = samp_rate = 20000
        self.rx_taps = rx_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.freq_bw = freq_bw = 2 * pi / 100
        self.fll_ntaps = fll_ntaps = 55
        self.const_points = const_points = 4

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccf(
            interpolation=3,
            decimation=25,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=25,
            decimation=3,
            taps=None,
            fractional_bw=None,
        )
        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.low_pass_filter_0_0 = filter.fir_filter_fff(
            1, firdes.low_pass(1, 500e3, 50e3, 10e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1, firdes.low_pass(1, 500e3, 50e3, 10e3, firdes.WIN_HAMMING, 6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 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_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (((-1 - 1j) / sqrt(2), (-1 + 1j) / sqrt(2), (1 - 1j) / sqrt(2),
              (1 + 1j) / sqrt(2))), 1)
        self.blocks_unpack_k_bits_bb_1 = blocks.unpack_k_bits_bb(2)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   20e3, 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_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, 6)
        self.blocks_pack_k_bits_bb_2 = blocks.pack_k_bits_bb(2)
        self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(2)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, ))
        self.blocks_interleave_0 = blocks.interleave(gr.sizeof_float * 1, 1)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/media/aaronjs/New Volume/IITB_Files/Annual_Academic_Files/Year_3/Semester_5/EE340/Labwork/P10/Original_Text.txt',
            False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/media/aaronjs/New Volume/IITB_Files/Annual_Academic_Files/Year_3/Semester_5/EE340/Labwork/P10/P10_3_ModDemod_Text.txt',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            500e3, analog.GR_COS_WAVE, 100e3, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_0_1, 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_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0),
                     (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_interleave_0, 0),
                     (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_1, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_2, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.blocks_skiphead_0, 0),
                     (self.blocks_pack_k_bits_bb_2, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_interleave_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.blocks_interleave_0, 1))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_1, 0))
        self.connect((self.blocks_unpack_k_bits_bb_1, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_unpack_k_bits_bb_1, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
Beispiel #29
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.nfilts = nfilts = 128
        self.timing_loop_bandwidth = timing_loop_bandwidth = .063
        self.samp_rate = samp_rate = 1000000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts)
        self.noise_voltage = noise_voltage = .063
        self.freq_offset = freq_offset = 0
        self.code2 = code2 = '11011010110111011000110011110101100010010011110111'
        self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001'

        self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]),
                                                          4, 1).base()

        ##################################################
        # Blocks
        ##################################################
        self._timing_loop_bandwidth_range = Range(.001, .2, .001, .063, 200)
        self._timing_loop_bandwidth_win = RangeWidget(
            self._timing_loop_bandwidth_range, self.set_timing_loop_bandwidth,
            "timing_loop_bandwidth", "counter_slider", float)
        self.top_grid_layout.addWidget(self._timing_loop_bandwidth_win, 0, 0,
                                       1, 1)
        self._noise_voltage_range = Range(0.0, 1, .001, .063, 200)
        self._noise_voltage_win = RangeWidget(self._noise_voltage_range,
                                              self.set_noise_voltage,
                                              "noise_voltage",
                                              "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_voltage_win, 0, 1, 1, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
            15,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(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)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = [
            'Real part', 'Imaginary Part', '', '', '', '', '', '', '', ''
        ]
        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 = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [0, 0, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2 * 1):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 1, 1,
                                       1, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            15,  #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(True)
        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 = ['Binary output (1 or 0)', '', '', '', '', '', '', '', '', '']
        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 = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 2, 0, 1,
                                       1)
        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(True)
        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,
                                       1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_loop_bandwidth, (rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=BPSK,
            differential=False,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(
            (0, 1), 1)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise_voltage,
            frequency_offset=freq_offset / samp_rate,
            epsilon=1.0,
            taps=(1, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char * 1,
                                                   samp_rate, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab3/example6/cat.png',
            True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab3/example8/hello_out.png',
            False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_packet_encoder_0_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=1,
                bits_per_symbol=1,
                preamble='',
                access_code=code2,
                pad_for_usrp=False,
            ),
            payload_length=4,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code=code2,
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blks2_packet_encoder_0_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blks2_packet_encoder_0_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.blocks_unpacked_to_packed_xx_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.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.qtgui_time_sink_x_0_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.rate = rate = 2
        self.polys = polys = [109, 79]
        self.k = k = 7
        self.eb = eb = 0.22
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 38
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50
        self.samp_rate = samp_rate = samp_rate_array_MCR[7]

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(sps, sps, 1.0, eb, 11*sps)


        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(sps, sps, 1.0, eb, 11*sps)



        self.pld_enc = pld_enc = map( (lambda a: fec.cc_encoder_make(440, k, rate, (polys), 0, fec.CC_TERMINATED, False)), range(0,4) );


        self.pld_dec = pld_dec = map( (lambda a: fec.cc_decoder.make(440, k, rate, (polys), 0, -1, 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.nfilts_rx = nfilts_rx = 4
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.filt_delay = filt_delay = 0
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 38, 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_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, 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_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_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)
        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, 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.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(sps, (rrc_taps))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_pfb_clock_sync_xxx_0_0_0 = digital.pfb_clock_sync_ccf(sps, 6.28/100.0, (rx_rrc_taps), sps, sps/2, 1.5, 1)
        self.digital_diff_encoder_bb_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,
          1, 'packet_len')
        self.digital_constellation_decoder_cb_0_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_stream_mux_0_1_0 = blocks.stream_mux(gr.sizeof_char*1, (96, 896))
        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_0_1 = blocks.repack_bits_bb(1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_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 = 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.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_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/andre/Desktop/nfiltesfir.txt', False)
        self.blocks_file_sink_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.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_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), (self.blocks_char_to_float_1_0_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.blocks_file_sink_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_freq_sink_x_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.digital_correlate_access_code_xx_ts_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_file_sink_0_0_0_2, 0))
        self.connect((self.blocks_repack_bits_bb_0_1, 0), (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0), (self.blocks_stream_mux_0_1_0, 1))
        self.connect((self.blocks_stream_mux_0_1_0, 0), (self.blocks_repack_bits_bb_0_1, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0_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_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_pfb_clock_sync_xxx_0_0_0, 0), (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.interp_fir_filter_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_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))
Beispiel #32
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")

        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.MiconstellationObject = MiconstellationObject = digital.constellation_calcdist(
            digital.constellation_qpsk().points(), (0, 1, 2, 3), 4, 1).base()
        self.Constelacion = Constelacion = MiconstellationObject.points()
        self.M = M = len(Constelacion)
        self.samp_rate_usrp_rx = samp_rate_usrp_rx = 100e6
        self.Rb = Rb = 100
        self.Bps = Bps = int(math.log(M, 2))
        self.samp_rate_to_usrp = samp_rate_to_usrp = int(samp_rate_usrp_rx /
                                                         512)
        self.samp_rate_audio = samp_rate_audio = 11000
        self.ntaps = ntaps = 128
        self.Sps = Sps = 160
        self.Rs = Rs = Rb / Bps
        self.Rolloff = Rolloff = 0.5
        self.NbpS = NbpS = 8
        self.samp_rate_0 = samp_rate_0 = int(Rs * Sps)
        self.samp_rate = samp_rate = Rb * Sps
        self.run_stop = run_stop = True
        self.mapinverse = mapinverse = coding.inverse_map(Constelacion)
        self.mapdirect = mapdirect = coding.direct_map(Constelacion)
        self.h_rrc = h_rrc = wform.rrcos(Sps, ntaps, Rolloff)
        self.Vp = Vp = 1.
        self.Tupdate = Tupdate = 1. / Rb
        self.Sps_0 = Sps_0 = int(math.floor(samp_rate_to_usrp / Rs))
        self.Rb_0 = Rb_0 = NbpS * samp_rate_audio
        self.P = P = 0.
        self.NnivelesQ = NnivelesQ = int(math.pow(2, NbpS))
        self.Kf = Kf = 200
        self.F = F = 0.
        self.BW = BW = (Rs / 2) * (1 + Rolloff)
        self.Ar = Ar = 0.
        self.A = A = 1.

        ##################################################
        # Blocks
        ##################################################
        self._P_range = Range(-2. * math.pi, 2. * math.pi,
                              (4. * math.pi) / 360., 0., 200)
        self._P_win = RangeWidget(self._P_range, self.set_P, 'Fase',
                                  "counter_slider", float)
        self.top_grid_layout.addWidget(self._P_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._Ar_range = Range(0, 4., (4.) / 50., 0., 200)
        self._Ar_win = RangeWidget(self._Ar_range, self.set_Ar, 'Ruido',
                                   "counter_slider", float)
        self.top_grid_layout.addWidget(self._Ar_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._A_range = Range(-1.5, 1.5, (1.5) / 100., 1., 200)
        self._A_win = RangeWidget(self._A_range, self.set_A, 'A',
                                  "counter_slider", float)
        self.top_grid_layout.addWidget(self._A_win, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        _run_stop_check_box = Qt.QCheckBox('Inicial/Parar')
        self._run_stop_choices = {True: True, False: False}
        self._run_stop_choices_inv = dict(
            (v, k) for k, v in self._run_stop_choices.items())
        self._run_stop_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _run_stop_check_box, "setChecked",
            Qt.Q_ARG("bool", self._run_stop_choices_inv[i]))
        self._run_stop_callback(self.run_stop)
        _run_stop_check_box.stateChanged.connect(
            lambda i: self.set_run_stop(self._run_stop_choices[bool(i)]))
        self.top_grid_layout.addWidget(_run_stop_check_box, 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.qtgui_time_sink_x_0_0_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate_audio,  #samp_rate
            'Nuevo',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0_1.set_y_axis(-128, 128)

        self.qtgui_time_sink_x_0_0_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0_1.enable_tags(True)
        self.qtgui_time_sink_x_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0_1.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0_1.enable_grid(False)
        self.qtgui_time_sink_x_0_0_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0_1.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0_1.enable_stem_plot(False)

        labels = [
            'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_1_win)
        self.qtgui_time_sink_x_0_0_0_0_0 = qtgui.time_sink_f(
            1024,  #size
            (samp_rate),  #samp_rate
            "compararacion entre mensaje y EC",  #name
            3  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0_0_0.set_update_time(Tupdate)
        self.qtgui_time_sink_x_0_0_0_0_0.set_y_axis(-1.5, 1.5)

        self.qtgui_time_sink_x_0_0_0_0_0.set_y_label('Amplitud', 'volts')

        self.qtgui_time_sink_x_0_0_0_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0_0_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_stem_plot(False)

        labels = [
            'Mensaje', 'FSK parte real', 'FSK parte Imaginaria', '', '', '',
            '', '', '', ''
        ]
        widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_0_win,
                                       4, 1, 1, 2)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_f(
            1024,  #size
            (samp_rate),  #samp_rate
            "Nivel de Amplitud",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0_0.set_update_time(Tupdate)
        self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-1.5, 1.5)

        self.qtgui_time_sink_x_0_0_0_0.set_y_label('Amplitud', 'volts')

        self.qtgui_time_sink_x_0_0_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0_0_0.enable_stem_plot(False)

        labels = ['.', '', '', '', '', '', '', '', '', '']
        widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_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.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f(
            1024,  #size
            (samp_rate),  #samp_rate
            "Nivel de Fase",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0.set_update_time(Tupdate)
        self.qtgui_time_sink_x_0_0_0.set_y_axis(-2 * math.pi, 2 * math.pi)

        self.qtgui_time_sink_x_0_0_0.set_y_label('Fase', 'radianes')

        self.qtgui_time_sink_x_0_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False)

        labels = ['.', '', '', '', '', '', '', '', '', '']
        widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_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.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            (samp_rate),  #samp_rate
            "Nivel de frecuencia",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(Tupdate)
        self.qtgui_time_sink_x_0_0.set_y_axis(-2.5, 2.5)

        self.qtgui_time_sink_x_0_0.set_y_label('Frecuencia', 'Hz')

        self.qtgui_time_sink_x_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

        labels = ['.', '', '', '', '', '', '', '', '', '']
        widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_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, 3, 2,
                                       1, 1)
        for r in range(3, 4):
            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 = qtgui.const_sink_c(
            8,  #size
            '',  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(Tupdate)
        self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5)
        self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.5)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        labels = ['.', '', '', '', '', '', '', '', '', '']
        widths = [4, 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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 4, 0,
                                       1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.epy_block_0 = epy_block_0.blk()
        self.e_VCO_fase_fc_0 = e_VCO_fase_fc_0.blk()
        self.digital_map_bb_0 = digital.map_bb(mapdirect)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(M)
        self.digital_chunks_to_symbols_xx = digital.chunks_to_symbols_bc(
            MiconstellationObject.points(), 1)
        self.d_freq_cf_assign_freq_cf_0 = d_freq_cf.assign_freq_cf()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            Bps, gr.GR_LSB_FIRST)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0_0_1_0_0 = blocks.multiply_const_ff(
            Kf * 2 * math.pi / samp_rate)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.b_quantizer_fb_0 = b_quantizer_fb(
            NivelesQ=NnivelesQ,
            Vmax=Vp,
        )
        self.b_bipolar_to_unipolar_ff_0 = b_bipolar_to_unipolar_ff()
        self.b_binary_bipolar_source_f_0 = b_binary_bipolar_source_f(
            Am=1.,
            Spb=Sps,
        )
        self.b_PSD_c_0 = b_PSD_c(
            Ensayos=1000000,
            Fc=0,
            N=1024,
            Ymax=1e-5,
            samp_rate_audio=samp_rate,
        )

        self.top_grid_layout.addWidget(self.b_PSD_c_0, 5, 1, 1, 2)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.analog_noise_source_x_1 = analog.noise_source_c(
            analog.GR_GAUSSIAN, Ar, 0)
        self.analog_const_source_x_0_0_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, P)
        self.analog_const_source_x_0_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, A)
        self._F_range = Range(-2.4, 2.4, (2 * 2.4) / 1000., 0., 200)
        self._F_win = RangeWidget(self._F_range, self.set_F, 'Frecuencia',
                                  "counter_slider", float)
        self.top_grid_layout.addWidget(self._F_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)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0_0, 0),
                     (self.e_VCO_fase_fc_0, 1))
        self.connect((self.analog_const_source_x_0_0, 0),
                     (self.qtgui_time_sink_x_0_0_0_0, 0))
        self.connect((self.analog_const_source_x_0_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_const_source_x_0_0_0, 0),
                     (self.qtgui_time_sink_x_0_0_0, 0))
        self.connect((self.analog_noise_source_x_1, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.b_binary_bipolar_source_f_0, 0),
                     (self.b_bipolar_to_unipolar_ff_0, 0))
        self.connect((self.b_bipolar_to_unipolar_ff_0, 0),
                     (self.b_quantizer_fb_0, 0))
        self.connect((self.b_bipolar_to_unipolar_ff_0, 0),
                     (self.epy_block_0, 0))
        self.connect((self.b_bipolar_to_unipolar_ff_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.b_bipolar_to_unipolar_ff_0, 0),
                     (self.qtgui_time_sink_x_0_0_0_0_0, 0))
        self.connect((self.b_quantizer_fb_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.e_VCO_fase_fc_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.qtgui_time_sink_x_0_0_0_0_0, 1))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.qtgui_time_sink_x_0_0_0_0_0, 2))
        self.connect((self.blocks_multiply_const_vxx_0_0_0_1_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.d_freq_cf_assign_freq_cf_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.d_freq_cf_assign_freq_cf_0, 0),
                     (self.qtgui_time_sink_x_0_0_1, 0))
        self.connect((self.digital_chunks_to_symbols_xx, 0),
                     (self.b_PSD_c_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx, 0),
                     (self.d_freq_cf_assign_freq_cf_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx, 0),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_map_bb_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx, 0))
        self.connect((self.e_VCO_fase_fc_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.epy_block_0, 0),
                     (self.blocks_multiply_const_vxx_0_0_0_1_0_0, 0))
Beispiel #33
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))
Beispiel #34
0
    def __init__(self, freq=88.5e6, gain=30, input_gain=.3, pilot_gain=.09, ps="DEFCON", rds_gain=.1, stereo_gain=.3, wavfile=""):
        gr.top_block.__init__(self, "Slackradio")

        ##################################################
        # Parameters
        ##################################################
        self.freq = freq
        self.gain = gain
        self.input_gain = input_gain
        self.pilot_gain = pilot_gain
        self.ps = ps
        self.rds_gain = rds_gain
        self.stereo_gain = stereo_gain
        self.wavfile = wavfile

        ##################################################
        # Variables
        ##################################################
        self.usrp_rate = usrp_rate = 19e3*20
        self.outbuffer = outbuffer = 1024
        self.fm_max_dev = fm_max_dev = 80e3

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink.set_samp_rate(1e6)
        self.uhd_usrp_sink.set_center_freq(freq, 0)
        self.uhd_usrp_sink.set_gain(gain, 0)
        self.uhd_usrp_sink.set_antenna("TX/RX", 0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=100,
                decimation=38,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
                interpolation=380,
                decimation=48,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=380,
                decimation=48,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0_0_0 = filter.interp_fir_filter_fff(1, firdes.low_pass(
        	1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.interp_fir_filter_fff(1, firdes.low_pass(
        	1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(1, firdes.low_pass(
        	1, usrp_rate, 2.5e3, .5e3, firdes.WIN_HAMMING, 6.76))
        (self.low_pass_filter_0).set_max_output_buffer(1024)
        self.gr_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        (self.gr_unpack_k_bits_bb_0).set_max_output_buffer(4096)
        self.gr_sub_xx_0 = blocks.sub_ff(1)
        self.gr_sig_source_x_0_1 = analog.sig_source_f(usrp_rate, analog.GR_SIN_WAVE, 19e3, 1, 0)
        self.gr_sig_source_x_0_0 = analog.sig_source_f(usrp_rate, analog.GR_SIN_WAVE, 57e3, 1, 0)
        self.gr_sig_source_x_0 = analog.sig_source_f(usrp_rate, analog.GR_SIN_WAVE, 38e3, 1, 0)
        self.gr_rds_encoder_0 = rds.encoder(1, 8, True, ps, 89.8e6,
        			True, False, 13, 3,
        			147, "CYBERSPECTRUM")
        	
        (self.gr_rds_encoder_0).set_max_output_buffer(4096)
        self.gr_multiply_xx_1 = blocks.multiply_vff(1)
        self.gr_multiply_xx_0 = blocks.multiply_vff(1)
        (self.gr_multiply_xx_0).set_max_output_buffer(1024)
        self.gr_map_bb_1 = digital.map_bb(([1,2]))
        (self.gr_map_bb_1).set_max_output_buffer(4096)
        self.gr_map_bb_0 = digital.map_bb(([-1,1]))
        (self.gr_map_bb_0).set_max_output_buffer(4096)
        self.gr_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2*math.pi*fm_max_dev/usrp_rate)
        (self.gr_frequency_modulator_fc_0).set_max_output_buffer(1024)
        self.gr_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        (self.gr_diff_encoder_bb_0).set_max_output_buffer(4096)
        self.gr_char_to_float_0 = blocks.char_to_float(1, 1)
        (self.gr_char_to_float_0).set_max_output_buffer(1024)
        self.gr_add_xx_1 = blocks.add_vff(1)
        (self.gr_add_xx_1).set_max_output_buffer(1024)
        self.gr_add_xx_0 = blocks.add_vff(1)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(wavfile, True)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52001", 10000, False)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, 160)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((input_gain, ))
        self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_vff((pilot_gain, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((rds_gain, ))
        (self.blocks_multiply_const_vxx_0_0).set_max_output_buffer(1024)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((input_gain, ))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.gr_rds_encoder_0, 'rds in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.gr_add_xx_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.gr_add_xx_1, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.rational_resampler_xxx_0_0, 0))    
        self.connect((self.blocks_repeat_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_multiply_const_vxx_0_1, 0))    
        self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0_0, 0))    
        self.connect((self.gr_add_xx_1, 0), (self.gr_frequency_modulator_fc_0, 0))    
        self.connect((self.gr_char_to_float_0, 0), (self.blocks_repeat_0, 0))    
        self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0))    
        self.connect((self.gr_frequency_modulator_fc_0, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0))    
        self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0))    
        self.connect((self.gr_multiply_xx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.gr_multiply_xx_1, 0), (self.gr_add_xx_1, 2))    
        self.connect((self.gr_rds_encoder_0, 0), (self.gr_diff_encoder_bb_0, 0))    
        self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 0))    
        self.connect((self.gr_sig_source_x_0_0, 0), (self.gr_multiply_xx_0, 0))    
        self.connect((self.gr_sig_source_x_0_1, 0), (self.blocks_multiply_const_vxx_0_0_1, 0))    
        self.connect((self.gr_sub_xx_0, 0), (self.low_pass_filter_0_0_0, 0))    
        self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 1))    
        self.connect((self.low_pass_filter_0_0, 0), (self.gr_add_xx_1, 3))    
        self.connect((self.low_pass_filter_0_0_0, 0), (self.gr_multiply_xx_1, 1))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.gr_add_xx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.gr_sub_xx_0, 0))    
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.gr_add_xx_0, 1))    
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.gr_sub_xx_0, 1))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.uhd_usrp_sink, 0))    
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Tx Send No Gui")

        ##################################################
        # 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 = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952
        ]
        self.vector = vector = [int(random.random() * 4) for i in range(49600)]
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50
        self.samp_rate = samp_rate = samp_rate_array_MCR[0]
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        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.k = k = 7
        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.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.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.digital_map_bb_1_0 = digital.map_bb((pld_const.pre_diff_code()))
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(4)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (pld_const.points()), 1)
        self.blocks_stream_mux_0_1_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (96, 896))
        self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb(
            1, 2, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            8, 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/andre/Desktop/TX_TEMP.txt', False)
        self.blocks_file_source_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),
                     (self.blocks_repack_bits_bb_0, 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_stream_mux_0_1_0, 1))
        self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0),
                     (self.insert_vec_cpp_new_vec_0, 0))
        self.connect((self.blocks_stream_mux_0_1_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_0, 0))
        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.digital_map_bb_1_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.insert_vec_cpp_new_vec_0, 0),
                     (self.digital_map_bb_1_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
Beispiel #36
0
    def __init__(self):
        gr.top_block.__init__(self, "Psk Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Psk Rx")
        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", "psk_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 2
        self.samp_rate = samp_rate = 1e6
        self.my_constellation = my_constellation = digital.constellation_calcdist(([-1,1]), ([0, 1]), 2, 1).base()
        self.freq = freq = 2.4e9

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_sink_x_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	freq, #fc
        	samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0/10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)
        
        self.qtgui_sink_x_0.enable_rf_freq(False)
        
        
          
        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)
        
        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_layout.addWidget(self._qtgui_const_sink_x_0_win)
        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(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 6.28/100.0, (filter.firdes.root_raised_cosine(32,32*sps,1.0,0.35,11*32*sps)), 32, 16, 1.5, 1)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, 0.35, 55, 6.28/100.0)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(my_constellation, 6.28/100.0, -0.25, 0.25)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(1)
        self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/ubuntu/recv.b", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_c(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.analog_agc2_xx_0 = analog.agc2_cc(0.06, 0.001, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0))    
        self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_packet_decoder_0, 0))    
        self.connect((self.digital_constellation_receiver_cb_0, 1), (self.blocks_null_sink_0, 0))    
        self.connect((self.digital_constellation_receiver_cb_0, 2), (self.blocks_null_sink_0_0, 0))    
        self.connect((self.digital_constellation_receiver_cb_0, 3), (self.blocks_null_sink_0_1, 0))    
        self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_diff_encoder_bb_0, 0))    
        self.connect((self.digital_constellation_receiver_cb_0, 4), (self.qtgui_const_sink_x_0, 0))    
        self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))    
        self.connect((self.digital_fll_band_edge_cc_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.osmosdr_source_0, 0), (self.analog_agc2_xx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_sink_x_0, 0))    
Beispiel #37
0
    def __init__(self,
                 samples_per_symbol=_def_samples_per_symbol,
                 excess_bw=_def_excess_bw,
                 verbose=_def_verbose,
                 log=_def_log):
        """
	Hierarchical block for RRC-filtered QPSK modulation.

	The input is a byte stream (unsigned char) and the
	output is the complex modulated signal at baseband.

	@param samples_per_symbol: samples per symbol >= 2
	@type samples_per_symbol: integer
	@param excess_bw: Root-raised cosine filter excess bandwidth
	@type excess_bw: float
        @param verbose: Print information about modulator?
        @type verbose: bool
        @param debug: Print modualtion data to files?
        @type debug: bool
	"""

	gr.hier_block2.__init__(self, "cqpsk_mod",
				gr.io_signature(1, 1, gr.sizeof_char),       # Input signature
				gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature

        self._samples_per_symbol = samples_per_symbol
        self._excess_bw = excess_bw

        if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2:
            raise TypeError, ("sbp must be an integer >= 2, is %d" % samples_per_symbol)

	ntaps = 11 * samples_per_symbol
 
        arity = 8

        # turn bytes into k-bit vectors
        self.bytes2chunks = \
          blocks.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)

        #	0	+45	1	[+1]
        #	1	+135	3	[+3]
        #	2	-45	7	[-1]
        #	3	-135	5	[-3]
        self.pi4map = [1, 3, 7, 5]
        self.symbol_mapper = digital.map_bb(self.pi4map)
        self.diffenc = digital.diff_encoder_bb(arity)
        self.chunks2symbols = digital.chunks_to_symbols_bc(psk.constellation[arity])

        # pulse shaping filter
	self.rrc_taps = filter.firdes.root_raised_cosine(
	    self._samples_per_symbol, # gain  (sps since we're interpolating by sps)
            self._samples_per_symbol, # sampling rate
            1.0,		      # symbol rate
            self._excess_bw,          # excess bandwidth (roll-off factor)
            ntaps)

	self.rrc_filter = filter.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps)

        if verbose:
            self._print_verbage()
        
        if log:
            self._setup_logging()
            
	# Connect & Initialize base class
        self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc,
                     self.chunks2symbols, self.rrc_filter, self)
Beispiel #38
0
    def __init__(self, cw_len=64, payload_len=255, samp_rate=1e6):
        gr.hier_block2.__init__(
            self,
            "Wes Packet Tx",
            gr.io_signature(1, 1, gr.sizeof_char * 1),
            gr.io_signaturev(6, 6, [
                gr.sizeof_gr_complex * 1, gr.sizeof_char * 1, gr.sizeof_char *
                1, gr.sizeof_char * 1, gr.sizeof_char * 1, gr.sizeof_char * 1
            ]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.cw_len = cw_len
        self.payload_len = payload_len
        self.samp_rate = samp_rate

        ##################################################
        # Variables
        ##################################################
        self.num_tag_key = num_tag_key = "packet_num"
        self.len_tag_key = len_tag_key = "packet_length"
        self.header_len = header_len = 32
        self.throttle_rate = throttle_rate = 100e3
        self.tag_s = tag_s = gr.tag_utils.python_to_tag(
            (0, pmt.intern(len_tag_key), pmt.from_long(payload_len),
             pmt.intern("vect_test_src")))
        self.tag0 = tag0 = gr.tag_utils.python_to_tag(
            (0, pmt.intern(len_tag_key), pmt.from_long(cw_len),
             pmt.intern("vect_cw_src")))
        self.sync_seq = sync_seq = [
            1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1,
            -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1,
            -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1,
            -1, -1, 1, 1, 1, 1, 1, 1
        ]
        self.sync_len = sync_len = 63
        self.sym_table = sym_table = [-1, 1]
        self.pi = pi = 3.141592654
        self.header_formatter = header_formatter = digital.packet_header_default(
            header_len, len_tag_key, num_tag_key, 1)
        self.diff_mod = diff_mod = 4
        self.cw = cw = int((cw_len / 4)) * [1, 0, 1, 0]
        self.const = const = digital.constellation_calcdist(
            digital.psk_4()[0],
            digital.psk_4()[1], 2, 1).base()

        ##################################################
        # Blocks
        ##################################################
        self.digital_packet_headergenerator_bb_0_0 = digital.packet_headergenerator_bb(
            header_formatter.formatter(), len_tag_key)
        self.digital_glfsr_source_x_0 = digital.glfsr_source_b(6, True, 0, 1)
        self.digital_diff_encoder_bb_0_0 = digital.diff_encoder_bb(2)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (-1, 1), 1)
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b(
            cw, True, 1, [tag0])
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_char * 1, len_tag_key, 0)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_char * 1, False)
        self.blocks_tag_gate_0.set_single_key("")
        self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, sync_len, "packet_length")
        self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, payload_len, len_tag_key)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, header_len, len_tag_key)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            1, 1, "packet_length", False, gr.GR_LSB_FIRST)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self, 5))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0),
                     (self.digital_diff_encoder_bb_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0),
                     (self.digital_packet_headergenerator_bb_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self, 2))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0), (self, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.blocks_tagged_stream_mux_0, 2))
        self.connect((self.digital_diff_encoder_bb_0, 0), (self, 4))
        self.connect((self.digital_diff_encoder_bb_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 3))
        self.connect((self.digital_diff_encoder_bb_0_0, 0), (self, 3))
        self.connect((self.digital_glfsr_source_x_0, 0),
                     (self.blocks_stream_to_tagged_stream_1, 0))
        self.connect((self.digital_packet_headergenerator_bb_0_0, 0),
                     (self.blocks_tag_gate_0, 0))
        self.connect((self, 0), (self.blocks_stream_to_tagged_stream_0_0_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))
Beispiel #40
0
    def __init__(self, constellation,
                 samples_per_symbol=_def_samples_per_symbol,
                 differential=_def_differential,
                 excess_bw=_def_excess_bw,
                 gray_coded=True,
                 verbose=_def_verbose,
                 log=_def_log):
        """
	Hierarchical block for RRC-filtered differential generic modulation.

	The input is a byte stream (unsigned char) and the
	output is the complex modulated signal at baseband.
        
	@param constellation: determines the modulation type
	@type constellation: gnuradio.digital.gr_constellation
	@param samples_per_symbol: samples per baud >= 2
	@type samples_per_symbol: float
	@param excess_bw: Root-raised cosine filter excess bandwidth
	@type excess_bw: float
        @param gray_coded: turn gray coding on/off
        @type gray_coded: bool
        @param verbose: Print information about modulator?
        @type verbose: bool
        @param log: Log modulation data to files?
        @type log: bool
	"""

	gr.hier_block2.__init__(self, "generic_mod",
				gr.io_signature(1, 1, gr.sizeof_char),       # Input signature
				gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature

        self._constellation = constellation.base()
        self._samples_per_symbol = samples_per_symbol
        self._excess_bw = excess_bw
        self._differential = differential

        if self._samples_per_symbol < 2:
            raise TypeError, ("sbp must be >= 2, is %f" % self._samples_per_symbol)
        
        arity = pow(2,self.bits_per_symbol())
        
        # turn bytes into k-bit vectors
        self.bytes2chunks = \
          gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)

        if gray_coded == True:
            self.symbol_mapper = digital.map_bb(self._constellation.pre_diff_code())

        if differential:
            self.diffenc = digital.diff_encoder_bb(arity)

        self.chunks2symbols = digital.chunks_to_symbols_bc(self._constellation.points())

        # pulse shaping filter
        nfilts = 32
        ntaps = nfilts * 11 * int(self._samples_per_symbol)    # make nfilts filters of ntaps each
        self.rrc_taps = gr.firdes.root_raised_cosine(
            nfilts,          # gain
            nfilts,          # sampling rate based on 32 filters in resampler
            1.0,             # symbol rate
            self._excess_bw, # excess bandwidth (roll-off factor)
            ntaps)
        self.rrc_filter = gr.pfb_arb_resampler_ccf(self._samples_per_symbol,
                                                   self.rrc_taps)

	# Connect
        blocks = [self, self.bytes2chunks]
        if gray_coded == True:
            blocks.append(self.symbol_mapper)
        if differential:
            blocks.append(self.diffenc)
        blocks += [self.chunks2symbols, self.rrc_filter, self]
        self.connect(*blocks)

        if verbose:
            self._print_verbage()
            
        if log:
            self._setup_logging()