예제 #1
0
def key_factory(index):
    print "FACTORY CALLED index = %d" % (index)

    r = es.es_pyhandler()

    excess_bw = 0.5
    sps = 4
    amplitude = sig_amp
    taps = gr.firdes.root_raised_cosine(
        sps * amplitude,  # Gain
        sps,  # Sampling rate
        1.0,  # Symbol rate
        excess_bw,  # Roll-off factor
        11 * sps)  # Number of taps

    blocks = {}
    blocks["src"] = es.vector_source([1])
    blocks["scrambler"] = digital.scrambler_bb(0x8A, 0x7F, 7)
    blocks["mapper"] = digital.chunks_to_symbols_bc(
        [-1 + 0j, 0 + 1j, 1 + 0j, 0 - 1j])
    blocks["rrc"] = filter.interp_fir_filter_ccf(sps, taps)
    r.sink = es.vector_sink([gr.sizeof_gr_complex])
    r.set_pyb2(blocks)

    tb = gr.top_block()
    tb.connect(blocks["src"], blocks["scrambler"], blocks["mapper"],
               blocks["rrc"], r.sink)

    r.tb = tb.to_top_block()
    return r
예제 #2
0
    def __init__(self, constellation, samples_per_symbol, differential,
                 excess_bw, gray_coded, verbose, log):

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

        # Create BERT data bit stream
        self._bits = blocks.vector_source_b([
            1,
        ], True)  # Infinite stream of ones
        self._scrambler = digital.scrambler_bb(0x8A, 0x7F,
                                               7)  # CCSDS 7-bit scrambler

        self._mod = digital.generic_mod(constellation, differential,
                                        samples_per_symbol, gray_coded,
                                        excess_bw, verbose, log)

        self._pack = blocks.unpacked_to_packed_bb(self._mod.bits_per_symbol(),
                                                  gr.GR_MSB_FIRST)

        self.connect(self._bits, self._scrambler, self._pack, self._mod, self)
예제 #3
0
def key_factory(index):
    print "FACTORY CALLED index = %d"%(index);
    
    r = es.es_pyhandler();

    excess_bw = 0.5;
    sps = 4;
    amplitude = sig_amp;
    taps = gr.firdes.root_raised_cosine(sps*amplitude,  # Gain
                        sps,        # Sampling rate
                        1.0,        # Symbol rate
                        excess_bw,      # Roll-off factor
                        11*sps)         # Number of taps

    blocks = {};
    blocks["src"] = es.vector_source([1]) 
    blocks["scrambler"] = digital.scrambler_bb(0x8A, 0x7F, 7);
    blocks["mapper"] = digital.chunks_to_symbols_bc( [-1+0j, 0+1j, 1+0j, 0-1j] );
    blocks["rrc"] = filter.interp_fir_filter_ccf(sps, taps);
    r.sink = es.vector_sink([gr.sizeof_gr_complex]);
    r.set_pyb2(blocks);

    tb  = gr.top_block();
    tb.connect( blocks["src"], blocks["scrambler"], blocks["mapper"], blocks["rrc"], r.sink );

    r.tb = tb.to_top_block();
    return r;
예제 #4
0
 def test_scrambler_descrambler(self):
     src_data = (1,)*1000
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.scrambler_bb(0x8a, 0x7F, 7)     # CCSDS 7-bit scrambler
     descrambler = digital.descrambler_bb(0x8a, 0x7F, 7)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.run()
     self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage during synchronization
예제 #5
0
 def test_scrambler_descrambler(self):
     src_data = (1,)*1000
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.scrambler_bb(0x8a, 0x7F, 7)     # CCSDS 7-bit scrambler
     descrambler = digital.descrambler_bb(0x8a, 0x7F, 7)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.run()
     self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage during synchronization
예제 #6
0
 def test_scrambler_descrambler_003(self):
     src_data = np.random.randint(0, 2, 1000, dtype=np.int8)
     src = blocks.vector_source_b(src_data, False)
     # this is the product of the other two
     scrambler = digital.scrambler_bb(*lfsr_args(1, 12, 10, 3, 2, 0))
     descrambler1 = digital.descrambler_bb(*lfsr_args(1, 5, 3, 0))
     descrambler2 = digital.descrambler_bb(*lfsr_args(1, 7, 2, 0))
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler1, descrambler2, dst)
     self.tb.run()
     # skip garbage during synchronization
     self.assertTrue(np.all(src_data[:-12] == dst.data()[12:]))
예제 #7
0
 def test_scrambler_descrambler_001(self):
     src_data = np.random.randint(0, 2, 500, dtype=np.int8)
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.scrambler_bb(*lfsr_args(0b1, 7, 2,
                                                 0))  # p(x) = x^7 + x^2 + 1
     # we can use any seed here, it is descrambling.
     descrambler = digital.descrambler_bb(*lfsr_args(0b111, 7, 2, 0))
     m_tap = blocks.vector_sink_b()
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.connect(scrambler, m_tap)
     self.tb.run()
     # skip garbage during synchronization
     self.assertEqual(src_data[:-7].tolist(), dst.data()[7:])
     self.assertEqual(
         tuple(np.convolve(m_tap.data(), [1, 0, 0, 0, 0, 1, 0, 1]) %
               2)[7:-10], tuple(src_data[:-10]))  # manual descrambling test
예제 #8
0
 def test_scrambler_descrambler_002(self):
     _a = lfsr_args(0b1, 51, 6, 0)  # p(x) = x^51+x^6+1
     src_data = np.random.randint(0, 2, 1000, dtype=np.int8)
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.scrambler_bb(*_a)
     m_tap = blocks.vector_sink_b()
     descrambler = digital.descrambler_bb(*_a)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.connect(scrambler, m_tap)
     self.tb.run()
     # skip garbage during synchronization
     self.assertTrue(np.all(src_data[:-51] == dst.data()[51:]))
     reg = np.zeros(52, np.int8)
     reg[::-1][(51, 6, 0), ] = 1
     self.assertTrue(
         np.all(
             np.convolve(m_tap.data(), reg)[51:-60] %
             2 == src_data[:-60]))  # manual descrambling test
예제 #9
0
    def __init__(self, constellation, samples_per_symbol,
                 differential, excess_bw, gray_coded,
                 verbose, log):

        gr.hier_block2.__init__(self, "bert_transmit",
                                gr.io_signature(0, 0, 0),                    # Output signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Input signature
        
        # Create BERT data bit stream	
	self._bits = blocks.vector_source_b([1,], True)      # Infinite stream of ones
        self._scrambler = digital.scrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit scrambler

        self._mod = digital.generic_mod(constellation, differential,
                                        samples_per_symbol,
                                        gray_coded, excess_bw,
                                        verbose, log)

        self._pack = blocks.unpacked_to_packed_bb(self._mod.bits_per_symbol(), gr.GR_MSB_FIRST)

        self.connect(self._bits, self._scrambler, self._pack, self._mod, self)
    def __init__(self, scrambler=0):
        gr.hier_block2.__init__(
            self, "AX.25 Line Coding Heir Block",
            gr.io_signature(1, 1, gr.sizeof_char*1),
            gr.io_signature(1, 1, gr.sizeof_char*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.scrambler = scrambler

        ##################################################
        # Blocks
        ##################################################
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x00, 16)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blks2_selector_0 = grc_blks2.selector(
        	item_size=gr.sizeof_char*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=scrambler,
        	output_index=0,
        )
        self.ax25_nrzi_encoder_0 = ax25.nrzi_encoder(0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.ax25_nrzi_encoder_0, 0), (self.blks2_selector_0, 0))    
        self.connect((self.ax25_nrzi_encoder_0, 0), (self.digital_scrambler_bb_0, 0))    
        self.connect((self.blks2_selector_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))    
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.ax25_nrzi_encoder_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self, 0))    
        self.connect((self.digital_scrambler_bb_0, 0), (self.blks2_selector_0, 1))    
        self.connect((self, 0), (self.blocks_packed_to_unpacked_xx_0, 0))    
예제 #11
0
    def __init__(self):
        gr.top_block.__init__(self, "Simple QAM Simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Simple QAM Simulation")
        self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        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)

        ##################################################
        # Variables
        ##################################################
        self.constellation_cardinality = constellation_cardinality = 16
        self.const_object = const_object = constellations()['qam'](
            constellation_cardinality)
        self.snr_db = snr_db = 20
        self.constellation = constellation = const_object.points()
        self.sps = sps = 8
        self.samp_rate = samp_rate = 250000
        self.noise_amp = noise_amp = sqrt((10**(-snr_db / 10.)) / 2.)
        self.constellation_power = constellation_power = sqrt(
            sum([abs(i)**2
                 for i in constellation]) / constellation_cardinality)

        ##################################################
        # Blocks
        ##################################################
        self.tabid_0 = Qt.QTabWidget()
        self.tabid_0_widget_0 = Qt.QWidget()
        self.tabid_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_0_widget_0)
        self.tabid_0_grid_layout_0 = Qt.QGridLayout()
        self.tabid_0_layout_0.addLayout(self.tabid_0_grid_layout_0)
        self.tabid_0.addTab(self.tabid_0_widget_0, "TX")
        self.tabid_0_widget_1 = Qt.QWidget()
        self.tabid_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_0_widget_1)
        self.tabid_0_grid_layout_1 = Qt.QGridLayout()
        self.tabid_0_layout_1.addLayout(self.tabid_0_grid_layout_1)
        self.tabid_0.addTab(self.tabid_0_widget_1, "CHANNEL")
        self.tabid_0_widget_2 = Qt.QWidget()
        self.tabid_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_0_widget_2)
        self.tabid_0_grid_layout_2 = Qt.QGridLayout()
        self.tabid_0_layout_2.addLayout(self.tabid_0_grid_layout_2)
        self.tabid_0.addTab(self.tabid_0_widget_2, "RX")
        self.top_grid_layout.addWidget(self.tabid_0, 30, 0, 10, 100)
        self.tabid_2 = Qt.QTabWidget()
        self.tabid_2_widget_0 = Qt.QWidget()
        self.tabid_2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_2_widget_0)
        self.tabid_2_grid_layout_0 = Qt.QGridLayout()
        self.tabid_2_layout_0.addLayout(self.tabid_2_grid_layout_0)
        self.tabid_2.addTab(self.tabid_2_widget_0, "symbol-based")
        self.tabid_2_widget_1 = Qt.QWidget()
        self.tabid_2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_2_widget_1)
        self.tabid_2_grid_layout_1 = Qt.QGridLayout()
        self.tabid_2_layout_1.addLayout(self.tabid_2_grid_layout_1)
        self.tabid_2.addTab(self.tabid_2_widget_1, "bit-based")
        self.tabid_2_widget_2 = Qt.QWidget()
        self.tabid_2_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_2_widget_2)
        self.tabid_2_grid_layout_2 = Qt.QGridLayout()
        self.tabid_2_layout_2.addLayout(self.tabid_2_grid_layout_2)
        self.tabid_2.addTab(self.tabid_2_widget_2, "BER")
        self.tabid_0_layout_2.addWidget(self.tabid_2)
        self.tabid_1 = Qt.QTabWidget()
        self.tabid_1_widget_0 = Qt.QWidget()
        self.tabid_1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_1_widget_0)
        self.tabid_1_grid_layout_0 = Qt.QGridLayout()
        self.tabid_1_layout_0.addLayout(self.tabid_1_grid_layout_0)
        self.tabid_1.addTab(self.tabid_1_widget_0, "bit-based")
        self.tabid_1_widget_1 = Qt.QWidget()
        self.tabid_1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_1_widget_1)
        self.tabid_1_grid_layout_1 = Qt.QGridLayout()
        self.tabid_1_layout_1.addLayout(self.tabid_1_grid_layout_1)
        self.tabid_1.addTab(self.tabid_1_widget_1, "scrambled")
        self.tabid_1_widget_2 = Qt.QWidget()
        self.tabid_1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.tabid_1_widget_2)
        self.tabid_1_grid_layout_2 = Qt.QGridLayout()
        self.tabid_1_layout_2.addLayout(self.tabid_1_grid_layout_2)
        self.tabid_1.addTab(self.tabid_1_widget_2, "symbol-based")
        self.tabid_0_grid_layout_0.addWidget(self.tabid_1, 0, 0, 10, 10)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #bw
            "QT GUI Plot",  #name
            1  #number of inputs
        )
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tabid_2_layout_2.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_sink_x_0_1_0_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            False,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self._qtgui_sink_x_0_1_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget)
        self.tabid_1_layout_0.addWidget(self._qtgui_sink_x_0_1_0_0_win)
        self.qtgui_sink_x_0_1_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            True,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self._qtgui_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.tabid_1_layout_1.addWidget(self._qtgui_sink_x_0_1_0_win)
        self.qtgui_sink_x_0_1 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            False,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self._qtgui_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.tabid_1_layout_2.addWidget(self._qtgui_sink_x_0_1_win)
        self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            True,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.tabid_2_layout_0.addWidget(self._qtgui_sink_x_0_0_0_0_win)
        self.qtgui_sink_x_0_0_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            False,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self._qtgui_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.tabid_2_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win)
        self.qtgui_sink_x_0_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            True,  #plotfreq
            False,  #plotwaterfall
            True,  #plottime
            False,  #plotconst
        )
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tabid_0_layout_1.addWidget(self._qtgui_sink_x_0_0_win)
        self.gr_vector_source_x_0_0 = gr.vector_source_b(([1, 0]), True, 1)
        self.gr_vector_source_x_0 = gr.vector_source_b(([1, 0]), True, 1)
        self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(
            int(log2(constellation_cardinality)))
        self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate)
        self.gr_pack_k_bits_bb_0 = gr.pack_k_bits_bb(
            int(log2(constellation_cardinality)))
        self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char * 1)
        self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_amp,
                                                     0)
        self.gr_nlog10_ff_0 = gr.nlog10_ff(1, 1, 0)
        self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vcc(
            (1. / constellation_power, ))
        self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc(
            (constellation_power, ))
        self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_gr_complex * 1,
                                               "rx_sym.32fc")
        self.gr_file_sink_0_1_0.set_unbuffered(False)
        self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_gr_complex * 1,
                                             "tx_sym.32fc")
        self.gr_file_sink_0_1.set_unbuffered(False)
        self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char * 1, "rx.8b")
        self.gr_file_sink_0_0.set_unbuffered(False)
        self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char * 1, "tx.8b")
        self.gr_file_sink_0.set_unbuffered(False)
        self.gr_descrambler_bb_0 = gr.descrambler_bb(0xe4001, 0x7ffff, 19)
        self.gr_char_to_float_1_0 = gr.char_to_float(1, 1)
        self.gr_char_to_float_1 = gr.char_to_float(1, 1)
        self.gr_char_to_float_0 = gr.char_to_float(1, 1)
        self.gr_add_xx_0 = gr.add_vcc(1)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(
            0xe4001, 0x7fffF, 19)
        self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(
            const_object.base(), 6.28 / 100, -0.25, +0.25)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (constellation), 1)
        self.blks2_error_rate_0 = grc_blks2.error_rate(
            type='BER',
            win_size=samp_rate,
            bits_per_symbol=1,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_vector_source_x_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.gr_pack_k_bits_bb_0, 0))
        self.connect((self.gr_pack_k_bits_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0),
                     (self.gr_file_sink_0_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0),
                     (self.gr_unpack_k_bits_bb_0, 0))
        self.connect((self.gr_unpack_k_bits_bb_0, 0),
                     (self.gr_descrambler_bb_0, 0))
        self.connect((self.gr_descrambler_bb_0, 0), (self.gr_null_sink_0, 0))
        self.connect((self.gr_multiply_const_vxx_0, 0),
                     (self.digital_constellation_receiver_cb_0, 0))
        self.connect((self.gr_descrambler_bb_0, 0),
                     (self.gr_char_to_float_0, 0))
        self.connect((self.gr_char_to_float_0, 0),
                     (self.qtgui_sink_x_0_0_0, 0))
        self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0))
        self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.gr_multiply_const_vxx_0_0, 0))
        self.connect((self.gr_multiply_const_vxx_0_0, 0),
                     (self.gr_file_sink_0_1, 0))
        self.connect((self.gr_multiply_const_vxx_0_0, 0),
                     (self.qtgui_sink_x_0_1, 0))
        self.connect((self.gr_char_to_float_1, 0),
                     (self.qtgui_sink_x_0_1_0, 0))
        self.connect((self.gr_pack_k_bits_bb_0, 0),
                     (self.gr_char_to_float_1, 0))
        self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_file_sink_0, 0))
        self.connect((self.gr_char_to_float_1_0, 0),
                     (self.qtgui_sink_x_0_1_0_0, 0))
        self.connect((self.gr_vector_source_x_0, 0),
                     (self.gr_char_to_float_1_0, 0))
        self.connect((self.gr_multiply_const_vxx_0_0, 0),
                     (self.gr_add_xx_0, 0))
        self.connect((self.gr_add_xx_0, 0), (self.qtgui_sink_x_0_0, 0))
        self.connect((self.gr_throttle_0, 0),
                     (self.gr_multiply_const_vxx_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_0_1_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0_0_0_0, 0))
        self.connect((self.gr_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blks2_error_rate_0, 0), (self.gr_nlog10_ff_0, 0))
        self.connect((self.gr_vector_source_x_0_0, 0),
                     (self.blks2_error_rate_0, 0))
        self.connect((self.gr_descrambler_bb_0, 0),
                     (self.blks2_error_rate_0, 1))
예제 #12
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.samp_per_sym = samp_per_sym = 5

        ##################################################
        # Blocks
        ##################################################
        self.satellites_pdu_to_kiss_0 = satellites.pdu_to_kiss()
        self.satellites_nrzi_encode_0 = satellites.nrzi_encode()
        self.satellites_nrzi_decode_0 = satellites.nrzi_decode()
        self.satellites_kiss_to_pdu_0 = satellites.kiss_to_pdu(True)
        self.satellites_hdlc_framer_0 = satellites.hdlc_framer(
            preamble_bytes=50, postamble_bytes=7)
        self.satellites_hdlc_deframer_0 = satellites.hdlc_deframer(
            check_fcs=True, max_length=10000)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #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(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            samp_per_sym * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '', '52001',
                                                     10000, True)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, samp_per_sym)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.5, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5, ))
        self.audio_source_0 = audio.source(samp_rate, '', True)
        self.audio_sink_0 = audio.sink(samp_rate, '', True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.satellites_hdlc_deframer_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.satellites_hdlc_deframer_0, 'out'),
                         (self.satellites_pdu_to_kiss_0, 'in'))
        self.msg_connect((self.satellites_hdlc_framer_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.satellites_kiss_to_pdu_0, 'out'),
                         (self.satellites_hdlc_framer_0, 'in'))
        self.msg_connect((self.satellites_pdu_to_kiss_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.audio_source_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.audio_source_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.satellites_kiss_to_pdu_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.satellites_nrzi_decode_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.satellites_hdlc_deframer_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.satellites_nrzi_encode_0, 0))
        self.connect((self.satellites_nrzi_decode_0, 0),
                     (self.digital_descrambler_bb_0, 0))
        self.connect((self.satellites_nrzi_encode_0, 0),
                     (self.blocks_repeat_0, 0))
예제 #13
0
    def __init__(self,
                 addr='0.0.0.0',
                 bb_gain=.4,
                 tx_correct=0,
                 tx_freq=433e6,
                 tx_gain=20,
                 tx_offset=50e3,
                 tx_period=50,
                 update_period=2000):
        gr.top_block.__init__(self, "MGS Rocksat Transceiver v2.0")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("MGS Rocksat Transceiver v2.0")
        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", "mgs_trx_1")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.addr = addr
        self.bb_gain = bb_gain
        self.tx_correct = tx_correct
        self.tx_freq = tx_freq
        self.tx_gain = tx_gain
        self.tx_offset = tx_offset
        self.tx_period = tx_period
        self.update_period = update_period

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 500e3
        self.baud = baud = 10e3
        self.samps_per_symb = samps_per_symb = int(samp_rate / baud)
        self.mult = mult = (samp_rate) / 2 / 3.141593
        self.decim = decim = 10
        self.alpha = alpha = 0.5

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(
            uhd.tune_request(tx_freq + tx_correct, tx_offset), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(False)
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=48,
                                                   postamble_bytes=10)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=50,
            bt=alpha,
            verbose=False,
            log=False,
        )
        self.blocks_random_pdu_0 = blocks.random_pdu(256, 256, chr(0xFF), 2)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(
            (bb_gain, ))
        self.blocks_message_strobe_0_1 = blocks.message_strobe(
            pmt.intern("TEST"), update_period)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(
            pmt.intern("TEST"), tx_period)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.blocks_message_strobe_0_1, 'strobe'),
                         (self.blocks_random_pdu_0, 'generate'))
        self.msg_connect((self.blocks_random_pdu_0, 'pdus'),
                         (self.blocks_message_strobe_0_0, 'set_msg'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.kiss_kiss_to_pdu_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
예제 #14
0
    def __init__(self, fsk_dev=10000, lpf_cutoff=12.5e3, lpf_trans=1e3):
        gr.top_block.__init__(self, "Fsk Tx Es")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fsk Tx Es")
        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", "fsk_tx_es")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Parameters
        ##################################################
        self.fsk_dev = fsk_dev
        self.lpf_cutoff = lpf_cutoff
        self.lpf_trans = lpf_trans

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48e3
        self.baud = baud = 9600
        self.samps_per_symb = samps_per_symb = int(samp_rate/baud)
        self.mult = mult = (samp_rate)/2/3.141593
        self.bb_gain = bb_gain = 10
        self.alpha = alpha = 0.5

        ##################################################
        # Blocks
        ##################################################
        self._bb_gain_range = Range(0, 10, .01, 10, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bb_gain_win, 6,0,1,4)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"TX Spectrum", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.010)
        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(True)
        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 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 2,0,4,4)
        self.pyqt_text_output_0_0 = pyqt.text_output()
        self._pyqt_text_output_0_0_win = self.pyqt_text_output_0_0;
        self.top_grid_layout.addWidget(self._pyqt_text_output_0_0_win, 0,0,2,4)
        self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True)
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=32, postamble_bytes=16)
        self.es_source_0 = es.source(1*[gr.sizeof_gr_complex], 1, 2, 0)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=samps_per_symb,
        	bt=alpha,
        	verbose=False,
        	log=False,
        )
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, '0.0.0.0', 9000, 1472, True)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.complex_t, 'packet_len')
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.blocks_tag_gate_0.set_single_key("packet_len")
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, 4096*3, "packet_len")
        (self.blocks_stream_to_tagged_stream_0).set_min_output_buffer(17000)
        self.blocks_socket_pdu_0_2 = blocks.socket_pdu("TCP_CLIENT", '0.0.0.0', '8000', 1024, False)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((bb_gain, ))



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.es_source_0, 'schedule_event'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.pyqt_text_output_0_0, 'pdus'))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.kiss_kiss_to_pdu_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_throttle_0_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_throttle_0_0, 0), (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.es_source_0, 0), (self.blocks_throttle_0_0, 0))
예제 #15
0
    def __init__(self, fsk_dev=10000, lpf_cutoff=12.5e3, lpf_trans=1e3):
        gr.top_block.__init__(self, "Usip Trx 1")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Usip Trx 1")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


        ##################################################
        # Parameters
        ##################################################
        self.fsk_dev = fsk_dev
        self.lpf_cutoff = lpf_cutoff
        self.lpf_trans = lpf_trans

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250000
        self.baud = baud = 9600
        self.samps_per_symb = samps_per_symb = int(samp_rate/baud)
        self.noise_amp = noise_amp = 0.3
        self.mult = mult = (samp_rate)/2/3.141593
        self.decim = decim = 5
        self.bb_gain = bb_gain = .75
        self.alpha = alpha = 0.5

        ##################################################
        # Blocks
        ##################################################
        self._noise_amp_range = Range(0, 1, 0.005, 0.3, 200)
        self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, "noise_amp", "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_amp_win, 6,0,1,4)
        self._bb_gain_range = Range(0, 1, .01, .75, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bb_gain_win, 5,0,1,4)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decim,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	2048, #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(True)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

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

        for i in xrange(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, 4,4,3,4)
        self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate/decim, #bw
        	"RX Spectrum", #name
        	1 #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(-80, 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(True)
        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 False:
          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 = ['', '', '', '', '',
                  '', '', '', '', '']
        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_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, 0,4,4,4)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"TX Spectrum", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_1.enable_autoscale(True)
        self.qtgui_freq_sink_x_1.enable_grid(True)
        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 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 0,0,4,4)
        self.pyqt_text_output_0 = pyqt.text_output()
        self._pyqt_text_output_0_win = self.pyqt_text_output_0;
        self.top_layout.addWidget(self._pyqt_text_output_0_win)
        self.pyqt_text_input_0 = pyqt.text_input()
        self._pyqt_text_input_0_win = self.pyqt_text_input_0;
        self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 4,0,1,4)
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate/decim, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76))
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=16)
        self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=samps_per_symb,
        	bt=alpha,
        	verbose=False,
        	log=False,
        )
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samps_per_symb*(1+0.0)/decim, 0.25*0.175*0.175, 0.25, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.blocks_tag_gate_0.set_single_key("packet_len")
        self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", '0.0.0.0', '52002', 1024, False)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((bb_gain, ))
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf((samp_rate/decim)/(2*math.pi*fsk_dev/8.0))
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_amp, 0, 8192)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_socket_pdu_0_2, 'pdus'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.pyqt_text_output_0, 'pdus'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in'))
        self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_1, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
예제 #16
0
    def __init__(self, principal_gui, options):
        '''
        See below for what options should hold
        '''
        gr.hier_block2.__init__(self, "transmit_path",
                gr.io_signature(0, 0, 0),                    # Input signature
                gr.io_signature(0, 0, 0)) # Output signature
        
        options = copy.copy(options)    # make a copy so we can destructively modify

        self._verbose            = options.verbose
        self._tx_amplitude       = options.tx_amplitude    # digital amplitude sent to USRP
        self._bitrate            = options.rate        # desired bit rate
        self._samples_per_symbol = options.sps  # desired samples/baud

        #setup usrp
        self._setup_usrp_sink(options)
        
        #create a BPSK modulator 
        self.modulator = bpsk_modulator(principal_gui, options)         # the modulator we are using
        
        #create packet input like in ieee 802.15.4
        #the size of the queue is 2 messages 
        #######################*************
        msgq_limit = 10
        self.pkt_input = blocks.message_source(gr.sizeof_char, msgq_limit)
             
        #The same chain like in ieee transceiver
        #add gain like in ieee802.15.4
        #######################################*****************
        #self.normal_gain = 8000
        #self.gain = gr.multiply_const_cc (self.normal_gain)
    
        self.amp = blocks.multiply_const_cc(options.amplitude)
        #self.set_tx_amplitude(self._tx_amplitude)

        # Display some information about the setup
        if self._verbose:
            self._print_verbage()

        # Connect components in the flowgraph
        #self.connect(self.packet_transmitter, self.amp, self)
#        self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
#            principal_gui.GetWin(),
#            title="Constellation Plot",
#            sample_rate=options.samp_rate,
#            frame_rate=5,
#            const_size=2048,
#            M=2,
#            theta=0,
#            fmax=0.06,
#            mu=0.5,
#            gain_mu=0.005,
#            symbol_rate=options.samp_rate/self._samples_per_symbol,
#            omega_limit=0.005,
#        )
#        principal_gui.Add(self.wxgui_constellationsink2_0.win)
        
        '''For Stream of bits '''
        self.vector_source = blocks.vector_source_b([1,], True)
        self.scrambler = digital.scrambler_bb(0x10,0x7F,7)
        #self.connect(self.vector_source,self.scrambler, self.modulator, self.amp, self.u)
        #self.connect(self.modulator,self.wxgui_constellationsink2_0)
        '''End For Stream of bits '''
        
        
        self.connect(self.pkt_input, self.modulator, self.amp, self.u)
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Outernet Flatsat Flowgraph")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Outernet Flatsat Flowgraph")
        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.rate = rate = 2
        self.polys = polys = [79, 109]
        self.k = k = 7
        self.frame_size = frame_size = 32
        self.uhd_samp_rate = uhd_samp_rate = 614400
        self.tx_gain = tx_gain = 0
        self.samples_per_symbol = samples_per_symbol = 64
        self.rx_gain = rx_gain = 0
        self.rf_tx_freq = rf_tx_freq = 145e6
        self.rf_rx_freq = rf_rx_freq = 401e6
        self.rf_offset_freq = rf_offset_freq = 80e3
        self.rf_bw = rf_bw = 100e3
        self.interleave = interleave = 4
        
        
        self.dec_cc = dec_cc = fec.cc_decoder.make(frame_size, k, rate, (polys), 0, -1, fec.CC_STREAMING, False)
            

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 90, 1, 0, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "TX Gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 90, 1, 0, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "RX Gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(uhd_samp_rate)
        self.uhd_usrp_source_0.set_center_freq(rf_rx_freq, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_bandwidth(rf_bw, 0)
        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_clock_rate(30.72e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(uhd_samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(rf_tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_bandwidth(rf_bw, 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=8,
                decimation=1,
                taps=None,
                fractional_bw=0.125,
        )
        self.pyqt_text_input_0 = pyqt.text_input()
        self._pyqt_text_input_0_win = self.pyqt_text_input_0;
        self.top_layout.addWidget(self._pyqt_text_input_0_win)
        self.fec_extended_decoder_0 = fec.extended_decoder(decoder_obj_list=dec_cc, threading= None, ann=None, puncpat=puncpat, integration_period=10000)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x00, 16)
        self.digital_map_bb_0 = digital.map_bb(([-1, 1]))
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=8,
        	bt=0.5,
        	verbose=False,
        	log=False,
        )
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=samples_per_symbol,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.ccsds_rs_decode_pdu_0 = ccsds.rs_decode_pdu(interleave)
        self.ccsds_asm_deframer_pdu_0 = ccsds.asm_deframer_pdu(0, interleave, 1, 255)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, "packet_len", 64*8)
        self.blocks_socket_pdu_1_0 = blocks.socket_pdu("TCP_CLIENT", "127.0.0.1", "51423", 892, False)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blocks_message_debug_0_1 = blocks.message_debug()
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.ax25_nrzi_encoder_0 = ax25.nrzi_encoder(0)
        self.ax25_encode_heir_0_0 = ax25_encode_heir(
            destination_callsign="PICASS",
            destination_ssid=0,
            post_flag_quantity=16,
            post_sync_quantity=16,
            pre_flag_quantity=16,
            pre_sync_quantity=128,
            source_callsign="BISAGS ",
            source_ssid=14,
            sync_value=85,
        )
        self.ais_invert_0 = ais.invert()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_1_0, 'pdus'), (self.ax25_encode_heir_0_0, 'pdus in'))    
        self.msg_connect((self.blocks_socket_pdu_1_0, 'pdus'), (self.blocks_message_debug_0_1, 'print_pdu'))    
        self.msg_connect((self.ccsds_asm_deframer_pdu_0, 'pdus'), (self.ccsds_rs_decode_pdu_0, 'pdu_in'))    
        self.msg_connect((self.ccsds_rs_decode_pdu_0, 'pdu_out'), (self.blocks_socket_pdu_1_0, 'pdus'))    
        self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.ax25_encode_heir_0_0, 'pdus in'))    
        self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.blocks_message_debug_0_1, 'print_pdu'))    
        self.connect((self.ais_invert_0, 0), (self.digital_map_bb_0, 0))    
        self.connect((self.ax25_encode_heir_0_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))    
        self.connect((self.ax25_nrzi_encoder_0, 0), (self.digital_scrambler_bb_0, 0))    
        self.connect((self.blocks_char_to_float_0_0, 0), (self.fec_extended_decoder_0, 0))    
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.ax25_nrzi_encoder_0, 0))    
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_gmsk_mod_0, 0))    
        self.connect((self.digital_gmsk_demod_0, 0), (self.ais_invert_0, 0))    
        self.connect((self.digital_gmsk_mod_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_0, 0))    
        self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))    
        self.connect((self.fec_extended_decoder_0, 0), (self.ccsds_asm_deframer_pdu_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.digital_gmsk_demod_0, 0))    
예제 #18
0
    def __init__(self,
                 fsk_dev=10000,
                 lpf_cutoff=12.5e3,
                 lpf_trans=1e3,
                 tx_freq=401.5e6,
                 tx_offset=250e3):
        gr.top_block.__init__(self, "Fsk Tx Uhd")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fsk Tx Uhd")
        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", "fsk_tx_uhd")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.fsk_dev = fsk_dev
        self.lpf_cutoff = lpf_cutoff
        self.lpf_trans = lpf_trans
        self.tx_freq = tx_freq
        self.tx_offset = tx_offset

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 240000
        self.baud = baud = 9600
        self.tx_gain = tx_gain = 0
        self.tx_correct = tx_correct = -300
        self.samps_per_symb = samps_per_symb = samp_rate / baud
        self.mult = mult = (samp_rate) / 2 / 3.141593
        self.interp = interp = 25
        self.decim = decim = 24
        self.bb_gain = bb_gain = .75
        self.alpha = alpha = .5

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 86, 1, 0, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        'TX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win, 7, 0, 1, 4)
        self._tx_correct_range = Range(-10000, 10000, 1, -300, 200)
        self._tx_correct_win = RangeWidget(self._tx_correct_range,
                                           self.set_tx_correct, "tx_correct",
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_correct_win, 8, 0, 1, 4)
        self._bb_gain_range = Range(0, 1, .01, .75, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain,
                                        'bb_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bb_gain_win, 6, 0, 1, 4)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0_0.set_samp_rate(250e3)
        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(
            uhd.tune_request(tx_freq + tx_correct, tx_offset), 0)
        self.uhd_usrp_sink_0_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=interp,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim * interp,  #bw
            "TX Spectrum",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.010)
        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(True)
        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 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 2, 0, 4,
                                       4)
        self.pyqt_text_output_0_0 = pyqt.text_output()
        self._pyqt_text_output_0_0_win = self.pyqt_text_output_0_0
        self.top_grid_layout.addWidget(self._pyqt_text_output_0_0_win, 0, 0, 2,
                                       4)
        self.kiss_nrzi_encode_0 = kiss.nrzi_encode()
        self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True)
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64,
                                                   postamble_bytes=64)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=int(samps_per_symb),
            bt=alpha,
            verbose=False,
            log=False,
        )
        self.blocks_socket_pdu_0_2 = blocks.socket_pdu("TCP_CLIENT", '0.0.0.0',
                                                       '8000', 1024, False)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(
            (bb_gain, ))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'),
                         (self.pyqt_text_output_0_0, 'pdus'))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.kiss_kiss_to_pdu_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.kiss_nrzi_encode_0, 0))
        self.connect((self.kiss_nrzi_encode_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.uhd_usrp_sink_0_0, 0))
예제 #19
0
    def __init__(self, EbN0):
        gr.top_block.__init__(self, "BER Simulation")

        ##################################################
        # Variables
        ##################################################
        self.N_BITS = N_BITS = 1e5
        self.EbN0 = EbN0
        self.sps = sps = 5
        self.samp_rate = samp_rate = 32000
        self.noise_voltage = noise_voltage = 1.0 / math.sqrt(
            1 / float(sps) * 10 ** (float(EbN0) / 10)
        )
        self.intdump_decim = intdump_decim = min(int(N_BITS / 10), 100000)
        self.const = const = digital.constellation_bpsk().base()
        self.alpha = alpha = 0.35
        self.SKIP = SKIP = 1000
        self.RAND_SEED = RAND_SEED = 42

        ##################################################
        # Blocks
        ##################################################
        self.lilacsat1_ber_bpsk_0 = lilacsat1_ber_bpsk(
            bfo=12000,
            callsign="",
            ip="::",
            latitude=0,
            longitude=0,
            port=7355,
            recstart="",
        )
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=const,
            differential=False,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=alpha,
            verbose=False,
            log=False,
        )
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise_voltage,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(0, 0, (1 + 1j) / numpy.sqrt(2),),
            noise_seed=RAND_SEED,
            block_tags=False,
        )
        self.blocks_vector_source_x_0 = blocks.vector_source_b([1], True, 1, [])
        self.blocks_vector_sink_x_0 = blocks.vector_sink_f(1, 1024)
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, SKIP)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(0.1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1.0 / intdump_decim)
        self.blocks_integrate_xx_0 = blocks.integrate_ff(intdump_decim, 1)
        self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, int(N_BITS))
        self.blocks_and_const_xx_0 = blocks.and_const_bb(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_and_const_xx_0, 0), (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_head_0, 0), (self.digital_scrambler_bb_0, 0))
        self.connect(
            (self.blocks_integrate_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)
        )
        self.connect(
            (self.blocks_multiply_const_vxx_0, 0), (self.blocks_vector_sink_x_0, 0)
        )
        self.connect(
            (self.blocks_multiply_const_vxx_1, 0), (self.lilacsat1_ber_bpsk_0, 0)
        )
        self.connect((self.blocks_not_xx_0, 0), (self.blocks_and_const_xx_0, 0))
        self.connect(
            (self.blocks_pack_k_bits_bb_0, 0),
            (self.digital_constellation_modulator_0, 0),
        )
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_not_xx_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_integrate_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_head_0, 0))
        self.connect(
            (self.channels_channel_model_0, 0), (self.blocks_multiply_const_vxx_1, 0)
        )
        self.connect(
            (self.digital_constellation_modulator_0, 0),
            (self.channels_channel_model_0, 0),
        )
        self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_skiphead_0, 0))
        self.connect(
            (self.digital_diff_decoder_bb_0, 0), (self.digital_descrambler_bb_0, 0)
        )
        self.connect(
            (self.digital_diff_encoder_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)
        )
        self.connect(
            (self.digital_scrambler_bb_0, 0), (self.digital_diff_encoder_bb_0, 0)
        )
        self.connect(
            (self.lilacsat1_ber_bpsk_0, 0), (self.digital_diff_decoder_bb_0, 0)
        )
예제 #20
0
    def __init__(self,
                 addr='0.0.0.0',
                 bb_gain=.4,
                 rx_gain=20,
                 tx_correct=0,
                 tx_freq=433e6,
                 tx_gain=20,
                 tx_offset=50e3):
        gr.top_block.__init__(self, "MGS Rocksat Transceiver v2.0")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("MGS Rocksat Transceiver v2.0")
        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", "fsk_trx_1")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.addr = addr
        self.bb_gain = bb_gain
        self.rx_gain = rx_gain
        self.tx_correct = tx_correct
        self.tx_freq = tx_freq
        self.tx_gain = tx_gain
        self.tx_offset = tx_offset

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 500e3
        self.baud = baud = 10e3
        self.samps_per_symb = samps_per_symb = int(samp_rate / baud)
        self.rx_freq = rx_freq = 433e6
        self.mult = mult = (samp_rate) / 2 / 3.141593
        self.decim = decim = 10
        self.alpha = alpha = 0.5

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(
            uhd.tune_request(rx_freq, samp_rate / 2), 0)
        self.uhd_usrp_source_0_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0_0.set_antenna('RX2', 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(
            uhd.tune_request(tx_freq + tx_correct, tx_offset), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.pyqt_text_input_0 = pyqt.text_input()
        self._pyqt_text_input_0_win = self.pyqt_text_input_0
        self.top_layout.addWidget(self._pyqt_text_input_0_win)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 15e3, 1000, firdes.WIN_HAMMING,
                            6.76))
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=48,
                                                   postamble_bytes=10)
        self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True,
                                                       max_length=256)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=50,
            bt=alpha,
            verbose=False,
            log=False,
        )
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            samps_per_symb * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.25, 0.175,
            0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_socket_pdu_0_1 = blocks.socket_pdu("TCP_SERVER", addr,
                                                       '52003', 1024, False)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pdu_set_0 = blocks.pdu_set(pmt.intern("key"),
                                               pmt.intern("value"))
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(
            (bb_gain, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(10)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_1, 'pdus'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.pyqt_text_input_0, 'pdus'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_descrambler_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.kiss_hdlc_deframer_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
예제 #21
0
    def __init__(self,
                 baudrate=9600,
                 default_attenuation=10,
                 default_dev=4950 / 2,
                 default_input=0,
                 default_ip='127.0.0.1',
                 default_port=5000,
                 freq=435750000,
                 samp_rate_tx=1920000,
                 sdr_dev='uhd=0'):
        gr.top_block.__init__(self, "GFSK TX")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("GFSK TX")
        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", "gfsk_tx_1U")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.baudrate = baudrate
        self.default_attenuation = default_attenuation
        self.default_dev = default_dev
        self.default_input = default_input
        self.default_ip = default_ip
        self.default_port = default_port
        self.freq = freq
        self.samp_rate_tx = samp_rate_tx
        self.sdr_dev = sdr_dev

        ##################################################
        # Variables
        ##################################################
        self.interp_tx = interp_tx = samp_rate_tx / baudrate
        self.sensitivity = sensitivity = 2 * math.pi * default_dev / samp_rate_tx

        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            1, samp_rate_tx, interp_tx, 0.3, 88)

        self.freq_offset = freq_offset = 0
        self.bt = bt = 0.5
        self.attenuation = attenuation = default_attenuation

        ##################################################
        # Blocks
        ##################################################
        self._freq_offset_range = Range(-20000, 20000, 100, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range,
                                            self.set_freq_offset,
                                            'Signal Frequency Offset',
                                            "counter_slider", int)
        self.top_grid_layout.addWidget(self._freq_offset_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._bt_range = Range(0, 1, 0.05, 0.5, 200)
        self._bt_win = RangeWidget(self._bt_range, self.set_bt, 'Gaussian BT',
                                   "counter_slider", float)
        self.top_grid_layout.addWidget(self._bt_win, 0, 4, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._attenuation_range = Range(0, 100, 1, default_attenuation, 200)
        self._attenuation_win = RangeWidget(self._attenuation_range,
                                            self.set_attenuation,
                                            'Signal Attenuation',
                                            "counter_slider", int)
        self.top_grid_layout.addWidget(self._attenuation_win, 0, 0, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate_tx,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 3,
                                       0, 2, 6)
        for r in range(3, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            500,  #size
            samp_rate_tx,  #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(-2, 2)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1, 0, 1,
                                       3)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 3):
            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_tx,  #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 = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_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, 3, 1,
                                       3)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.iio_fmcomms2_sink_0 = iio.fmcomms2_sink_f32c(
            'ip:pluto.local', freq + freq_offset, samp_rate_tx, 20000000, True,
            False, 0x8000, False, "A", attenuation, 10.0, '', True)
        self.digital_scrambler_bb_1 = digital.scrambler_bb(0x21, 0x7F, 16)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=interp_tx,
            sensitivity=sensitivity,
            bt=bt,
            verbose=False,
            log=False,
        )
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blks2_tcp_source = grc_blks2.tcp_source(
            itemsize=gr.sizeof_char * 1,
            addr=default_ip,
            port=default_port,
            server=True,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_tcp_source, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.digital_gfsk_mod_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.digital_scrambler_bb_1, 0))
        self.connect((self.digital_gfsk_mod_0, 0),
                     (self.iio_fmcomms2_sink_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.digital_scrambler_bb_1, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
    def __init__(
        self,
        EbN0=0,
        esprit_decimation=128,
        fc=436e6,
        mx=4,
        my=4,
        n=1,
        phi=50,
        rs_decimation=8,
        theta=30,
    ):
        gr.top_block.__init__(self, "BER Simulation")

        ##################################################
        # Parameters
        ##################################################
        self.EbN0 = EbN0
        self.esprit_decimation = esprit_decimation
        self.fc = fc
        self.mx = mx
        self.my = my
        self.n = n
        self.phi = phi
        self.rs_decimation = rs_decimation
        self.theta = theta

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 5
        self.N_BITS = N_BITS = 1e5
        self.samp_rate = samp_rate = 32000
        self.noise_voltage = noise_voltage = 1.0 / math.sqrt(
            1 / float(sps) * 10**(float(EbN0) / 10))
        self.intdump_decim = intdump_decim = min(int(N_BITS / 10), 100000)
        self.const = const = digital.constellation_bpsk().base()
        self.alpha = alpha = 0.35
        self.SKIP = SKIP = 1000
        self.RAND_SEED = RAND_SEED = 42

        ##################################################
        # Blocks
        ##################################################
        self.lilacsat1_ber_bpsk_0 = lilacsat1_ber_bpsk(
            bfo=12000,
            callsign="",
            ip="::",
            latitude=0,
            longitude=0,
            port=7355,
            recstart="",
        )
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=const,
            differential=False,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=alpha,
            verbose=False,
            log=False,
        )
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise_voltage,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(
                0,
                0,
                (1 + 1j) / numpy.sqrt(2),
            ),
            noise_seed=RAND_SEED,
            block_tags=False,
        )
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, mx * my)
        self.blocks_vector_source_x_0 = blocks.vector_source_b([1], True, 1,
                                                               [])
        self.blocks_vector_sink_x_0_0_0 = blocks.vector_sink_f(1, 1024)
        self.blocks_vector_sink_x_0_0 = blocks.vector_sink_f(1, 1024)
        self.blocks_vector_sink_x_0 = blocks.vector_sink_f(1, 1024)
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, mx * my)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, SKIP)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(0.1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(
            1.0 / intdump_decim)
        self.blocks_integrate_xx_0 = blocks.integrate_ff(intdump_decim, 1)
        self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, int(N_BITS))
        self.blocks_and_const_xx_0 = blocks.and_const_bb(1)
        self.beamforming_randomsampler_py_cc_0_0 = beamforming.randomsampler_py_cc(
            mx * my, rs_decimation)
        self.beamforming_phasedarray_py_cc_0 = beamforming.phasedarray_py_cc(
            mx, my, theta, phi, fc, 0)
        self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf(
            128, mx, my, fc, n)
        self.beamforming_beamformer_py_cc_0 = beamforming.beamformer_py_cc(
            mx, my, fc, 0, 0, 8 * 128)

        ##################################################
        # Connections
        ##################################################
        self.connect(
            (self.beamforming_beamformer_py_cc_0, 0),
            (self.blocks_multiply_const_vxx_1, 0),
        )
        self.connect(
            (self.beamforming_doaesprit_py_cf_0, 0),
            (self.beamforming_beamformer_py_cc_0, 1),
        )
        self.connect(
            (self.beamforming_doaesprit_py_cf_0, 1),
            (self.beamforming_beamformer_py_cc_0, 2),
        )
        self.connect((self.beamforming_doaesprit_py_cf_0, 0),
                     (self.blocks_vector_sink_x_0_0, 0))
        self.connect(
            (self.beamforming_doaesprit_py_cf_0, 1),
            (self.blocks_vector_sink_x_0_0_0, 0),
        )
        self.connect(
            (self.beamforming_phasedarray_py_cc_0, 0),
            (self.blocks_vector_to_stream_0, 0),
        )
        self.connect(
            (self.beamforming_randomsampler_py_cc_0_0, 0),
            (self.beamforming_doaesprit_py_cf_0, 0),
        )
        self.connect((self.blocks_and_const_xx_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_head_0, 0), (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_integrate_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_vector_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.lilacsat1_ber_bpsk_0, 0))
        self.connect((self.blocks_not_xx_0, 0),
                     (self.blocks_and_const_xx_0, 0))
        self.connect(
            (self.blocks_pack_k_bits_bb_0, 0),
            (self.digital_constellation_modulator_0, 0),
        )
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_not_xx_0, 0))
        self.connect(
            (self.blocks_stream_to_vector_0, 0),
            (self.beamforming_beamformer_py_cc_0, 0),
        )
        self.connect(
            (self.blocks_stream_to_vector_0, 0),
            (self.beamforming_randomsampler_py_cc_0_0, 0),
        )
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.blocks_integrate_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_head_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect(
            (self.digital_constellation_modulator_0, 0),
            (self.beamforming_phasedarray_py_cc_0, 0),
        )
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.blocks_skiphead_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.digital_descrambler_bb_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.lilacsat1_ber_bpsk_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
예제 #23
0
    def __init__(self):
        gr.top_block.__init__(self, "Gfsk Loopback")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Gfsk Loopback")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.samp_rate = samp_rate = 32000
        self.fm_sensitivity = fm_sensitivity = 1


        self.enc = enc = fec.tpc_encoder_make(([3]), ([43]), 26, 6, 9, 3);


        self.dec = dec = fec.tpc_decoder_make(([3]), ([43]), 26, 6, 9, 3, 6, 0);

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_1_1 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	'TX_BITS', #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(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_1.set_line_label(i, "Data {0}".format(i))
            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)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	'RX_BITS', #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(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_sink_x_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #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_grid_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)



        self._fm_sensitivity_range = Range(0, 10, 0.01, 1, 200)
        self._fm_sensitivity_win = RangeWidget(self._fm_sensitivity_range, self.set_fm_sensitivity, "fm_sensitivity", "counter_slider", float)
        self.top_grid_layout.addWidget(self._fm_sensitivity_win)
        self.fec_extended_encoder_0 = fec.extended_encoder(encoder_obj_list=enc, threading= None, puncpat='11')
        self.fec_extended_decoder_0 = fec.extended_decoder(decoder_obj_list=dec, threading= None, ann=None, puncpat='11', integration_period=10000)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x8A, 0x7F, 7)
        self.digital_map_bb_0 = digital.map_bb(([-1, 1]))
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=4,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=4,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x8A, 0x7F, 7)
        self.blocks_vector_source_x_0 = blocks.vector_source_b((0, 0, 0x55, 0x55), True, 1, [])
        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, samp_rate,True)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_char_to_float_0_1 = 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)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_1_1, 0))
        self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_char_to_float_0_1, 0), (self.fec_extended_decoder_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_throttle_0_0, 0), (self.digital_gmsk_demod_0, 0))
        self.connect((self.blocks_throttle_0_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_char_to_float_0_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.digital_map_bb_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_throttle_0_0, 0))
        self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_1, 0))
        self.connect((self.digital_scrambler_bb_0, 0), (self.fec_extended_encoder_0, 0))
        self.connect((self.fec_extended_decoder_0, 0), (self.digital_descrambler_bb_0, 0))
        self.connect((self.fec_extended_encoder_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
예제 #24
0
	def __init__(self):
		gr.top_block.__init__(self, "Simple QAM Simulation")
		Qt.QWidget.__init__(self)
		self.setWindowTitle("Simple QAM Simulation")
		self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
		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)


		##################################################
		# Variables
		##################################################
		self.constellation_cardinality = constellation_cardinality = 16
		self.const_object = const_object = constellations()['qam'](constellation_cardinality)
		self.snr_db = snr_db = 20
		self.constellation = constellation = const_object.points()
		self.sps = sps = 8
		self.samp_rate = samp_rate = 250000
		self.noise_amp = noise_amp = sqrt(  (10**(-snr_db/10.))  /2. )
		self.constellation_power = constellation_power = sqrt(sum([abs(i)**2 for i in constellation])/constellation_cardinality)

		##################################################
		# Blocks
		##################################################
		self.tabid_0 = Qt.QTabWidget()
		self.tabid_0_widget_0 = Qt.QWidget()
		self.tabid_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_0)
		self.tabid_0_grid_layout_0 = Qt.QGridLayout()
		self.tabid_0_layout_0.addLayout(self.tabid_0_grid_layout_0)
		self.tabid_0.addTab(self.tabid_0_widget_0, "TX")
		self.tabid_0_widget_1 = Qt.QWidget()
		self.tabid_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_1)
		self.tabid_0_grid_layout_1 = Qt.QGridLayout()
		self.tabid_0_layout_1.addLayout(self.tabid_0_grid_layout_1)
		self.tabid_0.addTab(self.tabid_0_widget_1, "CHANNEL")
		self.tabid_0_widget_2 = Qt.QWidget()
		self.tabid_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_0_widget_2)
		self.tabid_0_grid_layout_2 = Qt.QGridLayout()
		self.tabid_0_layout_2.addLayout(self.tabid_0_grid_layout_2)
		self.tabid_0.addTab(self.tabid_0_widget_2, "RX")
		self.top_grid_layout.addWidget(self.tabid_0, 30,0,10,100)
		self.tabid_2 = Qt.QTabWidget()
		self.tabid_2_widget_0 = Qt.QWidget()
		self.tabid_2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_0)
		self.tabid_2_grid_layout_0 = Qt.QGridLayout()
		self.tabid_2_layout_0.addLayout(self.tabid_2_grid_layout_0)
		self.tabid_2.addTab(self.tabid_2_widget_0, "symbol-based")
		self.tabid_2_widget_1 = Qt.QWidget()
		self.tabid_2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_1)
		self.tabid_2_grid_layout_1 = Qt.QGridLayout()
		self.tabid_2_layout_1.addLayout(self.tabid_2_grid_layout_1)
		self.tabid_2.addTab(self.tabid_2_widget_1, "bit-based")
		self.tabid_2_widget_2 = Qt.QWidget()
		self.tabid_2_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_2_widget_2)
		self.tabid_2_grid_layout_2 = Qt.QGridLayout()
		self.tabid_2_layout_2.addLayout(self.tabid_2_grid_layout_2)
		self.tabid_2.addTab(self.tabid_2_widget_2, "BER")
		self.tabid_0_layout_2.addWidget(self.tabid_2)
		self.tabid_1 = Qt.QTabWidget()
		self.tabid_1_widget_0 = Qt.QWidget()
		self.tabid_1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_0)
		self.tabid_1_grid_layout_0 = Qt.QGridLayout()
		self.tabid_1_layout_0.addLayout(self.tabid_1_grid_layout_0)
		self.tabid_1.addTab(self.tabid_1_widget_0, "bit-based")
		self.tabid_1_widget_1 = Qt.QWidget()
		self.tabid_1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_1)
		self.tabid_1_grid_layout_1 = Qt.QGridLayout()
		self.tabid_1_layout_1.addLayout(self.tabid_1_grid_layout_1)
		self.tabid_1.addTab(self.tabid_1_widget_1, "scrambled")
		self.tabid_1_widget_2 = Qt.QWidget()
		self.tabid_1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabid_1_widget_2)
		self.tabid_1_grid_layout_2 = Qt.QGridLayout()
		self.tabid_1_layout_2.addLayout(self.tabid_1_grid_layout_2)
		self.tabid_1.addTab(self.tabid_1_widget_2, "symbol-based")
		self.tabid_0_grid_layout_0.addWidget(self.tabid_1, 0,0,10,10)
		self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
			1024, #size
			samp_rate, #bw
			"QT GUI Plot", #name
			1 #number of inputs
		)
		self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
		self.tabid_2_layout_2.addWidget(self._qtgui_time_sink_x_0_win)
		self.qtgui_sink_x_0_1_0_0 = qtgui.sink_f(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			False, #plotfreq
			False, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_1_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget)
		self.tabid_1_layout_0.addWidget(self._qtgui_sink_x_0_1_0_0_win)
		self.qtgui_sink_x_0_1_0 = qtgui.sink_f(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			False, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_1_0_win = sip.wrapinstance(self.qtgui_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
		self.tabid_1_layout_1.addWidget(self._qtgui_sink_x_0_1_0_win)
		self.qtgui_sink_x_0_1 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			False, #plotfreq
			False, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_1_win = sip.wrapinstance(self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget)
		self.tabid_1_layout_2.addWidget(self._qtgui_sink_x_0_1_win)
		self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			False, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
		self.tabid_2_layout_0.addWidget(self._qtgui_sink_x_0_0_0_0_win)
		self.qtgui_sink_x_0_0_0 = qtgui.sink_f(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			False, #plotfreq
			False, #plotwaterfall
			True, #plottime
			True, #plotconst
		)
		self._qtgui_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
		self.tabid_2_layout_1.addWidget(self._qtgui_sink_x_0_0_0_win)
		self.qtgui_sink_x_0_0 = qtgui.sink_c(
			1024, #fftsize
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			True, #plotfreq
			False, #plotwaterfall
			True, #plottime
			False, #plotconst
		)
		self._qtgui_sink_x_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)
		self.tabid_0_layout_1.addWidget(self._qtgui_sink_x_0_0_win)
		self.gr_vector_source_x_0_0 = gr.vector_source_b(([1,0]), True, 1)
		self.gr_vector_source_x_0 = gr.vector_source_b(([1,0]), True, 1)
		self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(int(log2(constellation_cardinality)))
		self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate)
		self.gr_pack_k_bits_bb_0 = gr.pack_k_bits_bb(int(log2(constellation_cardinality)))
		self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char*1)
		self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_amp, 0)
		self.gr_nlog10_ff_0 = gr.nlog10_ff(1, 1, 0)
		self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vcc((1./constellation_power, ))
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((constellation_power, ))
		self.gr_file_sink_0_1_0 = gr.file_sink(gr.sizeof_gr_complex*1, "rx_sym.32fc")
		self.gr_file_sink_0_1_0.set_unbuffered(False)
		self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_gr_complex*1, "tx_sym.32fc")
		self.gr_file_sink_0_1.set_unbuffered(False)
		self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char*1, "rx.8b")
		self.gr_file_sink_0_0.set_unbuffered(False)
		self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char*1, "tx.8b")
		self.gr_file_sink_0.set_unbuffered(False)
		self.gr_descrambler_bb_0 = gr.descrambler_bb(0xe4001, 0x7ffff, 19)
		self.gr_char_to_float_1_0 = gr.char_to_float(1, 1)
		self.gr_char_to_float_1 = gr.char_to_float(1, 1)
		self.gr_char_to_float_0 = gr.char_to_float(1, 1)
		self.gr_add_xx_0 = gr.add_vcc(1)
		self.digital_scrambler_bb_0 = digital.scrambler_bb(0xe4001, 0x7fffF, 19)
		self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(const_object.base(), 6.28/100, -0.25, +0.25)
		self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((constellation), 1)
		self.blks2_error_rate_0 = grc_blks2.error_rate(
			type='BER',
			win_size=samp_rate,
			bits_per_symbol=1,
		)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_vector_source_x_0, 0), (self.digital_scrambler_bb_0, 0))
		self.connect((self.digital_scrambler_bb_0, 0), (self.gr_pack_k_bits_bb_0, 0))
		self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
		self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_file_sink_0_0, 0))
		self.connect((self.digital_constellation_receiver_cb_0, 0), (self.gr_unpack_k_bits_bb_0, 0))
		self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_descrambler_bb_0, 0))
		self.connect((self.gr_descrambler_bb_0, 0), (self.gr_null_sink_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.digital_constellation_receiver_cb_0, 0))
		self.connect((self.gr_descrambler_bb_0, 0), (self.gr_char_to_float_0, 0))
		self.connect((self.gr_char_to_float_0, 0), (self.qtgui_sink_x_0_0_0, 0))
		self.connect((self.gr_add_xx_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1))
		self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0))
		self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_file_sink_0_1, 0))
		self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.qtgui_sink_x_0_1, 0))
		self.connect((self.gr_char_to_float_1, 0), (self.qtgui_sink_x_0_1_0, 0))
		self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_char_to_float_1, 0))
		self.connect((self.gr_pack_k_bits_bb_0, 0), (self.gr_file_sink_0, 0))
		self.connect((self.gr_char_to_float_1_0, 0), (self.qtgui_sink_x_0_1_0_0, 0))
		self.connect((self.gr_vector_source_x_0, 0), (self.gr_char_to_float_1_0, 0))
		self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 0))
		self.connect((self.gr_add_xx_0, 0), (self.qtgui_sink_x_0_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_0_1_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.qtgui_sink_x_0_0_0_0, 0))
		self.connect((self.gr_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0))
		self.connect((self.blks2_error_rate_0, 0), (self.gr_nlog10_ff_0, 0))
		self.connect((self.gr_vector_source_x_0_0, 0), (self.blks2_error_rate_0, 0))
		self.connect((self.gr_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1))
예제 #25
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)            
예제 #26
0
    def __init__(self,
                 gs_name='VTGS',
                 ip='0.0.0.0',
                 meta_rate=.1,
                 port='52003',
                 record_iq=0,
                 record_rfo=0,
                 record_snr=0,
                 tx_freq=1265e6,
                 tx_offset=250e3):
        gr.top_block.__init__(self, "VTGS Rocksat-X 2017 Transceiver v2.0")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("VTGS Rocksat-X 2017 Transceiver v2.0")
        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", "vtgs_trx_file")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.gs_name = gs_name
        self.ip = ip
        self.meta_rate = meta_rate
        self.port = port
        self.record_iq = record_iq
        self.record_rfo = record_rfo
        self.record_snr = record_snr
        self.tx_freq = tx_freq
        self.tx_offset = tx_offset

        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(),
                                           "%Y%m%d_%H%M%S.%f") + '_UTC'
        self.samp_rate = samp_rate = 500e3
        self.baud = baud = 125e3
        self.snr_fn = snr_fn = "{:s}_{:s}.snr".format(gs_name, ts_str)
        self.samps_per_symb = samps_per_symb = int(samp_rate / baud)
        self.rx_freq = rx_freq = 2395e6
        self.rfo_fn = rfo_fn = "{:s}_{:s}.rfo".format(gs_name, ts_str)
        self.iq_fn = iq_fn = "{:s}_{:s}_{:s}k.fc32".format(
            gs_name, ts_str, str(int(samp_rate) / 1000))
        self.alpha = alpha = 0.5
        self.uplink_label = uplink_label = ''
        self.tx_gain = tx_gain = 25
        self.tx_correct = tx_correct = 2000
        self.snr_fp = snr_fp = "/captures/rocksat/{:s}".format(snr_fn)
        self.rx_offset = rx_offset = 250e3
        self.rx_gain = rx_gain = 1
        self.rx_freq_lbl = rx_freq_lbl = "{:4.3f}".format(rx_freq / 1e6)

        self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine(
            32, 1.0, 1.0 / (samps_per_symb * 32), alpha, samps_per_symb * 32)

        self.rfo_fp = rfo_fp = "/captures/rocksat/{:s}".format(rfo_fn)
        self.mult = mult = (samp_rate) / 2 / 3.141593

        self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate,
                                                   samp_rate / 2, 1000,
                                                   firdes.WIN_HAMMING, 6.76)

        self.lo = lo = 1833e6
        self.khz_offset = khz_offset = 0
        self.iq_fp = iq_fp = "/captures/rocksat/{:s}".format(iq_fn)
        self.bb_gain = bb_gain = .75

        ##################################################
        # Blocks
        ##################################################
        self._khz_offset_range = Range(-150, 150, 1, 0, 200)
        self._khz_offset_win = RangeWidget(self._khz_offset_range,
                                           self.set_khz_offset, 'Offset [kHz]',
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._khz_offset_win, 4, 8, 1, 4)
        self._bb_gain_range = Range(0, 1, .01, .75, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain,
                                        'bb_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bb_gain_win, 11, 8, 1, 4)
        self.vtgs_mult_descrambler_0 = vtgs.mult_descrambler(17, 0x3FFFF)
        self.vtgs_ao40_decoder_0_0 = vtgs.ao40_decoder()
        self._uplink_label_tool_bar = Qt.QToolBar(self)

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

        self._uplink_label_tool_bar.addWidget(Qt.QLabel('TX MSG' + ": "))
        self._uplink_label_label = Qt.QLabel(
            str(self._uplink_label_formatter(self.uplink_label)))
        self._uplink_label_tool_bar.addWidget(self._uplink_label_label)
        self.top_grid_layout.addWidget(self._uplink_label_tool_bar, 9, 8, 1, 1)

        self._tx_gain_range = Range(0, 86, 1, 25, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        'TX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win, 10, 8, 1, 4)
        self._tx_correct_range = Range(-10000, 10000, 1, 2000, 200)
        self._tx_correct_win = RangeWidget(self._tx_correct_range,
                                           self.set_tx_correct, "tx_correct",
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_correct_win, 12, 8, 1, 4)
        self._rx_gain_range = Range(0, 86, 1, 1, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'RX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win, 3, 8, 1, 4)
        self._rx_freq_lbl_tool_bar = Qt.QToolBar(self)

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

        self._rx_freq_lbl_tool_bar.addWidget(Qt.QLabel('RX Freq [MHz]' + ": "))
        self._rx_freq_lbl_label = Qt.QLabel(
            str(self._rx_freq_lbl_formatter(self.rx_freq_lbl)))
        self._rx_freq_lbl_tool_bar.addWidget(self._rx_freq_lbl_label)
        self.top_grid_layout.addWidget(self._rx_freq_lbl_tool_bar, 0, 10, 1, 2)

        self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=10,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=8,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=8,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            '',  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(True)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not False:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

        labels = ['pre-d', 'post', '', '', '', '', '', '', '', '']
        colors = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-130, -20)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 5,
                                       0, 4, 8)
        self.qtgui_number_sink_2 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_2.set_update_time(0.10)
        self.qtgui_number_sink_2.set_title("")

        labels = ['EVM', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_2.set_min(i, -1)
            self.qtgui_number_sink_2.set_max(i, 1)
            self.qtgui_number_sink_2.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_2.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_2.set_label(i, labels[i])
            self.qtgui_number_sink_2.set_unit(i, units[i])
            self.qtgui_number_sink_2.set_factor(i, factor[i])

        self.qtgui_number_sink_2.enable_autoscale(False)
        self._qtgui_number_sink_2_win = sip.wrapinstance(
            self.qtgui_number_sink_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_2_win, 2, 8, 1,
                                       4)
        self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0_0.set_title("")

        labels = ['SNR', '', '', '', '', '', '', '', '', '']
        units = ['dB', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0_0_0_0.set_min(i, 0)
            self.qtgui_number_sink_0_0_0_0.set_max(i, 30)
            self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0],
                                                     colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0_0_0.set_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 1,
                                       8, 1, 4)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['RX Freq Offset', 'SNR', '', '', '', '', '', '', '', '']
        units = ['Hz', 'dB', '', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 8, 1,
                                       2)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / 10,  #bw
            "TX Spectrum",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(True)
        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 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 9, 0, 4,
                                       8)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024 * 4,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.0010)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -20)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 5,
                                       8)
        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(-1, 1)
        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, 5, 8, 4,
                                       4)
        self.pyqt_text_input_0 = pyqt.text_input()
        self._pyqt_text_input_0_win = self.pyqt_text_input_0
        self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 9, 9, 1, 3)
        self.mapper_demapper_soft_0 = mapper.demapper_soft(
            mapper.BPSK, ([0, 1]))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000,
                            firdes.WIN_HAMMING, 6.76))
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64,
                                                   postamble_bytes=16)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (lpf_taps), khz_offset * 1000, samp_rate)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(
            samps_per_symb, math.pi * 2 / 100, (rrc_filter_taps), 32, 16, 1.5,
            1)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=50,
            bt=alpha,
            verbose=False,
            log=False,
        )
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            math.pi * 2 / 100, 2, False)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            math.pi * 2 / 100, 2, False)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", ip,
                                                       '52002', 1024, False)
        self.blocks_socket_pdu_0_1 = blocks.socket_pdu("TCP_SERVER", ip, port,
                                                       1024, False)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(
            (bb_gain, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, ))
        self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff(
            100000, 0.00001, 4000)
        self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(
            1000, 0.001, 4000)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            100000, 0.00001, 4000)
        self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, int(samp_rate * meta_rate))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, int(samp_rate / 8 * meta_rate))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/captures/rocksat/testing/trimmed_500k.fc32', True)
        self.blocks_file_sink_1_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                     rfo_fp, False)
        self.blocks_file_sink_1_0.set_unbuffered(False)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1, snr_fp,
                                                   False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   iq_fp, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.blks2_selector_0_0_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=1,
            num_outputs=2,
            input_index=0,
            output_index=int(record_snr),
        )
        self.blks2_selector_0_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=1,
            num_outputs=2,
            input_index=0,
            output_index=int(record_rfo),
        )
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=1,
            num_outputs=2,
            input_index=0,
            output_index=int(record_iq),
        )
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 125e3, 1, 0)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_1, 'pdus'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.pyqt_text_input_0, 'pdus'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.vtgs_ao40_decoder_0_0, 'valid_frames'),
                         (self.blocks_socket_pdu_0_1, 'pdus'))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blks2_selector_0, 1), (self.blocks_file_sink_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.blks2_selector_0_0, 1),
                     (self.blocks_file_sink_1_0, 0))
        self.connect((self.blks2_selector_0_0, 0),
                     (self.blocks_null_sink_0_0, 0))
        self.connect((self.blks2_selector_0_0_0, 1),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blks2_selector_0_0_0, 0),
                     (self.blocks_null_sink_0_0_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.qtgui_number_sink_2, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_moving_average_xx_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_nlog10_ff_0_1, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blks2_selector_0_0_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_0, 0),
                     (self.blks2_selector_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_keep_one_in_n_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0_1, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0_1, 0),
                     (self.qtgui_number_sink_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.rational_resampler_xxx_2, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_nlog10_ff_0_1, 0),
                     (self.blocks_moving_average_xx_0_0_1, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.mapper_demapper_soft_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_0, 1),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.vtgs_mult_descrambler_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_agc2_xx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.mapper_demapper_soft_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.rational_resampler_xxx_2, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.vtgs_mult_descrambler_0, 0),
                     (self.vtgs_ao40_decoder_0_0, 0))
예제 #27
0
    def __init__(self, tx_freq=401.5e6, tx_offset=250e3):
        gr.top_block.__init__(self, "Simple GMSK/AX.25 Transmitter")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Simple GMSK/AX.25 Transmitter")
        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", "fsk_tx_file")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Parameters
        ##################################################
        self.tx_freq = tx_freq
        self.tx_offset = tx_offset

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 240000
        self.baud = baud = 9600
        self.tx_gain = tx_gain = 0
        self.tx_correct = tx_correct = -300
        self.samps_per_symb = samps_per_symb = samp_rate/baud
        self.interp = interp = 25
        self.decim = decim = 24
        self.bb_gain = bb_gain = .75
        self.alpha = alpha = .5

        ##################################################
        # Blocks
        ##################################################
        self._bb_gain_range = Range(0, 1, .01, .75, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bb_gain_win, 6, 0, 1, 4)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.vcc_qt_hex_text_0 = vcc.qt_hex_text()
        self._vcc_qt_hex_text_0_win = self.vcc_qt_hex_text_0;
        self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_win, 0, 0, 2, 4)
        for r in range(0, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)

        self._tx_gain_range = Range(0, 86, 1, 0, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win, 7, 0, 1, 4)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._tx_correct_range = Range(-10000, 10000, 1, -300, 200)
        self._tx_correct_win = RangeWidget(self._tx_correct_range, self.set_tx_correct, "tx_correct", "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_correct_win, 8, 0, 1, 4)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=5,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=interp,
                decimation=decim,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate/decim * interp/5, #bw
        	"TX Spectrum", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.010)
        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(True)
        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 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 2, 0, 4, 4)
        for r in range(2, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.kiss_nrzi_encode_0 = kiss.nrzi_encode()
        self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True)
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=64)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=int(samps_per_symb),
        	bt=alpha,
        	verbose=False,
        	log=False,
        )
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.blocks_tag_gate_0.set_single_key("packet_len")
        self.blocks_socket_pdu_0_2 = blocks.socket_pdu("TCP_CLIENT", '0.0.0.0', '8000', 1024, False)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((bb_gain, ))



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.vcc_qt_hex_text_0, 'pdus'))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.kiss_kiss_to_pdu_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0), (self.kiss_nrzi_encode_0, 0))
        self.connect((self.kiss_nrzi_encode_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_1, 0))
예제 #28
0
    def __init__(self, address='serial=30AD34D'):
        gr.top_block.__init__(self, "MPSK TX RX")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("MPSK TX 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", "MPSK_TX_RX")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.address = address

        ##################################################
        # Variables
        ##################################################
        self.const_type = const_type = 2
        self.bits_per_symbol = bits_per_symbol = int(const_type + 1)
        self.samples_per_symbol = samples_per_symbol = int(2 *
                                                           (bits_per_symbol))
        self.probe_SNR = probe_SNR = 0
        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.timing_bw = timing_bw = 2 * math.pi / 100.0
        self.samp_rate = samp_rate = samples_per_symbol * bitrate
        self.phase_bw = phase_bw = 2 * math.pi / 100.0
        self.ntaps = ntaps = 11 * int(samples_per_symbol * nfilts)
        self.lo_offset = lo_offset = 6e6
        self.gain_rx = gain_rx = 0.75
        self.freq_rx = freq_rx = 2390e6
        self.freq_bw = freq_bw = 2 * math.pi / 100.0
        self.fll_ntaps = fll_ntaps = 55
        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
        self.SNR = SNR = probe_SNR

        ##################################################
        # 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._lo_offset_options = (
            0,
            6e6,
            11e6,
        )
        self._lo_offset_labels = (
            str(self._lo_offset_options[0]),
            str(self._lo_offset_options[1]),
            str(self._lo_offset_options[2]),
        )
        self._lo_offset_tool_bar = Qt.QToolBar(self)
        self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": "))
        self._lo_offset_combo_box = Qt.QComboBox()
        self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box)
        for label in self._lo_offset_labels:
            self._lo_offset_combo_box.addItem(label)
        self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._lo_offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._lo_offset_options.index(i)))
        self._lo_offset_callback(self.lo_offset)
        self._lo_offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_lo_offset(self._lo_offset_options[i]))
        self.top_grid_layout.addWidget(self._lo_offset_tool_bar, 2, 1, 1, 1)
        self._gain_rx_range = Range(0, 1, 0.01, 0.75, 200)
        self._gain_rx_win = RangeWidget(self._gain_rx_range, self.set_gain_rx,
                                        'UHD Rx Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_rx_win, 1, 1, 1, 1)
        self._freq_rx_range = Range(2350e6, 2500e6, 10e6, 2390e6, 200)
        self._freq_rx_win = RangeWidget(self._freq_rx_range, self.set_freq_rx,
                                        'UHD Rx Freq (Hz)', "counter_slider",
                                        float)
        self.top_grid_layout.addWidget(self._freq_rx_win, 0, 1, 1, 1)
        self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c(
            2, 1000, 10 / bitrate)
        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: 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_source_0 = uhd.usrp_source(
            ",".join((address, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_subdev_spec('A:A', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq_rx,
                             rf_freq=freq_rx - lo_offset,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(gain_rx, 0)
        self.uhd_usrp_source_0.set_antenna('TX/RX', 0)
        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.qtgui_number_sink_0_1 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_HORIZ,
                                                       1)
        self.qtgui_number_sink_0_1.set_update_time(0.10)
        self.qtgui_number_sink_0_1.set_title("BER")

        labels = ['BER', '', '', '', '', '', '', '', '', '']
        units = ['x10^-6', '', '', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1e6, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0_1.set_min(i, 0)
            self.qtgui_number_sink_0_1.set_max(i, 1)
            self.qtgui_number_sink_0_1.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_1.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_1.set_label(i, labels[i])
            self.qtgui_number_sink_0_1.set_unit(i, units[i])
            self.qtgui_number_sink_0_1.set_factor(i, factor[i])

        self.qtgui_number_sink_0_1.enable_autoscale(True)
        self._qtgui_number_sink_0_1_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_1_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_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.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, 3, 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(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 3, 1, 1,
                                       1)

        def _probe_SNR_probe():
            while True:
                val = self.digital_probe_mpsk_snr_est_c_0.snr()
                try:
                    self.set_probe_SNR(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _probe_SNR_thread = threading.Thread(target=_probe_SNR_probe)
        _probe_SNR_thread.daemon = True
        _probe_SNR_thread.start()

        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_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            samples_per_symbol, timing_bw, (firdes.root_raised_cosine(
                nfilts, nfilts * samples_per_symbol, 1.0, 0.35, ntaps)),
            nfilts, nfilts // 2, 1.5, 1)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(
            samples_per_symbol, excess_bw, fll_ntaps, freq_bw)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(arrity)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(arrity)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x8A, 0x7F, 7)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            timing_bw, pow(2, bits_per_symbol), False)
        self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(
            constellation[const_type].base())
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (constellation[const_type].points()), 1)
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b([
            1,
        ], True, 1, [])
        self.blocks_vector_source_x_0 = blocks.vector_source_b([
            1,
        ], True, 1, [])
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(
            bits_per_symbol)
        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, ))
        self.blks2_error_rate_0 = grc_blks2.error_rate(
            type='BER',
            win_size=10000,
            bits_per_symbol=1,
        )
        self.analog_agc2_xx_0 = analog.agc2_cc(0.6e-1, 1e-3, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)
        self._SNR_tool_bar = Qt.QToolBar(self)

        if None:
            self._SNR_formatter = None
        else:
            self._SNR_formatter = lambda x: x

        self._SNR_tool_bar.addWidget(Qt.QLabel("SNR" + ": "))
        self._SNR_label = Qt.QLabel(str(self._SNR_formatter(self.SNR)))
        self._SNR_tool_bar.addWidget(self._SNR_label)
        self.top_layout.addWidget(self._SNR_tool_bar)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.blks2_error_rate_0, 0),
                     (self.qtgui_number_sink_0_1, 0))
        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_unpack_k_bits_bb_0, 0),
                     (self.digital_descrambler_bb_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0),
                     (self.blks2_error_rate_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_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_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, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_probe_mpsk_snr_est_c_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.blks2_error_rate_0, 1))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_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))
        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))
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
예제 #29
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))
예제 #30
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "Superposition coding with MPSK modulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Superposition coding with MPSK modulation")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.snr_db = snr_db = 10
        self.noisevar = noisevar = 10**(-snr_db / 10)
        self.block = block = 1000
        self.alpha = alpha = .1
        self.R = R = 100e3

        ##################################################
        # Blocks
        ##################################################
        self._alpha_range = Range(0, 1, .01, .1, 200)
        self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha,
                                      'P1/P', "counter_slider", float)
        self.top_layout.addWidget(self._alpha_win)
        self._snr_db_range = Range(0, 20, 1, 10, 200)
        self._snr_db_win = RangeWidget(self._snr_db_range, self.set_snr_db,
                                       'P/sigma^2 (dB)', "counter_slider",
                                       float)
        self.top_layout.addWidget(self._snr_db_win)
        self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_HORIZ,
                                                       1)
        self.qtgui_number_sink_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0.set_title("BER 2 (Raw)")

        labels = ['BER', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0_0.set_min(i, 0)
            self.qtgui_number_sink_0_0.set_max(i, 1)
            self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 0, 1,
                                       1, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("BER1 (Raw)")

        labels = ['BER', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, 0)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 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(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.digital_scrambler_bb_0_1 = digital.scrambler_bb(0x8A, 0x7F, 7)
        self.digital_scrambler_bb_0_0 = digital.scrambler_bb(0xDA, 0x7F, 7)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x8A, 0x7F, 7)
        self.digital_psk_mod_0_1 = digital.psk.psk_mod(
            constellation_points=4,
            mod_code="gray",
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_psk_mod_0_0 = digital.psk.psk_mod(
            constellation_points=4,
            mod_code="gray",
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_psk_mod_0 = digital.psk.psk_mod(
            constellation_points=4,
            mod_code="gray",
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_psk_demod_0_0 = digital.psk.psk_demod(
            constellation_points=4,
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.digital_psk_demod_0 = digital.psk.psk_demod(
            constellation_points=4,
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.digital_descrambler_bb_0_1 = digital.descrambler_bb(0xDA, 0x7F, 7)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x8A, 0x7F, 7)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char * 1, R, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, R, True)
        self.blocks_sub_xx_2 = blocks.sub_cc(1)
        self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc(
            (alpha**0.5, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc(
            ((1 - alpha)**0.5, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (alpha**0.5, ))
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blks2_error_rate_0_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.blks2_error_rate_0 = grc_blks2.error_rate(
            type='BER',
            win_size=block * 100,
            bits_per_symbol=2,
        )
        self.analog_random_source_x_1 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, block)), True)
        self.analog_random_source_x_0_0_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, block)), True)
        self.analog_random_source_x_0_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, block)), True)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, block)), True)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, noisevar, -42)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.analog_random_source_x_0_0, 0),
                     (self.blks2_error_rate_0, 0))
        self.connect((self.analog_random_source_x_0_0_0, 0),
                     (self.blks2_error_rate_0_0, 0))
        self.connect((self.analog_random_source_x_1, 0),
                     (self.digital_scrambler_bb_0_0, 0))
        self.connect((self.blks2_error_rate_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blks2_error_rate_0_0, 0),
                     (self.qtgui_number_sink_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.digital_psk_demod_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.digital_psk_demod_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_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_2, 0),
                     (self.blocks_sub_xx_2, 1))
        self.connect((self.blocks_sub_xx_2, 0), (self.blocks_null_sink_0_1, 0))
        self.connect((self.blocks_throttle_0, 0), (self.digital_psk_mod_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.digital_psk_mod_0_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.blks2_error_rate_0, 1))
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.digital_scrambler_bb_0_1, 0))
        self.connect((self.digital_descrambler_bb_0_1, 0),
                     (self.blks2_error_rate_0_0, 1))
        self.connect((self.digital_psk_demod_0, 0),
                     (self.digital_descrambler_bb_0, 0))
        self.connect((self.digital_psk_demod_0_0, 0),
                     (self.digital_descrambler_bb_0_1, 0))
        self.connect((self.digital_psk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_psk_mod_0_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.digital_psk_mod_0_1, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_scrambler_bb_0_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.digital_scrambler_bb_0_1, 0),
                     (self.digital_psk_mod_0_1, 0))