def __init__(self):
        gr.hier_block2.__init__(
            self,
            "AX.25 Packet Deformatter",
            gr.io_signature(1, 1, gr.sizeof_char * 1),
            gr.io_signature(0, 0, 0),
        )
        self.message_port_register_hier_out("out")

        ##################################################
        # Blocks
        ##################################################
        self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(8, 512)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_and_const_xx_0 = blocks.and_const_bb(0x01)
        self.amateur_AX25_Packet_Decoder_0 = amateur.AX25_Packet_Decoder()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.amateur_AX25_Packet_Decoder_0, 'out'),
                         (self, 'out'))
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'),
                         (self.amateur_AX25_Packet_Decoder_0, 'in'))
        self.connect((self.blocks_and_const_xx_0, 0),
                     (self.digital_hdlc_deframer_bp_0, 0))
        self.connect((self.blocks_not_xx_0, 0),
                     (self.blocks_and_const_xx_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_not_xx_0, 0))
        self.connect((self, 0), (self.digital_diff_decoder_bb_0, 0))
예제 #2
0
    def __init__(self, samp_per_sym=4):
        gr.hier_block2.__init__(
            self, "PSK31 Modulator",
            gr.io_signature(1, 1, gr.sizeof_char*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

        self.samp_per_sym = samp_per_sym

        self.connect(
            self,

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

            digital.diff_encoder_bb(2),
            blocks.char_to_float(1, 1),
            blocks.add_const_vff((-0.5, )),
            blocks.multiply_const_vff((2, )),
            interp_fir_filter_fff(samp_per_sym, self._envelope_taps()),
            blocks.float_to_complex(1),
            self,
        )
예제 #3
0
    def __init__(self, varicode_decode=True, differential_decode=True):
        gr.hier_block2.__init__(
            self,
            "Coherent PSK31 Demodulator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_char * 1),
        )

        our_blocks = [self]

        constellation = digital.constellation_bpsk().base()
        our_blocks.append(digital.constellation_decoder_cb(constellation))

        if differential_decode:
            # PSK31 defines 0 as a phase change, opposite the usual
            # differential encoding which is: out = (next - prev) % 2
            our_blocks.extend([
                digital.diff_decoder_bb(2),
                blocks.not_bb(),
                blocks.and_const_bb(1),
            ])

        if varicode_decode:
            our_blocks.append(varicode_decode_bb())

        our_blocks.append(self)
        self.connect(*our_blocks)
예제 #4
0
    def __init__(self):
        gr.hier_block2.__init__(self, "BitErrors",
                                gr.io_signature(1, 1, gr.sizeof_char),
                                gr.io_signature(1, 1, gr.sizeof_int))

        intdump_decim = min(int(N_BITS / 10), 100000)
        self.connect(self, blocks.skiphead(gr.sizeof_char, SKIP),
                     blocks.not_bb(), blocks.and_const_bb(1),
                     blocks.uchar_to_float(),
                     blocks.integrate_ff(intdump_decim),
                     blocks.multiply_const_ff(1.0 / intdump_decim), self)
예제 #5
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="BER Test")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="%",
        	minval=-100,
        	maxval=100,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="BER",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((100, ))
        self.bitErrorRate_0 = bitErrorRate()
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 16)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.bitErrorRate_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.bitErrorRate_0, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_not_xx_0, 0))
        self.connect((self.blocks_not_xx_0, 0), (self.bitErrorRate_0, 1))
예제 #6
0
 def test_not_bb(self):
     src1_data = [1, 2, 2, 3, 0x04, 0x50]
     expected_result = [0xFE, 0xFD, 0xFD, 0xFC, 0xFB, 0xAF]
     op = blocks.not_bb()
     self.help_bb(((src1_data), ), expected_result, op)
 def test_not_bb (self):
     src1_data =       (1,     2,    2,     3,     0x04,   0x50)
     expected_result = (0xFE,  0xFD, 0xFD,  0xFC,  0xFB,   0xAF)
     op = blocks.not_bb ()
     self.help_bb (((src1_data), ),
                   expected_result, op)
예제 #8
0
    def __init__(self):
        gr.top_block.__init__(self, "Adds")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Adds")
        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", "addsignal")

        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 = 44100

        ##################################################
        # 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(-1, 1)

        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.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_char * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_and_const_xx_0 = blocks.and_const_bb(1)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_SQR_WAVE, 22.7273, 1, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_and_const_xx_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_not_xx_0, 0))
        self.connect((self.blocks_not_xx_0, 0),
                     (self.blocks_and_const_xx_0, 0))
        self.connect((self.blocks_null_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_null_sink_0, 0))
예제 #9
0
    def __init__(self,
                 hdr_format=digital.header_format_default(
                     digital.packet_utils.default_access_code, 0)):
        gr.top_block.__init__(self, "BFSK")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("BFSK")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Parameters
        ##################################################
        self.hdr_format = hdr_format

        ##################################################
        # Variables
        ##################################################
        self.freq_symbol_1 = freq_symbol_1 = 10584
        self.freq_symbol_0 = freq_symbol_0 = 8820
        self.samp_rate = samp_rate = 44.1e3
        self.fsk_deviation_hz = fsk_deviation_hz = freq_symbol_1 - freq_symbol_0
        self.filter_taps = filter_taps = firdes.low_pass(
            1.0, samp_rate, fsk_deviation_hz, 400)
        self.SPS = SPS = 200

        ##################################################
        # Blocks
        ##################################################
        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(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(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)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf(
            1, filter_taps, (freq_symbol_1 + freq_symbol_0) / 2, samp_rate)
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(
            hdr_format, 'len_key')
        self.digital_correlate_access_code_xx_ts_1_0_0 = digital.correlate_access_code_bb_ts(
            digital.packet_utils.default_access_code, 6, 'len_key2')
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            SPS, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0), True, 1,
                                                               [])
        self.blocks_tagged_stream_to_pdu_0_0_0_0_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, 'len_key2')
        self.blocks_tagged_stream_mux_1 = blocks.tagged_stream_mux(
            gr.sizeof_char * 1, 'len_key', 0)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_char * 1, 'len_key', 0)
        self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, 147, 'len_key')
        self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, 100, 'len_key')
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, SPS)
        self.blocks_repack_bits_bb_0_0_0_0 = blocks.repack_bits_bb(
            1, 8, 'len_key2', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            8, 1, 'len_key', False, gr.GR_MSB_FIRST)
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.6)
        self.blocks_message_debug_0_0_0_0_0 = blocks.message_debug()
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/peter/Desktop/acoustic_radio/Testings/test_input.txt', True,
            0, 0)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/peter/Desktop/output.txt', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_char_to_float_2 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_1 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_ff(2)
        self.band_pass_filter_0_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, samp_rate, freq_symbol_1 - 100,
                             freq_symbol_1 + 100, 100, firdes.WIN_HAMMING,
                             6.76))
        self.band_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, samp_rate, freq_symbol_0 - 100,
                             freq_symbol_0 + 100, 100, firdes.WIN_HAMMING,
                             6.76))
        self.audio_source_0 = audio.source(44100, '', True)
        self.audio_sink_0 = audio.sink(44100, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, freq_symbol_1, 1, 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, freq_symbol_0, 1, 0, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 'pdus'),
                         (self.blocks_message_debug_0_0_0_0_0, 'print'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.audio_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.band_pass_filter_0_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_char_to_float_1, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.blocks_char_to_float_2, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_stream_to_tagged_stream_1, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_not_xx_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))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.band_pass_filter_0_0, 0))
        self.connect((self.blocks_not_xx_0, 0),
                     (self.blocks_char_to_float_2, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_tagged_stream_mux_1, 1))
        self.connect((self.blocks_repack_bits_bb_0_0_0_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.blocks_tagged_stream_mux_1, 0))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0),
                     (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_tagged_stream_mux_1, 0),
                     (self.blocks_char_to_float_1, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_correlate_access_code_xx_ts_1_0_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_1_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0_0, 0))
        self.connect((self.digital_protocol_formatter_bb_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
예제 #10
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)            
예제 #11
0
    def __init__(self):
        gr.top_block.__init__(self, "APRS Symbol Recovery")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("APRS Symbol Recovery")
        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", "aprs_symbol_recov")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.ch_rate = ch_rate = 48e3
        self.bb_rate = bb_rate = 192e3
        self.afsk_spec = afsk_spec = [1200, 1200, 2200]
        self.thresh = thresh = -50*2
        self.samp_rate = samp_rate = 2.88e6
        self.rfgain = rfgain = 10
        self.out_sps = out_sps = 2
        self.in_sps = in_sps = int(ch_rate) / afsk_spec[0]
        self.gain_mu = gain_mu = 0.175
        self.freq = freq = 144.39e6
        self.dev_ppm = dev_ppm = 52
        self.bb_decim = bb_decim = int(bb_rate)/int(ch_rate)
        self.afgain = afgain = -7

        ##################################################
        # Blocks
        ##################################################
        self._rfgain_range = Range(0, 49, 1, 10, 100)
        self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain, 'RF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rfgain_win, 3,0,1,1)
        self.show_text_2 = display.show_text()
        self._show_text_2_win = sip.wrapinstance(self.show_text_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._show_text_2_win, 2,2,2,1)
        self.show_text_0 = display.show_text()
        self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._show_text_0_win, 2,0,1,2)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	4096, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	192e3, #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(False)
        
        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 = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [6, 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(-105, -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, 0,2,1,1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	1200, #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(-4.2, 4.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(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(False)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [2, 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, 1,0,1,3)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	144.39e6, #fc
        	192e3, #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(-120, -10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(False)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [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 = [0.8, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,2)
        self.pfb_decimator_ccf_0_0 = pfb.decimator_ccf(
        	  int(samp_rate / ch_rate),
        	  (),
        	  0,
        	  100,
                  True,
                  True)
        self.pfb_decimator_ccf_0_0.declare_sample_delay(0)
        	
        self.pfb_decimator_ccf_0 = pfb.decimator_ccf(
        	  int(samp_rate / bb_rate),
        	  (),
        	  0,
        	  100,
                  True,
                  True)
        self.pfb_decimator_ccf_0.declare_sample_delay(0)
        	
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(dev_ppm, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(rfgain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.hdlc_to_ax25 = hdlc_to_ax25.blk()
        self.fsk_demod_0 = fsk_demod(
            baud=afsk_spec[0],
            fsk_hi_tone=afsk_spec[2],
            fsk_lo_tone=afsk_spec[1],
            in_sps=in_sps,
            out_sps=out_sps,
        )
        self.fft_filter_xxx_1 = filter.fft_filter_fff(1, (firdes.band_pass(1,ch_rate,400,5e3,400,firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(32, 500)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(out_sps*(1+0.0), 0.25*gain_mu*gain_mu, 0.5, gain_mu, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '', '52001', 10000, False)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_and_const_xx_0 = blocks.and_const_bb(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(ch_rate/(2*math.pi*12e3/8.0))
        self.afsk_afsk1200_0 = afsk.afsk1200(int(ch_rate),4)
        self._afgain_range = Range(-20, -1, 0.1, -7, 100)
        self._afgain_win = RangeWidget(self._afgain_range, self.set_afgain, 'AF Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._afgain_win, 3,1,1,1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.hdlc_to_ax25, 'hdlc in'))    
        self.msg_connect((self.hdlc_to_ax25, 'ax25 out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus'))    
        self.msg_connect((self.hdlc_to_ax25, 'ax25 out'), (self.blocks_socket_pdu_0, 'pdus'))    
        self.connect((self.afsk_afsk1200_0, 0), (self.show_text_2, 0))    
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fft_filter_xxx_1, 0))    
        self.connect((self.blocks_and_const_xx_0, 0), (self.digital_hdlc_deframer_bp_0, 0))    
        self.connect((self.blocks_not_xx_0, 0), (self.blocks_and_const_xx_0, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.show_text_0, 0))    
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_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_diff_decoder_bb_0, 0), (self.blocks_not_xx_0, 0))    
        self.connect((self.fft_filter_xxx_1, 0), (self.afsk_afsk1200_0, 0))    
        self.connect((self.fft_filter_xxx_1, 0), (self.fsk_demod_0, 0))    
        self.connect((self.fsk_demod_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.pfb_decimator_ccf_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.pfb_decimator_ccf_0_0, 0))    
        self.connect((self.pfb_decimator_ccf_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.pfb_decimator_ccf_0, 0), (self.qtgui_waterfall_sink_x_0, 0))    
        self.connect((self.pfb_decimator_ccf_0_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
예제 #12
0
    def __init__(self, baudrate=9600, costas_loop_bw=2*math.pi/200, excess_bw=0.5, fll_loop_bw=2*math.pi/350, max_cfo=4e3, rf_samp_rate=2.4e6, symbol_Sync_loop_bw=2*math.pi/100):
        gr.hier_block2.__init__(self,
            "bpsk_ax25_demod",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signaturev(3, 3, [gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1])
            ) # Output signature

        self.message_port_register_hier_out("out")
        
        ##################################################
        # Parameters
        ##################################################
        self.baudrate = baudrate
        self.costas_loop_bw = costas_loop_bw
        self.excess_bw = excess_bw
        self.fll_loop_bw = fll_loop_bw
        self.max_cfo = max_cfo
        self.rf_samp_rate = rf_samp_rate
        self.symbol_Sync_loop_bw = symbol_Sync_loop_bw

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 9600*20
        self.sps = sps = int(samp_rate/baudrate)
        self.nfilts = nfilts = 64
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), excess_bw, 11*sps*nfilts)

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

        ##################################################
        # Blocks
        ##################################################
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  samp_rate/rf_samp_rate,
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.low_pass_filter_0_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, ((1.0 + excess_bw) * baudrate/2.0) + min(baudrate, abs(1000*1.2)), baudrate / 10.0, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, (max_cfo+baudrate/2), baudrate / 10.0, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, (max_cfo+baudrate/2), baudrate / 10.0, firdes.WIN_HAMMING, 6.76))
        self.hsl_rms_agc_0 = hsl.rms_agc(alpha=1e-2, reference=0.5, )
        self.hsl_kiss_encoder_0 = hsl.kiss_encoder()
        self.digital_symbol_sync_xx_0_0 = digital.symbol_sync_cc(digital.TED_SIGNUM_TIMES_SLOPE_ML, sps, symbol_Sync_loop_bw, 1/math.sqrt(2.0), 1, 2*math.pi/100, 1, digital.constellation_bpsk().base(), digital.IR_PFB_MF, nfilts, (rrc_taps))
        self.digital_hdlc_deframer_bp_0_0 = digital.hdlc_deframer_bp(15, 500)
        self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(15, 500)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, excess_bw, 300, fll_loop_bw)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(costas_loop_bw, 2, False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(bpsk_constellation)
        self.blocks_not_xx_0_0_0 = blocks.not_bb()
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_and_const_xx_0_0_0 = blocks.and_const_bb(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.hsl_kiss_encoder_0, 'packet'))
        self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'), (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'), (self.hsl_kiss_encoder_0, 'packet'))
        self.msg_connect((self.hsl_kiss_encoder_0, 'encoded_packet'), (self, 'out'))
        self.connect((self.blocks_and_const_xx_0_0_0, 0), (self.digital_descrambler_bb_0, 0))
        self.connect((self.blocks_and_const_xx_0_0_0, 0), (self.digital_hdlc_deframer_bp_0_0, 0))
        self.connect((self.blocks_not_xx_0_0_0, 0), (self.blocks_and_const_xx_0_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_symbol_sync_xx_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self, 1))
        self.connect((self.digital_descrambler_bb_0, 0), (self.digital_hdlc_deframer_bp_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_not_xx_0_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0), (self.low_pass_filter_0_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0), (self, 2))
        self.connect((self.digital_symbol_sync_xx_0_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_symbol_sync_xx_0_0, 0), (self, 0))
        self.connect((self.hsl_rms_agc_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.hsl_rms_agc_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.low_pass_filter_0_0_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
예제 #13
0
파일: text_pam.py 프로젝트: davidfdzp/sdr
    def __init__(self):
        gr.top_block.__init__(self, "Pulse Amplitude Modulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Pulse Amplitude 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", "text_pam")

        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 = 44100
        self.lowF = lowF = 1200
        self.highF = highF = 2200
        self.baud_rate = baud_rate = 1000
        self.sps = sps = int(samp_rate / baud_rate)
        self.fsk_deviation_hz = fsk_deviation_hz = highF - lowF
        self.bits_per_symbol = bits_per_symbol = 1
        self.tag = tag = gr.tag_utils.python_to_tag(
            (0, pmt.intern("Z"), pmt.intern("0x5a"), pmt.intern("Vsrc")))
        self.samp_dly_fsk = samp_dly_fsk = int(4 * sps)
        self.samp_dly = samp_dly = int(7.04 * sps)
        self.ptype = ptype = 'rect'
        self.polar = polar = 0
        self.noise = noise = 0
        self.filter_taps = filter_taps = firdes.low_pass(
            1.0, samp_rate, fsk_deviation_hz, 400)
        self.baud_delay_fsk = baud_delay_fsk = 0
        self.baud_delay = baud_delay = 0
        self.alpha = alpha = 0.2
        self.M = M = 2**bits_per_symbol
        self.An = An = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_dly_fsk_range = Range(0, sps * 8, 1, int(4 * sps), 200)
        self._samp_dly_fsk_win = RangeWidget(self._samp_dly_fsk_range,
                                             self.set_samp_dly_fsk,
                                             'samp_dly_fsk', "counter_slider",
                                             int)
        self.top_grid_layout.addWidget(self._samp_dly_fsk_win)
        self._samp_dly_range = Range(0, sps * 8, 1, int(7.04 * sps), 200)
        self._samp_dly_win = RangeWidget(self._samp_dly_range,
                                         self.set_samp_dly, 'samp_dly',
                                         "counter_slider", int)
        self.top_grid_layout.addWidget(self._samp_dly_win)
        # Create the options list
        self._ptype_options = ["rect", "rcf", "rrcf", "tri", "man", "msin"]
        # Create the labels list
        self._ptype_labels = ["rect", "rcf", "rrcf", "tri", "man", "msin"]
        # Create the combo box
        self._ptype_tool_bar = Qt.QToolBar(self)
        self._ptype_tool_bar.addWidget(Qt.QLabel('ptype' + ": "))
        self._ptype_combo_box = Qt.QComboBox()
        self._ptype_tool_bar.addWidget(self._ptype_combo_box)
        for _label in self._ptype_labels:
            self._ptype_combo_box.addItem(_label)
        self._ptype_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._ptype_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._ptype_options.index(i)))
        self._ptype_callback(self.ptype)
        self._ptype_combo_box.currentIndexChanged.connect(
            lambda i: self.set_ptype(self._ptype_options[i]))
        # Create the radio buttons
        self.top_grid_layout.addWidget(self._ptype_tool_bar)
        # Create the options list
        self._polar_options = (
            0,
            1,
        )
        # Create the labels list
        self._polar_labels = (
            'unipolar',
            'polar',
        )
        # Create the combo box
        self._polar_tool_bar = Qt.QToolBar(self)
        self._polar_tool_bar.addWidget(Qt.QLabel('polar' + ": "))
        self._polar_combo_box = Qt.QComboBox()
        self._polar_tool_bar.addWidget(self._polar_combo_box)
        for _label in self._polar_labels:
            self._polar_combo_box.addItem(_label)
        self._polar_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._polar_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._polar_options.index(i)))
        self._polar_callback(self.polar)
        self._polar_combo_box.currentIndexChanged.connect(
            lambda i: self.set_polar(self._polar_options[i]))
        # Create the radio buttons
        self.top_grid_layout.addWidget(self._polar_tool_bar)
        self._noise_range = Range(0, 1, 1e-3, 0, 200)
        self._noise_win = RangeWidget(self._noise_range, self.set_noise,
                                      'noise level in [mV]', "counter_slider",
                                      float)
        self.top_grid_layout.addWidget(self._noise_win)
        self._lowF_range = Range(1000, 100000, 1, 1200, 200)
        self._lowF_win = RangeWidget(self._lowF_range, self.set_lowF, 'lowF',
                                     "counter_slider", float)
        self.top_grid_layout.addWidget(self._lowF_win)
        self._highF_range = Range(1000, 100000, 1, 2200, 200)
        self._highF_win = RangeWidget(self._highF_range, self.set_highF,
                                      'highF', "counter_slider", float)
        self.top_grid_layout.addWidget(self._highF_win)
        self._baud_delay_fsk_range = Range(0, 8, 1, 0, 8)
        self._baud_delay_fsk_win = RangeWidget(self._baud_delay_fsk_range,
                                               self.set_baud_delay_fsk,
                                               'Baud delay FSK',
                                               "counter_slider", int)
        self.top_grid_layout.addWidget(self._baud_delay_fsk_win)
        self._baud_delay_range = Range(0, 8, 1, 0, 8)
        self._baud_delay_win = RangeWidget(self._baud_delay_range,
                                           self.set_baud_delay, 'Baud delay',
                                           "counter_slider", int)
        self.top_grid_layout.addWidget(self._baud_delay_win)
        self._alpha_range = Range(0, 1, 0.5, 0.2, 200)
        self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha,
                                      'alpha', "counter_slider", float)
        self.top_grid_layout.addWidget(self._alpha_win)
        self._An_range = Range(0, 1, 0.01, 0, 200)
        self._An_win = RangeWidget(self._An_range, self.set_An, 'An',
                                   "counter_slider", float)
        self.top_grid_layout.addWidget(self._An_win)
        self.sym2byte_float2byteMSB_0_0 = sym2byte_float2byteMSB(
            baud_delay=baud_delay_fsk,
            bit_endianess=1,
            bits_per_symbol=bits_per_symbol,
            bits_to_use_per_byte_mask=255,
            gain=1,
            invert=0,
            polar=polar,
        )
        self.sym2byte_float2byteMSB_0 = sym2byte_float2byteMSB(
            baud_delay=baud_delay,
            bit_endianess=1,
            bits_per_symbol=bits_per_symbol,
            bits_to_use_per_byte_mask=255,
            gain=1,
            invert=0,
            polar=polar,
        )
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            3  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

        self.qtgui_time_sink_x_1_0.enable_tags(True)
        self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_1_0.enable_autoscale(True)
        self.qtgui_time_sink_x_1_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_0.enable_control_panel(True)
        self.qtgui_time_sink_x_1_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(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            4  #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(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(True)
        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(True)
        self.qtgui_time_sink_x_1.enable_stem_plot(False)

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

        for i in range(4):
            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_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            3  #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(True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "Z")
        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(True)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            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(-1, 1)

        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_TAG,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "Z")
        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(True)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

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

        for i in range(4):
            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)
        self.qtgui_sink_x_0 = qtgui.sink_f(
            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.qtgui_sink_x_0.enable_rf_freq(False)

        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win)
        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 range(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)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                       qtgui.TRIG_SLOPE_POS,
                                                       0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)

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

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

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

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

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

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

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

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.pamrcvr216_ff_0 = pamrcvr216_ff(
            a_sps=sps,
            b_ptype='rect',
            c_alpha=alpha,
            d_k=sps / 2,
            dly=samp_dly_fsk,
        )
        self.pamrcvr216_cc_0 = pamrcvr216_cc(
            a_sps=sps,
            b_ptype=ptype,
            c_alpha=alpha,
            d_k=sps / 2,
            dly=samp_dly,
        )
        self.pam_xmtr16_ff_0 = pam_xmtr16_ff(
            a_sps=sps,
            b_ptype=ptype,
            c_alpha=alpha,
            d_k=sps / 2,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf(
            1, filter_taps, (lowF + highF) / 2, samp_rate)
        self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0)
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=[1.0 + 1.0j],
            noise_seed=0,
            block_tags=False)
        self.byte2sym_byte2floatMSB_0 = byte2sym_byte2floatMSB(
            bit_endianess=1,
            bits_per_symbol=bits_per_symbol,
            bits_to_use_per_byte_mask=255,
            invert=0,
            polar=polar,
        )
        self.blocks_vector_source_x_0 = blocks.vector_source_b(
            list(ord(i) for i in 'Zombie'), True, 1, [tag])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     '/dev/pts/2', False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/dev/pts/0', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(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.blocks_add_xx_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_add_const_vxx_0_1 = blocks.add_const_bb(2)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_ff(-0.5)
        self.blocks_add_const_vxx_0 = blocks.add_const_ff(0)
        self._baud_rate_range = Range(0, 8000, 1, 1000, 200)
        self._baud_rate_win = RangeWidget(self._baud_rate_range,
                                          self.set_baud_rate, 'Fb',
                                          "counter_slider", int)
        self.top_grid_layout.addWidget(self._baud_rate_win)
        self.analog_sig_source_x_1 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, lowF, 1, 0, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, highF, 2, 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, highF, 1, 0, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0))
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f(
            analog.GR_GAUSSIAN, An, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_binary_slicer_fb_0_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        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.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_add_const_vxx_0_1, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.qtgui_time_sink_x_0_0, 2))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_1, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.qtgui_time_sink_x_1_0, 2))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_1, 2))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.pamrcvr216_ff_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_1, 3))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_1_0, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.sym2byte_float2byteMSB_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.blocks_multiply_xx_1, 0), (self.pamrcvr216_cc_0, 0))
        self.connect((self.blocks_not_xx_0, 0),
                     (self.blocks_add_const_vxx_0_1, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.byte2sym_byte2floatMSB_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.fec_ber_bf_0, 0))
        self.connect((self.byte2sym_byte2floatMSB_0, 0),
                     (self.pam_xmtr16_ff_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_not_xx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.pam_xmtr16_ff_0, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.pam_xmtr16_ff_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.pam_xmtr16_ff_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.pamrcvr216_cc_0, 1),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.pamrcvr216_cc_0, 1),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.pamrcvr216_cc_0, 2), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.pamrcvr216_cc_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.pamrcvr216_ff_0, 2),
                     (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.pamrcvr216_ff_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.pamrcvr216_ff_0, 1),
                     (self.sym2byte_float2byteMSB_0_0, 0))
        self.connect((self.sym2byte_float2byteMSB_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.sym2byte_float2byteMSB_0, 0),
                     (self.fec_ber_bf_0, 1))
        self.connect((self.sym2byte_float2byteMSB_0_0, 0),
                     (self.blocks_file_sink_0_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))
예제 #15
0
    def __init__(self):
        gr.top_block.__init__(self, "Aprs Rx Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Aprs Rx Test")
        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", "aprs_rx_test")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48e3
        self.sps = sps = int(samp_rate / 1200)
        self.gain_mu = gain_mu = 0.175

        ##################################################
        # Blocks
        ##################################################
        self.show_text_0 = display.show_text()
        self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(),
                                                 Qt.QWidget)
        self.top_grid_layout.addWidget(self._show_text_0_win, 2, 0, 1, 2)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            2048,  #size
            1024,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        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.fsk_demod_0 = fsk_demod(
            baud=1200,
            fsk_hi_tone=2200,
            fsk_lo_tone=1200,
            in_sps=sps,
            out_sps=2,
        )
        self.fft_filter_xxx_0 = filter.fft_filter_fff(1, (firdes.band_pass(
            1, samp_rate, 1000, 2400, 300, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.epy_block_0 = epy_block_0.blk()
        self.digital_hdlc_deframer_bp_0_0 = digital.hdlc_deframer_bp(32, 500)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            2 * (1 + 0.0), 0.25 * gain_mu * gain_mu, 0.5, gain_mu, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/handiko/aprs_test.wav', True)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.1, ))
        self.blocks_and_const_xx_0 = blocks.and_const_bb(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(int(samp_rate), '', True)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f(
            analog.GR_UNIFORM, 0.1, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'),
                         (self.epy_block_0, 'hdlc in'))
        self.msg_connect((self.epy_block_0, 'ax25 out'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.fsk_demod_0, 0))
        self.connect((self.blocks_and_const_xx_0, 0),
                     (self.digital_hdlc_deframer_bp_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_not_xx_0, 0),
                     (self.blocks_and_const_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.show_text_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_diff_decoder_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_diff_decoder_bb_0, 0),
                     (self.blocks_not_xx_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.fsk_demod_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
예제 #16
0
    def __init__(self, inc_samp_rate):
        gr.hier_block2.__init__(self,
            "fsk_demod",
            gr.io_signature(1, 1, gr.sizeof_float),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_char) # Output signature
        )

        self.inc_samp_rate = inc_samp_rate

        self.sps = sps = 4
        self.baud_rate = baud_rate = 1200
        self.samp_rate = samp_rate = sps * baud_rate * 4
        self.mark = mark = 2200
        self.space = space = 1200
        self.center = center = int((mark + space) / 2)

        ##################################################
        # Blocks
        ##################################################
        # Stage 1: Force resampling to 19.2ksps
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=samp_rate,
                decimation=self.inc_samp_rate,
                taps=None,
                fractional_bw=None,
        )

        # Stage 2: Bandpass Filter
        self.bpf_width = bpf_width = 800
        self.bpf_trans = bpf_trans = 200

        self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass(
            1, samp_rate, 1700-bpf_width, 1700+bpf_width, bpf_trans, firdes.WIN_RECTANGULAR, 6.76))

        # Stage 3: Tone Detection
        self.window_len = window_len = self.samp_rate/self.baud_rate*2
        self.window = window = signal.windows.cosine(window_len)

        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_fcf(4, (window), mark, samp_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf(4, (window), space, samp_rate)
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        # Stage 4: AGC
        self.decay = decay = 0.00022
        self.attack = attack = 0.8
        self.bruninga_direwolf_agc_0_0 = bruninga.direwolf_agc(attack, decay)
        self.bruninga_direwolf_agc_0 = bruninga.direwolf_agc(attack, decay)
        self.blocks_sub_xx_1 = blocks.sub_ff(1)

        # Stage 5: Clock Recovery
        self.gain_mu = gain_mu = 0.45

        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(self.sps*(1+0.0), 0.25*gain_mu*gain_mu, 0.5, gain_mu, 0.05)

        # Stage 6: Differential Decoding
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_and_const_xx_0 = blocks.and_const_bb(1)

        # Stage 7: Output
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()

        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.band_pass_filter_0, 0))

        self.connect((self.band_pass_filter_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))

        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.bruninga_direwolf_agc_0, 0))
        self.connect((self.blocks_complex_to_mag_0_0, 0), (self.bruninga_direwolf_agc_0_0, 0))

        self.connect((self.bruninga_direwolf_agc_0_0, 0), (self.blocks_sub_xx_1, 1))
        self.connect((self.bruninga_direwolf_agc_0, 0), (self.blocks_sub_xx_1, 0))
        self.connect((self.blocks_sub_xx_1, 0), (self.digital_clock_recovery_mm_xx_0, 0))

        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))

        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_not_xx_0, 0))
        self.connect((self.blocks_not_xx_0, 0), (self.blocks_and_const_xx_0, 0))
        self.connect((self.blocks_and_const_xx_0, 0), (self, 0))

        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0))
예제 #17
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)
        )
예제 #18
0
    def __init__(self, center_freq=867.4105, find_chan_nums=False, freq_list=[866.0375, 866.2875, 866.5375, 866.7875, 867.0375, 867.2875, 867.5375, 867.7875, 868.0375, 868.2875, 868.5375, 868.7875, 866.0625, 866.3125, 866.5625, 866.8125, 867.0625, 867.3125, 867.5625, 867.8125], noise_threshold=5, sink_rate=48000, source_rate=4000000, talkgroup=1796, tone_threshold=0.1, track_analog=True, track_digital=True, voice_threshold=0.4):
        gr.hier_block2.__init__(
            self, "Trunked Radio",
                gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
                gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_char*1]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.center_freq = center_freq
        self.find_chan_nums = find_chan_nums
        self.freq_list = freq_list
        self.noise_threshold = noise_threshold
        self.sink_rate = sink_rate
        self.source_rate = source_rate
        self.talkgroup = talkgroup
        self.tone_threshold = tone_threshold
        self.track_analog = track_analog
        self.track_digital = track_digital
        self.voice_threshold = voice_threshold

        ##################################################
        # Variables
        ##################################################
        self.baud_rate = baud_rate = 9600
        self.samp_per_sym = samp_per_sym = sink_rate / baud_rate
        self.fp_sel_index = fp_sel_index = 0

        ##################################################
        # Blocks
        ##################################################
        self.edacs_handle_eot_0 = edacs.handle_eot(sink_rate, 4800, tone_threshold, noise_threshold)
        def _fp_sel_index_probe():
            while True:

                val = self.edacs_handle_eot_0.get_sel_index()
                try:
                    self.set_fp_sel_index(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (100))
        _fp_sel_index_thread = threading.Thread(target=_fp_sel_index_probe)
        _fp_sel_index_thread.daemon = True
        _fp_sel_index_thread.start()

        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
                interpolation=int(sink_rate / 8000),
                decimation=1,
                taps=None,
                fractional_bw=None)
        self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc(
                interpolation=int(sink_rate / 1000),
                decimation=int(source_rate / 1000),
                taps=None,
                fractional_bw=None)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=int(sink_rate / 1000),
                decimation=int(source_rate / 100000),
                taps=None,
                fractional_bw=None)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            100,
            firdes.low_pass(
                1,
                source_rate,
                .00625e6,
                .002e6,
                firdes.WIN_HAMMING,
                6.76))
        self.edacs_proc_msg_0 = edacs.proc_msg(talkgroup, freq_list, center_freq, find_chan_nums, track_analog, track_digital)
        self.edacs_find_chan_nums_0 = edacs.find_chan_nums(freq_list, center_freq, source_rate, voice_threshold)
        self.dsd_block_ff_0 = dsd.dsd_block_ff(dsd.dsd_FRAME_PROVOICE,dsd.dsd_MOD_AUTO_SELECT,3,False,3)
        self.digital_gfsk_demod_0 = digital.gfsk_demod(
            samples_per_symbol=int(samp_per_sym),
            sensitivity=1.0,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False)
        self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb('010101010101010101010111000100100101010101010101', 0)
        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.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1-fp_sel_index)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1024)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_1 = analog.sig_source_c(source_rate, analog.GR_COS_WAVE, 0, 1, 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(source_rate, analog.GR_COS_WAVE, 0, 1, 0, 0)
        self.analog_fm_demod_cf_0 = analog.fm_demod_cf(
        	channel_rate=sink_rate,
        	audio_decim=1,
        	deviation=7000,
        	audio_pass=6.25e3,
        	audio_stop=10e3,
        	gain=2.0,
        	tau=75e-6,
        )



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.edacs_find_chan_nums_0, 'status_out'), (self.edacs_proc_msg_0, 'chan_status_in'))
        self.msg_connect((self.edacs_handle_eot_0, 'status_out'), (self.edacs_proc_msg_0, 'eot_status_in'))
        self.msg_connect((self.edacs_proc_msg_0, 'ctrl_freq'), (self.analog_sig_source_x_0, 'freq'))
        self.msg_connect((self.edacs_proc_msg_0, 'voice_freq'), (self.analog_sig_source_x_1, 'freq'))
        self.msg_connect((self.edacs_proc_msg_0, 'chan_status_out'), (self.edacs_find_chan_nums_0, 'status_in'))
        self.msg_connect((self.edacs_proc_msg_0, 'eot_status_out'), (self.edacs_handle_eot_0, 'status_in'))
        self.connect((self.analog_fm_demod_cf_0, 0), (self.edacs_handle_eot_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_add_xx_0, 0), (self, 0))
        self.connect((self.blocks_delay_0, 0), (self.edacs_find_chan_nums_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.rational_resampler_xxx_0_0_0, 0))
        self.connect((self.blocks_not_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_not_xx_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_correlate_access_code_bb_0, 0))
        self.connect((self.digital_correlate_access_code_bb_0, 0), (self.edacs_proc_msg_0, 0))
        self.connect((self.digital_gfsk_demod_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.edacs_handle_eot_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.edacs_handle_eot_0, 0), (self.dsd_block_ff_0, 0))
        self.connect((self.edacs_proc_msg_0, 0), (self, 1))
        self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self, 0), (self.blocks_delay_0, 0))
        self.connect((self, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.digital_gfsk_demod_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.analog_fm_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_add_xx_0, 1))
예제 #19
0
    def __init__(self):
        gr.top_block.__init__(self, "APRS - AFSK Decoder (Test)")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("APRS - AFSK Decoder (Test)")
        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", "APRS_AFSK_Complete")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.space = space = 2400
        self.samp_rate = samp_rate = 24e3
        self.out_sps = out_sps = 2
        self.mark = mark = 1200
        self.baud = baud = 1200

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Input Signal')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Demodulator Output')
        self.top_layout.addWidget(self.tab)
        self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f(
            256,  #size
            baud,  #samp_rate
            'Clock Sync Output',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0_0.set_y_axis(-5, 5)

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

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

        if not False:
            self.qtgui_time_sink_x_0_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "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_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_0_win, 1,
                                         0, 1, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            512,  #size
            baud * out_sps,  #samp_rate
            'Demodulator Output',  #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(-5, 5)

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

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

        if not False:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [2, 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.tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win, 0, 0,
                                         1, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            'Input Waveform',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not False:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 0, 0,
                                         1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            'Input 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(-120, -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(1.0)
        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 "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not False)

        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.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 1, 0,
                                         1, 1)
        self.fft_filter_xxx_0 = filter.fft_filter_fff(1, (firdes.band_pass(
            10, samp_rate, 1e3, 2.6e3, 100, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.epy_block_0 = epy_block_0.blk()
        self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(32, 500)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            out_sps * (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, False)
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_and_const_xx_0 = blocks.and_const_bb(1)
        self.audio_source_0 = audio.source(int(samp_rate), '', True)
        self.AFSK_Demod_0 = AFSK_Demod(
            baud=baud,
            fsk_hi_tone=space,
            fsk_lo_tone=mark,
            in_sps=int(samp_rate / baud),
            out_sps=out_sps,
        )

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'),
                         (self.epy_block_0, 'hdlc in'))
        self.msg_connect((self.epy_block_0, 'ax25 out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.AFSK_Demod_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.AFSK_Demod_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.audio_source_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_and_const_xx_0, 0),
                     (self.digital_hdlc_deframer_bp_0, 0))
        self.connect((self.blocks_not_xx_0, 0),
                     (self.blocks_and_const_xx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_diff_decoder_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_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_not_xx_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.AFSK_Demod_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0))
예제 #20
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.r2_baud = r2_baud = 40e3
        self.r1_freq_offset = r1_freq_offset = 80e3
        self.r1_baud = r1_baud = 19.2e3
        self.tx_sps = tx_sps = 2
        self.tx_gain = tx_gain = 35
        self.tx_freq_offset_1 = tx_freq_offset_1 = 14e3
        self.tx_freq_offset = tx_freq_offset = -25e3
        self.taps = taps = firdes.low_pass(1, samp_rate, 150e3, 50e3,
                                           firdes.WIN_HAMMING)
        self.rx_if_gain = rx_if_gain = 24
        self.rx_freq_offset = rx_freq_offset = 0
        self.rx_bb_gain = rx_bb_gain = 24
        self.r3_freq_offset = r3_freq_offset = 30e3
        self.r2_sps = r2_sps = int(samp_rate / r2_baud)
        self.r2_freq_offset = r2_freq_offset = r1_freq_offset + 2e4
        self.r1_sps = r1_sps = int(samp_rate / r1_baud)
        self.preamble_len = preamble_len = 80
        self.center_freq = center_freq = 868420000

        ##################################################
        # Blocks
        ##################################################
        _tx_freq_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_freq_offset_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tx_freq_offset_sizer,
            value=self.tx_freq_offset,
            callback=self.set_tx_freq_offset,
            label="Transmitting Frequency Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tx_freq_offset_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tx_freq_offset_sizer,
            value=self.tx_freq_offset,
            callback=self.set_tx_freq_offset,
            minimum=-200e3,
            maximum=200e3,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_tx_freq_offset_sizer)
        _rx_freq_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_freq_offset_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_freq_offset_sizer,
            value=self.rx_freq_offset,
            callback=self.set_rx_freq_offset,
            label="Receiving Frequency Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_freq_offset_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_freq_offset_sizer,
            value=self.rx_freq_offset,
            callback=self.set_rx_freq_offset,
            minimum=-200e3,
            maximum=200e3,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rx_freq_offset_sizer)
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ("localhost", 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(
            target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "")
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(center_freq + rx_freq_offset, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(14, 0)
        self.rtlsdr_source_0.set_if_gain(24, 0)
        self.rtlsdr_source_0.set_bb_gain(24, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=250,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "")
        self.osmosdr_sink_0.set_sample_rate(samp_rate * 10)
        self.osmosdr_sink_0.set_center_freq(center_freq + tx_freq_offset, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(18, 0)
        self.osmosdr_sink_0.set_if_gain(tx_gain, 0)
        self.osmosdr_sink_0.set_bb_gain(0, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.low_pass_filter_0_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 40e3, 10e3, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 40e3, 10e3, firdes.WIN_HAMMING,
                            6.76))
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(
            1, (taps), -1 * r2_freq_offset, samp_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (taps), -1 * r1_freq_offset, samp_rate)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=tx_sps,
            sensitivity=2,
            bt=1,
            verbose=False,
            log=False,
        )
        self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(
            r2_sps, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            r2_sps, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_CLIENT",
                                                       "127.0.0.1", "52002",
                                                       10000, False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1",
                                                     "52001", 10000, False)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")
        self.blocks_not_xx_0 = blocks.not_bb()
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.9, ))
        self.analog_simple_squelch_cc_0_0 = analog.simple_squelch_cc(-40, 1)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-40, 1)
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(
            2 * (samp_rate) / (2 * math.pi * 20e3 / 8.0))
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            2 * (samp_rate) / (2 * math.pi * 20e3 / 8.0))
        self.Zwave_preamble_0 = Zwave.preamble(preamble_len)
        self.Zwave_packet_sink_0_1 = Zwave.packet_sink()
        self.Zwave_packet_sink_0 = Zwave.packet_sink()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.Zwave_packet_sink_0, 'out'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.msg_connect((self.Zwave_packet_sink_0_1, 'out'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.msg_connect((self.Zwave_preamble_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.Zwave_preamble_0, 'in'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.analog_simple_squelch_cc_0_0, 0),
                     (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_not_xx_0, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_not_xx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.Zwave_packet_sink_0_1, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0),
                     (self.Zwave_packet_sink_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, 0),
                     (self.digital_binary_slicer_fb_0_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.analog_simple_squelch_cc_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.digital_clock_recovery_mm_xx_0_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.osmosdr_sink_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0, 0))
    def __init__(self,
                 baud_rate=1200,
                 mark_freq=1200,
                 offset=50e3,
                 postamble_len=4,
                 preamble_len=.1,
                 rf_samp_rate=2.4e6,
                 space_freq=2200):
        gr.hier_block2.__init__(
            self,
            "afsk_ax25_mod",
            gr.io_signature(0, 0, 0),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_gr_complex))  # Output signature

        self.message_port_register_hier_in("packets")

        ##################################################
        # Parameters
        ##################################################
        self.baud_rate = baud_rate
        self.mark_freq = mark_freq
        self.offset = offset
        self.postamble_len = postamble_len
        self.preamble_len = preamble_len
        self.rf_samp_rate = rf_samp_rate
        self.space_freq = space_freq

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.sps = sps = samp_rate / baud_rate

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(rf_samp_rate),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.hsl_ptt_cc_0 = hsl.ptt_cc()
        self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb('packet_len')
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bf(
            ([mark_freq, space_freq]), 1)
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b([0x7e], True,
                                                                 1, [])
        self.blocks_vector_source_x_0 = blocks.vector_source_b([0x7e], True, 1,
                                                               [])
        self.blocks_vco_f_0 = blocks.vco_f(samp_rate, 2 * math.pi, .95)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_char * 1, 'packet_len', 0)
        self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, postamble_len * 8, "packet_len")
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, int(baud_rate * preamble_len), "packet_len")
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, sps)
        self.blocks_packed_to_unpacked_xx_0_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_LSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_LSB_FIRST)
        self.blocks_not_xx_0_0_0_0 = blocks.not_bb()
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_and_const_xx_0_0_0_0 = blocks.and_const_bb(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            rf_samp_rate, analog.GR_COS_WAVE, offset, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=samp_rate,
            quad_rate=samp_rate,
            tau=75e-6,
            max_dev=5e3,
            fh=-1.0,
        )

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self, 'packets'),
                         (self.digital_hdlc_framer_pb_0, 'in'))
        self.connect((self.analog_nbfm_tx_0, 0), (self.hsl_ptt_cc_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_and_const_xx_0_0_0_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self, 0))
        self.connect((self.blocks_not_xx_0_0_0_0, 0),
                     (self.blocks_and_const_xx_0_0_0_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.digital_chunks_to_symbols_xx_1, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 2))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.blocks_not_xx_0_0_0_0, 0))
        self.connect((self.blocks_vco_f_0, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_vco_f_0, 0), (self.hsl_ptt_cc_0, 1))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_1, 0),
                     (self.blocks_vco_f_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.digital_hdlc_framer_pb_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.hsl_ptt_cc_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 1))