Beispiel #1
0
    def __init__(self):
        gr.top_block.__init__(self, "Dvbt Tx")

        ##################################################
        # Variables
        ##################################################
        self._bandwidth_config = ConfigParser.ConfigParser()
        self._bandwidth_config.read('./dvbt.conf')
        try:
            bandwidth = self._bandwidth_config.getint('dvbt', 'bandwidth')
        except:
            bandwidth = 8000000
        self.bandwidth = bandwidth
        self.samp_rate = samp_rate = (bandwidth / 7) * 8
        self._rf_gain_config = ConfigParser.ConfigParser()
        self._rf_gain_config.read('./dvbt.conf')
        try:
            rf_gain = self._rf_gain_config.getint('hackrf', 'rf_gain')
        except:
            rf_gain = 0
        self.rf_gain = rf_gain
        self._mode_config = ConfigParser.ConfigParser()
        self._mode_config.read('./dvbt.conf')
        try:
            mode = self._mode_config.get('dvbt', 'mode')
        except:
            mode = 0
        self.mode = mode
        self._if_gain_config = ConfigParser.ConfigParser()
        self._if_gain_config.read('./dvbt.conf')
        try:
            if_gain = self._if_gain_config.getint('hackrf', 'if_gain')
        except:
            if_gain = 0
        self.if_gain = if_gain
        self._guard_interval_config = ConfigParser.ConfigParser()
        self._guard_interval_config.read('./dvbt.conf')
        try:
            guard_interval = self._guard_interval_config.get(
                'dvbt', 'guard_interval')
        except:
            guard_interval = 0
        self.guard_interval = guard_interval
        self._frequency_config = ConfigParser.ConfigParser()
        self._frequency_config.read('./dvbt.conf')
        try:
            frequency = self._frequency_config.getint('hackrf', 'frequency')
        except:
            frequency = 858000000
        self.frequency = frequency
        self._constellation_config = ConfigParser.ConfigParser()
        self._constellation_config.read('./dvbt.conf')
        try:
            constellation = self._constellation_config.get(
                'dvbt', 'constellation')
        except:
            constellation = 0
        self.constellation = constellation
        self._coderate_config = ConfigParser.ConfigParser()
        self._coderate_config.read('./dvbt.conf')
        try:
            coderate = self._coderate_config.get('dvbt', 'coderate')
        except:
            coderate = 0
        self.coderate = coderate

        infile = str(sys.argv[1])

        #Constellation QPSK 16QAM 64QAM
        if constellation == "QPSK":
            const = dtv.MOD_QPSK
        elif constellation == "16QAM":
            const = dtv.MOD_16QAM
        elif constellation == "64QAM":
            const = dtv.MOD_64QAM
        else:
            sys.stderr.write(
                "CONSTELLATION IN CONFIG WRONG! Values: QPSK, 16QAM or 64QAM \n"
            )
            sys.exit(1)

# Coderate 1/2 2/3 3/4 5/6 7/8

        if coderate == "1/2":
            codr = dtv.C1_2
        elif coderate == "2/3":
            codr = dtv.C2_3
        elif coderate == "3/4":
            codr = dtv.C3_4
        elif coderate == "5/6":
            codr = dtv.C5_6
        elif coderate == "7/8":
            codr = dtv.C7_8
        else:
            sys.stderr.write(
                "CODERATE IN CONFIG WRONG! Values: 1/2, 2/3, 3/4, 5/6 or 7/8 \n"
            )
            sys.exit(1)

        if mode == "2k":
            factor = 1
            carriers = 2048
            modus = dtv.T2k
        elif mode == "8k":
            factor = 4
            carriers = 8192
            modus = dtv.T8k
        else:
            sys.stderr.write("MODE IN CONFIG WRONG! Values: 2k or 8k \n")
            sys.exit(1)

#guard_interval dtv.GI_1_32 1/4 1/8 1/16 1/32
        if guard_interval == "1/4":
            guardi = dtv.GI_1_4
            gi = carriers / 4
        elif guard_interval == "1/8":
            guardi = dtv.GI_1_8
            gi = carriers / 8
        elif guard_interval == "1/16":
            guardi = dtv.GI_1_16
            gi = carriers / 16
        elif guard_interval == "1/32":
            guardi = dtv.GI_1_32
            gi = carriers / 32
        else:
            sys.stderr.write(
                "GUARD_INTERVAL IN CONFIG WRONG! Values: 1/4, 1/8, 1/16 or 1/32 \n"
            )
            sys.exit(1)

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + '')
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(frequency, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(rf_gain, 0)
        self.osmosdr_sink_0.set_if_gain(if_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.fft_vxx_0 = fft.fft_vcc(carriers, False,
                                     (window.rectangular(carriers)), True, 1)
        self.dtv_dvbt_symbol_inner_interleaver_0 = dtv.dvbt_symbol_inner_interleaver(
            (1512 * factor), modus, 1)
        self.dtv_dvbt_reference_signals_0 = dtv.dvbt_reference_signals(
            gr.sizeof_gr_complex, (1512 * factor), carriers, const, dtv.NH,
            codr, codr, guardi, modus, 1, 0)
        self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, (8 * factor))
        self.dtv_dvbt_map_0 = dtv.dvbt_map((1512 * factor), const, dtv.NH,
                                           modus, 1)
        self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder(
            1, (1512 * factor), const, dtv.NH, codr)
        self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1 *
                                                                     factor)
        self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver(
            (136 * factor), 12, 17)
        self.dtv_dvbt_bit_inner_interleaver_0 = dtv.dvbt_bit_inner_interleaver(
            (1512 * factor), const, dtv.NH, modus)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            carriers, carriers + (gi), 0, '')
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (0.0022097087, ))

        if infile == "-":
            self.blocks_file_descriptor_source_0 = blocks.file_descriptor_source(
                gr.sizeof_char * 1, 0, True)
        else:
            self.blocks_file_source_0 = blocks.file_source(
                gr.sizeof_char * 1, infile, True)

        ##################################################
        # Connections
        ##################################################

        if infile == "-":
            self.connect((self.blocks_file_descriptor_source_0, 0),
                         (self.dtv_dvbt_energy_dispersal_0, 0))
        else:
            self.connect((self.blocks_file_source_0, 0),
                         (self.dtv_dvbt_energy_dispersal_0, 0))

        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.osmosdr_sink_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.dtv_dvbt_bit_inner_interleaver_0, 0),
                     (self.dtv_dvbt_symbol_inner_interleaver_0, 0))
        self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0),
                     (self.dtv_dvbt_inner_coder_0, 0))
        self.connect((self.dtv_dvbt_energy_dispersal_0, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0, 0))
        self.connect((self.dtv_dvbt_inner_coder_0, 0),
                     (self.dtv_dvbt_bit_inner_interleaver_0, 0))
        self.connect((self.dtv_dvbt_map_0, 0),
                     (self.dtv_dvbt_reference_signals_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0),
                     (self.dtv_dvbt_convolutional_interleaver_0, 0))
        self.connect((self.dtv_dvbt_reference_signals_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.dtv_dvbt_symbol_inner_interleaver_0, 0),
                     (self.dtv_dvbt_map_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
Beispiel #2
0
def main(args):
    nargs = len(args)
    if nargs == 1:
        port    = int(args[0])
        outfile = None
    elif nargs == 2:
        port     = int(args[0])
        outfile  = args[1]
    else:
        sys.stderr.write("Usage: dvbt-hackrf.py port [output_file]\n");
        sys.exit(1)

    channel_mhz = 6
    mode = dtv.T2k
    code_rate = dtv.C1_2
    constellation = dtv.MOD_QPSK
    guard_interval = dtv.GI_1_32
    symbol_rate = channel_mhz * 8000000.0 / 7
    center_freq = 441000000
    rf_gain = 14
    if_gain = 40

    if mode == dtv.T2k:
        factor = 1
        carriers = 2048
    elif mode == dtv.T8k:
        factor = 4
        carriers = 8192

    if guard_interval == dtv.GI_1_32:
        gi = carriers / 32
    elif guard_interval == dtv.GI_1_16:
        gi = carriers / 16
    elif guard_interval == dtv.GI_1_8:
        gi = carriers / 8
    elif guard_interval == dtv.GI_1_4:
        gi = carriers / 4

    if channel_mhz == 8:
        bandwidth = 8750000
    elif channel_mhz == 7:
        bandwidth = 7000000
    elif channel_mhz == 6:
        bandwidth = 6000000
    elif channel_mhz == 5:
        bandwidth = 5000000
    else:
        bandwidth = 8750000

    tb = gr.top_block()

    src = grc_blks2.tcp_source(gr.sizeof_char*1, "127.0.0.1", port, True)

    dvbt_energy_dispersal = dtv.dvbt_energy_dispersal(1 * factor)
    dvbt_reed_solomon_enc = dtv.dvbt_reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, (8 * factor))
    dvbt_convolutional_interleaver = dtv.dvbt_convolutional_interleaver((136 * factor), 12, 17)
    dvbt_inner_coder = dtv.dvbt_inner_coder(1, (1512 * factor), constellation, dtv.NH, code_rate)
    dvbt_bit_inner_interleaver = dtv.dvbt_bit_inner_interleaver((1512 * factor), constellation, dtv.NH, mode)
    dvbt_symbol_inner_interleaver = dtv.dvbt_symbol_inner_interleaver((1512 * factor), mode, 1)
    dvbt_map = dtv.dvbt_map((1512 * factor), constellation, dtv.NH, mode, 1)
    dvbt_reference_signals = dtv.dvbt_reference_signals(gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dtv.NH, code_rate, code_rate, dtv.GI_1_32, mode, 0, 0)
    fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)), True, 10)
    digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(carriers, carriers+(gi), 0, "")
    blocks_multiply_const_vxx = blocks.multiply_const_vcc((0.0022097087 * 2.5, ))

    out = osmosdr.sink()
    out.set_sample_rate(symbol_rate)
    out.set_center_freq(center_freq, 0)
    out.set_freq_corr(0, 0)
    out.set_gain(rf_gain, 0)
    out.set_if_gain(if_gain, 0)
    out.set_bandwidth(bandwidth, 0)

    tb.connect(src, dvbt_energy_dispersal)
    tb.connect(dvbt_energy_dispersal, dvbt_reed_solomon_enc)
    tb.connect(dvbt_reed_solomon_enc, dvbt_convolutional_interleaver)
    tb.connect(dvbt_convolutional_interleaver, dvbt_inner_coder)
    tb.connect(dvbt_inner_coder, dvbt_bit_inner_interleaver)
    tb.connect(dvbt_bit_inner_interleaver, dvbt_symbol_inner_interleaver)
    tb.connect(dvbt_symbol_inner_interleaver, dvbt_map)
    tb.connect(dvbt_map, dvbt_reference_signals)
    tb.connect(dvbt_reference_signals, fft_vxx)
    tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer)
    tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx)
    tb.connect(blocks_multiply_const_vxx, out)


    if outfile:
        dst = blocks.file_sink(gr.sizeof_gr_complex, outfile)
        tb.connect(blocks_multiply_const_vxx, dst)

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

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

        ##################################################
        # Variables
        ##################################################
        self.variable = variable = 0.00001
        self.samp_rate_0 = samp_rate_0 = 32000
        self.rf_gain = rf_gain = 64
        self.if_gain = if_gain = 15
        self.bb_gain = bb_gain = 15

        ##################################################
        # Blocks
        ##################################################
        self._variable_range = Range(0.00001, 0.01, 0.00001, 0.00001, 200)
        self._variable_win = RangeWidget(self._variable_range,
                                         self.set_variable, 'variable',
                                         "counter_slider", float)
        self.top_layout.addWidget(self._variable_win)
        self._rf_gain_range = Range(0, 200, 1, 64, 200)
        self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain,
                                        'rf_gain', "counter_slider", float)
        self.top_layout.addWidget(self._rf_gain_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=63,
            decimation=64,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            (4096 + 512) * 2,  #size
            8127000,  #samp_rate
            "Senal en el tiempo",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            (4096 + 512) * 2,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            8127000,  #bw
            "ESPECTRO OFDM",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(True)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

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

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.isdbt_tsp_resize_0_2_1 = isdbt.tsp_resize()
        self.isdbt_tsp_resize_0_2_0 = isdbt.tsp_resize()
        self.isdbt_tsp_resize_0_2 = isdbt.tsp_resize()
        self.isdbt_time_interleaver_0 = isdbt.time_interleaver(3, 4, True)
        self.isdbt_sync_adjust_0_1 = isdbt.sync_adjust()
        self.isdbt_sync_adjust_0_0 = isdbt.sync_adjust()
        self.isdbt_sync_adjust_0 = isdbt.sync_adjust()
        self.isdbt_ofdm_frame_structure_0 = isdbt.ofdm_frame_structure(
            3, True, 3, 3, 3, 0, 0, 0, 4, 4, 4, 1, 6, 6)
        self.isdbt_mapper_0_1 = isdbt.mapper(3, 6, 6, 0.125)
        self.isdbt_mapper_0_0 = isdbt.mapper(3, 6, 6, 0.125)
        self.isdbt_mapper_0 = isdbt.mapper(3, 6, 1, 0.125)
        self.isdbt_hierarchical_divisor_0 = isdbt.hierarchical_divisor(
            3, 0.125, 1, 6, 0.5, 6, 6, 0.5, 6, 6, 0.5)
        self.isdbt_hierarchical_combination_0 = isdbt.hierarchical_combination(
            3, 1, 6, 6)
        self.isdbt_frec_interleaver_0 = isdbt.frec_interleaver(3, True)
        self.isdbt_energy_dispersal_0_1 = isdbt.energy_dispersal(72 * 6)
        self.isdbt_energy_dispersal_0_0 = isdbt.energy_dispersal(432)
        self.isdbt_energy_dispersal_0 = isdbt.energy_dispersal(72)
        self.isdbt_byte_interleaver_0_1 = isdbt.byte_interleaver(3, 0, 6, 6)
        self.isdbt_byte_interleaver_0_0 = isdbt.byte_interleaver(3, 0, 6, 6)
        self.isdbt_byte_interleaver_0 = isdbt.byte_interleaver(3, 0, 6, 1)
        self._if_gain_range = Range(0, 30, 1, 15, 200)
        self._if_gain_win = RangeWidget(self._if_gain_range, self.set_if_gain,
                                        'if_gain', "counter_slider", float)
        self.top_layout.addWidget(self._if_gain_win)
        self.fft_vxx_0 = fft.fft_vcc(4096 * 2, False,
                                     (window.rectangular(4096 * 2)), True, 1)
        self.dtv_dvbt_reed_solomon_enc_0_0_1 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 1)
        self.dtv_dvbt_reed_solomon_enc_0_0_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 1)
        self.dtv_dvbt_reed_solomon_enc_0_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 1)
        self.dtv_dvbt_inner_coder_0_1 = dtv.dvbt_inner_coder(
            1, 1512, dtv.MOD_64QAM, dtv.ALPHA2, dtv.C1_2)
        self.dtv_dvbt_inner_coder_0_0 = dtv.dvbt_inner_coder(
            1, 1512, dtv.MOD_64QAM, dtv.ALPHA2, dtv.C1_2)
        self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder(
            1, 1512, dtv.MOD_64QAM, dtv.ALPHA2, dtv.C1_2)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            4096 * 2, 4096 * 2 + 512 * 2, 0, "")
        self.blocks_vector_to_stream_1_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 4096 * 2)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 4096 * 2)
        self.blocks_vector_to_stream_0_1_2 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 1512)
        self.blocks_vector_to_stream_0_1_1 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 1512)
        self.blocks_vector_to_stream_0_1 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 1512)
        self.blocks_vector_to_stream_0_0_2 = blocks.vector_to_stream(
            gr.sizeof_char * 204, 144 * 6)
        self.blocks_vector_to_stream_0_0_1 = blocks.vector_to_stream(
            gr.sizeof_char * 204, 144 * 6)
        self.blocks_vector_to_stream_0_0_0_1 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 204)
        self.blocks_vector_to_stream_0_0_0_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 204)
        self.blocks_vector_to_stream_0_0_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 204)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(
            gr.sizeof_char * 204, 144)
        self.blocks_stream_to_vector_1_1 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 384 * 6)
        self.blocks_stream_to_vector_1_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 384 * 6)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 384)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (variable, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_source_0_0_0 = blocks.file_source(
            gr.sizeof_char * 204 * 2304 * 2,
            '/home/habbo/Documents/BTS_Validos/BTS_ISDB_T_3_CAPAS.ts', True)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self._bb_gain_range = Range(0, 30, 1, 15, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain,
                                        'bb_gain', "counter_slider", float)
        self.top_layout.addWidget(self._bb_gain_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_file_source_0_0_0, 0),
                     (self.isdbt_hierarchical_divisor_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0),
                     (self.isdbt_hierarchical_combination_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0, 0),
                     (self.isdbt_hierarchical_combination_0, 1))
        self.connect((self.blocks_stream_to_vector_1_1, 0),
                     (self.isdbt_hierarchical_combination_0, 2))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.isdbt_tsp_resize_0_2, 0))
        self.connect((self.blocks_vector_to_stream_0_0_0, 0),
                     (self.dtv_dvbt_inner_coder_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0_0_0, 0),
                     (self.dtv_dvbt_inner_coder_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0_0_1, 0),
                     (self.dtv_dvbt_inner_coder_0_1, 0))
        self.connect((self.blocks_vector_to_stream_0_0_1, 0),
                     (self.isdbt_tsp_resize_0_2_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0_2, 0),
                     (self.isdbt_tsp_resize_0_2_1, 0))
        self.connect((self.blocks_vector_to_stream_0_1, 0),
                     (self.isdbt_mapper_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_1, 0),
                     (self.isdbt_mapper_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_2, 0),
                     (self.isdbt_mapper_0_1, 0))
        self.connect((self.blocks_vector_to_stream_1, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_vector_to_stream_1_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.dtv_dvbt_inner_coder_0, 0),
                     (self.blocks_vector_to_stream_0_1, 0))
        self.connect((self.dtv_dvbt_inner_coder_0_0, 0),
                     (self.blocks_vector_to_stream_0_1_1, 0))
        self.connect((self.dtv_dvbt_inner_coder_0_1, 0),
                     (self.blocks_vector_to_stream_0_1_2, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0_0, 0),
                     (self.isdbt_sync_adjust_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0_0_0, 0),
                     (self.isdbt_sync_adjust_0_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0_0_1, 0),
                     (self.isdbt_sync_adjust_0_1, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_vector_to_stream_1_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
        self.connect((self.isdbt_byte_interleaver_0, 0),
                     (self.blocks_vector_to_stream_0_0_0, 0))
        self.connect((self.isdbt_byte_interleaver_0_0, 0),
                     (self.blocks_vector_to_stream_0_0_0_0, 0))
        self.connect((self.isdbt_byte_interleaver_0_1, 0),
                     (self.blocks_vector_to_stream_0_0_0_1, 0))
        self.connect((self.isdbt_energy_dispersal_0, 0),
                     (self.isdbt_byte_interleaver_0, 0))
        self.connect((self.isdbt_energy_dispersal_0_0, 0),
                     (self.isdbt_byte_interleaver_0_0, 0))
        self.connect((self.isdbt_energy_dispersal_0_1, 0),
                     (self.isdbt_byte_interleaver_0_1, 0))
        self.connect((self.isdbt_frec_interleaver_0, 0),
                     (self.isdbt_ofdm_frame_structure_0, 0))
        self.connect((self.isdbt_hierarchical_combination_0, 0),
                     (self.isdbt_time_interleaver_0, 0))
        self.connect((self.isdbt_hierarchical_divisor_0, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.isdbt_hierarchical_divisor_0, 1),
                     (self.blocks_vector_to_stream_0_0_1, 0))
        self.connect((self.isdbt_hierarchical_divisor_0, 2),
                     (self.blocks_vector_to_stream_0_0_2, 0))
        self.connect((self.isdbt_mapper_0, 0),
                     (self.blocks_stream_to_vector_1, 0))
        self.connect((self.isdbt_mapper_0_0, 0),
                     (self.blocks_stream_to_vector_1_0, 0))
        self.connect((self.isdbt_mapper_0_1, 0),
                     (self.blocks_stream_to_vector_1_1, 0))
        self.connect((self.isdbt_ofdm_frame_structure_0, 0),
                     (self.blocks_vector_to_stream_1, 0))
        self.connect((self.isdbt_ofdm_frame_structure_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.isdbt_sync_adjust_0, 0),
                     (self.isdbt_energy_dispersal_0, 0))
        self.connect((self.isdbt_sync_adjust_0_0, 0),
                     (self.isdbt_energy_dispersal_0_0, 0))
        self.connect((self.isdbt_sync_adjust_0_1, 0),
                     (self.isdbt_energy_dispersal_0_1, 0))
        self.connect((self.isdbt_time_interleaver_0, 0),
                     (self.isdbt_frec_interleaver_0, 0))
        self.connect((self.isdbt_tsp_resize_0_2, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0_0, 0))
        self.connect((self.isdbt_tsp_resize_0_2_0, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0_0_0, 0))
        self.connect((self.isdbt_tsp_resize_0_2_1, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0_0_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_null_sink_0, 0))
Beispiel #4
0
def main(args):
    d = 'Transmit a DVB-T signal using the bladeRF and gr-dtv'
    parser = argparse.ArgumentParser()

    mode_help = '# of carriers. Options: t2k, t8k (default).'
    parser.add_argument('-m',
                        '--mode',
                        dest='mode',
                        default='t8k',
                        type=str,
                        help=mode_help)

    ch_help = 'channel width in MHz. Options: 5, 6, 7, 8 (default).'
    parser.add_argument('-c',
                        '--channel',
                        dest='channel',
                        default=8,
                        metavar='CH',
                        type=int,
                        help=ch_help)

    const_help = 'constellation. qpsk, qam16, qam64 (default).'
    parser.add_argument('-C',
                        '--cons',
                        dest='cons',
                        default='qam64',
                        metavar='TYPE',
                        type=str,
                        help=const_help)

    rate_help = 'Viterbi rate. 1/2, 2/3, 3/4, 5/6, 7/8 (default).'
    parser.add_argument('-r',
                        '--rate',
                        dest='rate',
                        default='7/8',
                        type=str,
                        help=rate_help)

    guard_help = 'guard interval. 1/32 (default), 1/16, 1/8, 1/4.'
    parser.add_argument('-g',
                        '--guard',
                        dest='interval',
                        default='1/32',
                        metavar='D',
                        type=str,
                        help=guard_help)

    freq_help = 'center frequency (Hz). Default is 429e6.'
    parser.add_argument('-f',
                        '--freq',
                        dest='freq',
                        default=429e6,
                        type=float,
                        help=freq_help)

    vga1_help = 'bladeRF TXVGA1 gain. Default is -6.'
    parser.add_argument('--txvga1',
                        dest='txvga1',
                        default=-6,
                        metavar='gain',
                        type=int,
                        help=vga1_help)

    vga2_help = 'bladeRF TXVGA2 gain. Default is 9.'
    parser.add_argument('--txvga2',
                        dest='txvga2',
                        default=9,
                        metavar='gain',
                        type=int,
                        help=vga2_help)

    outfile_help = 'write to specified file.'
    parser.add_argument('-o',
                        '--output',
                        dest='outfile',
                        default=None,
                        metavar='OUT',
                        type=str,
                        help=outfile_help)

    parser.add_argument('infile',
                        metavar='input-file',
                        type=str,
                        help='Input file')

    args = parser.parse_args()
    print args

    if args.mode.lower() == 't2k':
        mode = dtv.T2k
    elif args.mode.lower() == 't8k':
        mode = dtv.T8k
    else:
        sys.stderr.write('Invalid mode provided: ' + args.mode + '\n')
        sys.exit(1)

    if args.channel < 5 or args.channel > 8:
        sys.stderr.write('Invalid channel: ' + str(args.channel) + '\n')
        sys.exit(1)
    else:
        channel_mhz = args.channel

    if args.cons.lower() == 'qpsk':
        constellation = dtv.MOD_QPSK
    elif args.cons.lower() == 'qam16':
        constellation = dtv.MOD_16QAM
    elif args.cons.lower() == 'qam64':
        constellation = dtv.MOD_64QAM
    else:
        sys.stderr.write('Invalid constellation type: ' + args.cons + '\n')
        sys.exit(1)

    if args.rate == '1/2':
        code_rate = dtv.C1_2
    elif args.rate == '2/3':
        code_rate = dtv.C2_3
    elif args.rate == '3/4':
        code_rate = dtv.C3_4
    elif args.rate == '5/6':
        code_rate = dtv.C5_6
    elif args.rate == '7/8':
        code_rate = dtv.C7_8
    else:
        sys.stderr.write('Invalid Viterbi rate: ' + args.rate + '\n')
        sys.exit(1)

    if args.interval == '1/32':
        guard_interval = dtv.GI_1_32
    elif args.interval == '1/16':
        guard_interval = dtv.GI_1_16
    elif args.interval == '1/8':
        guard_interval = dtv.GI_1_8
    elif args.interval == '1/4':
        guard_interval = dtv.GI_1_4
    else:
        sys.stderr.write('Invalid guard interval: ' + args.interval + '\n')
        sys.exit(1)

    if args.freq < 300e6 or args.freq > 3.8e9:
        sys.stderr.write('Invalid center frequency: ' + str(args.freq) + '\n')
        sys.exit(1)
    else:
        center_freq = int(args.freq)

    if args.txvga1 < -35 or args.txvga1 > -4:
        sys.stderr.write('Invalid bladeRF TXVGA1 gain: ' + str(args.txvga1) +
                         '\n')
        sys.exit(1)
    else:
        txvga1_gain = args.txvga1

    if args.txvga2 < 0 or args.txvga2 > 25:
        sys.stderr.write('Invalid bladeRF TXVGA2 gain: ' + str(args.txvga2) +
                         '\n')
        sys.exit(1)
    else:
        txvga2_gain = args.txvga2

    infile = args.infile
    outfile = args.outfile
    symbol_rate = channel_mhz * 8000000.0 / 7

    if mode == dtv.T2k:
        factor = 1
        carriers = 2048
    elif mode == dtv.T8k:
        factor = 4
        carriers = 8192

    if guard_interval == dtv.GI_1_32:
        gi = carriers / 32
    elif guard_interval == dtv.GI_1_16:
        gi = carriers / 16
    elif guard_interval == dtv.GI_1_8:
        gi = carriers / 8
    elif guard_interval == dtv.GI_1_4:
        gi = carriers / 4

    if channel_mhz == 8:
        bandwidth = 8750000
    elif channel_mhz == 7:
        bandwidth = 7000000
    elif channel_mhz == 6:
        bandwidth = 6000000
    elif channel_mhz == 5:
        bandwidth = 5000000
    else:
        bandwidth = 8750000

    tb = gr.top_block()

    src = blocks.file_source(gr.sizeof_char, infile, True)

    dtv_dvbt_energy_dispersal = dtv.dvbt_energy_dispersal(1 * factor)
    dtv_dvbt_reed_solomon_enc = dtv.dvbt_reed_solomon_enc(
        2, 8, 0x11d, 255, 239, 8, 51, (8 * factor))
    dtv_dvbt_convolutional_interleaver = dtv.dvbt_convolutional_interleaver(
        (136 * factor), 12, 17)
    dtv_dvbt_inner_coder = dtv.dvbt_inner_coder(1, (1512 * factor),
                                                constellation, dtv.NH,
                                                code_rate)
    dtv_dvbt_bit_inner_interleaver = dtv.dvbt_bit_inner_interleaver(
        (1512 * factor), constellation, dtv.NH, mode)
    dtv_dvbt_symbol_inner_interleaver = dtv.dvbt_symbol_inner_interleaver(
        (1512 * factor), mode, 1)
    dtv_dvbt_map = dtv.dvbt_map((1512 * factor), constellation, dtv.NH, mode,
                                1)
    dtv_dvbt_reference_signals = dtv.dvbt_reference_signals(
        gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dtv.NH,
        code_rate, code_rate, guard_interval, mode, 0, 0)
    fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)),
                          True, 10)
    digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(
        carriers, carriers + (gi), 0, "")
    blocks_multiply_const_vxx = blocks.multiply_const_vcc((0.0022097087, ))

    out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768")
    out.set_sample_rate(symbol_rate)
    out.set_center_freq(center_freq, 0)
    out.set_freq_corr(0, 0)
    out.set_gain(txvga2_gain, 0)
    out.set_bb_gain(txvga1_gain, 0)
    out.set_bandwidth(bandwidth, 0)

    tb.connect(src, dtv_dvbt_energy_dispersal)
    tb.connect(dtv_dvbt_energy_dispersal, dtv_dvbt_reed_solomon_enc)
    tb.connect(dtv_dvbt_reed_solomon_enc, dtv_dvbt_convolutional_interleaver)
    tb.connect(dtv_dvbt_convolutional_interleaver, dtv_dvbt_inner_coder)
    tb.connect(dtv_dvbt_inner_coder, dtv_dvbt_bit_inner_interleaver)
    tb.connect(dtv_dvbt_bit_inner_interleaver,
               dtv_dvbt_symbol_inner_interleaver)
    tb.connect(dtv_dvbt_symbol_inner_interleaver, dtv_dvbt_map)
    tb.connect(dtv_dvbt_map, dtv_dvbt_reference_signals)
    tb.connect(dtv_dvbt_reference_signals, fft_vxx)
    tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer)
    tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx)
    tb.connect(blocks_multiply_const_vxx, out)

    if outfile:
        dst = blocks.file_sink(gr.sizeof_gr_complex, outfile)
        tb.connect(blocks_multiply_const_vxx, dst)

    tb.run()
Beispiel #5
0
def main(args):
    d = 'Transmit a DVB-T signal using the bladeRF and gr-dtv'
    parser = argparse.ArgumentParser()

    mode_help = '# of carriers. Options: t2k, t8k (default).'
    parser.add_argument('-m', '--mode', dest='mode', default='t8k',
                        type=str, help=mode_help)

    ch_help = 'channel width in MHz. Options: 5, 6, 7, 8 (default).'
    parser.add_argument('-c', '--channel', dest='channel', default=8,
                        metavar='CH', type=int, help=ch_help)

    const_help = 'constellation. qpsk, qam16, qam64 (default).'
    parser.add_argument('-C', '--cons', dest='cons', default='qam64',
                        metavar='TYPE', type=str, help=const_help)

    rate_help = 'Viterbi rate. 1/2, 2/3, 3/4, 5/6, 7/8 (default).'
    parser.add_argument('-r', '--rate', dest='rate', default='7/8',
                        type=str, help=rate_help)

    guard_help = 'guard interval. 1/32 (default), 1/16, 1/8, 1/4.'
    parser.add_argument('-g', '--guard', dest='interval', default='1/32',
                        metavar='D', type=str, help=guard_help)

    freq_help = 'center frequency (Hz). Default is 429e6.'
    parser.add_argument('-f', '--freq', dest='freq', default=429e6,
                        type=float, help=freq_help)

    vga1_help = 'bladeRF TXVGA1 gain. Default is -6.'
    parser.add_argument('--txvga1', dest='txvga1', default=-6,
                        metavar='gain', type=int, help=vga1_help)

    vga2_help = 'bladeRF TXVGA2 gain. Default is 9.'
    parser.add_argument('--txvga2', dest='txvga2', default=9,
                        metavar='gain', type=int, help=vga2_help)

    outfile_help = 'write to specified file.'
    parser.add_argument('-o', '--output', dest='outfile', default=None,
                        metavar='OUT', type=str, help=outfile_help)

    parser.add_argument('infile', metavar='input-file', type=str,
                        help='Input file')

    args = parser.parse_args()
    print args

    if args.mode.lower() == 't2k':
        mode = dtv.T2k
    elif args.mode.lower() == 't8k':
        mode = dtv.T8k
    else:
        sys.stderr.write('Invalid mode provided: ' + args.mode + '\n')
        sys.exit(1)

    if args.channel < 5 or args.channel > 8:
        sys.stderr.write('Invalid channel: ' + str(args.channel) + '\n')
        sys.exit(1)
    else:
        channel_mhz = args.channel

    if args.cons.lower() == 'qpsk':
        constellation = dtv.MOD_QPSK
    elif args.cons.lower() == 'qam16':
        constellation = dtv.MOD_16QAM
    elif args.cons.lower() == 'qam64':
        constellation = dtv.MOD_64QAM
    else:
        sys.stderr.write('Invalid constellation type: ' + args.cons + '\n')
        sys.exit(1)

    if args.rate == '1/2':
        code_rate = dtv.C1_2
    elif args.rate == '2/3':
        code_rate = dtv.C2_3
    elif args.rate == '3/4':
        code_rate = dtv.C3_4
    elif args.rate == '5/6':
        code_rate = dtv.C5_6
    elif args.rate == '7/8':
        code_rate = dtv.C7_8
    else:
        sys.stderr.write('Invalid Viterbi rate: ' + args.rate + '\n')
        sys.exit(1)

    if args.interval == '1/32':
        guard_interval = dtv.GI_1_32
    elif args.interval == '1/16':
        guard_interval = dtv.GI_1_16
    elif args.interval == '1/8':
        guard_interval = dtv.GI_1_8
    elif args.interval == '1/4':
        guard_interval = dtv.GI_1_4
    else:
        sys.stderr.write('Invalid guard interval: ' + args.interval + '\n')
        sys.exit(1)

    if args.freq < 300e6 or args.freq > 3.8e9:
        sys.stderr.write('Invalid center frequency: ' + str(args.freq) + '\n')
        sys.exit(1)
    else:
        center_freq = int(args.freq)

    if args.txvga1 < -35 or args.txvga1 > -4:
        sys.stderr.write('Invalid bladeRF TXVGA1 gain: ' +
                         str(args.txvga1) + '\n')
        sys.exit(1)
    else:
        txvga1_gain = args.txvga1

    if args.txvga2 < 0 or args.txvga2 > 25:
        sys.stderr.write('Invalid bladeRF TXVGA2 gain: ' +
                         str(args.txvga2) + '\n')
        sys.exit(1)
    else:
        txvga2_gain = args.txvga2

    infile = args.infile
    outfile = args.outfile
    symbol_rate = channel_mhz * 8000000.0 / 7

    if mode == dtv.T2k:
        factor = 1
        carriers = 2048
    elif mode == dtv.T8k:
        factor = 4
        carriers = 8192

    if guard_interval == dtv.GI_1_32:
        gi = carriers / 32
    elif guard_interval == dtv.GI_1_16:
        gi = carriers / 16
    elif guard_interval == dtv.GI_1_8:
        gi = carriers / 8
    elif guard_interval == dtv.GI_1_4:
        gi = carriers / 4

    if channel_mhz == 8:
        bandwidth = 8750000
    elif channel_mhz == 7:
        bandwidth = 7000000
    elif channel_mhz == 6:
        bandwidth = 6000000
    elif channel_mhz == 5:
        bandwidth = 5000000
    else:
        bandwidth = 8750000

    tb = gr.top_block()

    src = blocks.file_source(gr.sizeof_char, infile, True)

    dtv_dvbt_energy_dispersal = dtv.dvbt_energy_dispersal(1 * factor)
    dtv_dvbt_reed_solomon_enc = dtv.dvbt_reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, (8 * factor))
    dtv_dvbt_convolutional_interleaver = dtv.dvbt_convolutional_interleaver((136 * factor), 12, 17)
    dtv_dvbt_inner_coder = dtv.dvbt_inner_coder(1, (1512 * factor), constellation, dtv.NH, code_rate)
    dtv_dvbt_bit_inner_interleaver = dtv.dvbt_bit_inner_interleaver((1512 * factor), constellation, dtv.NH, mode)
    dtv_dvbt_symbol_inner_interleaver = dtv.dvbt_symbol_inner_interleaver((1512 * factor), mode, 1)
    dtv_dvbt_map = dtv.dvbt_map((1512 * factor), constellation, dtv.NH, mode, 1)
    dtv_dvbt_reference_signals = dtv.dvbt_reference_signals(gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dtv.NH, code_rate, code_rate, guard_interval, mode, 0, 0)
    fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)), True, 10)
    digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(carriers, carriers+(gi), 0, "")
    blocks_multiply_const_vxx = blocks.multiply_const_vcc((0.0022097087, ))

    out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768")
    out.set_sample_rate(symbol_rate)
    out.set_center_freq(center_freq, 0)
    out.set_freq_corr(0, 0)
    out.set_gain(txvga2_gain, 0)
    out.set_bb_gain(txvga1_gain, 0)
    out.set_bandwidth(bandwidth, 0)

    tb.connect(src, dtv_dvbt_energy_dispersal)
    tb.connect(dtv_dvbt_energy_dispersal, dtv_dvbt_reed_solomon_enc)
    tb.connect(dtv_dvbt_reed_solomon_enc, dtv_dvbt_convolutional_interleaver)
    tb.connect(dtv_dvbt_convolutional_interleaver, dtv_dvbt_inner_coder)
    tb.connect(dtv_dvbt_inner_coder, dtv_dvbt_bit_inner_interleaver)
    tb.connect(dtv_dvbt_bit_inner_interleaver, dtv_dvbt_symbol_inner_interleaver)
    tb.connect(dtv_dvbt_symbol_inner_interleaver, dtv_dvbt_map)
    tb.connect(dtv_dvbt_map, dtv_dvbt_reference_signals)
    tb.connect(dtv_dvbt_reference_signals, fft_vxx)
    tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer)
    tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx)
    tb.connect(blocks_multiply_const_vxx, out)


    if outfile:
        dst = blocks.file_sink(gr.sizeof_gr_complex, outfile)
        tb.connect(blocks_multiply_const_vxx, dst)

    tb.run()
Beispiel #6
0
    def __init__(self):
        gr.top_block.__init__(self, "Video Codif and Decodif")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Video Codif and Decodif")
        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", "DVB_Cod")

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            188 * 10,  #size
            samp_rate,  #samp_rate
            "File Sink",  #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('Byte Value', "")

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = [
            'Byte given to file sink', '', '', '', '', '', '', '', '', ''
        ]
        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.dtv_dvbt_viterbi_decoder_0 = dtv.dvbt_viterbi_decoder(
            dtv.MOD_QPSK, dtv.NH, dtv.C5_6, 1512 * 4)
        self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dtv_dvbt_reed_solomon_dec_0 = dtv.dvbt_reed_solomon_dec(
            2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder(
            1, 1512 * 4, dtv.MOD_QPSK, dtv.NH, dtv.C5_6)
        self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1)
        self.dtv_dvbt_energy_descramble_0 = dtv.dvbt_energy_descramble(1504 /
                                                                       188)
        self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver(
            136, 12, 17)
        self.dtv_dvbt_convolutional_deinterleaver_0 = dtv.dvbt_convolutional_deinterleaver(
            136, 12, 17)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 6048)
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/teddy/Documents/DVB_last_stand/Received_Files/Test_Video_CodDecod_received.ts',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.Video_Source = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/teddy/Documents/DVB_last_stand/Source_Files/Test_Video.ts',
            False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Video_Source, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.dtv_dvbt_energy_dispersal_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.dtv_dvbt_viterbi_decoder_0, 0))
        self.connect((self.dtv_dvbt_convolutional_deinterleaver_0, 0),
                     (self.dtv_dvbt_reed_solomon_dec_0, 0))
        self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0),
                     (self.dtv_dvbt_inner_coder_0, 0))
        self.connect((self.dtv_dvbt_energy_descramble_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.dtv_dvbt_energy_descramble_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.dtv_dvbt_energy_dispersal_0, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0, 0))
        self.connect((self.dtv_dvbt_inner_coder_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_dec_0, 0),
                     (self.dtv_dvbt_energy_descramble_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0),
                     (self.dtv_dvbt_convolutional_interleaver_0, 0))
        self.connect((self.dtv_dvbt_viterbi_decoder_0, 0),
                     (self.dtv_dvbt_convolutional_deinterleaver_0, 0))
Beispiel #7
0
    def __init__(self):
        gr.top_block.__init__(self, "DVB-S B200 Transmitter")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("DVB-S B200 Transmitter")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        #self.symbol_rate = symbol_rate = 1000000
        self.symbol_rate = symbol_rate
        self.variable_qtgui_push_button_0 = variable_qtgui_push_button_0 = 1
        self.tx_gain = tx_gain = 45
        self.symbol_rate_display = symbol_rate_display = symbol_rate/1000
        self.samp_rate = samp_rate = symbol_rate * 2
        self.rrc_taps = rrc_taps = 100
        #self.fec_display = fec_display = "7/8"
        self.fec_display = fec_display
        self.center_freq = center_freq = 1280e6

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 89, 1, 65, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'Tx Gain [dB]', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win, 9,0,1,5)
        self._center_freq_options = (50e6, 437e6, 1280e6, 2400.0e6, )
        self._center_freq_labels = ('50 MHz', '437 MHz', "1'280 MHz", "10'400 MHz", )
        self._center_freq_group_box = Qt.QGroupBox('TX Frequency')
        self._center_freq_box = Qt.QHBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._center_freq_button_group = variable_chooser_button_group()
        self._center_freq_group_box.setLayout(self._center_freq_box)
        for i, label in enumerate(self._center_freq_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._center_freq_box.addWidget(radio_button)
        	self._center_freq_button_group.addButton(radio_button, i)
        self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._center_freq_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._center_freq_options.index(i)))
        self._center_freq_callback(self.center_freq)
        self._center_freq_button_group.buttonClicked[int].connect(
        	lambda i: self.set_center_freq(self._center_freq_options[i]))
        self.top_grid_layout.addWidget(self._center_freq_group_box, 0,0, 1,5)
        _variable_qtgui_push_button_0_push_button = Qt.QPushButton('TRANSMIT')
        self._variable_qtgui_push_button_0_choices = {'Pressed': 0, 'Released': 1}
        _variable_qtgui_push_button_0_push_button.pressed.connect(lambda: self.set_variable_qtgui_push_button_0(self._variable_qtgui_push_button_0_choices['Pressed']))
        _variable_qtgui_push_button_0_push_button.released.connect(lambda: self.set_variable_qtgui_push_button_0(self._variable_qtgui_push_button_0_choices['Released']))
        self.top_grid_layout.addWidget(_variable_qtgui_push_button_0_push_button, 10,0,1,5)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
        	",".join(("send_frame_size=65536,num_send_frames=256,master_clock_rate=" + str(samp_rate*2), "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0_0.set_clock_source('external', 0)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(uhd.tune_request(center_freq, ((symbol_rate * 1.35) / 2 ) + 1e5), 0)
        self.uhd_usrp_sink_0_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0)
        self._symbol_rate_display_tool_bar = Qt.QToolBar(self)

        if "{0:,}".format:
          self._symbol_rate_display_formatter = "{0:,}".format
        else:
          self._symbol_rate_display_formatter = lambda x: x

        self._symbol_rate_display_tool_bar.addWidget(Qt.QLabel('              Symbol Rate [ks/s] '+": "))
        self._symbol_rate_display_label = Qt.QLabel(str(self._symbol_rate_display_formatter(self.symbol_rate_display)))
        self._symbol_rate_display_tool_bar.addWidget(self._symbol_rate_display_label)
        self.top_grid_layout.addWidget(self._symbol_rate_display_tool_bar, 1,1,1,1)

        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	center_freq, #fc
        	samp_rate, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -20)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.1)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 3,0,6,5)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate/2, 0.35, rrc_taps)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self._fec_display_tool_bar = Qt.QToolBar(self)

        if "":
          self._fec_display_formatter = ""
        else:
          self._fec_display_formatter = lambda x: x

        self._fec_display_tool_bar.addWidget(Qt.QLabel('FEC '+": "))
        self._fec_display_label = Qt.QLabel(str(self._fec_display_formatter(self.fec_display)))
        self._fec_display_tool_bar.addWidget(self._fec_display_label)
        self.top_grid_layout.addWidget(self._fec_display_tool_bar, 1,3,1,2)

        self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder(1, 1512, dtv.MOD_QPSK, dtv.NH, dtv.C5_6)
        self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1)
        self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver(136, 12, 17)
        self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc(dtv.FECFRAME_NORMAL,
        dtv.C5_6, dtv.MOD_QPSK, dtv.INTERPOLATION_ON)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_char*1, 1512)
	fifo_path = os.path.dirname(os.path.realpath(__file__)) + '/fifo.ts'
        self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_char*1, fifo_path, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0_0, 0), (self.dtv_dvbt_energy_dispersal_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0))
        self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0), (self.dtv_dvbt_inner_coder_0, 0))
        self.connect((self.dtv_dvbt_energy_dispersal_0, 0), (self.dtv_dvbt_reed_solomon_enc_0, 0))
        self.connect((self.dtv_dvbt_inner_coder_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0), (self.dtv_dvbt_convolutional_interleaver_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.uhd_usrp_sink_0_0, 0))
Beispiel #8
0
    def __init__(self):
        gr.top_block.__init__(self, "Dvbt Tx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Dvbt Tx")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.vga2_gain = vga2_gain = 10
        self.vga1_gain = vga1_gain = -8
        self.tx_gain = tx_gain = 50
        self.samp_rate = samp_rate = (8000000.0 * 8) / 7
        self.center_freq = center_freq = 429e6

        ##################################################
        # Blocks
        ##################################################
        self._vga2_gain_range = Range(0, 25, 1, 10, 200)
        self._vga2_gain_win = RangeWidget(self._vga2_gain_range,
                                          self.set_vga2_gain, "vga2_gain",
                                          "counter_slider", int)
        self.top_layout.addWidget(self._vga2_gain_win)
        self._vga1_gain_range = Range(-35, -4, 1, -8, 200)
        self._vga1_gain_win = RangeWidget(self._vga1_gain_range,
                                          self.set_vga1_gain, "vga1_gain",
                                          "counter_slider", int)
        self.top_layout.addWidget(self._vga1_gain_win)
        self._tx_gain_range = Range(0, 89, 1, 50, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                           'hackrf=0,buffers=128,buflen=32768')
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(center_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(vga2_gain, 0)
        self.osmosdr_sink_0.set_if_gain(0, 0)
        self.osmosdr_sink_0.set_bb_gain(vga1_gain, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(8750000, 0)

        self.fft_vxx_0 = fft.fft_vcc(8192, False, (window.rectangular(8192)),
                                     True, 1)
        self.dtv_dvbt_symbol_inner_interleaver_0 = dtv.dvbt_symbol_inner_interleaver(
            6048, dtv.T8k, 1)
        self.dtv_dvbt_reference_signals_0 = dtv.dvbt_reference_signals(
            gr.sizeof_gr_complex, 6048, 8192, dtv.MOD_64QAM, dtv.NH, dtv.C2_3,
            dtv.C2_3, dtv.GI_1_32, dtv.T8k, 1, 0)
        self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dtv_dvbt_map_0 = dtv.dvbt_map(6048, dtv.MOD_64QAM, dtv.NH,
                                           dtv.T8k, 1)
        self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder(
            1, 6048, dtv.MOD_64QAM, dtv.NH, dtv.C2_3)
        self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1)
        self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver(
            136, 12, 17)
        self.dtv_dvbt_bit_inner_interleaver_0 = dtv.dvbt_bit_inner_interleaver(
            6048, dtv.MOD_64QAM, dtv.NH, dtv.T8k)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            8192, 8192 + 256, 0, '')
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 8192)
        self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc(
            0.0022097087)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            'C:\\Users\\hamin\\Desktop\\Fall2020\\CSE310\\CSE310_FinalProject\\dmb\\honne2.ts',
            True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.dtv_dvbt_energy_dispersal_0, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0),
                     (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_xx_0, 0))
        self.connect((self.dtv_dvbt_bit_inner_interleaver_0, 0),
                     (self.dtv_dvbt_symbol_inner_interleaver_0, 0))
        self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0),
                     (self.dtv_dvbt_inner_coder_0, 0))
        self.connect((self.dtv_dvbt_energy_dispersal_0, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0, 0))
        self.connect((self.dtv_dvbt_inner_coder_0, 0),
                     (self.dtv_dvbt_bit_inner_interleaver_0, 0))
        self.connect((self.dtv_dvbt_map_0, 0),
                     (self.dtv_dvbt_reference_signals_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0),
                     (self.dtv_dvbt_convolutional_interleaver_0, 0))
        self.connect((self.dtv_dvbt_reference_signals_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.dtv_dvbt_reference_signals_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.dtv_dvbt_symbol_inner_interleaver_0, 0),
                     (self.dtv_dvbt_map_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
Beispiel #9
0
    def __init__(self, fft_size=4096):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.fft_size = fft_size

        ##################################################
        # Variables
        ##################################################
        self.mode = mode = 2
        self.freq = freq = 551e6

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_const_sink_x_0_1_0_0_0_1 = qtgui.const_sink_c(
            4096,  #size
            "Time Denint OUT",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_1_0_0_0_1.set_update_time(0.1)
        self.qtgui_const_sink_x_0_1_0_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_1_0_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_1_0_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_1_0_0_0_1.enable_autoscale(False)
        self.qtgui_const_sink_x_0_1_0_0_0_1.enable_grid(True)
        self.qtgui_const_sink_x_0_1_0_0_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_1_0_0_0_1.disable_legend()

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

        self._qtgui_const_sink_x_0_1_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_1_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_1_0_0_0_1_win)
        self.isdbt_viterbi_decoder_0_1 = isdbt.viterbi_decoder(64, 0)
        self.isdbt_viterbi_decoder_0_0 = isdbt.viterbi_decoder(64, 0)
        self.isdbt_viterbi_decoder_0 = isdbt.viterbi_decoder(64, 0)
        self.isdbt_tsp_resize_0_0_0 = isdbt.tsp_resize()
        self.isdbt_tsp_resize_0_0 = isdbt.tsp_resize()
        self.isdbt_tsp_resize_0 = isdbt.tsp_resize()
        self.isdbt_tmcc_decoder_0 = isdbt.tmcc_decoder(2, False)
        self.isdbt_time_interleaver_0 = isdbt.time_interleaver(2, 8, True)
        self.isdbt_time_deinterleaver_0 = isdbt.time_deinterleaver(
            2, 1, 8, 6, 8, 6, 8)
        self.isdbt_symbol_demapper_0 = isdbt.symbol_demapper(
            2, 1, 64, 6, 64, 6, 64)
        self.isdbt_reed_solomon_dec_isdbt_0_1 = isdbt.reed_solomon_dec_isdbt()
        self.isdbt_reed_solomon_dec_isdbt_0_0 = isdbt.reed_solomon_dec_isdbt()
        self.isdbt_reed_solomon_dec_isdbt_0 = isdbt.reed_solomon_dec_isdbt()
        self.isdbt_ofdm_synchronization_0 = isdbt.ofdm_synchronization(
            2, 0.125, False)
        self.isdbt_ofdm_frame_structure_0 = isdbt.ofdm_frame_structure(
            2, True, 3, 3, 3, 0, 0, 0, 8, 8, 8, 1, 6, 6)
        self.isdbt_mapper_0_0_0 = isdbt.mapper(2, 6, 6)
        self.isdbt_mapper_0_0 = isdbt.mapper(2, 6, 6)
        self.isdbt_mapper_0 = isdbt.mapper(2, 6, 1)
        self.isdbt_hierarchical_divisor_0 = isdbt.hierarchical_divisor()
        self.isdbt_hierarchical_combination_0 = isdbt.hierarchical_combination(
            2, 1, 6, 6)
        self.isdbt_frequency_deinterleaver_0 = isdbt.frequency_deinterleaver(
            False, 2)
        self.isdbt_frec_interleaver_0 = isdbt.frec_interleaver(2, True)
        self.isdbt_energy_dispersal_0_0_0 = isdbt.energy_dispersal()
        self.isdbt_energy_dispersal_0_0 = isdbt.energy_dispersal()
        self.isdbt_energy_dispersal_0 = isdbt.energy_dispersal()
        self.isdbt_energy_descrambler_0_1 = isdbt.energy_descrambler()
        self.isdbt_energy_descrambler_0_0 = isdbt.energy_descrambler()
        self.isdbt_energy_descrambler_0 = isdbt.energy_descrambler()
        self.isdbt_byte_interleaver_0_0_0 = isdbt.byte_interleaver(2, 0, 6, 6)
        self.isdbt_byte_interleaver_0_0 = isdbt.byte_interleaver(2, 0, 6, 6)
        self.isdbt_byte_interleaver_0 = isdbt.byte_interleaver(2, 0, 6, 1)
        self.isdbt_byte_deinterleaver_0_1 = isdbt.byte_deinterleaver()
        self.isdbt_byte_deinterleaver_0_0 = isdbt.byte_deinterleaver()
        self.isdbt_byte_deinterleaver_0 = isdbt.byte_deinterleaver()
        self.isdbt_bit_deinterleaver_0_1 = isdbt.bit_deinterleaver(2, 6, 64)
        self.isdbt_bit_deinterleaver_0_0 = isdbt.bit_deinterleaver(2, 6, 64)
        self.isdbt_bit_deinterleaver_0 = isdbt.bit_deinterleaver(2, 1, 64)
        self.fft_vxx_0 = fft.fft_vcc(fft_size, False,
                                     (window.blackmanharris(fft_size)), True,
                                     1)
        self.dtv_dvbt_reed_solomon_enc_0_0_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 1)
        self.dtv_dvbt_reed_solomon_enc_0_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 1)
        self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 1)
        self.dtv_dvbt_inner_coder_0_0_0 = dtv.dvbt_inner_coder(
            1, 1512, dtv.MOD_64QAM, dtv.ALPHA2, dtv.C1_2)
        self.dtv_dvbt_inner_coder_0_0 = dtv.dvbt_inner_coder(
            1, 1512, dtv.MOD_64QAM, dtv.ALPHA2, dtv.C1_2)
        self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder(
            1, 1512, dtv.MOD_64QAM, dtv.ALPHA2, dtv.C1_2)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            4096, 4096 + 512, 0, "")
        self.blocks_vector_to_stream_1_2_0_0_0_0_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 192 * 13)
        self.blocks_vector_to_stream_0_1_0_1_1 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 204)
        self.blocks_vector_to_stream_0_1_0_1_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 204)
        self.blocks_vector_to_stream_0_1_0_1 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 204)
        self.blocks_vector_to_stream_0_1_0_0 = blocks.vector_to_stream(
            gr.sizeof_char * 204, 756)
        self.blocks_vector_to_stream_0_1_0 = blocks.vector_to_stream(
            gr.sizeof_char * 204, 756)
        self.blocks_vector_to_stream_0_1 = blocks.vector_to_stream(
            gr.sizeof_char * 204, 126)
        self.blocks_vector_to_stream_0_0_1_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 204)
        self.blocks_vector_to_stream_0_0_1 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 204)
        self.blocks_vector_to_stream_0_0_0_0_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 1512)
        self.blocks_vector_to_stream_0_0_0_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 1512)
        self.blocks_vector_to_stream_0_0_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 1512)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 204)
        self.blocks_unpacked_to_packed_xx_0_1 = blocks.unpacked_to_packed_bb(
            6, gr.GR_LSB_FIRST)
        self.blocks_unpacked_to_packed_xx_0_0 = blocks.unpacked_to_packed_bb(
            6, gr.GR_LSB_FIRST)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            6, gr.GR_LSB_FIRST)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   512 / 63e-6, True)
        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 204,
                                                   'LayA', "frame_begin")
        self.blocks_tag_debug_0.set_display(True)
        self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 192 * 6)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 192 * 6)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 192 * 1)
        self.blocks_packed_to_unpacked_xx_0_0_0 = blocks.packed_to_unpacked_bb(
            6, gr.GR_LSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0_0 = blocks.packed_to_unpacked_bb(
            6, gr.GR_LSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            6, gr.GR_LSB_FIRST)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.01, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 204 * 2304,
            '/home/habbo/Documents/BTS_Validos/BTS_ISDB_T_3_CAPAS.ts', False)
        self.blocks_file_sink_0_1 = blocks.file_sink(
            gr.sizeof_char * 188,
            '/home/habbo/Documents/PruebasISDBT/Salidas/Layer_C.ts', False)
        self.blocks_file_sink_0_1.set_unbuffered(False)
        self.blocks_file_sink_0_0_0_2 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/habbo/Documents/PruebasISDBT/Salidas/fs__VDin_layA.ts',
            False)
        self.blocks_file_sink_0_0_0_2.set_unbuffered(False)
        self.blocks_file_sink_0_0_0_1_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/habbo/Documents/PruebasISDBT/Salidas/fs__VDin_layC.ts',
            False)
        self.blocks_file_sink_0_0_0_1_0.set_unbuffered(False)
        self.blocks_file_sink_0_0_0_1 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/habbo/Documents/PruebasISDBT/Salidas/fs__RSin_layC.ts',
            False)
        self.blocks_file_sink_0_0_0_1.set_unbuffered(False)
        self.blocks_file_sink_0_0_0_0_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/habbo/Documents/PruebasISDBT/Salidas/fs__VDin_layB.ts',
            False)
        self.blocks_file_sink_0_0_0_0_0.set_unbuffered(False)
        self.blocks_file_sink_0_0_0_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/habbo/Documents/PruebasISDBT/Salidas/fs__RSin_layB.ts',
            False)
        self.blocks_file_sink_0_0_0_0.set_unbuffered(False)
        self.blocks_file_sink_0_0_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/habbo/Documents/PruebasISDBT/Salidas/fs__RSin_layA.ts',
            False)
        self.blocks_file_sink_0_0_0.set_unbuffered(False)
        self.blocks_file_sink_0_0 = blocks.file_sink(
            gr.sizeof_char * 188,
            '/home/habbo/Documents/PruebasISDBT/Salidas/Layer_B.ts', False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 188,
            '/home/habbo/Documents/PruebasISDBT/Salidas/Layer_A.ts', False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.isdbt_hierarchical_divisor_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.isdbt_mapper_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0_0, 0),
                     (self.isdbt_mapper_0_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0_0_0, 0),
                     (self.isdbt_mapper_0_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.isdbt_hierarchical_combination_0, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0),
                     (self.isdbt_hierarchical_combination_0, 1))
        self.connect((self.blocks_stream_to_vector_0_1, 0),
                     (self.isdbt_hierarchical_combination_0, 2))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.isdbt_ofdm_synchronization_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_file_sink_0_0_0_2, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.isdbt_viterbi_decoder_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_0, 0),
                     (self.blocks_file_sink_0_0_0_0_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_0, 0),
                     (self.isdbt_viterbi_decoder_0_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_1, 0),
                     (self.blocks_file_sink_0_0_0_1_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_1, 0),
                     (self.isdbt_viterbi_decoder_0_1, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.dtv_dvbt_inner_coder_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0_0_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0_0_0_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0_1, 0),
                     (self.dtv_dvbt_inner_coder_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0_1_0, 0),
                     (self.dtv_dvbt_inner_coder_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1, 0),
                     (self.isdbt_tsp_resize_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_0, 0),
                     (self.isdbt_tsp_resize_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_0_0, 0),
                     (self.isdbt_tsp_resize_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_0_1, 0),
                     (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_0_1_0, 0),
                     (self.blocks_file_sink_0_0_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1_0_1_1, 0),
                     (self.blocks_file_sink_0_0_0_1, 0))
        self.connect((self.blocks_vector_to_stream_1_2_0_0_0_0_0, 0),
                     (self.qtgui_const_sink_x_0_1_0_0_0_1, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.dtv_dvbt_inner_coder_0, 0),
                     (self.blocks_vector_to_stream_0_0_0, 0))
        self.connect((self.dtv_dvbt_inner_coder_0_0, 0),
                     (self.blocks_vector_to_stream_0_0_0_0, 0))
        self.connect((self.dtv_dvbt_inner_coder_0_0_0, 0),
                     (self.blocks_vector_to_stream_0_0_0_0_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0),
                     (self.isdbt_energy_dispersal_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0_0, 0),
                     (self.isdbt_energy_dispersal_0_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0_0_0, 0),
                     (self.isdbt_energy_dispersal_0_0_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
        self.connect((self.isdbt_bit_deinterleaver_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.isdbt_bit_deinterleaver_0_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0_0, 0))
        self.connect((self.isdbt_bit_deinterleaver_0_1, 0),
                     (self.blocks_unpacked_to_packed_xx_0_1, 0))
        self.connect((self.isdbt_byte_deinterleaver_0, 0),
                     (self.blocks_tag_debug_0, 0))
        self.connect((self.isdbt_byte_deinterleaver_0, 0),
                     (self.isdbt_energy_descrambler_0, 0))
        self.connect((self.isdbt_byte_deinterleaver_0_0, 0),
                     (self.isdbt_energy_descrambler_0_0, 0))
        self.connect((self.isdbt_byte_deinterleaver_0_1, 0),
                     (self.isdbt_energy_descrambler_0_1, 0))
        self.connect((self.isdbt_byte_interleaver_0, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.isdbt_byte_interleaver_0_0, 0),
                     (self.blocks_vector_to_stream_0_0_1, 0))
        self.connect((self.isdbt_byte_interleaver_0_0_0, 0),
                     (self.blocks_vector_to_stream_0_0_1_0, 0))
        self.connect((self.isdbt_energy_descrambler_0, 0),
                     (self.blocks_vector_to_stream_0_1_0_1, 0))
        self.connect((self.isdbt_energy_descrambler_0, 0),
                     (self.isdbt_reed_solomon_dec_isdbt_0, 0))
        self.connect((self.isdbt_energy_descrambler_0_0, 0),
                     (self.blocks_vector_to_stream_0_1_0_1_0, 0))
        self.connect((self.isdbt_energy_descrambler_0_0, 0),
                     (self.isdbt_reed_solomon_dec_isdbt_0_0, 0))
        self.connect((self.isdbt_energy_descrambler_0_1, 0),
                     (self.blocks_vector_to_stream_0_1_0_1_1, 0))
        self.connect((self.isdbt_energy_descrambler_0_1, 0),
                     (self.isdbt_reed_solomon_dec_isdbt_0_1, 0))
        self.connect((self.isdbt_energy_dispersal_0, 0),
                     (self.isdbt_byte_interleaver_0, 0))
        self.connect((self.isdbt_energy_dispersal_0_0, 0),
                     (self.isdbt_byte_interleaver_0_0, 0))
        self.connect((self.isdbt_energy_dispersal_0_0_0, 0),
                     (self.isdbt_byte_interleaver_0_0_0, 0))
        self.connect((self.isdbt_frec_interleaver_0, 0),
                     (self.isdbt_ofdm_frame_structure_0, 0))
        self.connect((self.isdbt_frequency_deinterleaver_0, 0),
                     (self.isdbt_time_deinterleaver_0, 0))
        self.connect((self.isdbt_hierarchical_combination_0, 0),
                     (self.isdbt_time_interleaver_0, 0))
        self.connect((self.isdbt_hierarchical_divisor_0, 0),
                     (self.blocks_vector_to_stream_0_1, 0))
        self.connect((self.isdbt_hierarchical_divisor_0, 1),
                     (self.blocks_vector_to_stream_0_1_0, 0))
        self.connect((self.isdbt_hierarchical_divisor_0, 2),
                     (self.blocks_vector_to_stream_0_1_0_0, 0))
        self.connect((self.isdbt_mapper_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.isdbt_mapper_0_0, 0),
                     (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.isdbt_mapper_0_0_0, 0),
                     (self.blocks_stream_to_vector_0_1, 0))
        self.connect((self.isdbt_ofdm_frame_structure_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.isdbt_ofdm_synchronization_0, 0),
                     (self.isdbt_tmcc_decoder_0, 0))
        self.connect((self.isdbt_reed_solomon_dec_isdbt_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.isdbt_reed_solomon_dec_isdbt_0_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.isdbt_reed_solomon_dec_isdbt_0_1, 0),
                     (self.blocks_file_sink_0_1, 0))
        self.connect((self.isdbt_symbol_demapper_0, 0),
                     (self.isdbt_bit_deinterleaver_0, 0))
        self.connect((self.isdbt_symbol_demapper_0, 1),
                     (self.isdbt_bit_deinterleaver_0_0, 0))
        self.connect((self.isdbt_symbol_demapper_0, 2),
                     (self.isdbt_bit_deinterleaver_0_1, 0))
        self.connect((self.isdbt_time_deinterleaver_0, 0),
                     (self.blocks_vector_to_stream_1_2_0_0_0_0_0, 0))
        self.connect((self.isdbt_time_deinterleaver_0, 0),
                     (self.isdbt_symbol_demapper_0, 0))
        self.connect((self.isdbt_time_interleaver_0, 0),
                     (self.isdbt_frec_interleaver_0, 0))
        self.connect((self.isdbt_tmcc_decoder_0, 0),
                     (self.isdbt_frequency_deinterleaver_0, 0))
        self.connect((self.isdbt_tsp_resize_0, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0, 0))
        self.connect((self.isdbt_tsp_resize_0_0, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0_0, 0))
        self.connect((self.isdbt_tsp_resize_0_0_0, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0_0_0, 0))
        self.connect((self.isdbt_viterbi_decoder_0, 0),
                     (self.isdbt_byte_deinterleaver_0, 0))
        self.connect((self.isdbt_viterbi_decoder_0_0, 0),
                     (self.isdbt_byte_deinterleaver_0_0, 0))
        self.connect((self.isdbt_viterbi_decoder_0_1, 0),
                     (self.isdbt_byte_deinterleaver_0_1, 0))
def main(args):
    nargs = len(args)
    if nargs == 1:
        port = int(args[0])
        outfile = None
    elif nargs == 2:
        port = int(args[0])
        outfile = args[1]
    else:
        sys.stderr.write("Usage: dvbt-hackrf.py port [output_file]\n")
        sys.exit(1)

    channel_mhz = 6
    mode = dtv.T2k
    code_rate = dtv.C1_2
    constellation = dtv.MOD_QPSK
    guard_interval = dtv.GI_1_32
    symbol_rate = channel_mhz * 8000000.0 / 7
    center_freq = 441000000
    rf_gain = 14
    if_gain = 40

    if mode == dtv.T2k:
        factor = 1
        carriers = 2048
    elif mode == dtv.T8k:
        factor = 4
        carriers = 8192

    if guard_interval == dtv.GI_1_32:
        gi = carriers / 32
    elif guard_interval == dtv.GI_1_16:
        gi = carriers / 16
    elif guard_interval == dtv.GI_1_8:
        gi = carriers / 8
    elif guard_interval == dtv.GI_1_4:
        gi = carriers / 4

    if channel_mhz == 8:
        bandwidth = 8750000
    elif channel_mhz == 7:
        bandwidth = 7000000
    elif channel_mhz == 6:
        bandwidth = 6000000
    elif channel_mhz == 5:
        bandwidth = 5000000
    else:
        bandwidth = 8750000

    tb = gr.top_block()

    src = grc_blks2.tcp_source(gr.sizeof_char * 1, "127.0.0.1", port, True)

    dvbt_energy_dispersal = dtv.dvbt_energy_dispersal(1 * factor)
    dvbt_reed_solomon_enc = dtv.dvbt_reed_solomon_enc(2, 8, 0x11d, 255, 239, 8,
                                                      51, (8 * factor))
    dvbt_convolutional_interleaver = dtv.dvbt_convolutional_interleaver(
        (136 * factor), 12, 17)
    dvbt_inner_coder = dtv.dvbt_inner_coder(1, (1512 * factor), constellation,
                                            dtv.NH, code_rate)
    dvbt_bit_inner_interleaver = dtv.dvbt_bit_inner_interleaver(
        (1512 * factor), constellation, dtv.NH, mode)
    dvbt_symbol_inner_interleaver = dtv.dvbt_symbol_inner_interleaver(
        (1512 * factor), mode, 1)
    dvbt_map = dtv.dvbt_map((1512 * factor), constellation, dtv.NH, mode, 1)
    dvbt_reference_signals = dtv.dvbt_reference_signals(
        gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dtv.NH,
        code_rate, code_rate, dtv.GI_1_32, mode, 0, 0)
    fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)),
                          True, 10)
    digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(
        carriers, carriers + (gi), 0, "")
    blocks_multiply_const_vxx = blocks.multiply_const_vcc(
        (0.0022097087 * 2.5, ))

    out = osmosdr.sink()
    out.set_sample_rate(symbol_rate)
    out.set_center_freq(center_freq, 0)
    out.set_freq_corr(0, 0)
    out.set_gain(rf_gain, 0)
    out.set_if_gain(if_gain, 0)
    out.set_bandwidth(bandwidth, 0)

    tb.connect(src, dvbt_energy_dispersal)
    tb.connect(dvbt_energy_dispersal, dvbt_reed_solomon_enc)
    tb.connect(dvbt_reed_solomon_enc, dvbt_convolutional_interleaver)
    tb.connect(dvbt_convolutional_interleaver, dvbt_inner_coder)
    tb.connect(dvbt_inner_coder, dvbt_bit_inner_interleaver)
    tb.connect(dvbt_bit_inner_interleaver, dvbt_symbol_inner_interleaver)
    tb.connect(dvbt_symbol_inner_interleaver, dvbt_map)
    tb.connect(dvbt_map, dvbt_reference_signals)
    tb.connect(dvbt_reference_signals, fft_vxx)
    tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer)
    tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx)
    tb.connect(blocks_multiply_const_vxx, out)

    if outfile:
        dst = blocks.file_sink(gr.sizeof_gr_complex, outfile)
        tb.connect(blocks_multiply_const_vxx, dst)

    tb.run()
Beispiel #11
0
    def __init__(self):
        gr.top_block.__init__(self, "DVB-S Simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("DVB-S Simulation")
        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", "dvbs_final")

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

        ##################################################
        # Variables
        ##################################################
        self.nfilts = nfilts = 100
        self.SampSymb = SampSymb = 4
        self.samp_rate = samp_rate = 6e6
        self.rrc_taps_0 = rrc_taps_0 = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(SampSymb), 0.35, 45 * nfilts)
        self.qpsk_const = qpsk_const = digital.constellation_rect(
            [-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j], [0, 1, 2, 3], 4, 2, 2, 1,
            1).base()
        self.delay = delay = 0
        self.Noise = Noise = 0
        self.FreqOff = FreqOff = 0

        ##################################################
        # Blocks
        ##################################################
        self._delay_range = Range(0, 100, 1, 0, 200)
        self._delay_win = RangeWidget(self._delay_range, self.set_delay,
                                      'Delay', "counter_slider", float)
        self.top_grid_layout.addWidget(self._delay_win)
        self._Noise_range = Range(0, 1, 0.01, 0, 200)
        self._Noise_win = RangeWidget(self._Noise_range, self.set_Noise,
                                      'Channel Noise', "counter_slider", float)
        self.top_grid_layout.addWidget(self._Noise_win)
        self._FreqOff_range = Range(-0.1, 0.1, 0.001, 0, 200)
        self._FreqOff_win = RangeWidget(self._FreqOff_range, self.set_FreqOff,
                                        'Frequency Offset', "counter_slider",
                                        float)
        self.top_grid_layout.addWidget(self._FreqOff_win)
        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(True)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        labels = [
            'RX', 'TX', '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.dtv_dvbt_viterbi_decoder_0 = dtv.dvbt_viterbi_decoder(
            dtv.MOD_QPSK, dtv.NH, dtv.C5_6, 1512 * 4)
        self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dtv_dvbt_reed_solomon_dec_0 = dtv.dvbt_reed_solomon_dec(
            2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder(
            1, 1512 * 4, dtv.MOD_QPSK, dtv.NH, dtv.C5_6)
        self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1)
        self.dtv_dvbt_energy_descramble_0 = dtv.dvbt_energy_descramble(8)
        self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver(
            136, 12, 17)
        self.dtv_dvbt_convolutional_deinterleaver_0 = dtv.dvbt_convolutional_deinterleaver(
            136, 12, 17)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            SampSymb, 0.1, rrc_taps_0, nfilts, nfilts / 2, 1.5, 2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.1, 4, False)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=qpsk_const,
            differential=True,
            samples_per_symbol=SampSymb,
            pre_diff_code=True,
            excess_bw=0.35,
            verbose=False,
            log=False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            qpsk_const)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, .01, 2)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=Noise,
            frequency_offset=FreqOff,
            epsilon=1.0,
            taps=[1.0 + 1.0j],
            noise_seed=0,
            block_tags=False)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 1512 * 4)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 '127.0.0.1', 4321, 1316, True)
        self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float()
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, 8)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            2, 8, "", False, gr.GR_LSB_FIRST)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, delay)
        self.Video_Source = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/quique/Documents/PSK-Simulation/DVB_Codification/DVB_Codification/Test_Video.ts',
            False, 0, 0)
        self.Video_Source.set_begin_tag(pmt.PMT_NIL)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Video_Source, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_skiphead_0, 0),
                     (self.dtv_dvbt_viterbi_decoder_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_uchar_to_float_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.dtv_dvbt_energy_dispersal_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_uchar_to_float_0_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.dtv_dvbt_convolutional_deinterleaver_0, 0),
                     (self.dtv_dvbt_reed_solomon_dec_0, 0))
        self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0),
                     (self.dtv_dvbt_inner_coder_0, 0))
        self.connect((self.dtv_dvbt_energy_descramble_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.dtv_dvbt_energy_descramble_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.dtv_dvbt_energy_dispersal_0, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0, 0))
        self.connect((self.dtv_dvbt_inner_coder_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_dec_0, 0),
                     (self.dtv_dvbt_energy_descramble_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0),
                     (self.dtv_dvbt_convolutional_interleaver_0, 0))
        self.connect((self.dtv_dvbt_viterbi_decoder_0, 0),
                     (self.dtv_dvbt_convolutional_deinterleaver_0, 0))
Beispiel #12
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_0 = samp_rate_0 = 32000

        ##################################################
        # Blocks
        ##################################################
        self.isdbt_viterbi_decoder_0 = isdbt.viterbi_decoder(64, 0)
        self.isdbt_tsp_resize_0_2 = isdbt.tsp_resize()
        self.isdbt_sync_adjust_0 = isdbt.sync_adjust()
        self.isdbt_reed_solomon_dec_isdbt_0 = isdbt.reed_solomon_dec_isdbt()
        self.isdbt_hierarchical_divisor_0 = isdbt.hierarchical_divisor(
            3, 0.125, 1, 6, 0.5, 6, 6, 0.5, 6, 6, 0.5)
        self.isdbt_energy_dispersal_0 = isdbt.energy_dispersal(72)
        self.isdbt_energy_descrambler_0 = isdbt.energy_descrambler()
        self.isdbt_byte_interleaver_0 = isdbt.byte_interleaver(2, 0, 6, 1)
        self.isdbt_byte_deinterleaver_0 = isdbt.byte_deinterleaver()
        self.dtv_dvbt_reed_solomon_enc_0_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 1)
        self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder(
            1, 1512, dtv.MOD_64QAM, dtv.ALPHA2, dtv.C1_2)
        self.blocks_vector_to_stream_0_1 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 1512)
        self.blocks_vector_to_stream_0_0_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 204)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(
            gr.sizeof_char * 204, 144)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 188)
        self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 204, 72, "frame_begin")
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 204 * 144 *
                                                   6)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 204 * 144 *
                                                   6)
        self.blocks_file_source_0_0_0 = blocks.file_source(
            gr.sizeof_char * 204 * 2304 * 2,
            '/home/habbo/Documents/BTS_Validos/BTS_ISDB_T_3_CAPAS.ts', False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/habbo/Documents/PruebasISDBT/Salidas/Salida_Test_4.ts',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0_0_0, 0),
                     (self.isdbt_hierarchical_divisor_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.isdbt_energy_descrambler_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.isdbt_tsp_resize_0_2, 0))
        self.connect((self.blocks_vector_to_stream_0_0_0, 0),
                     (self.dtv_dvbt_inner_coder_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1, 0),
                     (self.isdbt_viterbi_decoder_0, 0))
        self.connect((self.dtv_dvbt_inner_coder_0, 0),
                     (self.blocks_vector_to_stream_0_1, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0_0, 0),
                     (self.isdbt_sync_adjust_0, 0))
        self.connect((self.isdbt_byte_deinterleaver_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0, 0))
        self.connect((self.isdbt_byte_interleaver_0, 0),
                     (self.blocks_vector_to_stream_0_0_0, 0))
        self.connect((self.isdbt_energy_descrambler_0, 0),
                     (self.isdbt_reed_solomon_dec_isdbt_0, 0))
        self.connect((self.isdbt_energy_dispersal_0, 0),
                     (self.isdbt_byte_interleaver_0, 0))
        self.connect((self.isdbt_hierarchical_divisor_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.isdbt_hierarchical_divisor_0, 2),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.isdbt_hierarchical_divisor_0, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.isdbt_reed_solomon_dec_isdbt_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.isdbt_sync_adjust_0, 0),
                     (self.isdbt_energy_dispersal_0, 0))
        self.connect((self.isdbt_tsp_resize_0_2, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0_0, 0))
        self.connect((self.isdbt_viterbi_decoder_0, 0),
                     (self.isdbt_byte_deinterleaver_0, 0))
Beispiel #13
0
    def __init__(self):
        gr.top_block.__init__(self, "Dvbt Tx Demo")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Dvbt Tx Demo")
        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", "dvbt_tx_demo")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = (8000000.0 * 8) / 7

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_waterfall_sink_x_1 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	1269000000, #fc
        	samp_rate, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_1.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_1.enable_grid(False)
        
        if not True:
          self.qtgui_waterfall_sink_x_1.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_1.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_1.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_1.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_1.set_intensity_range(-140, 10)
        
        self._qtgui_waterfall_sink_x_1_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_1_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	1269000000, #fc
        	samp_rate, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label("Relative Gain", "dB")
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        
        if not True:
          self.qtgui_const_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(1269000000, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(14, 0)
        self.osmosdr_sink_0.set_if_gain(30, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.fft_vxx_0 = fft.fft_vcc(2048, False, (window.rectangular(2048)), True, 1)
        self.dtv_dvbt_symbol_inner_interleaver_0 = dtv.dvbt_symbol_inner_interleaver(1512, dtv.T2k, 1)
        self.dtv_dvbt_reference_signals_0 = dtv.dvbt_reference_signals(gr.sizeof_gr_complex, 1512, 2048, dtv.MOD_64QAM, dtv.NH, dtv.C2_3, dtv.C2_3, dtv.GI_1_32, dtv.T2k, 1, 0)
        self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dtv_dvbt_map_0 = dtv.dvbt_map(1512, dtv.MOD_64QAM, dtv.NH, dtv.T2k, 1)
        self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder(1, 1512, dtv.MOD_64QAM, dtv.NH, dtv.C2_3)
        self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1)
        self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver(136, 12, 17)
        self.dtv_dvbt_bit_inner_interleaver_0 = dtv.dvbt_bit_inner_interleaver(1512, dtv.MOD_64QAM, dtv.NH, dtv.T2k)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(2048, 2048+64, 0, "")
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 2048)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.0022097087, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/Volumes/work/satellite_ground_emulator/DVB_S2/run/shm/adv16apsk910.ts", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.dtv_dvbt_energy_dispersal_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_waterfall_sink_x_1, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_const_sink_x_0, 0))    
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.dtv_dvbt_bit_inner_interleaver_0, 0), (self.dtv_dvbt_symbol_inner_interleaver_0, 0))    
        self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0), (self.dtv_dvbt_inner_coder_0, 0))    
        self.connect((self.dtv_dvbt_energy_dispersal_0, 0), (self.dtv_dvbt_reed_solomon_enc_0, 0))    
        self.connect((self.dtv_dvbt_inner_coder_0, 0), (self.dtv_dvbt_bit_inner_interleaver_0, 0))    
        self.connect((self.dtv_dvbt_map_0, 0), (self.dtv_dvbt_reference_signals_0, 0))    
        self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0), (self.dtv_dvbt_convolutional_interleaver_0, 0))    
        self.connect((self.dtv_dvbt_reference_signals_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.dtv_dvbt_reference_signals_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.dtv_dvbt_symbol_inner_interleaver_0, 0), (self.dtv_dvbt_map_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))