示例#1
0
    def __init__(self,
                 channel_shift_hz=0,
                 random_source_seed=0,
                 sample_rate=0,
                 symbol_rate=1):
        gr.hier_block2.__init__(
            self,
            "Hurdle2 Psk",
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.channel_shift_hz = channel_shift_hz
        self.random_source_seed = random_source_seed
        self.sample_rate = sample_rate
        self.symbol_rate = symbol_rate

        ##################################################
        # Blocks
        ##################################################
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, sample_rate, symbol_rate * 5, symbol_rate,
                            firdes.WIN_HAMMING, 6.76))
        self.digital_psk_mod_0 = digital.psk.psk_mod(
            constellation_points=4,
            mod_code="gray",
            differential=True,
            samples_per_symbol=sample_rate / symbol_rate,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            sample_rate, analog.GR_COS_WAVE, channel_shift_hz, 1, 0)
        self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(
            0, 254, random_source_seed)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_uniform_source_x_0, 0),
                     (self.digital_psk_mod_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self, 0))
        self.connect((self.digital_psk_mod_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
示例#2
0
 def test_001_byte(self):
     minimum = 0
     maximum = 5
     seed = 3
     n_items = 10000
     rnd_src = analog.random_uniform_source_b(minimum, maximum, seed)
     head = blocks.head(1, n_items)
     snk = blocks.vector_sink_b(1)
     self.tb.connect(rnd_src, head, snk)
     # set up fg
     self.tb.run()
     # check data
     res = snk.data()
     self.assertGreaterEqual(minimum, np.min(res))
     self.assertLess(np.max(res), maximum)
    def __init__(self):
        gr.top_block.__init__(self, "Minimal Working Example")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.var_sink_x_0 = var_sink_b(num_inputs=1,
                                       log_level=logging.NOTSET,
                                       log_filename='')
        self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(
            0, 200, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_uniform_source_x_0, 0),
                     (self.var_sink_x_0, 0))
    def __init__(self):
        gr.top_block.__init__(self,
                              "Symbol Mapping Demo",
                              catch_exceptions=True)
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Symbol Mapping Demo")
        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", "symbol_mapping_demo")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.constellation_order = constellation_order = 6

        ##################################################
        # Blocks
        ##################################################
        self.symbolmapping_symbol_mapper_bc_0 = symbolmapping.symbol_mapper_bc(
            constellation_order, 'GRAY', True)
        self.symbolmapping_symbol_demapper_cf_0 = symbolmapping.symbol_demapper_cf(
            constellation_order, 'GRAY', 'snr')
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            2,  #number of inputs
            None  # parent
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 260)

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

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

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1,  #number of inputs
            None  # parent
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float()
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, -1)
        self.blocks_add_const_vxx_0 = blocks.add_const_ff(1)
        self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(
            0, 256, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_uniform_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.symbolmapping_symbol_mapper_bc_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_uchar_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_uchar_to_float_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.symbolmapping_symbol_demapper_cf_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.symbolmapping_symbol_mapper_bc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.symbolmapping_symbol_mapper_bc_0, 0),
                     (self.symbolmapping_symbol_demapper_cf_0, 0))
示例#5
0
    def __init__(self):
        gr.top_block.__init__(self, "Example5A Tx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Example5A 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", "example5a_tx")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.time_preamble = time_preamble = [
            0.125000 + 0.000000j, 0.522104 - 0.148216j, -0.495528 + 0.114832j,
            -0.267916 + 0.091700j, 0.236544 - 0.138456j, -0.098500 + 0.473800j,
            0.476480 - 0.225344j, -0.187516 + 0.035372j, 0.051776 - 0.353552j,
            -0.104936 + 0.059916j, 0.228684 + 0.117504j, -0.530912 + 0.560756j,
            0.359128 + 0.015872j, -0.132852 + 0.632840j, -0.105164 - 0.368872j,
            0.368272 - 0.032412j, 0.125000 + 0.750000j, 0.463968 + 0.457792j,
            0.151476 - 0.430948j, 0.685052 + 0.238524j, 0.494428 + 0.119428j,
            -0.557540 - 0.050056j, 0.416348 + 0.017368j, 0.104256 - 0.568836j,
            -0.301776 - 0.353552j, 0.079812 + 0.451516j, 0.439152 + 0.528072j,
            0.642060 + 0.178484j, -0.090096 + 0.465096j, -0.446492 + 0.305776j,
            -0.111440 - 0.093688j, -0.538848 - 0.320228j, 0.125000 + 0.000000j,
            -0.538848 + 0.320228j, -0.111440 + 0.093688j,
            -0.446492 - 0.305776j, -0.090096 - 0.465096j, 0.642060 - 0.178484j,
            0.439152 - 0.528072j, 0.079812 - 0.451516j, -0.301776 + 0.353552j,
            0.104256 + 0.568836j, 0.416348 - 0.017368j, -0.557540 + 0.050056j,
            0.494428 - 0.119428j, 0.685052 - 0.238524j, 0.151476 + 0.430948j,
            0.463968 - 0.457792j, 0.125000 - 0.750000j, 0.368272 + 0.032412j,
            -0.105164 + 0.368872j, -0.132852 - 0.632840j, 0.359128 - 0.015872j,
            -0.530912 - 0.560756j, 0.228684 - 0.117504j, -0.104936 - 0.059916j,
            0.051776 + 0.353552j, -0.187516 - 0.035372j, 0.476480 + 0.225344j,
            -0.098500 - 0.473800j, 0.236544 + 0.138456j, -0.267916 - 0.091700j,
            -0.495528 - 0.114832j, 0.522104 + 0.148216j
        ]
        self.time_offset = time_offset = 1
        self.samp_rate = samp_rate = 1000000
        self.preamble_len = preamble_len = 64
        self.packet_len = packet_len = 1024
        self.noise = noise = 0
        self.freq_offset = freq_offset = 0

        ##################################################
        # Blocks
        ##################################################
        self._time_offset_range = Range(0.999, 1.001, 0.00001, 1, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range,
                                            self.set_time_offset,
                                            'Time offset', "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._time_offset_win, 2, 0, 1, 2)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)]
        self._noise_range = Range(0, 0.2, 0.001, 0, 200)
        self._noise_win = RangeWidget(self._noise_range, self.set_noise,
                                      'Noise', "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_win, 0, 0, 1, 2)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)]
        self._freq_offset_range = Range(0, 0.02, 0.0001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range,
                                            self.set_freq_offset,
                                            'Freq offset', "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._freq_offset_win, 1, 0, 1, 2)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)]
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
            preamble_len + packet_len,  #size
            samp_rate,  #samp_rate
            "Frame (Preamble + Packet) Samples",  #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)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 4, 0,
                                       1, 2)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(4, 5)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)]
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            preamble_len,  #size
            samp_rate,  #samp_rate
            "Preamble Samples",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

        for i in xrange(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, 3, 0, 1,
                                       2)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(3, 4)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)]
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=2,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise,
            frequency_offset=freq_offset,
            epsilon=time_offset,
            taps=(1 + 1j, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_vector_source_x_0 = blocks.vector_source_c(
            time_preamble, True, 1, [])
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                 '127.0.0.1', 4000, 1472 * 16,
                                                 True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_stream_mux_0 = blocks.stream_mux(
            gr.sizeof_gr_complex * 1, (preamble_len, packet_len))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((0.5, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.1, ))
        self.blks2_packet_encoder_1 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=2,
                bits_per_symbol=1,
                preamble='',
                access_code='',
                pad_for_usrp=False,
            ),
            payload_length=0,
        )
        self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(
            0, 255, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_uniform_source_x_0, 0),
                     (self.blks2_packet_encoder_1, 0))
        self.connect((self.blks2_packet_encoder_1, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_stream_mux_0, 1))
        self.connect((self.blocks_stream_mux_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_mux_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
示例#6
0
    def __init__(self):
        gr.top_block.__init__(self, "Transmitter")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("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", "transmitter")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
        self.freq = freq = 2.5e9

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("serial=313107A", "")),
            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(freq, 0)
        self.uhd_usrp_sink_0.set_gain(60, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.digital_qam_mod_0 = digital.qam.qam_mod(
            constellation_points=4,
            mod_code="gray",
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            verbose=True,
            log=False,
        )
        self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(
            0, 2, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_uniform_source_x_0, 0),
                     (self.digital_qam_mod_0, 0))
        self.connect((self.digital_qam_mod_0, 0), (self.uhd_usrp_sink_0, 0))
示例#7
0
    def __init__(self,
                 channel_shift_hz=0,
                 random_source_seed=0,
                 sample_rate=0,
                 occupied_bw=0,
                 tx_len_s=1.0):
        gr.hier_block2.__init__(
            self,
            "Hurdle2 Psk",
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        symbol_rate = occupied_bw / 0.7 / 2.0  # spectral efficiency
        #print("sample rate: {}".format(sample_rate))
        #print("symbol rate: {}".format(symbol_rate))

        ##################################################
        # Parameters
        ##################################################
        self.channel_shift_hz = channel_shift_hz
        self.random_source_seed = random_source_seed
        self.sample_rate = sample_rate
        self.symbol_rate = symbol_rate
        self.samples_per_symbol = int(sample_rate / symbol_rate)
        #print("qpsk samp rate: {} sym rate: {} samples per symbol:{}".format(sample_rate, symbol_rate, self.samples_per_symbol))

        self.num_samples = int(sample_rate * tx_len_s)

        self.qpsk = qpsk = digital.constellation_rect(
            ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 2, 2, 1,
            1).base()

        ##################################################
        # Blocks
        ##################################################
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, sample_rate, symbol_rate * 5, symbol_rate,
                            firdes.WIN_HAMMING, 6.76))

        self.qpsk_mod = digital.generic_mod(
            constellation=qpsk,
            differential=True,
            samples_per_symbol=self.samples_per_symbol,
            pre_diff_code=True,
            excess_bw=0.7,
            verbose=False,
            log=False,
        )
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            sample_rate, analog.GR_COS_WAVE, channel_shift_hz, 1, 0)
        self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(
            0, 256, random_source_seed)

        # this is in response to the QPSK block refusing to shut down for certain numbers of samples
        self.modulo_map = {60: 29, 30: 29, 20: 9, 15: 7, 12: 5, 10: 9}
        extra_samples = self.modulo_map[
            self.
            samples_per_symbol] - self.num_samples % self.samples_per_symbol + self.samples_per_symbol
        # ask for a known good number of samples such that QPSK will shut down, then limit to the number of
        # samples we actually want with a downstream head block
        self.head_hack = blocks.head(gr.sizeof_gr_complex * 1,
                                     int(self.num_samples + extra_samples))

        # this limits output to the requested number of samples
        self.head = blocks.head(gr.sizeof_gr_complex * 1,
                                int(self.num_samples))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_uniform_source_x_0, 0),
                     (self.qpsk_mod, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.qpsk_mod, 0), self.head_hack,
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))

        # limit output
        self.connect(self.blocks_multiply_xx_0, self.head, self)
示例#8
0
    def __init__(self):
        gr.top_block.__init__(self, "Hdf5Sink Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Hdf5Sink Test")
        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", "hdf5sink_test")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.data_filename = data_filename = "/tmp/dataset.hdf5"

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 4)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

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

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.hdf5_sink_x_0_2 = hdf5_sink_f(num_inputs=1,
                                           dataset_name='dataset_f',
                                           shrink=True,
                                           data_filename=data_filename,
                                           log_level=logging.NOTSET,
                                           log_filename='')
        self.hdf5_sink_x_0_1 = hdf5_sink_i(num_inputs=1,
                                           dataset_name='dataset_i',
                                           shrink=True,
                                           data_filename=data_filename,
                                           log_level=logging.NOTSET,
                                           log_filename='')
        self.hdf5_sink_x_0_0 = hdf5_sink_s(num_inputs=1,
                                           dataset_name='dataset_s',
                                           shrink=True,
                                           data_filename=data_filename,
                                           log_level=logging.NOTSET,
                                           log_filename='')
        self.hdf5_sink_x_0 = hdf5_sink_b(num_inputs=1,
                                         dataset_name='dataset_b',
                                         shrink=True,
                                         data_filename=data_filename,
                                         log_level=logging.NOTSET,
                                         log_filename='')
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 255)
        self.blocks_int_to_float_0 = blocks.int_to_float(1, 1)
        self.blocks_float_to_int_0 = blocks.float_to_int(1, 1)
        self.blocks_char_to_short_0 = blocks.char_to_short(1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(
            0, 255, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_uniform_source_x_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.analog_random_uniform_source_x_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.analog_random_uniform_source_x_0, 0),
                     (self.blocks_char_to_short_0, 0))
        self.connect((self.analog_random_uniform_source_x_0, 0),
                     (self.hdf5_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_float_to_int_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.hdf5_sink_x_0_2, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_number_sink_0, 3))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_char_to_short_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_char_to_short_0, 0),
                     (self.hdf5_sink_x_0_0, 0))
        self.connect((self.blocks_float_to_int_0, 0),
                     (self.blocks_int_to_float_0, 0))
        self.connect((self.blocks_float_to_int_0, 0),
                     (self.hdf5_sink_x_0_1, 0))
        self.connect((self.blocks_int_to_float_0, 0),
                     (self.qtgui_number_sink_0, 2))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.qtgui_number_sink_0, 1))
示例#9
0
    def __init__(self,
                 channel_shift_hz=0,
                 random_source_seed=0,
                 sample_rate=0,
                 occupied_bw=0,
                 tx_len_s=1.0):
        gr.hier_block2.__init__(
            self,
            "Hurdle2 Gmsk",
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        symbol_rate = occupied_bw / 1.0  # spectral efficiency

        self.num_samples = int(sample_rate * tx_len_s)

        #print("sample rate: {}".format(sample_rate))
        #print("symbol rate: {}".format(symbol_rate))

        ##################################################
        # Parameters
        ##################################################
        self.channel_shift_hz = channel_shift_hz
        self.random_source_seed = random_source_seed
        self.sample_rate = sample_rate
        self.symbol_rate = symbol_rate

        ##################################################
        # Blocks
        ##################################################
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1.0, sample_rate, symbol_rate * 5, symbol_rate,
                            firdes.WIN_HAMMING, 6.76))
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=sample_rate / symbol_rate,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            sample_rate, analog.GR_COS_WAVE, channel_shift_hz, 1, 0)
        self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(
            0, 256, random_source_seed)

        # this limits output to the requested number of samples
        self.head = blocks.head(gr.sizeof_gr_complex * 1,
                                int(self.num_samples))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_uniform_source_x_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 1))
        self.connect((self.digital_gmsk_mod_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 0))

        # limit output
        self.connect(self.blocks_multiply_xx_0_0_0, self.head, self)
示例#10
0
    def __init__(self):
        gr.top_block.__init__(self, "dibit_mapper_example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("dibit_mapper_example")
        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", "dibit_mapper_example")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-4, 4)

        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 = ['Original', 'Mapped', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_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.p25_dibit_mapper_bf_0 = p25.dibit_mapper_bf(
            dibit_map=([1, 3, -1, -3]),
            log_level=logging.NOTSET,
            filename=''
          )
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(0, 4, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_uniform_source_x_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.analog_random_uniform_source_x_0, 0), (self.p25_dibit_mapper_bf_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.p25_dibit_mapper_bf_0, 0), (self.qtgui_time_sink_x_0, 1))
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.interleave_depth = interleave_depth = 4
        self.hamming_distance = hamming_distance = 0
        self.ber = ber = 0

        ##################################################
        # Blocks
        ##################################################
        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("")
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        units = ["", "", "", "", "",
                 "", "", "", "", ""]
        colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")]
        factor = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, 0)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])
        
        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.channelcoding_binary_symmetric_channel_0 = channelcoding.binary_symmetric_channel(0.1,8,1653)
        self.ccsds_rs_encode_0 = ccsds.rs_encode(1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char*1, (256, interleave_depth*255+4))
        self.blks2_error_rate_0 = grc_blks2.error_rate(
        	type='BER',
        	win_size=1000,
        	bits_per_symbol=8,
        )
        self._ber_range = Range(0, 1, 0.01, 0, 200)
        self._ber_win = RangeWidget(self._ber_range, self.set_ber, "BER", "counter_slider", float)
        self.top_layout.addWidget(self._ber_win)
        self.analog_random_uniform_source_x_0_0 = analog.random_uniform_source_b(0, 256, 27)
        self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(0, 256, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_uniform_source_x_0, 0), (self.blocks_stream_mux_0, 0))    
        self.connect((self.analog_random_uniform_source_x_0_0, 0), (self.ccsds_rs_encode_0, 0))    
        self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0))    
        self.connect((self.blocks_stream_mux_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blks2_error_rate_0, 1))    
        self.connect((self.blocks_throttle_0, 0), (self.channelcoding_binary_symmetric_channel_0, 0))    
        self.connect((self.ccsds_rs_encode_0, 0), (self.blocks_stream_mux_0, 1))    
        self.connect((self.channelcoding_binary_symmetric_channel_0, 0), (self.blks2_error_rate_0, 0))    
示例#12
0
    def __init__(self):
        gr.top_block.__init__(self, "Psk8")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Psk8")
        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", "psk8")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 3
        self.nfilts = nfilts = 25
        self.vec = vec = [0,1,2,3,4,5,6]
        self.samp_rate = samp_rate = 32e3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts)

        self.psk = psk = digital.constellation_calcdist(([-1-1j, -1+1j, 1+1j, 1-1j, 1.414, -1.414, 1.414j, -1.414j]), ([0, 1, 3, 2, 4, 5, 6, 7]), 4, 1).base()


        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.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_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, .063, (rrc_taps), nfilts, nfilts/2, 1.5, 1)
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=psk,
          differential=False,
          samples_per_symbol=3,
          pre_diff_code=True,
          excess_bw=.25,
          verbose=True,
          log=True,
          )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b(0, 256, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_uniform_source_x_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.digital_constellation_modulator_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_time_sink_x_0, 0))