コード例 #1
0
    def test_cpfsk_bc_002(self):
        src_data = 10*[0, 1]
        expected_result = map(lambda x: complex(2*x-1,0), src_data)

        src = blocks.vector_source_b(src_data)
        op = analog.cpfsk_bc(2, 1, 2)
        dst = blocks.vector_sink_c()

        self.tb.connect(src, op)
        self.tb.connect(op, dst)
        self.tb.run()

        result_data = dst.data()[0:len(expected_result)]
        self.assertComplexTuplesAlmostEqual(expected_result, result_data, 4)
コード例 #2
0
ファイル: qa_cpfsk.py プロジェクト: 0x7678/gnuradio-wg-grc
    def test_cpfsk_bc_002(self):
        src_data = 10*[0, 1]
        expected_result = map(lambda x: complex(2*x-1,0), src_data)

        src = blocks.vector_source_b(src_data)
        op = analog.cpfsk_bc(2, 1, 2)
        dst = blocks.vector_sink_c()

        self.tb.connect(src, op)
        self.tb.connect(op, dst)
        self.tb.run()

        result_data = dst.data()[0:len(expected_result)]
        self.assertComplexTuplesAlmostEqual(expected_result, result_data, 4)
コード例 #3
0
ファイル: qa_cpfsk.py プロジェクト: 0x7678/gnuradio-wg-grc
    def test_cpfsk_bc_001(self):
        # Test set/gets

        op = analog.cpfsk_bc(2, 1, 2)

        op.set_amplitude(2)
        a = op.amplitude()
        self.assertEqual(2, a)

        freq = 2*math.pi/2.0
        f = op.freq()
        self.assertAlmostEqual(freq, f, 5)

        p = op.phase()
        self.assertEqual(0, p)
コード例 #4
0
    def test_cpfsk_bc_001(self):
        # Test set/gets
        
        op = analog.cpfsk_bc(2, 1, 2)

        op.set_amplitude(2)
        a = op.amplitude()
        self.assertEqual(2, a)

        freq = 2*math.pi/2.0
        f = op.freq()
        self.assertAlmostEqual(freq, f, 5)

        p = op.phase()
        self.assertEqual(0, p)
コード例 #5
0
ファイル: TXDigital.py プロジェクト: acarmon2/FM
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Txdigital")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.baud_rate = baud_rate = 49260
        self.samp_rate = samp_rate = baud_rate*10
        self.deviation = deviation = 180000
        self.sps = sps = samp_rate/baud_rate
        self.samp_rate_TX = samp_rate_TX = samp_rate*2
        self.modulation_index = modulation_index = (float)(deviation)/((float)(baud_rate / 2))

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate_TX)
        self.uhd_usrp_sink_0.set_center_freq(434e6, 0)
        self.uhd_usrp_sink_0.set_gain(20, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=samp_rate_TX,
                decimation=samp_rate,
                taps=None,
                fractional_bw=None,
        )
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.8, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/gema/Documents/RF12B.dat", True)
        self.analog_cpfsk_bc_0 = analog.cpfsk_bc((float)((float)(deviation)/baud_rate), 0.1, sps)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_cpfsk_bc_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.analog_cpfsk_bc_0, 0))
 def __init__(self):
     gr.hier_block2.__init__(self, "transmitter_cpfsk",
                             gr.io_signature(1, 1, gr.sizeof_char),
                             gr.io_signature(1, 1, gr.sizeof_gr_complex))
     self.mod = analog.cpfsk_bc(0.5, 1.0, sps)
     self.connect(self, self.mod, self)
コード例 #7
0
ファイル: top_block.py プロジェクト: ganlubbq/ECE395A
    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.pam4_constellation = pam4_constellation = digital.constellation_calcdist(
            ([0, 1, 3, 2]), ([0, 1, 3, 2]), 4, 1).base()
        self.noiseamp = noiseamp = (10**(-0.9) + 10) / 2
        self.noise_enable = noise_enable = 0
        self.mod_select = mod_select = 1
        self.ebw_range = ebw_range = 0.35
        self.a_src_freq = a_src_freq = 200e3

        ##################################################
        # Blocks
        ##################################################
        self._noiseamp_range = Range(10**(-0.9), 10, 0.001,
                                     (10**(-0.9) + 10) / 2, 200)
        self._noiseamp_win = RangeWidget(self._noiseamp_range,
                                         self.set_noiseamp, "Noise Amplitude",
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._noiseamp_win, 0, 2)
        _noise_enable_check_box = Qt.QCheckBox("Noise Enable")
        self._noise_enable_choices = {True: 1, False: 0}
        self._noise_enable_choices_inv = dict(
            (v, k) for k, v in self._noise_enable_choices.iteritems())
        self._noise_enable_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _noise_enable_check_box, "setChecked",
            Qt.Q_ARG("bool", self._noise_enable_choices_inv[i]))
        self._noise_enable_callback(self.noise_enable)
        _noise_enable_check_box.stateChanged.connect(
            lambda i: self.set_noise_enable(self._noise_enable_choices[bool(i)]
                                            ))
        self.top_grid_layout.addWidget(_noise_enable_check_box, 0, 1)
        self._mod_select_options = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        self._mod_select_labels = [
            "BPSK", "QPSK", "8PSK", "QAM16", "QAM64", "PAM4", "GFSK", "CPFSK",
            "WBFM", "AM-DSB", "AM-SSB"
        ]
        self._mod_select_tool_bar = Qt.QToolBar(self)
        self._mod_select_tool_bar.addWidget(Qt.QLabel("mod_select" + ": "))
        self._mod_select_combo_box = Qt.QComboBox()
        self._mod_select_tool_bar.addWidget(self._mod_select_combo_box)
        for label in self._mod_select_labels:
            self._mod_select_combo_box.addItem(label)
        self._mod_select_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._mod_select_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._mod_select_options.index(i)))
        self._mod_select_callback(self.mod_select)
        self._mod_select_combo_box.currentIndexChanged.connect(
            lambda i: self.set_mod_select(self._mod_select_options[i]))
        self.top_grid_layout.addWidget(self._mod_select_tool_bar, 0, 0)
        self._a_src_freq_range = Range(44100, 200e3, 10, 200e3, 200)
        self._a_src_freq_win = RangeWidget(self._a_src_freq_range,
                                           self.set_a_src_freq,
                                           "Analog Source Frequency",
                                           "counter_slider", float)
        self.top_layout.addWidget(self._a_src_freq_win)
        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(0, 0)
        self.uhd_usrp_sink_0.set_gain(0, 0)
        self.sig_source_0 = analog.sig_source_f(samp_rate, analog.GR_TRI_WAVE,
                                                44100, 1, 0)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            2048,  #size
            samp_rate,  #samp_rate
            "Times Series",  #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_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1, 2)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Frequency Spectrum",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(True)
        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_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 1,
                                       3)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            2048,  #size
            "Constellation",  #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(True)
        self.qtgui_const_sink_x_0.enable_grid(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 0, 1,
                                       2)
        self.hilbert_fc_0 = filter.hilbert_fc(401, firdes.WIN_HAMMING, 6.76)
        self.fractional_interpolator_xx_0 = filter.fractional_interpolator_ff(
            0, 44100 / a_src_freq)
        self.digital_qam_mod_0_1 = digital.qam.qam_mod(
            constellation_points=64,
            mod_code="gray",
            differential=True,
            samples_per_symbol=8,
            excess_bw=ebw_range,
            verbose=False,
            log=False,
        )
        self.digital_qam_mod_0_0 = digital.qam.qam_mod(
            constellation_points=16,
            mod_code="gray",
            differential=True,
            samples_per_symbol=8,
            excess_bw=ebw_range,
            verbose=False,
            log=False,
        )
        self.digital_psk_mod_1 = digital.psk.psk_mod(
            constellation_points=8,
            mod_code="gray",
            differential=True,
            samples_per_symbol=8,
            excess_bw=ebw_range,
            verbose=False,
            log=False,
        )
        self.digital_psk_mod_0_0 = digital.psk.psk_mod(
            constellation_points=2,
            mod_code="gray",
            differential=True,
            samples_per_symbol=8,
            excess_bw=ebw_range,
            verbose=False,
            log=False,
        )
        self.digital_psk_mod_0 = digital.psk.psk_mod(
            constellation_points=4,
            mod_code="gray",
            differential=True,
            samples_per_symbol=8,
            excess_bw=ebw_range,
            verbose=False,
            log=False,
        )
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=8,
            sensitivity=0.1,
            bt=ebw_range,
            verbose=False,
            log=False,
        )
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=pam4_constellation,
            differential=True,
            samples_per_symbol=8,
            pre_diff_code=True,
            excess_bw=ebw_range,
            verbose=False,
            log=False,
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_packed_to_unpacked_xx_1 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_LSB_FIRST)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((0.1, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (1 + 1j, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((1, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((1, ))
        self.blks2_selector_1 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=noise_enable,
            output_index=0,
        )
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=11,
            num_outputs=1,
            input_index=mod_select,
            output_index=0,
        )
        self.analog_wfm_tx_0 = analog.wfm_tx(
            audio_rate=44100,
            quad_rate=220500,
            tau=75e-6,
            max_dev=75e3,
        )
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, a_src_freq, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, a_src_freq, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 64, 8192)), True)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, noiseamp, 31415)
        self.analog_cpfsk_bc_0 = analog.cpfsk_bc(0.5, 1.0, 8)
        self.analog_const_source_x_1 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blks2_selector_1, 0))
        self.connect((self.analog_const_source_x_1, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_cpfsk_bc_0, 0), (self.blks2_selector_0, 7))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blks2_selector_1, 1))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_packed_to_unpacked_xx_1, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.analog_wfm_tx_0, 0), (self.blks2_selector_0, 8))
        self.connect((self.blks2_selector_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blks2_selector_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blks2_selector_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blks2_selector_0, 9))
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.analog_cpfsk_bc_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_psk_mod_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_psk_mod_0_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_psk_mod_1, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_qam_mod_0_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_qam_mod_0_1, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_1, 0),
                     (self.digital_gfsk_mod_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blks2_selector_0, 5))
        self.connect((self.digital_gfsk_mod_0, 0), (self.blks2_selector_0, 6))
        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.blks2_selector_0, 0))
        self.connect((self.digital_psk_mod_1, 0), (self.blks2_selector_0, 2))
        self.connect((self.digital_qam_mod_0_0, 0), (self.blks2_selector_0, 3))
        self.connect((self.digital_qam_mod_0_1, 0), (self.blks2_selector_0, 4))
        self.connect((self.fractional_interpolator_xx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.fractional_interpolator_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.blks2_selector_0, 10))
        self.connect((self.sig_source_0, 0), (self.analog_wfm_tx_0, 0))
        self.connect((self.sig_source_0, 0),
                     (self.fractional_interpolator_xx_0, 0))
コード例 #8
0
    def __init__(self):
        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())

        ##################################################
        # Variables
        ##################################################
        self.afsk_space = afsk_space = 2200
        self.afsk_mark = afsk_mark = 1200
        self.bitrate = bitrate = 1200
        self.afsk_deviation = afsk_deviation = (afsk_space - afsk_mark)/2
        self.uhd_samp_rate = uhd_samp_rate = 614400
        self.tx_gain = tx_gain = 0
        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.interpolation = interpolation = 16
        self.afsk_sensitivity = afsk_sensitivity = 2.0*afsk_deviation/bitrate
        self.afsk_centre_freq = afsk_centre_freq = afsk_mark + afsk_deviation

        ##################################################
        # 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),
        	),
        )
        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=4,
                decimation=1,
                taps=None,
                fractional_bw=0.25,
        )
        self.qtgui_sink_x_0_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	uhd_samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0_0.set_update_time(1.0/10)
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_0_win)
        
        self.qtgui_sink_x_0_0.enable_rf_freq(False)
        
        
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, bitrate*interpolation, 1.2*afsk_deviation, 50, firdes.WIN_HAMMING, 6.76))
        self.ec_ax25_decoder_b_0 = ec.ax25_decoder_b(True, 0, "")
        self.bruninga_fsk_demod_0 = bruninga.fsk_demod(19200)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, "packet_len", 4096)
        self.blocks_socket_pdu_1_0 = blocks.socket_pdu("TCP_CLIENT", "127.0.0.1", "51423", 10000, False)
        self.blocks_socket_pdu_1 = blocks.socket_pdu("TCP_CLIENT", "127.0.0.1", "51423", 10000, False)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.ax25_nrzi_encoder_0 = ax25.nrzi_encoder(0)
        self.ax25_encode_heir_0 = ax25_encode_heir(
            destination_callsign="SPACE",
            destination_ssid=0,
            post_flag_quantity=16,
            post_sync_quantity=16,
            pre_flag_quantity=16,
            pre_sync_quantity=128,
            source_callsign="EARTH",
            source_ssid=0,
            sync_value=85,
        )
        self.analog_sig_source_x_0 = analog.sig_source_c(bitrate*interpolation, analog.GR_COS_WAVE, afsk_centre_freq, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=bitrate*interpolation,
        	quad_rate=uhd_samp_rate/4,
        	tau=75e-6*0,
        	max_dev=2.5e3,
        	fh=-1.0,
                )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=19200,
        	quad_rate=4*153600,
        	tau=0.01,
        	max_dev=2.5e3,
          )
        self.analog_cpfsk_bc_0 = analog.cpfsk_bc(afsk_sensitivity, 1, interpolation)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_1_0, 'pdus'), (self.ax25_encode_heir_0, 'pdus in'))    
        self.msg_connect((self.ec_ax25_decoder_b_0, 'pdus'), (self.blocks_socket_pdu_1, 'pdus'))    
        self.connect((self.analog_cpfsk_bc_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.analog_nbfm_rx_0, 0), (self.bruninga_fsk_demod_0, 0))    
        self.connect((self.analog_nbfm_tx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.ax25_encode_heir_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))    
        self.connect((self.ax25_nrzi_encoder_0, 0), (self.analog_cpfsk_bc_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.analog_nbfm_tx_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_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.qtgui_sink_x_0_0, 0))    
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.bruninga_fsk_demod_0, 0), (self.ec_ax25_decoder_b_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_xx_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.analog_nbfm_rx_0, 0))