Example #1
0
    def test_002_cc(self):
        N = 10000  # number of samples to use
        fs = 1000  # baseband sampling rate
        rrate = 1.123  # resampling rate

        freq = 10
        data = sig_source_c(fs, freq, 1, N)
        signal = blocks.vector_source_c(data)
        op = filter.mmse_resampler_cc(0.0, rrate)
        snk = blocks.vector_sink_c()

        self.tb.connect(signal, op, snk)
        self.tb.run()

        Ntest = 5000
        L = len(snk.data())
        t = [float(x) / (fs / rrate) for x in range(L)]

        phase = 0.1884
        expected_data = [math.cos(2.*math.pi*freq*x+phase) + \
                                1j*math.sin(2.*math.pi*freq*x+phase) for x in t]

        dst_data = snk.data()

        self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:],
                                            dst_data[-Ntest:], 3)
    def test_002_cc(self):
        N = 10000        # number of samples to use
        fs = 1000        # baseband sampling rate
        rrate = 1.123    # resampling rate

        freq = 10
        data = sig_source_c(fs, freq, 1, N)
        signal = blocks.vector_source_c(data)
        op = filter.mmse_resampler_cc(0.0, rrate)
        snk = blocks.vector_sink_c()

        self.tb.connect(signal, op, snk)
        self.tb.run()

        Ntest = 5000
        L = len(snk.data())
        t = [float(x) / (fs / rrate) for x in range(L)]

        phase = 0.1884
        expected_data = [math.cos(2.*math.pi*freq*x+phase) + \
                                1j*math.sin(2.*math.pi*freq*x+phase) for x in t]

        dst_data = snk.data()

        self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 3)
    def __init__(self):
        gr.top_block.__init__(self, "SQ5BPF Tetra live receiver 1ch UDP HEADLESS")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2000000
        self.first_decim = first_decim = 32
        self.xlate_offset_fine1 = xlate_offset_fine1 = 0
        self.xlate_offset1 = xlate_offset1 = 500e3
        self.udp_packet_size = udp_packet_size = 1472
        self.udp_dest_addr = udp_dest_addr = "127.0.0.1"
        self.telive_receiver_name = telive_receiver_name = 'SQ5BPF 1-channel headless rx for telive'
        self.telive_receiver_channels = telive_receiver_channels = 1
        self.sdr_ifgain = sdr_ifgain = 20
        self.sdr_gain = sdr_gain = 38
        self.ppm_corr = ppm_corr = 56
        self.out_sample_rate = out_sample_rate = 36000
        self.options_low_pass = options_low_pass = 12500
        self.if_samp_rate = if_samp_rate = samp_rate/first_decim
        self.freq = freq = 435e6
        self.first_port = first_port = 42000

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer(('0.0.0.0', first_port), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + ''
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(ppm_corr, 0)
        self.osmosdr_source_0.set_gain(sdr_gain, 0)
        self.osmosdr_source_0.set_if_gain(sdr_ifgain, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
        self.mmse_resampler_xx_0 = filter.mmse_resampler_cc(0, float(float(if_samp_rate)/float(out_sample_rate)))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(first_decim, firdes.low_pass(1, samp_rate, options_low_pass, options_low_pass*0.2), xlate_offset1+xlate_offset_fine1, samp_rate)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, udp_dest_addr, first_port+1, udp_packet_size, False)
        self.analog_agc3_xx_0 = analog.agc3_cc(1e-3, 1e-4, 1.0, 1.0, 1)
        self.analog_agc3_xx_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc3_xx_0, 0), (self.mmse_resampler_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc3_xx_0, 0))
        self.connect((self.mmse_resampler_xx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
Example #4
0
    def __init__(self, N, sps, rolloff, ntaps, bw, noise,
                 foffset, toffset, poffset, mode=0):
        gr.top_block.__init__(self)

        rrc_taps = filter.firdes.root_raised_cosine(
            sps, sps, 1.0, rolloff, ntaps)

        gain = bw
        nfilts = 32
        rrc_taps_rx = filter.firdes.root_raised_cosine(
            nfilts, sps*nfilts, 1.0, rolloff, ntaps*nfilts)

        data = 2.0*scipy.random.randint(0, 2, N) - 1.0
        data = scipy.exp(1j*poffset) * data

        self.src = blocks.vector_source_c(data.tolist(), False)
        self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps)
        self.chn = channels.channel_model(noise, foffset, toffset)
        self.off = filter.mmse_resampler_cc(0.20, 1.0)

        if mode == 0:
            self.clk = digital.pfb_clock_sync_ccf(sps, gain, rrc_taps_rx,
                                                  nfilts, nfilts//2, 1)
            self.taps = self.clk.taps()
            self.dtaps = self.clk.diff_taps()

            self.delay = int(scipy.ceil(((len(rrc_taps)-1)//2 +
                                         (len(self.taps[0])-1)//2 )//float(sps))) + 1

            self.vsnk_err = blocks.vector_sink_f()
            self.vsnk_rat = blocks.vector_sink_f()
            self.vsnk_phs = blocks.vector_sink_f()

            self.connect((self.clk,1), self.vsnk_err)
            self.connect((self.clk,2), self.vsnk_rat)
            self.connect((self.clk,3), self.vsnk_phs)

        else: # mode == 1
            mu = 0.5
            gain_mu = bw
            gain_omega = 0.25*gain_mu*gain_mu
            omega_rel_lim = 0.02
            self.clk = digital.clock_recovery_mm_cc(sps, gain_omega,
                                                    mu, gain_mu,
                                                    omega_rel_lim)

            self.vsnk_err = blocks.vector_sink_f()

            self.connect((self.clk,1), self.vsnk_err)

        self.vsnk_src = blocks.vector_sink_c()
        self.vsnk_clk = blocks.vector_sink_c()

        self.connect(self.src, self.rrc, self.chn, self.off, self.clk, self.vsnk_clk)
        self.connect(self.src, self.vsnk_src)
Example #5
0
    def __init__(self, N, sps, rolloff, ntaps, bw, noise,
                 foffset, toffset, poffset, mode=0):
        gr.top_block.__init__(self)

        rrc_taps = filter.firdes.root_raised_cosine(
            sps, sps, 1.0, rolloff, ntaps)

        gain = bw
        nfilts = 32
        rrc_taps_rx = filter.firdes.root_raised_cosine(
            nfilts, sps*nfilts, 1.0, rolloff, ntaps*nfilts)

        data = 2.0*numpy.random.randint(0, 2, N) - 1.0
        data = numpy.exp(1j*poffset) * data

        self.src = blocks.vector_source_c(data.tolist(), False)
        self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps)
        self.chn = channels.channel_model(noise, foffset, toffset)
        self.off = filter.mmse_resampler_cc(0.20, 1.0)

        if mode == 0:
            self.clk = digital.pfb_clock_sync_ccf(sps, gain, rrc_taps_rx,
                                                  nfilts, nfilts//2, 1)
            self.taps = self.clk.taps()
            self.dtaps = self.clk.diff_taps()

            self.delay = int(numpy.ceil(((len(rrc_taps)-1)//2 +
                                         (len(self.taps[0])-1)//2 )//float(sps))) + 1

            self.vsnk_err = blocks.vector_sink_f()
            self.vsnk_rat = blocks.vector_sink_f()
            self.vsnk_phs = blocks.vector_sink_f()

            self.connect((self.clk,1), self.vsnk_err)
            self.connect((self.clk,2), self.vsnk_rat)
            self.connect((self.clk,3), self.vsnk_phs)

        else: # mode == 1
            mu = 0.5
            gain_mu = bw
            gain_omega = 0.25*gain_mu*gain_mu
            omega_rel_lim = 0.02
            self.clk = digital.clock_recovery_mm_cc(sps, gain_omega,
                                                    mu, gain_mu,
                                                    omega_rel_lim)

            self.vsnk_err = blocks.vector_sink_f()

            self.connect((self.clk,1), self.vsnk_err)

        self.vsnk_src = blocks.vector_sink_c()
        self.vsnk_clk = blocks.vector_sink_c()

        self.connect(self.src, self.rrc, self.chn, self.off, self.clk, self.vsnk_clk)
        self.connect(self.src, self.vsnk_src)
Example #6
0
    def __init__(self, noise_voltage, freq, timing):
        gr.hier_block2.__init__(self, "channel_model",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        timing_offset = filter.mmse_resampler_cc(0, timing)
        noise_adder = blocks.add_cc()
        noise = analog.noise_source_c(analog.GR_GAUSSIAN, noise_voltage, 0)
        freq_offset = analog.sig_source_c(1, analog.GR_SIN_WAVE, freq, 1.0,
                                          0.0)
        mixer_offset = blocks.multiply_cc()

        self.connect(self, timing_offset)
        self.connect(timing_offset, (mixer_offset, 0))
        self.connect(freq_offset, (mixer_offset, 1))
        self.connect(mixer_offset, (noise_adder, 1))
        self.connect(noise, (noise_adder, 0))
        self.connect(noise_adder, self)
    def __init__(self, noise_voltage, freq, timing):
        gr.hier_block2.__init__(self, "channel_model",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))


        timing_offset = filter.mmse_resampler_cc(0, timing)
        noise_adder = blocks.add_cc()
        noise = analog.noise_source_c(analog.GR_GAUSSIAN,
                                      noise_voltage, 0)
        freq_offset = analog.sig_source_c(1, analog.GR_SIN_WAVE,
                                          freq, 1.0, 0.0)
        mixer_offset = blocks.multiply_cc();

        self.connect(self, timing_offset)
        self.connect(timing_offset, (mixer_offset,0))
        self.connect(freq_offset, (mixer_offset,1))
        self.connect(mixer_offset, (noise_adder,1))
        self.connect(noise, (noise_adder,0))
        self.connect(noise_adder, self)
Example #8
0
    def __init__(self, dab_params, rx_params, verbose=False, debug=False):
        """
		Hierarchical block for OFDM demodulation

		@param dab_params DAB parameter object (grdab.parameters.dab_parameters)
		@param rx_params RX parameter object (grdab.parameters.receiver_parameters)
		@param debug enables debug output to files
		@param verbose whether to produce verbose messages
		"""

        self.dp = dp = dab_params
        self.rp = rp = rx_params
        self.verbose = verbose

        if self.rp.softbits:
            gr.hier_block2.__init__(
                self,
                "ofdm_demod",
                gr.io_signature(1, 1, gr.sizeof_gr_complex),  # input signature
                gr.io_signature(1, 1, gr.sizeof_float * self.dp.num_carriers *
                                2))  # output signature
        else:
            gr.hier_block2.__init__(
                self,
                "ofdm_demod",
                gr.io_signature(1, 1, gr.sizeof_gr_complex),  # input signature
                gr.io_signature(1, 1, gr.sizeof_char * self.dp.num_carriers /
                                4))  # output signature

        # workaround for a problem that prevents connecting more than one block directly (see trac ticket #161)
        #self.input = gr.kludge_copy(gr.sizeof_gr_complex)
        self.input = blocks.multiply_const_cc(1.0)  # FIXME
        self.connect(self, self.input)

        # input filtering
        if self.rp.input_fft_filter:
            if verbose: print("--> RX filter enabled")
            lowpass_taps = filter.firdes_low_pass(
                1.0,  # gain
                dp.sample_rate,  # sampling rate
                rp.filt_bw,  # cutoff frequency
                rp.filt_tb,  # width of transition band
                filter.firdes.WIN_HAMMING)  # Hamming window
            self.fft_filter = filter.fft_filter_ccc(1, lowpass_taps)

        # correct sample rate offset, if enabled
        if self.rp.autocorrect_sample_rate:
            if verbose: print("--> dynamic sample rate correction enabled")
            self.rate_detect_ns = grdab.detect_null(dp.ns_length, False)
            self.rate_estimator = grdab.estimate_sample_rate_bf(
                dp.sample_rate, dp.frame_length)
            self.rate_prober = blocks.probe_signal_f()
            self.connect(self.input, self.rate_detect_ns, self.rate_estimator,
                         self.rate_prober)
            # self.resample = gr.fractional_interpolator_cc(0, 1)
            self.resample = grdab.fractional_interpolator_triggered_update_cc(
                0, 1)
            self.connect(self.rate_detect_ns, (self.resample, 1))
            self.updater = Timer(0.1, self.update_correction)
            # self.updater = threading.Thread(target=self.update_correction)
            self.run_interpolater_update_thread = True
            self.updater.setDaemon(True)
            self.updater.start()
        else:
            self.run_interpolater_update_thread = False
            if self.rp.sample_rate_correction_factor != 1 or self.rp.always_include_resample:
                if verbose: print("--> static sample rate correction enabled")
                self.resample = filter.mmse_resampler_cc(
                    0, self.rp.sample_rate_correction_factor)

        # timing and fine frequency synchronisation
        self.sync = grdab.ofdm_sync_dab2(self.dp, self.rp, debug)

        # ofdm symbol sampler
        self.sampler = grdab.ofdm_sampler(dp.fft_length, dp.cp_length,
                                          dp.symbols_per_frame, rp.cp_gap)

        # fft for symbol vectors
        self.fft = fft.fft_vcc(dp.fft_length, True, [], True)

        # coarse frequency synchronisation
        self.cfs = grdab.ofdm_coarse_frequency_correct(dp.fft_length,
                                                       dp.num_carriers,
                                                       dp.cp_length)

        # diff phasor
        self.phase_diff = grdab.diff_phasor_vcc(dp.num_carriers)

        # remove pilot symbol
        self.remove_pilot = grdab.ofdm_remove_first_symbol_vcc(dp.num_carriers)

        # magnitude equalisation
        if self.rp.equalize_magnitude:
            if verbose: print("--> magnitude equalization enabled")
            self.equalizer = grdab.magnitude_equalizer_vcc(
                dp.num_carriers, rp.symbols_for_magnitude_equalization)

        # frequency deinterleaving
        self.deinterleave = grdab.frequency_interleaver_vcc(
            dp.frequency_deinterleaving_sequence_array)

        # symbol demapping
        self.demapper = grdab.qpsk_demapper_vcb(dp.num_carriers)

        #
        # connect everything
        #

        if self.rp.autocorrect_sample_rate or self.rp.sample_rate_correction_factor != 1 or self.rp.always_include_resample:
            self.connect(self.input, self.resample)
            self.input2 = self.resample
        else:
            self.input2 = self.input
        if self.rp.input_fft_filter:
            self.connect(self.input2, self.fft_filter, self.sync)
        else:
            self.connect(self.input2, self.sync)

        # data stream
        self.connect(self.sync, self.sampler, self.fft, self.cfs,
                     self.phase_diff, self.remove_pilot)
        if self.rp.equalize_magnitude:
            self.connect(self.remove_pilot, self.equalizer, self.deinterleave)
        else:
            self.connect(self.remove_pilot, self.deinterleave)
        if self.rp.softbits:
            if verbose: print("--> using soft bits")
            self.softbit_interleaver = grdab.complex_to_interleaved_float_vcf(
                self.dp.num_carriers)
            self.connect(self.deinterleave, self.softbit_interleaver,
                         (self, 0))
        else:
            self.connect(self.deinterleave, self.demapper, (self, 0))

        # calculate an estimate of the SNR
        self.phase_var_decim = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * self.dp.num_carriers,
            self.rp.phase_var_estimate_downsample)
        self.phase_var_arg = blocks.complex_to_arg(dp.num_carriers)
        self.phase_var_v2s = blocks.vector_to_stream(gr.sizeof_float,
                                                     dp.num_carriers)
        self.phase_var_mod = grdab.modulo_ff(pi / 2)
        self.phase_var_avg_mod = filter.iir_filter_ffd(
            [rp.phase_var_estimate_alpha],
            [0, 1 - rp.phase_var_estimate_alpha])
        self.phase_var_sub_avg = blocks.sub_ff()
        self.phase_var_sqr = blocks.multiply_ff()
        self.phase_var_avg = filter.iir_filter_ffd(
            [rp.phase_var_estimate_alpha],
            [0, 1 - rp.phase_var_estimate_alpha])
        self.probe_phase_var = blocks.probe_signal_f()
        self.connect((self.remove_pilot, 0), self.phase_var_decim,
                     self.phase_var_arg, self.phase_var_v2s,
                     self.phase_var_mod, (self.phase_var_sub_avg, 0),
                     (self.phase_var_sqr, 0))
        self.connect(self.phase_var_mod, self.phase_var_avg_mod,
                     (self.phase_var_sub_avg, 1))
        self.connect(self.phase_var_sub_avg, (self.phase_var_sqr, 1))
        self.connect(self.phase_var_sqr, self.phase_var_avg,
                     self.probe_phase_var)

        # measure processing rate
        self.measure_rate = grdab.measure_processing_rate(
            gr.sizeof_gr_complex, 2000000)
        self.connect(self.input, self.measure_rate)

        # debugging
        if debug:
            self.connect(
                self.fft,
                blocks.file_sink(gr.sizeof_gr_complex * dp.fft_length,
                                 "debug/ofdm_after_fft.dat"))
            self.connect(
                (self.cfs, 0),
                blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers,
                                 "debug/ofdm_after_cfs.dat"))
            self.connect(
                self.phase_diff,
                blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers,
                                 "debug/ofdm_diff_phasor.dat"))
            self.connect(
                (self.remove_pilot, 0),
                blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers,
                                 "debug/ofdm_pilot_removed.dat"))
            self.connect((self.remove_pilot, 1),
                         blocks.file_sink(gr.sizeof_char,
                                          "debug/ofdm_after_cfs_trigger.dat"))
            self.connect(
                self.deinterleave,
                blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers,
                                 "debug/ofdm_deinterleaved.dat"))
            if self.rp.equalize_magnitude:
                self.connect(
                    self.equalizer,
                    blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers,
                                     "debug/ofdm_equalizer.dat"))
            if self.rp.softbits:
                self.connect(
                    self.softbit_interleaver,
                    blocks.file_sink(gr.sizeof_float * dp.num_carriers * 2,
                                     "debug/softbits.dat"))
Example #9
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        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.dect_symbol_rate = dect_symbol_rate = 1152000
        self.dect_occupied_bandwidth = dect_occupied_bandwidth = 1.2 * dect_symbol_rate
        self.dect_channel_bandwidth = dect_channel_bandwidth = 1.728e6
        self.baseband_sampling_rate = baseband_sampling_rate = 100000000 / 32
        self.rx_gain = rx_gain = 0
        self.rx_freq = rx_freq = 1897344000
        self.resampler_filter_taps = resampler_filter_taps = firdes.low_pass_2(
            1, 3 * baseband_sampling_rate, dect_occupied_bandwidth / 2,
            (dect_channel_bandwidth - dect_occupied_bandwidth) / 2, 30)
        self.resample_ratio = resample_ratio = int(
            (3.0 * baseband_sampling_rate / 2.0) / dect_symbol_rate / 4.0)
        self.part_id = part_id = 0

        ##################################################
        # Blocks
        ##################################################
        self._rx_gain_range = Range(0, 30, 1, 0, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'RX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win)
        # Create the options list
        self._rx_freq_options = [
            1897344000,
            1881792000,
            1883520000,
            1885248000,
            1886876000,
            1888704000,
            1890432000,
            1892160000,
            1893888000,
            1895616000,
        ]
        # Create the labels list
        self._rx_freq_labels = [
            "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
        ]
        # Create the combo box
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('Carrier Number' + ": "))
        self._rx_freq_combo_box = Qt.QComboBox()
        self._rx_freq_tool_bar.addWidget(self._rx_freq_combo_box)
        for _label in self._rx_freq_labels:
            self._rx_freq_combo_box.addItem(_label)
        self._rx_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._rx_freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._rx_freq_options.index(i)))
        self._rx_freq_callback(self.rx_freq)
        self._rx_freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_rx_freq(self._rx_freq_options[i]))
        # Create the radio buttons
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar)
        self.vocoder_g721_decode_bs_0 = vocoder.g721_decode_bs()
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=[],
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(rx_freq, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('LNAW', 0)
        self.uhd_usrp_source_0.set_samp_rate(3125000)
        # No synchronization enforced.
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=6, decimation=1, taps=None, fractional_bw=None)
        self.rational_resampler = filter.rational_resampler_base_ccc(
            3, 2, resampler_filter_taps)
        # Create the options list
        self._part_id_options = [0, 1, 2, 3, 4, 5, 6, 7, 8]
        # Create the labels list
        self._part_id_labels = ["0", "1", "2", "3", "4", "5", "6", "7", "8"]
        # Create the combo box
        self._part_id_tool_bar = Qt.QToolBar(self)
        self._part_id_tool_bar.addWidget(Qt.QLabel('Select Part' + ": "))
        self._part_id_combo_box = Qt.QComboBox()
        self._part_id_tool_bar.addWidget(self._part_id_combo_box)
        for _label in self._part_id_labels:
            self._part_id_combo_box.addItem(_label)
        self._part_id_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._part_id_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._part_id_options.index(i)))
        self._part_id_callback(self.part_id)
        self._part_id_combo_box.currentIndexChanged.connect(
            lambda i: self.set_part_id(self._part_id_options[i]))
        # Create the radio buttons
        self.top_grid_layout.addWidget(self._part_id_tool_bar)
        self.mmse_resampler_xx_0 = filter.mmse_resampler_cc(0, resample_ratio)
        self.dect2_phase_diff_0 = dect2.phase_diff()
        self.dect2_packet_receiver_0 = dect2.packet_receiver()
        self.dect2_packet_decoder_0 = dect2.packet_decoder()
        self.console_0 = dect2.console()
        self.top_grid_layout.addWidget(self.console_0)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32768)
        self.audio_sink_0 = audio.sink(48000, 'plughw:0,0', True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.dect2_packet_decoder_0, 'log_out'),
                         (self.console_0, 'in'))
        self.msg_connect((self.dect2_packet_receiver_0, 'rcvr_msg_out'),
                         (self.dect2_packet_decoder_0, 'rcvr_msg_in'))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.dect2_packet_decoder_0, 0),
                     (self.vocoder_g721_decode_bs_0, 0))
        self.connect((self.dect2_packet_receiver_0, 0),
                     (self.dect2_packet_decoder_0, 0))
        self.connect((self.dect2_phase_diff_0, 0),
                     (self.dect2_packet_receiver_0, 0))
        self.connect((self.mmse_resampler_xx_0, 0),
                     (self.dect2_phase_diff_0, 0))
        self.connect((self.rational_resampler, 0),
                     (self.mmse_resampler_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler, 0))
        self.connect((self.vocoder_g721_decode_bs_0, 0),
                     (self.blocks_short_to_float_0, 0))
Example #10
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        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.dect_symbol_rate = dect_symbol_rate = 1152000
        self.dect_occupied_bandwidth = dect_occupied_bandwidth = 1.2 * dect_symbol_rate
        self.dect_channel_bandwidth = dect_channel_bandwidth = 1.728e6
        self.baseband_sampling_rate = baseband_sampling_rate = 4000000
        self.xlate_offset1 = xlate_offset1 = 1000000
        self.rx_freq = rx_freq = 1897344000
        self.resampler_filter_taps = resampler_filter_taps = firdes.low_pass_2(
            1, 3 * baseband_sampling_rate, dect_occupied_bandwidth / 2,
            (dect_channel_bandwidth - dect_occupied_bandwidth) / 2, 30)
        self.resample_ratio = resample_ratio = int(
            (3.0 * baseband_sampling_rate / 2.0) / dect_symbol_rate / 4.0)
        self.ppm_corr = ppm_corr = 20
        self.part_id = part_id = 0
        self.options_low_pass = options_low_pass = 1400500
        self.if_gain = if_gain = 40
        self.VGA_bb_gain = VGA_bb_gain = 34
        self.LNA_rf_gain = LNA_rf_gain = 0

        ##################################################
        # Blocks
        ##################################################
        # Create the options list
        self._rx_freq_options = [
            1897344000, 1895616000, 1893888000, 1892160000, 1890432000,
            1888704000, 1886876000, 1885248000, 1883520000, 1881792000,
            1899072000, 1900800000, 1902528000, 1904256000, 1905984000,
            1907712000, 1909440000, 1911168000, 1912896000, 1914624000,
            1916352000, 1918080000, 1919808000, 1921536000, 1923264000,
            1924992000, 1926720000, 1928448000, 1930176000, 1931904000,
            1933632000, 1935360000, 1937088000, 1938816000, 1940544000,
            1942272000, 1944000000, 1945728000, 1947456000, 1949184000,
            1950912000, 1952640000, 1954368000, 1956096000, 1957824000,
            1959552000, 1961280000, 1963008000, 1964736000, 1966464000,
            1968192000, 1969920000, 1971648000, 1973376000, 1975104000,
            1976832000, 2011392000, 2013120000, 2014848000, 2016576000,
            2018304000, 2020032000, 2021760000, 2023488000
        ]
        # Create the labels list
        self._rx_freq_labels = [
            "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
            "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23",
            "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34",
            "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45",
            "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56",
            "57", "58", "59", "60", "61", "62", "63"
        ]
        # Create the combo box
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('Carrier Number' + ": "))
        self._rx_freq_combo_box = Qt.QComboBox()
        self._rx_freq_tool_bar.addWidget(self._rx_freq_combo_box)
        for _label in self._rx_freq_labels:
            self._rx_freq_combo_box.addItem(_label)
        self._rx_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._rx_freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._rx_freq_options.index(i)))
        self._rx_freq_callback(self.rx_freq)
        self._rx_freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_rx_freq(self._rx_freq_options[i]))
        # Create the radio buttons
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar)
        self._ppm_corr_range = Range(-100, 100, 1, 20, 200)
        self._ppm_corr_win = RangeWidget(self._ppm_corr_range,
                                         self.set_ppm_corr, 'ppm',
                                         "counter_slider", int)
        self.top_grid_layout.addWidget(self._ppm_corr_win)
        self._if_gain_range = Range(0, 40, 8, 40, 200)
        self._if_gain_win = RangeWidget(self._if_gain_range, self.set_if_gain,
                                        'IF Gain', "counter_slider", int)
        self.top_grid_layout.addWidget(self._if_gain_win)
        self._VGA_bb_gain_range = Range(0, 62, 2, 34, 200)
        self._VGA_bb_gain_win = RangeWidget(self._VGA_bb_gain_range,
                                            self.set_VGA_bb_gain,
                                            'VGA BB Gain', "counter_slider",
                                            int)
        self.top_grid_layout.addWidget(self._VGA_bb_gain_win)
        self._LNA_rf_gain_range = Range(0, 14, 14, 0, 200)
        self._LNA_rf_gain_win = RangeWidget(self._LNA_rf_gain_range,
                                            self.set_LNA_rf_gain,
                                            'LNA RF Gain', "counter_slider",
                                            int)
        self.top_grid_layout.addWidget(self._LNA_rf_gain_win)
        self.vocoder_g721_decode_bs_0 = vocoder.g721_decode_bs()
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              'hackrf=0')
        self.rtlsdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.rtlsdr_source_0.set_sample_rate(baseband_sampling_rate)
        self.rtlsdr_source_0.set_center_freq(rx_freq - xlate_offset1, 0)
        self.rtlsdr_source_0.set_freq_corr(ppm_corr, 0)
        self.rtlsdr_source_0.set_gain(LNA_rf_gain, 0)
        self.rtlsdr_source_0.set_if_gain(if_gain, 0)
        self.rtlsdr_source_0.set_bb_gain(VGA_bb_gain, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=6, decimation=1, taps=None, fractional_bw=None)
        self.rational_resampler = filter.rational_resampler_base_ccc(
            3, 2, resampler_filter_taps)
        # Create the options list
        self._part_id_options = [0, 1, 2, 3, 4, 5, 6, 7, 8]
        # Create the labels list
        self._part_id_labels = ["0", "1", "2", "3", "4", "5", "6", "7", "8"]
        # Create the combo box
        self._part_id_tool_bar = Qt.QToolBar(self)
        self._part_id_tool_bar.addWidget(Qt.QLabel('Select Part' + ": "))
        self._part_id_combo_box = Qt.QComboBox()
        self._part_id_tool_bar.addWidget(self._part_id_combo_box)
        for _label in self._part_id_labels:
            self._part_id_combo_box.addItem(_label)
        self._part_id_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._part_id_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._part_id_options.index(i)))
        self._part_id_callback(self.part_id)
        self._part_id_combo_box.currentIndexChanged.connect(
            lambda i: self.set_part_id(self._part_id_options[i]))
        # Create the radio buttons
        self.top_grid_layout.addWidget(self._part_id_tool_bar)
        self.mmse_resampler_xx_0 = filter.mmse_resampler_cc(
            0, (3.0 * baseband_sampling_rate / 2.0) / dect_symbol_rate / 4.0)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1,
            firdes.low_pass(1, baseband_sampling_rate, options_low_pass,
                            options_low_pass * 0.2), xlate_offset1,
            baseband_sampling_rate)
        self.dect2_phase_diff_0 = dect2.phase_diff()
        self.dect2_packet_receiver_0 = dect2.packet_receiver()
        self.dect2_packet_decoder_0 = dect2.packet_decoder()
        self.console_0 = dect2.console()
        self.top_grid_layout.addWidget(self.console_0)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32768)
        self.audio_sink_0 = audio.sink(48000, '', True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.dect2_packet_decoder_0, 'log_out'),
                         (self.console_0, 'in'))
        self.msg_connect((self.dect2_packet_receiver_0, 'rcvr_msg_out'),
                         (self.dect2_packet_decoder_0, 'rcvr_msg_in'))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.dect2_packet_decoder_0, 0),
                     (self.vocoder_g721_decode_bs_0, 0))
        self.connect((self.dect2_packet_receiver_0, 0),
                     (self.dect2_packet_decoder_0, 0))
        self.connect((self.dect2_phase_diff_0, 0),
                     (self.dect2_packet_receiver_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.rational_resampler, 0))
        self.connect((self.mmse_resampler_xx_0, 0),
                     (self.dect2_phase_diff_0, 0))
        self.connect((self.rational_resampler, 0),
                     (self.mmse_resampler_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.vocoder_g721_decode_bs_0, 0),
                     (self.blocks_short_to_float_0, 0))