Esempio n. 1
0
    def __init__(
        self,
        samp_per_sym=4,
        sync_bandwidth=.6,
        costas_bandwidth=0.15,
        agc_time_const=8,
        sync_phases=32,
    ):
        gr.hier_block2.__init__(
            self,
            "PSK31 Coherent Demodulator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
        )

        _psk31_sync_base.__init__(
            self,
            samp_per_sym,
            sync_bandwidth,
            agc_time_const,
            sync_phases,
        )

        self.costas_bandwidth = costas_bandwidth
        self._costas_loop = digital.costas_loop_cc(costas_bandwidth, 2, True)

        self._reset()

        self.connect(
            self._post_sync_agc,
            self._costas_loop,
            self,
        )
Esempio n. 2
0
    def test04(self):
        # QPSK Convergence test with static rotation
        natfreq = 0.25
        order = 4
        self.test = digital.costas_loop_cc(natfreq, order)

        rot = cmath.exp(0.2j) # some small rotation
        data = [complex(2*random.randint(0,1)-1, 2*random.randint(0,1)-1)
                for i in xrange(100)]
        
        N = 40 # settling time
        expected_result = data[N:]
        data = [rot*d for d in data]

        self.src = blocks.vector_source_c(data, False)
        self.snk = blocks.vector_sink_c()

        self.tb.connect(self.src, self.test, self.snk)
        self.tb.run()

        dst_data = self.snk.data()[N:]

        # generously compare results; the loop will converge near to, but
        # not exactly on, the target data
        self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 2)
Esempio n. 3
0
    def test05(self):
        # 8PSK Convergence test with static rotation
        natfreq = 0.25
        order = 8
        self.test = digital.costas_loop_cc(natfreq, order)

        rot = cmath.exp(-cmath.pi/8.0j) # rotate to match Costas rotation
        const = psk.psk_constellation(order)
        data = [random.randint(0,7) for i in xrange(100)]
        data = [2*rot*const.points()[d] for d in data]
        
        N = 40 # settling time
        expected_result = data[N:]

        rot = cmath.exp(0.1j) # some small rotation
        data = [rot*d for d in data]

        self.src = blocks.vector_source_c(data, False)
        self.snk = blocks.vector_sink_c()

        self.tb.connect(self.src, self.test, self.snk)
        self.tb.run()

        dst_data = self.snk.data()[N:]
        
	# generously compare results; the loop will converge near to, but
        # not exactly on, the target data
        self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 2)
Esempio n. 4
0
    def test04(self):
        # QPSK Convergence test with static rotation
        natfreq = 0.25
        order = 4
        self.test = digital.costas_loop_cc(natfreq, order)

        rot = cmath.exp(0.2j)  # some small rotation
        data = [
            complex(2 * random.randint(0, 1) - 1, 2 * random.randint(0, 1) - 1)
            for i in range(100)
        ]

        N = 40  # settling time
        expected_result = data[N:]
        data = [rot * d for d in data]

        self.src = blocks.vector_source_c(data, False)
        self.snk = blocks.vector_sink_c()

        self.tb.connect(self.src, self.test, self.snk)
        self.tb.run()

        dst_data = self.snk.data()[N:]

        # generously compare results; the loop will converge near to, but
        # not exactly on, the target data
        self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 2)
Esempio n. 5
0
    def __init__(self):
        gr.top_block.__init__(self, "METEOR-M2 receiver")

        ##################################################
        # Variables
        ##################################################
        self.symb_rate = symb_rate = 72e3
        self.samp_rate = samp_rate = 960e3
        self.decimation = decimation = 4
        self.samp_per_sym = samp_per_sym = samp_rate/decimation/symb_rate
        self.clock_alpha = clock_alpha = 30e-3
        self.bitstream_name = bitstream_name = os.getcwd() + "/Data/meteor_LRPT_" + datetime.now().strftime("%d%m%Y_%H%M") + ".s"
        self.Tuning_offset = Tuning_offset = 300e3
        self.LO_freq = LO_freq = 137.903e6
        self.BPF_width = BPF_width = 140e3

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(LO_freq-Tuning_offset, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(2, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(2, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(42, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(10, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(
        	1, samp_rate/decimation, symb_rate, 0.3, 361))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decimation, (firdes.low_pass(1,samp_rate,BPF_width/2,20e3)), Tuning_offset, samp_rate)
        (self.freq_xlating_fir_filter_xxx_0).set_processor_affinity([0])
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1e-3, 4)
        (self.digital_costas_loop_cc_0).set_processor_affinity([1])
        self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf(digital.constellation_calcdist(([-1-1j, -1+1j, 1+1j, 1-1j]), ([0, 1, 3, 2]), 4, 1).base())
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(samp_per_sym*(1+0.0), clock_alpha**2/4.0, 0.5, clock_alpha, 0.005)
        (self.digital_clock_recovery_mm_xx_0).set_processor_affinity([2])
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 127)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, bitstream_name, False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.analog_rail_ff_0 = analog.rail_ff(-1, 1)
        self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0)
        self.analog_agc_xx_0.set_max_gain(4000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0))
        self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0))
        self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
Esempio n. 6
0
    def test05(self):
        # 8PSK Convergence test with static rotation
        natfreq = 0.25
        order = 8
        self.test = digital.costas_loop_cc(natfreq, order)

        rot = cmath.exp(-cmath.pi / 8.0j)  # rotate to match Costas rotation
        const = psk.psk_constellation(order)
        data = [random.randint(0, 7) for i in range(100)]
        data = [2 * rot * const.points()[d] for d in data]

        N = 40  # settling time
        expected_result = data[N:]

        rot = cmath.exp(0.1j)  # some small rotation
        data = [rot * d for d in data]

        self.src = blocks.vector_source_c(data, False)
        self.snk = blocks.vector_sink_c()

        self.tb.connect(self.src, self.test, self.snk)
        self.tb.run()

        dst_data = self.snk.data()[N:]

        # generously compare results; the loop will converge near to, but
        # not exactly on, the target data
        self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 2)
    def __init__(self, principal_gui, options):
    
        gr.hier_block2.__init__(self, "bpsk_demod",
                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                gr.io_signature(1, 1, gr.sizeof_gr_complex))       # Output signature
        
        #Enter the parameters of modulation         
        self._samples_per_symbol = options.samples_per_symbol
        
        self.verbose = options.verbose

        self._gray_code =_def_gray_code
        
        if self._samples_per_symbol < 2:
            raise TypeError, "samples_per_symbol must be >= 2, is %r" % (self._samples_per_symbol,)

        arity = pow(2,self.bits_per_symbol())

        # Automatic gain control
        
        #self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100)
        self.agc = gr.agc_cc(1e-5, 1.0,1.0,1.0)
        #self.agc = gr.feedforward_agc_cc(16, 2.0)

        # RRC data filter
        ntaps = 11 * self._samples_per_symbol
        self.rrc_taps = gr.firdes.root_raised_cosine(
            1.0,                      # gain
            self._samples_per_symbol, # sampling rate
            1.0,                      # symbol rate
            0.35,                      # excess bandwidth (roll-off factor)
            ntaps)
        self.rrc_filter=gr.interp_fir_filter_ccf(1, self.rrc_taps)        
                
        self._costas = digital.costas_loop_cc(6.28/100.0, 2)
        self.gr_null_sink = gr.null_sink(gr.sizeof_float*1)
        self.connect((self._costas, 1), (self.gr_null_sink, 0))
        
        self._mm = digital.clock_recovery_mm_cc(self._samples_per_symbol,       # Initial samples/symbol
                                           1e-06,  # Second order gain
                                           0.5,          # Initial symbol phase
                                           0.001,     # First order gain
                                           0.0001) # Maximum timing offset
        
        if self.verbose:
            self._print_verbage()
        
        # Do differential decoding based on phase change of symbols
        #self.diffdec = gr.diff_phasor_cc()
 
        # Connect and Initialize base class
        self.connect(self, self.agc, self.rrc_filter, (self._costas,0), self._mm, self)
Esempio n. 8
0
    def __init__(self, bw_clock_sync=2*math.pi/100, bw_fll=math.pi/1600, bw_costas=2*math.pi/100, n_filts=32, len_sym_srrc=7, constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(), samp_per_sym=3, alfa=0.35, bits_per_sym=2, alpha_probe=0.1, th_probe=0):
        gr.hier_block2.__init__(
            self, "Hier Rx",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_char*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.bw_clock_sync = bw_clock_sync
        self.bw_fll = bw_fll
        self.bw_costas = bw_costas
        self.n_filts = n_filts
        self.len_sym_srrc = len_sym_srrc
        self.constellation = constellation
        self.samp_per_sym = samp_per_sym
        self.alfa = alfa
        self.bits_per_sym = bits_per_sym
        self.alpha_probe = alpha_probe
        self.th_probe = th_probe

        ##################################################
        # Variables
        ##################################################
        self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts)

        ##################################################
        # Blocks
        ##################################################
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, bw_clock_sync, (filtro_srrc), n_filts, 16, 5, 1)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, bw_fll)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym)
        self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(bw_costas, 2**bits_per_sym)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym)
        self.analog_probe_avg_mag_sqrd_x_0 = analog.probe_avg_mag_sqrd_c(th_probe, alpha_probe)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0_0, 0))
        self.connect((self, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self, 0))
        self.connect((self, 0), (self.analog_probe_avg_mag_sqrd_x_0, 0))
Esempio n. 9
0
 def __init__(self, costas_loop_bw = 10E-3, costas_order = 2, mm_omega = 2, mm_gain_omega = 0.00765625, mm_mu = .5, mm_gain_mu = .175, mm_omega_relative_limit = .005):
     gr.hier_block2.__init__(self,
         "generic_synch",
         gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
         gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
         )
         
     self.digital_costas_loop_cc_0 = digital.costas_loop_cc(costas_loop_bw, costas_order)
     self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(mm_omega, mm_gain_omega, mm_mu, mm_gain_mu, mm_omega_relative_limit)
     
     self.connect((self, 0), (self.digital_costas_loop_cc_0, 0))
     self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
     self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self, 0))
Esempio n. 10
0
    def __init__(self):
        gr.top_block.__init__(self, "CC1101 Burst Detector")

        def rx_callback():
            print "Callback Fired"

        # Variables
        self.samp_rate = samp_rate = 250e3
        self.f_center = f_center = 510e6
        self.bandwidth = bandwidth = 125e3
        self.gain = gain = 15
        self.sps = sps = 2

        # Blocks
        self.uhd_src = uhd.usrp_source(
            device_addr="serial=E8R10Z2B1", #cheetara
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )

        self.uhd_src.set_samp_rate(samp_rate)
        self.uhd_src.set_center_freq(f_center, 0)
        self.uhd_src.set_gain(gain, 0)
        self.uhd_src.set_antenna("TX/RX", 0)
        self.uhd_src.set_bandwidth(bandwidth, 0)

        self.uhd_src.set_samp_rate(self.samp_rate)
        self.uhd_src.set_center_freq(self.f_center, 0)
        self.uhd_src.set_gain(self.gain, 0)

        # change magic_num until abs(ratio) as close to 0 (when sending all A's) 
        # as possible (.000X or closer)
        # need to solve clock synchronization
        self.msk_demod = level.msk_demod_cf(ti_adj=False, magic_num=.022)

        self.agc = gr.agc2_cc()
        #self.clock_sync = digital.pfb_clock_sync_ccf(sps=2,)
        self.costas_loop = digital.costas_loop_cc(2*3.14/100.0, 4)

        self.packet_receiver = level.cc1k_demod_pkts(callback=rx_callback())

        self.vec_sink = gr.vector_sink_f(1)
        self.slicer = digital.binary_slicer_fb()
        self.bin_sink = gr.vector_sink_b(1)

        # Connections
        self.connect(self.uhd_src, self.agc, self.msk_demod, self.slicer, self.bin_sink)
        self.connect(self.msk_demod, self.vec_sink)
        self.connect(self.uhd_src, self.packet_receiver)
Esempio n. 11
0
    def __init__(self, sample_rate, symbol_rate):
        gr.hier_block2.__init__(
            self,
            "dvb_s_demodulator2_cc",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_gr_complex))  # Output signature

        samples_per_symbol = sample_rate / symbol_rate

        # Automatic gain control
        self.agc = gr.agc2_cc(
            0.06,  # Attack rate
            0.001,  # Decay rate
            1,  # Reference
            1,  # Initial gain
            100)  # Max gain

        # Frequency correction with band-edge filters FLL
        freq_beta = freq_alpha * freq_alpha / 4
        self.freq_recov = digital.fll_band_edge_cc(
            samples_per_symbol,
            dvb_swig.RRC_ROLLOFF_FACTOR,
            11 * int(samples_per_symbol),  # Size of the filter in taps
            freq_bw)
        self.freq_recov.set_alpha(freq_alpha)
        self.freq_recov.set_beta(freq_beta)

        # Symbol timing recovery with RRC data filter
        ntaps = 11 * int(samples_per_symbol * nfilts)
        rrc_taps = gr.firdes.root_raised_cosine(nfilts, nfilts,
                                                1.0 / samples_per_symbol,
                                                dvb_swig.RRC_ROLLOFF_FACTOR,
                                                ntaps)
        self.time_recov = gr.pfb_clock_sync_ccf(
            samples_per_symbol,  # Samples per second in the incoming signal
            timing_alpha,  # Alpha gain of control loop
            rrc_taps,  # The filter taps
            nfilts,  # Number of filters in the filter bank
            nfilts /
            2)  # Initial phase to look at (or which filter to start with)
        self.time_recov.set_beta(timing_beta)

        # Perform phase / fine frequency correction using Costas PLL
        phase_beta = phase_alpha * phase_alpha / 4
        self.phase_recov = digital.costas_loop_cc(phase_bw, M)
        self.phase_recov.set_alpha(phase_alpha)
        self.phase_recov.set_beta(phase_beta)

        self.connect(self, self.agc, self.freq_recov, self.time_recov,
                     self.phase_recov, self)
    def test01(self):
        # test basic functionality by setting all gains to 0
        natfreq = 0.0
        order = 2
        self.test = digital.costas_loop_cc(natfreq, order)

        data = 100*[complex(1,0),]
        self.src = blocks.vector_source_c(data, False)
        self.snk = blocks.vector_sink_c()

        self.tb.connect(self.src, self.test, self.snk)
        self.tb.run()
        
        expected_result = data
        dst_data = self.snk.data()
        self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 5)
Esempio n. 13
0
    def __init__(self, excessBW=0.35, sps=4, arity=2):
        gr.hier_block2.__init__(
            self,
            "DPSKReceiver",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.arity = arity
        self.excessBW = excessBW
        self.sps = sps

        if (arity != 2 and arity != 4):
            raise ValueError, "Unsupported modulation order '%d'" % (arity, )

        ##################################################
        # Variables
        ##################################################
        self.nfilts = nfilts = 32
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), excessBW, 45 * nfilts)

        ##################################################
        # Blocks
        ##################################################
        self.digital_pfb_clock_sync_xxx = digital.pfb_clock_sync_ccf(
            sps, 0.1, (rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_costas_loop_cc = digital.costas_loop_cc(0.1, arity, False)
        self.digital_cma_equalizer_cc = digital.cma_equalizer_cc(6, 1, 0.1, 1)
        self.SatelliteModem_DPSKDemodulator = SatelliteModem.DPSKDemodulator(
            arity)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.SatelliteModem_DPSKDemodulator, 0), (self, 0))
        self.connect((self.digital_cma_equalizer_cc, 0),
                     (self.digital_costas_loop_cc, 0))
        self.connect((self.digital_costas_loop_cc, 0),
                     (self.SatelliteModem_DPSKDemodulator, 0))
        self.connect((self.digital_pfb_clock_sync_xxx, 0),
                     (self.digital_cma_equalizer_cc, 0))
        self.connect((self, 0), (self.digital_pfb_clock_sync_xxx, 0))
Esempio n. 14
0
    def test02(self):
        # Make sure it doesn't diverge given perfect data
        natfreq = 0.25
        order = 2
        self.test = digital.costas_loop_cc(natfreq, order)

        data = [complex(2*random.randint(0,1)-1, 0) for i in xrange(100)]
        self.src = blocks.vector_source_c(data, False)
        self.snk = blocks.vector_sink_c()

        self.tb.connect(self.src, self.test, self.snk)
        self.tb.run()

        expected_result = data
        dst_data = self.snk.data()

        self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 5)
Esempio n. 15
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.5e+06
        self.decim = decim = 3
        self.baud = baud = 40000
        self.samp_per_sym = samp_per_sym = float(samp_rate/decim)/baud
        self.clock_alpha = clock_alpha = 0.0037

        ##################################################
        # Blocks
        ##################################################
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.complex_band_pass(1, samp_rate, -samp_rate/(2*decim), samp_rate/(2*decim), 10000)), 1.4e6, samp_rate)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(samp_per_sym, 0.1, (firdes.root_raised_cosine(32, 32, 1.0/float(samp_per_sym), 0.35, 11*int(samp_per_sym)*32)), 32, 16, 0.1, 1)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(50e-3, 4, False)
        self.blocks_wavfile_source_0 = blocks.wavfile_source('/Volumes/My Passport/Basebands/Satellites/GOES-16/gqrx_20170124_060211_1694100000_2500000_fc.wav', False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_char*1, 16)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 127)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_char*16,
        	addr='127.0.0.1',
        	port=5000,
        	server=False,
        )
        self.analog_feedforward_agc_cc_0_0 = analog.feedforward_agc_cc(1024, 2.0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_feedforward_agc_cc_0_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_float_to_char_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.blks2_tcp_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1))
        self.connect((self.digital_costas_loop_cc_0_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_feedforward_agc_cc_0_0, 0))
Esempio n. 16
0
    def test02(self):
        # Make sure it doesn't diverge given perfect data
        natfreq = 0.25
        order = 2
        self.test = digital.costas_loop_cc(natfreq, order)

        data = [complex(2 * random.randint(0, 1) - 1, 0) for i in range(100)]
        self.src = blocks.vector_source_c(data, False)
        self.snk = blocks.vector_sink_c()

        self.tb.connect(self.src, self.test, self.snk)
        self.tb.run()

        expected_result = data
        dst_data = self.snk.data()

        self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 5)
Esempio n. 17
0
	def __init__(self, sample_rate, symbol_rate):
		gr.hier_block2.__init__(self, "dvb_s_demodulator2_cc",
				gr.io_signature(1, 1, gr.sizeof_gr_complex),	# Input signature
				gr.io_signature(1, 1, gr.sizeof_gr_complex))	# Output signature

		samples_per_symbol = sample_rate / symbol_rate

		# Automatic gain control
		self.agc = gr.agc2_cc(
				0.06,				# Attack rate
				0.001,				# Decay rate
				1,					# Reference
				1,					# Initial gain
				100)				# Max gain

		# Frequency correction with band-edge filters FLL
		freq_beta = freq_alpha * freq_alpha / 4
		self.freq_recov = digital.fll_band_edge_cc(
				samples_per_symbol,
				dvb_swig.RRC_ROLLOFF_FACTOR,
				11 * int(samples_per_symbol),	# Size of the filter in taps
				freq_bw)
		self.freq_recov.set_alpha(freq_alpha)
		self.freq_recov.set_beta(freq_beta)


		# Symbol timing recovery with RRC data filter
		ntaps = 11 * int(samples_per_symbol * nfilts)
		rrc_taps = gr.firdes.root_raised_cosine(nfilts, nfilts,
				1.0 / samples_per_symbol, dvb_swig.RRC_ROLLOFF_FACTOR, ntaps)
		self.time_recov = gr.pfb_clock_sync_ccf(
				samples_per_symbol,				# Samples per second in the incoming signal
				timing_alpha,					# Alpha gain of control loop
				rrc_taps,						# The filter taps
				nfilts,							# Number of filters in the filter bank
				nfilts / 2)						# Initial phase to look at (or which filter to start with)
		self.time_recov.set_beta(timing_beta)

		# Perform phase / fine frequency correction using Costas PLL
		phase_beta  = phase_alpha * phase_alpha / 4
		self.phase_recov = digital.costas_loop_cc(phase_bw, M)
		self.phase_recov.set_alpha(phase_alpha)
		self.phase_recov.set_beta(phase_beta)

		self.connect(self, self.agc, self.freq_recov, self.time_recov, self.phase_recov, self)
Esempio n. 18
0
    def __init__(self, samp_rate, symbol_rate=31.25):

	super(psk31_receiver, self).__init__(
            "psk31_receiver",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(0, 0, 1))
        self.symbol_rate = symbol_rate
	self.costas = digital.costas_loop_cc(2*3.14/100, 4)
        self.clock_recovery = digital.clock_recovery_mm_cc(
            1.0*samp_rate/symbol_rate, 0.25 * 0.1*0.1, 0.05, 0.1, 0.001)
	self.receiver = digital.constellation_receiver_cb(
            digital.constellation_bpsk().base(), 2*3.14/100, -0.25, 0.25)
	self.diff = gr.diff_decoder_bb(2)
        self.decoder = ham.psk31_decode_bb(True)
        self.msgq_out = gr.msg_queue()
	self.snk = gr.message_sink(gr.sizeof_char, self.msgq_out, True)
        self.connect(self, self.costas, self.clock_recovery,
                     self.receiver, self.diff, self.decoder, self.snk)
Esempio n. 19
0
    def __init__(self, N, sps, rolloff, ntaps, bw, noise, foffset, toffset, poffset):
        gr.top_block.__init__(self)

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

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

        self.src = gr.vector_source_c(data.tolist(), False)
        self.rrc = gr.interp_fir_filter_ccf(sps, rrc_taps)
        self.chn = gr.channel_model(noise, foffset, toffset)
        self.cst = digital.costas_loop_cc(bw, 2)

        self.vsnk_src = gr.vector_sink_c()
        self.vsnk_cst = gr.vector_sink_c()
        self.vsnk_frq = gr.vector_sink_f()

        self.connect(self.src, self.rrc, self.chn, self.cst, self.vsnk_cst)
        self.connect(self.rrc, self.vsnk_src)
        self.connect((self.cst, 1), self.vsnk_frq)
Esempio n. 20
0
    def __init__(self, N, sps, rolloff, ntaps, bw, noise, foffset, toffset,
                 poffset):
        gr.top_block.__init__(self)

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

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

        self.src = gr.vector_source_c(data.tolist(), False)
        self.rrc = gr.interp_fir_filter_ccf(sps, rrc_taps)
        self.chn = gr.channel_model(noise, foffset, toffset)
        self.cst = digital.costas_loop_cc(bw, 2)

        self.vsnk_src = gr.vector_sink_c()
        self.vsnk_cst = gr.vector_sink_c()
        self.vsnk_frq = gr.vector_sink_f()

        self.connect(self.src, self.rrc, self.chn, self.cst, self.vsnk_cst)
        self.connect(self.rrc, self.vsnk_src)
        self.connect((self.cst, 1), self.vsnk_frq)
Esempio n. 21
0
    def __init__(self):
        gr.top_block.__init__(self, "Meteor QPSK LRPT")

        ##################################################
        # Variables
        ##################################################
        self.freq = freq = 137900000
        self.symb_rate = symb_rate = 72000
        self.samp_rate = samp_rate = 128000
        self.doppler_freq = doppler_freq = freq
        self.sps = sps = (samp_rate * 1.0) / (symb_rate * 1.0)
        self.samp_rate_rtlsdr = samp_rate_rtlsdr = 1536000
        self.pll_alpha = pll_alpha = float(sys.argv[2])
        self.doppler_shift = doppler_shift = doppler_freq - freq
        self.decim = decim = 8
        self.clock_alpha = clock_alpha = .001
        self.bitstream_name = bitstream_name = sys.argv[1] + '.s'

        ##################################################
        # Blocks
        ##################################################
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 0.6, 361))
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=int(samp_rate_rtlsdr / samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate_rtlsdr)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(44, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.gpredict_doppler_0 = gpredict.doppler(self.set_doppler_freq,
                                                   "localhost", 4532, True)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            pll_alpha, 4, False)
        self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf(
            digital.constellation_calcdist(
                ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4,
                1).base())
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(
            sps, clock_alpha**2 / 4.0, 0.5, clock_alpha, 0.005)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 127)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   bitstream_name, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, doppler_shift, 1, 0)
        self.analog_rail_ff_0 = analog.rail_ff(-1, 1)
        self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0)
        self.analog_agc_xx_0.set_max_gain(4000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.analog_rail_ff_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_constellation_soft_decoder_cf_1, 0))
        self.connect((self.digital_constellation_soft_decoder_cf_1, 0),
                     (self.analog_rail_ff_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
Esempio n. 22
0
    def __init__(self):
        gr.top_block.__init__(self, "Mpsk Stage6")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Mpsk Stage6")
        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", "mpsk_stage6")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate = samp_rate = 2e6
        self.bps = bps = 500e3
        self.decimation = decimation = int(samp_rate / (bps * sps))
        self.transition_bw = transition_bw = samp_rate / (2 * decimation * 5)
        self.nfilts = nfilts = 32
        self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0
        self.time_offset = time_offset = 1.00
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts)
        self.qpsk = qpsk = digital.constellation_rect(
            ([-1, 0 + 1j, 0 - 1j, 1 + 0.0j]), ([0, 1, 2, 3]), 4, 2, 2, 1,
            1).base()
        self.phase_bw = phase_bw = 6.28 / 100.0
        self.noise_volt = noise_volt = 0.0001
        self.freq_offset = freq_offset = 0
        self.fir_taps = fir_taps = firdes.low_pass(
            1, samp_rate, samp_rate / (2 * decimation), transition_bw)
        self.excess_bw = excess_bw = 0.35
        self.eq_gain = eq_gain = 0.01
        self.delay = delay = 0
        self.channel_freq = channel_freq = 2.4e9
        self.center_freq = center_freq = 2.3995e9
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self.controls = Qt.QTabWidget()
        self.controls_widget_0 = Qt.QWidget()
        self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.controls_widget_0)
        self.controls_grid_layout_0 = Qt.QGridLayout()
        self.controls_layout_0.addLayout(self.controls_grid_layout_0)
        self.controls.addTab(self.controls_widget_0, "Channel")
        self.controls_widget_1 = Qt.QWidget()
        self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.controls_widget_1)
        self.controls_grid_layout_1 = Qt.QGridLayout()
        self.controls_layout_1.addLayout(self.controls_grid_layout_1)
        self.controls.addTab(self.controls_widget_1, "Receiver")
        self.top_grid_layout.addWidget(self.controls, 0, 0, 1, 2)
        self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200)
        self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range,
                                               self.set_timing_loop_bw,
                                               "Time: BW", "slider", float)
        self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0, 0,
                                              1, 1)
        self.received = Qt.QTabWidget()
        self.received_widget_0 = Qt.QWidget()
        self.received_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.received_widget_0)
        self.received_grid_layout_0 = Qt.QGridLayout()
        self.received_layout_0.addLayout(self.received_grid_layout_0)
        self.received.addTab(self.received_widget_0, "Constellation")
        self.received_widget_1 = Qt.QWidget()
        self.received_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.received_widget_1)
        self.received_grid_layout_1 = Qt.QGridLayout()
        self.received_layout_1.addLayout(self.received_grid_layout_1)
        self.received.addTab(self.received_widget_1, "Symbols")
        self.top_grid_layout.addWidget(self.received, 2, 0, 1, 1)
        self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200)
        self._phase_bw_win = RangeWidget(self._phase_bw_range,
                                         self.set_phase_bw, "Phase: Bandwidth",
                                         "slider", float)
        self.controls_grid_layout_1.addWidget(self._phase_bw_win, 0, 2, 1, 1)
        self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200)
        self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain,
                                        "Equalizer: rate", "slider", float)
        self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0, 1, 1, 1)
        self._channel_freq_range = Range(2.4e9 - samp_rate / 2,
                                         2.4e9 + samp_rate / 2, 100, 2.4e9,
                                         200)
        self._channel_freq_win = RangeWidget(self._channel_freq_range,
                                             self.set_channel_freq,
                                             "channel_freq", "counter_slider",
                                             float)
        self.top_grid_layout.addWidget(self._channel_freq_win, 2, 2, 1, 1)
        self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range,
                                            self.set_time_offset,
                                            "Timing Offset", "counter_slider",
                                            float)
        self.controls_grid_layout_0.addWidget(self._time_offset_win, 0, 2, 1,
                                              1)
        self.rms_agc_0 = rms_agc(
            alpha=1e-2,
            reference=0.5,
        )
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1.set_y_label("Amplitude", "")

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

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

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

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_const_sink_x_1_1 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_1_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_1_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1_1.enable_grid(False)

        if not True:
            self.qtgui_const_sink_x_1_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_1_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_1_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_1_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_1_win)
        self.qtgui_const_sink_x_1_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_1_0.set_update_time(0.10)
        self.qtgui_const_sink_x_1_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_1_0.enable_autoscale(False)
        self.qtgui_const_sink_x_1_0.enable_grid(False)

        if not True:
            self.qtgui_const_sink_x_1_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_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_0_win)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1.enable_grid(False)

        if not True:
            self.qtgui_const_sink_x_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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win,
                                              0, 0, 1, 1)
        self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200)
        self._noise_volt_win = RangeWidget(self._noise_volt_range,
                                           self.set_noise_volt,
                                           "Noise Voltage", "counter_slider",
                                           float)
        self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            decimation, (fir_taps), channel_freq - center_freq, samp_rate)
        self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range,
                                            self.set_freq_offset,
                                            "Frequency Offset",
                                            "counter_slider", float)
        self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0, 1, 1,
                                              1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            phase_bw, arity, False)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, eq_gain, 2)
        self._delay_range = Range(0, 200, 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, 1, 0, 1, 1)
        self.channels_channel_model_0_0 = channels.channel_model(
            noise_voltage=0.0,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0 + 1.0j, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   samp_rate, True)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            "/home/ascl/sbandtest/text/fc_2_3995/500kbps/sps2M", True)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   "output", False)
        self.blocks_file_sink_1.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.channels_channel_model_0_0, 0))
        self.connect((self.channels_channel_model_0_0, 0), (self.rms_agc_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.qtgui_const_sink_x_1_1, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.qtgui_const_sink_x_1_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_const_sink_x_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.rms_agc_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Esempio n. 23
0
    def __init__(self):
        gr.top_block.__init__(self, "Sync Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Sync Test")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


        ##################################################
        # Variables
        ##################################################
        self.pream_len = pream_len = 84
        self.samp_rate = samp_rate = 32000
        self.pream = pream = (mapper.preamble_generator(pream_len,511,1033)).get_preamble()
        self.SNR = SNR = 40
        self.Rotation = Rotation = 0
        self.Offset = Offset = 0

        ##################################################
        # Blocks
        ##################################################
        self._SNR_tool_bar = Qt.QToolBar(self)
        self._SNR_tool_bar.addWidget(Qt.QLabel("SNR"+": "))
        self._SNR_line_edit = Qt.QLineEdit(str(self.SNR))
        self._SNR_tool_bar.addWidget(self._SNR_line_edit)
        self._SNR_line_edit.returnPressed.connect(
        	lambda: self.set_SNR(eng_notation.str_to_num(self._SNR_line_edit.text().toAscii())))
        self.top_layout.addWidget(self._SNR_tool_bar)
        self._Rotation_layout = Qt.QVBoxLayout()
        self._Rotation_label = Qt.QLabel("Rotation")
        self._Rotation_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._Rotation_slider.setRange(0, 2*pi, pi/100)
        self._Rotation_slider.setValue(self.Rotation)
        self._Rotation_slider.setMinimumWidth(200)
        self._Rotation_slider.valueChanged.connect(self.set_Rotation)
        self._Rotation_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._Rotation_layout.addWidget(self._Rotation_label)
        self._Rotation_layout.addWidget(self._Rotation_slider)
        self.top_layout.addLayout(self._Rotation_layout)
        self._Offset_layout = Qt.QVBoxLayout()
        self._Offset_tool_bar = Qt.QToolBar(self)
        self._Offset_layout.addWidget(self._Offset_tool_bar)
        self._Offset_tool_bar.addWidget(Qt.QLabel("Offset"+": "))
        self._Offset_counter = Qwt.QwtCounter()
        self._Offset_counter.setRange(-100, 100, 1)
        self._Offset_counter.setNumButtons(2)
        self._Offset_counter.setValue(self.Offset)
        self._Offset_tool_bar.addWidget(self._Offset_counter)
        self._Offset_counter.valueChanged.connect(self.set_Offset)
        self._Offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._Offset_slider.setRange(-100, 100, 1)
        self._Offset_slider.setValue(self.Offset)
        self._Offset_slider.setMinimumWidth(200)
        self._Offset_slider.valueChanged.connect(self.set_Offset)
        self._Offset_layout.addWidget(self._Offset_slider)
        self.top_layout.addLayout(self._Offset_layout)
        self.qtgui_const_sink_x_0_1 = qtgui.const_sink_c(
        	840-84, #size
        	"QT GUI Plot", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_1.set_x_axis(-2, 2)
        self._qtgui_const_sink_x_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_1_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	840-84, #size
        	"QT GUI Plot", #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_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.mapper_preamble_sync_cc_0 = mapper.preamble_sync_cc(pream_len*10, (pream), mapper.PSK8, ([0,1,2,3,4,5,6,7]), .97, .90)
        self.mapper_preamble_insert_bb_0 = mapper.preamble_insert_bb(pream_len*10, (pream))
        self.mapper_mapper_0 = mapper.mapper(mapper.PSK8, ([0,1,2,3,4,5,6,7]))
        self.mapper_demapper_0 = mapper.demapper(mapper.PSK8, ([0,1,2,3,4,5,6,7]))
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1.5*pi/100, 8)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=10**(-SNR/20.0),
        	frequency_offset=Offset,
        	epsilon=1.0,
        	taps=(exp( (0 + 1j*Rotation) ), ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_vector_sink_x_0_0 = blocks.vector_sink_b(1)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(3)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 7, 10000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.mapper_preamble_insert_bb_0, 0), (self.mapper_mapper_0, 0))
        self.connect((self.mapper_preamble_sync_cc_0, 0), (self.mapper_demapper_0, 0))
        self.connect((self.mapper_mapper_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.mapper_preamble_sync_cc_0, 0))
        self.connect((self.mapper_preamble_sync_cc_0, 0), (self.qtgui_const_sink_x_0_1, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.mapper_preamble_insert_bb_0, 0))
        self.connect((self.mapper_demapper_0, 0), (self.blocks_vector_sink_x_0_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0, 0))
Esempio n. 24
0
    def __init__(self):
        gr.top_block.__init__(self, "Cr Application")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Cr Application")
        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", "cr_application")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.usrp_rf_freq = usrp_rf_freq = 2405000000
        self.usrp_int_freq = usrp_int_freq = 2400000000
        self.timing_loop_bw = timing_loop_bw = 6.28/100
        self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j]
        self.samp_rate = samp_rate = 390625
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.phase_bw = phase_bw = 6.28/100
        self.excess_bw = excess_bw = 0.35
        self.eq_gain = eq_gain = 0.01
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self.crew_db_channel_selector_0 = crew.db_channel_selector('test_may14_r1', 'zigbee', 'max', 0.05)
        def _usrp_rf_freq_probe():
        	while True:
        		val = self.crew_db_channel_selector_0.get_freq()
        		try: self.set_usrp_rf_freq(val)
        		except AttributeError, e: pass
        		time.sleep(1.0/(0.2))
        _usrp_rf_freq_thread = threading.Thread(target=_usrp_rf_freq_probe)
        _usrp_rf_freq_thread.daemon = True
        _usrp_rf_freq_thread.start()
        self._usrp_int_freq_layout = Qt.QVBoxLayout()
        self._usrp_int_freq_tool_bar = Qt.QToolBar(self)
        self._usrp_int_freq_layout.addWidget(self._usrp_int_freq_tool_bar)
        self._usrp_int_freq_tool_bar.addWidget(Qt.QLabel("usrp_int_freq"+": "))
        self._usrp_int_freq_counter = Qwt.QwtCounter()
        self._usrp_int_freq_counter.setRange(2400000000, 2480000000, 5000000)
        self._usrp_int_freq_counter.setNumButtons(2)
        self._usrp_int_freq_counter.setValue(self.usrp_int_freq)
        self._usrp_int_freq_tool_bar.addWidget(self._usrp_int_freq_counter)
        self._usrp_int_freq_counter.valueChanged.connect(self.set_usrp_int_freq)
        self._usrp_int_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._usrp_int_freq_slider.setRange(2400000000, 2480000000, 5000000)
        self._usrp_int_freq_slider.setValue(self.usrp_int_freq)
        self._usrp_int_freq_slider.setMinimumWidth(100)
        self._usrp_int_freq_slider.valueChanged.connect(self.set_usrp_int_freq)
        self._usrp_int_freq_layout.addWidget(self._usrp_int_freq_slider)
        self.top_layout.addLayout(self._usrp_int_freq_layout)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	device_addr="addr=192.168.30.2",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(usrp_rf_freq, 0)
        self.uhd_usrp_source_0_0.set_gain(10, 0)
        self.uhd_usrp_sink_1 = uhd.usrp_sink(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		args="addr=192.168.40.2",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_1.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_1.set_center_freq(usrp_int_freq, 0)
        self.uhd_usrp_sink_1.set_gain(40, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	device_addr="addr=192.168.20.2",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(usrp_rf_freq, 0)
        self.uhd_usrp_sink_0.set_gain(10, 0)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate/2, #samp_rate
        	"BER", #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.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, "BER")
        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.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2)
        self.digital_map_bb_0 = digital.map_bb(([0,1,2,3]))
        self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(20, 0.02, 2, qpsk)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=2,
        	sensitivity=1.0,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity)
        self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(qpsk, timing_loop_bw, 0.0001, 0.0002)
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=qpsk,
          differential=True,
          samples_per_symbol=4,
          pre_diff_code=True,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b((170,170), True, 1, [])
        self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blks2_error_rate_0 = grc_blks2.error_rate(
        	type='BER',
        	win_size=1000,
        	bits_per_symbol=1,
        )
        self.analog_random_source_x_1 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_receiver_cb_0, 0))
        self.connect((self.digital_map_bb_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0))
        self.connect((self.blks2_error_rate_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_error_rate_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blks2_error_rate_0, 1))
        self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0))
        self.connect((self.analog_random_source_x_1, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.uhd_usrp_sink_1, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_map_bb_0, 0))
        self.connect((self.blks2_error_rate_0, 0), (self.crew_db_channel_selector_0, 0))
Esempio n. 25
0
    def __init__(self):
        gr.top_block.__init__(self, "Mpsk Stage3")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Mpsk Stage3")
        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", "mpsk_stage3")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.payload = payload = range(256)
        self.nfilts = nfilts = 32
        self.timing_loop_bw = timing_loop_bw = 6.28/100.0
        self.taps = taps = [1.0 + 0.0j, ]
        self.samp_rate = samp_rate = 250e3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts)
        self.qpsk_const = qpsk_const = digital.constellation_rect(([-1, +1]), ([0, 1]), 1, 2, 1, 1, 1).base()
        self.payload_str = payload_str = ''.join(map(lambda x: "{0:08b}".format(x), payload))
        self.gain = gain = 50
        self.freq = freq = 2.3e9
        self.excess_bw = excess_bw = 0.35
        self.delay = delay = 32
        self.decim = decim = 1
        self.arity = arity = 2
        self.access_code_str = access_code_str = "1111100110101"
        self.access_code = access_code = [31, 53]

        ##################################################
        # Blocks
        ##################################################
        self._delay_layout = Qt.QVBoxLayout()
        self._delay_tool_bar = Qt.QToolBar(self)
        self._delay_layout.addWidget(self._delay_tool_bar)
        self._delay_tool_bar.addWidget(Qt.QLabel("delay"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._delay_counter = qwt_counter_pyslot()
        self._delay_counter.setRange(0, 100, 1)
        self._delay_counter.setNumButtons(2)
        self._delay_counter.setValue(self.delay)
        self._delay_tool_bar.addWidget(self._delay_counter)
        self._delay_counter.valueChanged.connect(self.set_delay)
        self._delay_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._delay_slider.setRange(0, 100, 1)
        self._delay_slider.setValue(self.delay)
        self._delay_slider.setMinimumWidth(200)
        self._delay_slider.valueChanged.connect(self.set_delay)
        self._delay_layout.addWidget(self._delay_slider)
        self.top_layout.addLayout(self._delay_layout)
        self.west_stream_trigged_pdu_0 = west.stream_trigged_pdu("start_payload", 2048)
        self.west_ber_pdu_0 = west.ber_pdu(payload_str)
        self._timing_loop_bw_layout = Qt.QVBoxLayout()
        self._timing_loop_bw_label = Qt.QLabel("Time: BW")
        self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005)
        self._timing_loop_bw_slider.setValue(self.timing_loop_bw)
        self._timing_loop_bw_slider.setMinimumWidth(200)
        self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw)
        self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label)
        self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider)
        self.top_grid_layout.addLayout(self._timing_loop_bw_layout, 3,1,1,1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-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)
        
        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_const_sink_x_1_0 = qtgui.const_sink_c(
        	1024, #size
        	"Equalizer", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_1_0.set_update_time(0.10)
        self.qtgui_const_sink_x_1_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_1_0.enable_autoscale(False)
        self.qtgui_const_sink_x_1_0.enable_grid(False)
        
        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_1_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_1_0_win = sip.wrapinstance(self.qtgui_const_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_0_win)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
        	1024, #size
        	"Clock Sync Output", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1.enable_grid(False)
        
        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_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
        	2048, #size
        	"Costas Loop Output", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        
        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_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0,1,1,1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  1,
                  taps=(rrc_taps[:-1]),
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        	
        self._gain_layout = Qt.QVBoxLayout()
        self._gain_tool_bar = Qt.QToolBar(self)
        self._gain_layout.addWidget(self._gain_tool_bar)
        self._gain_tool_bar.addWidget(Qt.QLabel("RF gain"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._gain_counter = qwt_counter_pyslot()
        self._gain_counter.setRange(0, 90, 1)
        self._gain_counter.setNumButtons(2)
        self._gain_counter.setValue(self.gain)
        self._gain_tool_bar.addWidget(self._gain_counter)
        self._gain_counter.valueChanged.connect(self.set_gain)
        self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._gain_slider.setRange(0, 90, 1)
        self._gain_slider.setValue(self.gain)
        self._gain_slider.setMinimumWidth(200)
        self._gain_slider.valueChanged.connect(self.set_gain)
        self._gain_layout.addWidget(self._gain_slider)
        self.top_layout.addLayout(self._gain_layout)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.015, 2)
        self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb(access_code_str, 1)
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=qpsk_const,
          differential=True,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=excess_bw,
          verbose=False,
          log=False,
          )
        (self.digital_constellation_modulator_0).set_processor_affinity([2])
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk_const)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(16, 1, 0.15/100., 1)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(sps*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b([135, 201]*5000 + access_code + payload*100000, False, 1, [])
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.0001, ))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, int(delay))
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 0.3, 0, 8192)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_1, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_char_to_float_0_0, 0))
        self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_correlate_access_code_bb_0, 0), (self.west_stream_trigged_pdu_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_correlate_access_code_bb_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.west_stream_trigged_pdu_0, "pdus", self.west_ber_pdu_0, "pdus")
Esempio n. 26
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.ntaps = ntaps = 1408
        self.nfilts = nfilts = 32
        self.excess_bw = excess_bw = 0.45
        self.timing_bw = timing_bw = 2*pi/100
        self.sr2 = sr2 = 1600e3
        self.samp_rate = samp_rate = 32000
        self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0,excess_bw, ntaps)
        self.freq_bw = freq_bw = 2*pi/100
        self.fll_ntaps = fll_ntaps = 55

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=400e3,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=400e3,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_sample_rate(sr2)
        self.rtlsdr_source_0.set_center_freq(850e6, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(30, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 1)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, excess_bw, 55, freq_bw)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(freq_bw, 4, False)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(10, 1, 0.0001, 1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, 400e3,True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.digital_fll_band_edge_cc_0, 0))    
Esempio n. 27
0
    def __init__(self):
        gr.top_block.__init__(self, "Bob")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Bob")
        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", "bob")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952, 200000
        ]
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = rpower
        self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = jpower
        self.samp_rate = samp_rate = samp_rate_array_MCR[15]

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts)

        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 24e8
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, rpower, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0,
                                       1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._variable_qtgui_range_0_0_range = Range(0, 90, 1, jpower, 200)
        self._variable_qtgui_range_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_range,
            self.set_variable_qtgui_range_0_0, 'Gain_Jamming',
            "counter_slider", float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0,
                                       2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("serial=F5EAC0", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0)
        self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAC0", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX JAMMING USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "RX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Rx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1_0.set_y_axis(-1, 256)

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

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

        if not True:
            self.qtgui_time_sink_x_0_1_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_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win, 2, 3,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 1, 2, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c(
            1024,  #size
            "RX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_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_0_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2,
                                       1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "RX Treated",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                       qtgui.TRIG_SLOPE_POS,
                                                       0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_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_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2,
                                       2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(
            4, ([1, 0, 0, 0]))
        self.interp_fir_filter_xxx_1.declare_sample_delay(0)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(
            pld_const.arity())
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            6.28 / 100.0, pld_const.arity(), False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            pld_const)
        self.digital_cma_equalizer_cc_0_0 = digital.cma_equalizer_cc(
            15, 1, 0.01, 2)
        self.custom_corr = correlate_and_delay.corr_and_delay(
            200 * sps, 0, 0.9995, sps)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            pld_const.bits_per_symbol(), 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, ))
        self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/it/ELI/' + num + '/BOB_55_8000_BRUTO.txt', False)
        self.blocks_file_sink_0_0_0_0_2.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 1, '/home/it/ELI/' + num + '/BOB_EVM.txt',
            False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_char_to_float_1_0_1_0 = blocks.char_to_float(1, 1)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, -5)
        self.adapt_lms_filter_xx_0 = adapt.lms_filter_cc(
            True, 64, 0.0001, 0, 1, True, False, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.adapt_lms_filter_xx_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.adapt_lms_filter_xx_0, 1),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.analog_noise_source_x_0_0, 0),
                     (self.interp_fir_filter_xxx_1, 0))
        self.connect((self.blocks_char_to_float_1_0_1_0, 0),
                     (self.qtgui_time_sink_x_0_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.custom_corr, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_time_sink_x_1_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_char_to_float_1_0_1_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_file_sink_0_0_0_0_2, 0))
        self.connect((self.custom_corr, 0), (self.adapt_lms_filter_xx_0, 1))
        self.connect((self.custom_corr, 1), (self.adapt_lms_filter_xx_0, 0))
        self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0))
        self.connect((self.digital_cma_equalizer_cc_0_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_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, 0))
        self.connect((self.interp_fir_filter_xxx_1, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
Esempio n. 28
0
    def __init__(self, antenna=satnogs.not_set_antenna, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/tmp/.satnogs/data/data', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=1000, enable_iq_dump=0, file_path='test.wav', if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=100e6, rx_sdr_device='usrpb200', udp_IP='127.0.0.1', udp_port=16887, waterfall_file_path='/tmp/waterfall.dat'):
        gr.top_block.__init__(self, "FSK9600 AX.25 decoder ")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.bb_gain = bb_gain
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.file_path = file_path
        self.if_gain = if_gain
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.ppm = ppm
        self.rf_gain = rf_gain
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.rx_sdr_device = rx_sdr_device
        self.udp_IP = udp_IP
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[rx_sdr_device]['samp_rate']
        self.deviation = deviation = 5000
        self.baud_rate = baud_rate = 9600
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate_rx, 125000, 25000, firdes.WIN_HAMMING, 6.76)

        self.taps = taps = firdes.low_pass(12.0, samp_rate_rx, 100e3, 60000, firdes.WIN_HAMMING, 6.76)

        self.modulation_index = modulation_index = deviation / (baud_rate / 2.0)
        self.filter_rate = filter_rate = 250000
        self.audio_samp_rate = audio_samp_rate = 48000
        self.audio_gain = audio_gain = satnogs.fm_demod_settings[rx_sdr_device]['audio_gain']

        ##################################################
        # Blocks
        ##################################################
        self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(audio_samp_rate, 0.0, 10, 1024, waterfall_file_path, 1)
        self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(udp_IP, udp_port, 1500)
        self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, 1000, 1500)
        self.satnogs_quad_demod_filter_ff_0 = satnogs.quad_demod_filter_ff(((audio_samp_rate) / baud_rate)/(math.pi*modulation_index))
        self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(file_path, audio_samp_rate, 1.0)
        self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, '/tmp/iq.bin', False, enable_iq_dump)
        self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink(decoded_data_file_path, 0)
        self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx)
        self.satnogs_ax25_decoder_bm_0 = satnogs.ax25_decoder_bm('GND', 0, True, False, 1024)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args) )
        self.osmosdr_source_0.set_sample_rate(samp_rate_rx)
        self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0)
        self.osmosdr_source_0.set_freq_corr(ppm, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0)
        self.osmosdr_source_0.set_if_gain(satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0)
        self.osmosdr_source_0.set_bb_gain(satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0)
        self.osmosdr_source_0.set_antenna(satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0)

        self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, audio_samp_rate, 7850, audio_samp_rate * 0.15, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate_rx/filter_rate), (xlate_filter_taps), lo_offset, samp_rate_rx)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2.0 * math.pi / 100.0, 2, False)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(48e3/9600, 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True)
        self.blks2_rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=48000,
                decimation=int(samp_rate_rx / (int(samp_rate_rx/filter_rate))),
                taps=None,
                fractional_bw=None,
        )
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(((audio_samp_rate) / baud_rate)/(math.pi*modulation_index))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_frame_file_sink_0_1_0, 'frame'))
        self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq'))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.satnogs_iq_sink_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.satnogs_waterfall_sink_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.satnogs_ax25_decoder_bm_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.satnogs_quad_demod_filter_ff_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.blks2_rational_resampler_xxx_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.satnogs_ogg_encoder_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0))
        self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.satnogs_quad_demod_filter_ff_0, 0), (self.digital_binary_slicer_fb_0, 0))
Esempio n. 29
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Psk31 Rx")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.center_freq = center_freq = 441000000
        self.samp_rate = samp_rate = 960000
        self.psk_offset = psk_offset = 1000
        self.psk_center = psk_center = center_freq + 141000
        self.int_rate = int_rate = 48000
        self.gain = gain = 30
        self.corr = corr = 0
        self.audio_rate = audio_rate = 8000

        ##################################################
        # Message Queues
        ##################################################
        blocks_message_sink_0_msgq_out = wxgui_termsink_0_msgq_in = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        _psk_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._psk_offset_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_psk_offset_sizer,
        	value=self.psk_offset,
        	callback=self.set_psk_offset,
        	label="PSK offset",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._psk_offset_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_psk_offset_sizer,
        	value=self.psk_offset,
        	callback=self.set_psk_offset,
        	minimum=0,
        	maximum=3000,
        	num_steps=300,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_psk_offset_sizer, 1, 0, 1, 2)
        _psk_center_sizer = wx.BoxSizer(wx.VERTICAL)
        self._psk_center_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_psk_center_sizer,
        	value=self.psk_center,
        	callback=self.set_psk_center,
        	label="Tuning",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._psk_center_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_psk_center_sizer,
        	value=self.psk_center,
        	callback=self.set_psk_center,
        	minimum=center_freq + 110000,
        	maximum=center_freq + 150000,
        	num_steps=40,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_psk_center_sizer, 0, 0, 1, 2)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "960 kHz")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "48 kHz")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "4 kHz")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "I/Q scope")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Constellation")
        self.GridAdd(self.nb, 3, 0, 1, 2)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label='gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=49.6,
        	num_steps=124,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_gain_sizer, 2, 0, 1, 1)
        _corr_sizer = wx.BoxSizer(wx.VERTICAL)
        self._corr_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_corr_sizer,
        	value=self.corr,
        	callback=self.set_corr,
        	label='corr',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._corr_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_corr_sizer,
        	value=self.corr,
        	callback=self.set_corr,
        	minimum=-150,
        	maximum=150,
        	num_steps=300,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_corr_sizer, 2, 1, 1, 1)
        self.wxgui_waterfallsink2_2 = waterfallsink2.waterfall_sink_f(
        	self.nb.GetPage(2).GetWin(),
        	baseband_freq=0,
        	dynamic_range=30,
        	ref_level=-40,
        	ref_scale=2.0,
        	sample_rate=audio_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        	win=window.blackmanharris,
        	size=((800,400)),
        )
        self.nb.GetPage(2).Add(self.wxgui_waterfallsink2_2.win)
        def wxgui_waterfallsink2_2_callback(x, y):
        	self.set_psk_offset(x)
        
        self.wxgui_waterfallsink2_2.set_callback(wxgui_waterfallsink2_2_callback)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
        	self.nb.GetPage(1).GetWin(),
        	baseband_freq=psk_center,
        	dynamic_range=30,
        	ref_level=-30,
        	ref_scale=2.0,
        	sample_rate=int_rate,
        	fft_size=2048,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        	size=((800,400)),
        )
        self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_1.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.nb.GetPage(0).GetWin(),
        	baseband_freq=center_freq,
        	dynamic_range=30,
        	ref_level=-20,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=2048,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        	size=((800,400)),
        )
        self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
        def wxgui_waterfallsink2_0_callback(x, y):
        	self.set_psk_center(x)
        
        self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback)
        self.wxgui_termsink_0 = termsink.termsink(
        	parent=self.GetWin(),
        	size=(500,100),
        	msgq=wxgui_termsink_0_msgq_in,
        )
        self.Add(self.wxgui_termsink_0)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
        	self.nb.GetPage(4).GetWin(),
        	title="Scope Plot",
        	sample_rate=31.25,
        	v_scale=0.4,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.nb.GetPage(3).GetWin(),
        	title="Scope Plot",
        	sample_rate=500,
        	v_scale=0.4,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Hz",
        	minval=-500 / math.pi,
        	maxval=500 / math.pi,
        	factor=500 / math.pi,
        	decimal_places=1,
        	ref_level=0,
        	sample_rate=500,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Carrier tracking offset",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(corr, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(0, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.ham_varicode_rx_0 = ham.varicode_rx()
        self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc(16, (firdes.low_pass(10, audio_rate, 120, 40, firdes.WIN_HAMMING, 6.76)), psk_offset, audio_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(samp_rate / int_rate, (firdes.low_pass(1, samp_rate, 12000, 12000, firdes.WIN_HAMMING, 6.76)), round(psk_center - center_freq,-3), samp_rate)
        self.digital_diff_phasor_cc_0 = digital.diff_phasor_cc()
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(5 * math.pi /100.0, 2)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(16, 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_char*1, blocks_message_sink_0_msgq_out, True)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.band_pass_filter_0 = filter.fir_filter_ccc(int_rate / audio_rate, firdes.complex_band_pass(
        	1, int_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(audio_rate, "plughw:0,0", True)
        self.analog_agc_xx_0 = analog.agc_cc(1e-3, 0.1, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.wxgui_waterfallsink2_2, 0))
        self.connect((self.digital_costas_loop_cc_0, 1), (self.wxgui_numbersink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_diff_phasor_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.ham_varicode_rx_0, 0), (self.blocks_message_sink_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.ham_varicode_rx_0, 0))
        self.connect((self.blocks_complex_to_real_1, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_diff_phasor_cc_0, 0), (self.blocks_complex_to_real_1, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_1, 0))
Esempio n. 30
0
    def __init__(self):
        gr.top_block.__init__(self, "QPSK Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("QPSK Test")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


        ##################################################
        # Variables
        ##################################################
        self.sym_rate = sym_rate = 500000
        self.samp_rate = samp_rate = 2000000
        self.sps = sps = int(samp_rate/sym_rate)
        self.nfilts = nfilts = 32
        self.trans_width = trans_width = 10000
        self.timing_loop_bw = timing_loop_bw = 6.28/100.0
        self.time_offset = time_offset = 1.00
        self.taps = taps = [1.0 + 0.0j, ]
        self.sps_out = sps_out = 2
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.phase_bw = phase_bw = 6.28/100.0
        self.noise_volt = noise_volt = 0.0001
        self.freq_offset = freq_offset = 0
        self.filter_gain = filter_gain = 1
        self.excess_bw = excess_bw = 0.35
        self.eq_gain = eq_gain = 0.01
        self.co_freq = co_freq = samp_rate/2
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self.controls = Qt.QTabWidget()
        self.controls_widget_0 = Qt.QWidget()
        self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0)
        self.controls_grid_layout_0 = Qt.QGridLayout()
        self.controls_layout_0.addLayout(self.controls_grid_layout_0)
        self.controls.addTab(self.controls_widget_0, "Channel")
        self.controls_widget_1 = Qt.QWidget()
        self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1)
        self.controls_grid_layout_1 = Qt.QGridLayout()
        self.controls_layout_1.addLayout(self.controls_grid_layout_1)
        self.controls.addTab(self.controls_widget_1, "LPF")
        self.controls_widget_2 = Qt.QWidget()
        self.controls_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_2)
        self.controls_grid_layout_2 = Qt.QGridLayout()
        self.controls_layout_2.addLayout(self.controls_grid_layout_2)
        self.controls.addTab(self.controls_widget_2, "Receiver")
        self.top_grid_layout.addWidget(self.controls, 0,0,1,1)
        self._trans_width_layout = Qt.QHBoxLayout()
        self._trans_width_layout.addWidget(Qt.QLabel("Transition Width"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._trans_width_counter = qwt_counter_pyslot()
        self._trans_width_counter.setRange(1000, 100000, 1000)
        self._trans_width_counter.setNumButtons(2)
        self._trans_width_counter.setMinimumWidth(200)
        self._trans_width_counter.setValue(self.trans_width)
        self._trans_width_layout.addWidget(self._trans_width_counter)
        self._trans_width_counter.valueChanged.connect(self.set_trans_width)
        self.controls_grid_layout_1.addLayout(self._trans_width_layout, 1,0,1,1)
        self._timing_loop_bw_layout = Qt.QHBoxLayout()
        self._timing_loop_bw_layout.addWidget(Qt.QLabel("Timing Loop BW "+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._timing_loop_bw_counter = qwt_counter_pyslot()
        self._timing_loop_bw_counter.setRange(0.0, 0.2, 0.01)
        self._timing_loop_bw_counter.setNumButtons(2)
        self._timing_loop_bw_counter.setMinimumWidth(200)
        self._timing_loop_bw_counter.setValue(self.timing_loop_bw)
        self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_counter)
        self._timing_loop_bw_counter.valueChanged.connect(self.set_timing_loop_bw)
        self.controls_grid_layout_2.addLayout(self._timing_loop_bw_layout,  0,0,1,1)
        self._time_offset_layout = Qt.QHBoxLayout()
        self._time_offset_layout.addWidget(Qt.QLabel("Timing Offset"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._time_offset_counter = qwt_counter_pyslot()
        self._time_offset_counter.setRange(0.995, 1.005, 0.0001)
        self._time_offset_counter.setNumButtons(2)
        self._time_offset_counter.setMinimumWidth(200)
        self._time_offset_counter.setValue(self.time_offset)
        self._time_offset_layout.addWidget(self._time_offset_counter)
        self._time_offset_counter.valueChanged.connect(self.set_time_offset)
        self.controls_grid_layout_0.addLayout(self._time_offset_layout,  1,0,1,1)
        self._phase_bw_layout = Qt.QHBoxLayout()
        self._phase_bw_layout.addWidget(Qt.QLabel("Phase Loop BW   "+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._phase_bw_counter = qwt_counter_pyslot()
        self._phase_bw_counter.setRange(0.0, 1.0, 0.01)
        self._phase_bw_counter.setNumButtons(2)
        self._phase_bw_counter.setMinimumWidth(200)
        self._phase_bw_counter.setValue(self.phase_bw)
        self._phase_bw_layout.addWidget(self._phase_bw_counter)
        self._phase_bw_counter.valueChanged.connect(self.set_phase_bw)
        self.controls_grid_layout_2.addLayout(self._phase_bw_layout,  2,0,1,1)
        self._noise_volt_layout = Qt.QHBoxLayout()
        self._noise_volt_layout.addWidget(Qt.QLabel("Noise Voltage"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._noise_volt_counter = qwt_counter_pyslot()
        self._noise_volt_counter.setRange(0, 1, 0.01)
        self._noise_volt_counter.setNumButtons(2)
        self._noise_volt_counter.setMinimumWidth(200)
        self._noise_volt_counter.setValue(self.noise_volt)
        self._noise_volt_layout.addWidget(self._noise_volt_counter)
        self._noise_volt_counter.valueChanged.connect(self.set_noise_volt)
        self.controls_grid_layout_0.addLayout(self._noise_volt_layout,  0,0,1,1)
        self._freq_offset_layout = Qt.QHBoxLayout()
        self._freq_offset_layout.addWidget(Qt.QLabel("Frequency Offset"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._freq_offset_counter = qwt_counter_pyslot()
        self._freq_offset_counter.setRange(-0.1, 0.1, 0.001)
        self._freq_offset_counter.setNumButtons(2)
        self._freq_offset_counter.setMinimumWidth(200)
        self._freq_offset_counter.setValue(self.freq_offset)
        self._freq_offset_layout.addWidget(self._freq_offset_counter)
        self._freq_offset_counter.valueChanged.connect(self.set_freq_offset)
        self.controls_grid_layout_0.addLayout(self._freq_offset_layout,  2,0,1,1)
        self._filter_gain_layout = Qt.QHBoxLayout()
        self._filter_gain_layout.addWidget(Qt.QLabel("Filter Gain"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._filter_gain_counter = qwt_counter_pyslot()
        self._filter_gain_counter.setRange(1, 10, 1)
        self._filter_gain_counter.setNumButtons(2)
        self._filter_gain_counter.setMinimumWidth(200)
        self._filter_gain_counter.setValue(self.filter_gain)
        self._filter_gain_layout.addWidget(self._filter_gain_counter)
        self._filter_gain_counter.valueChanged.connect(self.set_filter_gain)
        self.controls_grid_layout_1.addLayout(self._filter_gain_layout, 2,0,1,1)
        self.fig_tabs = Qt.QTabWidget()
        self.fig_tabs_widget_0 = Qt.QWidget()
        self.fig_tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.fig_tabs_widget_0)
        self.fig_tabs_grid_layout_0 = Qt.QGridLayout()
        self.fig_tabs_layout_0.addLayout(self.fig_tabs_grid_layout_0)
        self.fig_tabs.addTab(self.fig_tabs_widget_0, "LPF output")
        self.fig_tabs_widget_1 = Qt.QWidget()
        self.fig_tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.fig_tabs_widget_1)
        self.fig_tabs_grid_layout_1 = Qt.QGridLayout()
        self.fig_tabs_layout_1.addLayout(self.fig_tabs_grid_layout_1)
        self.fig_tabs.addTab(self.fig_tabs_widget_1, "PFB output")
        self.fig_tabs_widget_2 = Qt.QWidget()
        self.fig_tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.fig_tabs_widget_2)
        self.fig_tabs_grid_layout_2 = Qt.QGridLayout()
        self.fig_tabs_layout_2.addLayout(self.fig_tabs_grid_layout_2)
        self.fig_tabs.addTab(self.fig_tabs_widget_2, "CMA output")
        self.fig_tabs_widget_3 = Qt.QWidget()
        self.fig_tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.fig_tabs_widget_3)
        self.fig_tabs_grid_layout_3 = Qt.QGridLayout()
        self.fig_tabs_layout_3.addLayout(self.fig_tabs_grid_layout_3)
        self.fig_tabs.addTab(self.fig_tabs_widget_3, "Costas output")
        self.top_grid_layout.addWidget(self.fig_tabs, 1,0,1,2)
        self._eq_gain_layout = Qt.QHBoxLayout()
        self._eq_gain_layout.addWidget(Qt.QLabel("Equalizer Gain     "+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._eq_gain_counter = qwt_counter_pyslot()
        self._eq_gain_counter.setRange(0.0, 0.1, 0.001)
        self._eq_gain_counter.setNumButtons(2)
        self._eq_gain_counter.setMinimumWidth(200)
        self._eq_gain_counter.setValue(self.eq_gain)
        self._eq_gain_layout.addWidget(self._eq_gain_counter)
        self._eq_gain_counter.valueChanged.connect(self.set_eq_gain)
        self.controls_grid_layout_2.addLayout(self._eq_gain_layout,  1,0,1,1)
        self._co_freq_layout = Qt.QHBoxLayout()
        self._co_freq_layout.addWidget(Qt.QLabel("Cutoff Frequency"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._co_freq_counter = qwt_counter_pyslot()
        self._co_freq_counter.setRange(0, samp_rate/2, 100000)
        self._co_freq_counter.setNumButtons(2)
        self._co_freq_counter.setMinimumWidth(200)
        self._co_freq_counter.setValue(self.co_freq)
        self._co_freq_layout.addWidget(self._co_freq_counter)
        self._co_freq_counter.valueChanged.connect(self.set_co_freq)
        self.controls_grid_layout_1.addLayout(self._co_freq_layout, 0,0,1,1)
        self.qtgui_sink_x_0_2 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate*sps_out/sps, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0_2.set_update_time(1.0/10)
        self._qtgui_sink_x_0_2_win = sip.wrapinstance(self.qtgui_sink_x_0_2.pyqwidget(), Qt.QWidget)
        self.fig_tabs_layout_3.addWidget(self._qtgui_sink_x_0_2_win)
        
        self.qtgui_sink_x_0_2.enable_rf_freq(False)
        
        
          
        self.qtgui_sink_x_0_1 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate*sps_out/sps, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0_1.set_update_time(1.0/10)
        self._qtgui_sink_x_0_1_win = sip.wrapinstance(self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.fig_tabs_layout_1.addWidget(self._qtgui_sink_x_0_1_win)
        
        self.qtgui_sink_x_0_1.enable_rf_freq(False)
        
        
          
        self.qtgui_sink_x_0_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0_0.set_update_time(1.0/10)
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.fig_tabs_layout_0.addWidget(self._qtgui_sink_x_0_0_win)
        
        self.qtgui_sink_x_0_0.enable_rf_freq(False)
        
        
          
        self.qtgui_sink_x_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate*sps_out/sps, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0/10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.fig_tabs_layout_2.addWidget(self._qtgui_sink_x_0_win)
        
        self.qtgui_sink_x_0.enable_rf_freq(False)
        
        
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	filter_gain, samp_rate, co_freq, trans_width, firdes.WIN_RECTANGULAR, 6.76))
        self.digital_psk_mod_0 = digital.psk.psk_mod(
          constellation_points=arity,
          mod_code="gray",
          differential=True,
          samples_per_symbol=sps,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, sps_out)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity, False)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(11, 1, eq_gain, sps_out)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=noise_volt,
        	frequency_offset=freq_offset,
        	epsilon=time_offset,
        	taps=(taps),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0))
        self.connect((self.digital_psk_mod_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_sink_x_0_1, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_sink_x_0_2, 0))
        self.connect((self.low_pass_filter_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_cma_equalizer_cc_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_sink_x_0_0, 0))
Esempio n. 31
0
    def __init__(self):
        gr.top_block.__init__(self, "Trcbpsk")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Trcbpsk")
        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", "trcbpsk")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j]
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([1,1j, -1, -1j]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base()
        self.excess_bw = excess_bw = 0.35

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024/2, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10/2)
        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(True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0,0,1,1)
        self.digital_psk_mod_0 = digital.psk.psk_mod(
          constellation_points=4,
          mod_code="gray",
          differential=True,
          samples_per_symbol=sps,
          excess_bw=excess_bw,
          verbose=False,
          log=False,
          )
        self.digital_psk_demod_0 = digital.psk.psk_demod(
          constellation_points=4,
          differential=True,
          samples_per_symbol=sps,
          excess_bw=0.35,
          phase_bw=6.28/100.0,
          timing_bw=6.28/100.0,
          mod_code="gray",
          verbose=False,
          log=False,
          )
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 0.2, (rrc_taps), nfilts, 16, 1.5, sps/4)
        self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(21, 0.000001, 4, qpsk)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(4, excess_bw, 45, 0.034)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(0.34, 4, False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/arun/Desktop/Untitled Folder/abc.txt", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0))    
        self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_psk_demod_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0))    
        self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_costas_loop_cc_0, 0))    
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.digital_fll_band_edge_cc_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0))    
        self.connect((self.digital_psk_demod_0, 0), (self.blks2_packet_decoder_0, 0))    
        self.connect((self.digital_psk_mod_0, 0), (self.blocks_throttle_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "Rx Application")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rx Application")
        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", "rx_application")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.preamble = preamble = [
            1,
            -1,
            1,
            -1,
            1,
            1,
            -1,
            -1,
            1,
            1,
            -1,
            1,
            1,
            1,
            -1,
            1,
            1,
            -1,
            1,
            -1,
            -1,
            1,
            -1,
            -1,
            1,
            1,
            1,
            -1,
            -1,
            -1,
            1,
            -1,
            1,
            1,
            1,
            1,
            -1,
            -1,
            1,
            -1,
            1,
            -1,
            -1,
            -1,
            1,
            1,
            -1,
            -1,
            -1,
            -1,
            1,
            -1,
            -1,
            -1,
            -1,
            -1,
            1,
            1,
            1,
            1,
            1,
            1,
            -1,
            -1,
        ]
        self.nfilts = nfilts = 32
        self.eb = eb = 0.35
        self.usrp_rf_freq = usrp_rf_freq = 2475e6
        self.samp_rate = samp_rate = 200000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0 / float(sps), eb, 5 * sps * nfilts)
        self.preamble_qpsk = preamble_qpsk = map(lambda x: x * (1 + 1j) / pow(2, 0.5), preamble)
        self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11 * sps * nfilts))
        self.gain = gain = 29
        self.digital_gain = digital_gain = 15
        self.addr = addr = "addr=192.168.50.2"

        ##################################################
        # Blocks
        ##################################################
        self._usrp_rf_freq_range = Range(2400e6, 2500e6, 100e3, 2475e6, 200)
        self._usrp_rf_freq_win = RangeWidget(
            self._usrp_rf_freq_range, self.set_usrp_rf_freq, "Rx Frequency", "counter_slider"
        )
        self.top_grid_layout.addWidget(self._usrp_rf_freq_win, 3, 0, 1, 2)
        self._gain_range = Range(0, 40, 0.5, 29, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "Rx Gain", "counter_slider")
        self.top_grid_layout.addWidget(self._gain_win, 1, 0, 1, 2)
        self._digital_gain_range = Range(0, 60, 1, 15, 200)
        self._digital_gain_win = RangeWidget(
            self._digital_gain_range, self.set_digital_gain, "Digital Gain", "counter_slider"
        )
        self.top_grid_layout.addWidget(self._digital_gain_win, 2, 0, 1, 2)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join((addr, "")), uhd.stream_args(cpu_format="fc32", channels=range(1))
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(usrp_rf_freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna("J1", 0)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1)
        self.qtgui_number_sink_0.set_update_time(0.1)
        self.qtgui_number_sink_0.set_title("Packet Received")

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

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

        if not False:
            self.qtgui_const_sink_x_0_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_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0, 0, 1, 1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 2 * 3.14 / 100.0, (rrc_taps), nfilts, 0, 0.5, sps / 4
        )
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, eb, 45, 2 * 3.14 / 100.0)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1 * 3.14 / 50.0, 4, False)
        self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble_qpsk), (matched_filter), sps)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, 0.01, 1)
        self.crew_packet_decoder_cb_0 = crew.packet_decoder_cb((preamble_qpsk))
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((digital_gain,))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.crew_packet_decoder_cb_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.crew_packet_decoder_cb_0, 1), (self.qtgui_number_sink_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_null_sink_0_0, 0))
        self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.crew_packet_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_correlate_and_sync_cc_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
Esempio n. 33
0
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rx")
        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", "rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952
        ]
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22
        self.H_dec = H_dec = fec.ldpc_H_matrix(
            '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist',
            24)
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 30
        self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 52
        self.variable_qtgui_check_box_0 = variable_qtgui_check_box_0 = True
        self.samp_rate = samp_rate = samp_rate_array_MCR[15]

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts)

        self.pld_dec = pld_dec = map((lambda a: fec.ldpc_bit_flip_decoder.make(
            H_dec.get_base_sptr(), 100)), range(0, 8))
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 30, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0,
                                       2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 52, 200)
        self._variable_qtgui_range_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_range,
            self.set_variable_qtgui_range_0_0, 'Gain_Jamming',
            "counter_slider", float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0,
                                       3, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        _variable_qtgui_check_box_0_check_box = Qt.QCheckBox('ENABLE JAM')
        self._variable_qtgui_check_box_0_choices = {True: True, False: False}
        self._variable_qtgui_check_box_0_choices_inv = dict(
            (v, k)
            for k, v in self._variable_qtgui_check_box_0_choices.iteritems())
        self._variable_qtgui_check_box_0_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _variable_qtgui_check_box_0_check_box, "setChecked",
            Qt.Q_ARG("bool", self._variable_qtgui_check_box_0_choices_inv[i]))
        self._variable_qtgui_check_box_0_callback(
            self.variable_qtgui_check_box_0)
        _variable_qtgui_check_box_0_check_box.stateChanged.connect(
            lambda i: self.set_variable_qtgui_check_box_0(
                self._variable_qtgui_check_box_0_choices[bool(i)]))
        self.top_grid_layout.addWidget(_variable_qtgui_check_box_0_check_box,
                                       0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("serial=F5EAC0", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0)
        self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAC0", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.scrambler_cpp_additive_descrambler_0 = scrambler_cpp.additive_descrambler(
            0x8A, 0x7F, 7, 440 - 32)
        self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX JAMMING USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "RX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Rx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256)

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

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

        if not True:
            self.qtgui_time_sink_x_0_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 1, 2, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c(
            1024,  #size
            "RX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_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_0_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2,
                                       1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "RX Treated",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                       qtgui.TRIG_SLOPE_POS,
                                                       0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_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_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2,
                                       2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(
            4, ([1, 0, 0, 0]))
        self.interp_fir_filter_xxx_1.declare_sample_delay(0)
        self.fec_extended_decoder_0_0_1_0_1_0_0 = fec.extended_decoder(
            decoder_obj_list=pld_dec,
            threading='capillary',
            ann=None,
            puncpat=puncpat,
            integration_period=10000)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_map_bb_0_0_0_0_0_0 = digital.map_bb(([-1, 1]))
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(
            pld_const.arity())
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            6.28 / 100.0, pld_const.arity(), False)
        self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts(
            digital.packet_utils.default_access_code, 4, 'packet_len')
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            pld_const)
        self.custom_corr = correlate_and_delay.corr_and_delay(
            200 * sps, 0, 0.99, sps)
        self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb(
            1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            pld_const.bits_per_symbol(), 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, ))
        self.blocks_keep_m_in_n_0_1_1_0 = blocks.keep_m_in_n(
            gr.sizeof_char, 440, 442, 0)
        self.blocks_keep_m_in_n_0_0_2_0_0 = blocks.keep_m_in_n(
            gr.sizeof_char, 1100, 1104, 0)
        self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/it/Desktop/Trasmited/depois.txt', False)
        self.blocks_file_sink_0_0_0_0_2.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   'rx_ber.txt', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1)
        self.blocks_copy_0.set_enabled(variable_qtgui_check_box_0)
        self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_2_0_0_0 = blocks.char_to_float(1, 1)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, -5)
        self.adapt_lms_filter_xx_0 = adapt.lms_filter_cc(
            True, 32, 0.0001, 0, 1, True, False, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.adapt_lms_filter_xx_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.adapt_lms_filter_xx_0, 1),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.analog_noise_source_x_0_0, 0),
                     (self.interp_fir_filter_xxx_1, 0))
        self.connect((self.blocks_char_to_float_0_2_0_0_0, 0),
                     (self.fec_extended_decoder_0_0_1_0_1_0_0, 0))
        self.connect((self.blocks_char_to_float_1_0_1, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_copy_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_keep_m_in_n_0_0_2_0_0, 0),
                     (self.digital_map_bb_0_0_0_0_0_0, 0))
        self.connect((self.blocks_keep_m_in_n_0_1_1_0, 0),
                     (self.scrambler_cpp_additive_descrambler_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_copy_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.custom_corr, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_time_sink_x_1_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_correlate_access_code_xx_ts_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_file_sink_0_0_0_0_2, 0))
        self.connect((self.custom_corr, 0), (self.adapt_lms_filter_xx_0, 1))
        self.connect((self.custom_corr, 1), (self.adapt_lms_filter_xx_0, 0))
        self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0),
                     (self.blocks_keep_m_in_n_0_0_2_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.digital_map_bb_0_0_0_0_0_0, 0),
                     (self.blocks_char_to_float_0_2_0_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.fec_extended_decoder_0_0_1_0_1_0_0, 0),
                     (self.blocks_keep_m_in_n_0_1_1_0, 0))
        self.connect((self.interp_fir_filter_xxx_1, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.scrambler_cpp_additive_descrambler_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0_1_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
Esempio n. 34
0
    def __init__(self):
        gr.top_block.__init__(self, "Mpsk Simul")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Mpsk Simul")
        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", "mpsk_simul")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.nfilts = nfilts = 32
        self.timing_loop_bw = timing_loop_bw = 6.28/100.0
        self.time_offset = time_offset = 1.00
        self.taps = taps = [1.0 + 0.0j, ]
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts)
        self.phase_bw = phase_bw = 6.28/100.0
        self.noise_volt = noise_volt = 0.001
        self.freq_offset = freq_offset = 0
        self.eq_gain = eq_gain = 0.01
        self.arity = arity = 8

        ##################################################
        # Blocks
        ##################################################
        self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28/100.0, 200)
        self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, "Time: BW", "slider", float)
        self.top_grid_layout.addWidget(self._timing_loop_bw_win, 3,1,1,1)
        self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, "Channel: Timing Offset", "slider", float)
        self.top_grid_layout.addWidget(self._time_offset_win, 3,0,1,1)
        self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28/100.0, 200)
        self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, "Phase: Bandwidth", "slider", float)
        self.top_grid_layout.addWidget(self._phase_bw_win, 4,1,1,1)
        self._noise_volt_range = Range(0, 1, 0.01, 0.001, 200)
        self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, "Channel: Noise Voltage", "slider", float)
        self.top_grid_layout.addWidget(self._noise_volt_win, 2,0,1,1)
        self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, "Channel: Frequency Offset", "slider", float)
        self.top_grid_layout.addWidget(self._freq_offset_win, 2,1,1,1)
        self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200)
        self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, "Equalizer: rate", "slider", float)
        self.top_grid_layout.addWidget(self._eq_gain_win, 4,0,1,1)
        self.snr_mpsk_receiver_snr_est_cc_0 = snr.mpsk_receiver_snr_est_cc(10000, 0.001)
        self.snr_channel_model_snr_0 = snr.channel_model_snr(
          noise_voltage=noise_volt,
          frequency_offset=freq_offset,
          epsilon=time_offset,
          taps=(taps),
          noise_seed=0,
          block_tags=False
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	4000, #size
        	samp_rate, #samp_rate
        	"QT GUI Plot", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.01)
        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_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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"QT GUI Plot", #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_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0,1,1,1)
        self.digital_psk_mod_0 = digital.psk.psk_mod(
          constellation_points=arity,
          mod_code="gray",
          differential=True,
          samples_per_symbol=sps,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity, False)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1+1j, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.snr_channel_model_snr_0, 'snr_level_out'), (self.snr_mpsk_receiver_snr_est_cc_0, 'snr_level_in'))    
        self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.snr_channel_model_snr_0, 0))    
        self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 1), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))    
        self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.snr_channel_model_snr_0, 0), (self.snr_mpsk_receiver_snr_est_cc_0, 0))    
        self.connect((self.snr_mpsk_receiver_snr_est_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))    
Esempio n. 35
0
    def __init__(self):
        gr.top_block.__init__(self, "Simulation for SDR TCC")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Simulation for SDR TCC")
        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", "sdrSim2")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.eb = eb = 0.35
        self.timing_loop_bw = timing_loop_bw = 0.005
        self.time_offset = time_offset = 1.00
        self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j]
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1]
        self.phase_bw = phase_bw = 6.28/100.0
        self.payload_size = payload_size = 992
        self.noise_volt = noise_volt = 0.0001
        self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts))
        self.freq_offset = freq_offset = 0
        self.freq_bw = freq_bw = 6.28/100.0
        self.excess_bw = excess_bw = 0.35
        self.eq_gain = eq_gain = 0.01
        self.delay = delay = 0
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self.controls = Qt.QTabWidget()
        self.controls_widget_0 = Qt.QWidget()
        self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0)
        self.controls_grid_layout_0 = Qt.QGridLayout()
        self.controls_layout_0.addLayout(self.controls_grid_layout_0)
        self.controls.addTab(self.controls_widget_0, "Channel")
        self.controls_widget_1 = Qt.QWidget()
        self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1)
        self.controls_grid_layout_1 = Qt.QGridLayout()
        self.controls_layout_1.addLayout(self.controls_grid_layout_1)
        self.controls.addTab(self.controls_widget_1, "Receiver")
        self.top_grid_layout.addWidget(self.controls, 0,0,1,2)
        self._timing_loop_bw_layout = Qt.QVBoxLayout()
        self._timing_loop_bw_label = Qt.QLabel("Time: BW")
        self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005)
        self._timing_loop_bw_slider.setValue(self.timing_loop_bw)
        self._timing_loop_bw_slider.setMinimumWidth(200)
        self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw)
        self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label)
        self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider)
        self.controls_grid_layout_1.addLayout(self._timing_loop_bw_layout,  0,0,1,1)
        self._time_offset_layout = Qt.QVBoxLayout()
        self._time_offset_tool_bar = Qt.QToolBar(self)
        self._time_offset_layout.addWidget(self._time_offset_tool_bar)
        self._time_offset_tool_bar.addWidget(Qt.QLabel("Timing Offset"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._time_offset_counter = qwt_counter_pyslot()
        self._time_offset_counter.setRange(0.999, 1.001, 0.0001)
        self._time_offset_counter.setNumButtons(2)
        self._time_offset_counter.setValue(self.time_offset)
        self._time_offset_tool_bar.addWidget(self._time_offset_counter)
        self._time_offset_counter.valueChanged.connect(self.set_time_offset)
        self._time_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._time_offset_slider.setRange(0.999, 1.001, 0.0001)
        self._time_offset_slider.setValue(self.time_offset)
        self._time_offset_slider.setMinimumWidth(200)
        self._time_offset_slider.valueChanged.connect(self.set_time_offset)
        self._time_offset_layout.addWidget(self._time_offset_slider)
        self.controls_grid_layout_0.addLayout(self._time_offset_layout,  0,2,1,1)
        self.received = Qt.QTabWidget()
        self.received_widget_0 = Qt.QWidget()
        self.received_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_0)
        self.received_grid_layout_0 = Qt.QGridLayout()
        self.received_layout_0.addLayout(self.received_grid_layout_0)
        self.received.addTab(self.received_widget_0, "Constellation")
        self.received_widget_1 = Qt.QWidget()
        self.received_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_1)
        self.received_grid_layout_1 = Qt.QGridLayout()
        self.received_layout_1.addLayout(self.received_grid_layout_1)
        self.received.addTab(self.received_widget_1, "Symbols")
        self.top_grid_layout.addWidget(self.received, 2,0,1,1)
        self._phase_bw_layout = Qt.QVBoxLayout()
        self._phase_bw_label = Qt.QLabel("Phase: Bandwidth")
        self._phase_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._phase_bw_slider.setRange(0.0, 1.0, 0.01)
        self._phase_bw_slider.setValue(self.phase_bw)
        self._phase_bw_slider.setMinimumWidth(200)
        self._phase_bw_slider.valueChanged.connect(self.set_phase_bw)
        self._phase_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._phase_bw_layout.addWidget(self._phase_bw_label)
        self._phase_bw_layout.addWidget(self._phase_bw_slider)
        self.controls_grid_layout_1.addLayout(self._phase_bw_layout,  0,2,1,1)
        self._noise_volt_layout = Qt.QVBoxLayout()
        self._noise_volt_tool_bar = Qt.QToolBar(self)
        self._noise_volt_layout.addWidget(self._noise_volt_tool_bar)
        self._noise_volt_tool_bar.addWidget(Qt.QLabel("Noise Voltage"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._noise_volt_counter = qwt_counter_pyslot()
        self._noise_volt_counter.setRange(0, 1, 0.01)
        self._noise_volt_counter.setNumButtons(2)
        self._noise_volt_counter.setValue(self.noise_volt)
        self._noise_volt_tool_bar.addWidget(self._noise_volt_counter)
        self._noise_volt_counter.valueChanged.connect(self.set_noise_volt)
        self._noise_volt_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._noise_volt_slider.setRange(0, 1, 0.01)
        self._noise_volt_slider.setValue(self.noise_volt)
        self._noise_volt_slider.setMinimumWidth(200)
        self._noise_volt_slider.valueChanged.connect(self.set_noise_volt)
        self._noise_volt_layout.addWidget(self._noise_volt_slider)
        self.controls_grid_layout_0.addLayout(self._noise_volt_layout,  0,0,1,1)
        self._freq_offset_layout = Qt.QVBoxLayout()
        self._freq_offset_tool_bar = Qt.QToolBar(self)
        self._freq_offset_layout.addWidget(self._freq_offset_tool_bar)
        self._freq_offset_tool_bar.addWidget(Qt.QLabel("Frequency Offset"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._freq_offset_counter = qwt_counter_pyslot()
        self._freq_offset_counter.setRange(-0.1, 0.1, 0.001)
        self._freq_offset_counter.setNumButtons(2)
        self._freq_offset_counter.setValue(self.freq_offset)
        self._freq_offset_tool_bar.addWidget(self._freq_offset_counter)
        self._freq_offset_counter.valueChanged.connect(self.set_freq_offset)
        self._freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._freq_offset_slider.setRange(-0.1, 0.1, 0.001)
        self._freq_offset_slider.setValue(self.freq_offset)
        self._freq_offset_slider.setMinimumWidth(200)
        self._freq_offset_slider.valueChanged.connect(self.set_freq_offset)
        self._freq_offset_layout.addWidget(self._freq_offset_slider)
        self.controls_grid_layout_0.addLayout(self._freq_offset_layout,  0,1,1,1)
        self._eq_gain_layout = Qt.QVBoxLayout()
        self._eq_gain_label = Qt.QLabel("Equalizer: rate")
        self._eq_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._eq_gain_slider.setRange(0.0, 0.1, 0.001)
        self._eq_gain_slider.setValue(self.eq_gain)
        self._eq_gain_slider.setMinimumWidth(200)
        self._eq_gain_slider.valueChanged.connect(self.set_eq_gain)
        self._eq_gain_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._eq_gain_layout.addWidget(self._eq_gain_label)
        self._eq_gain_layout.addWidget(self._eq_gain_slider)
        self.controls_grid_layout_1.addLayout(self._eq_gain_layout,  0,1,1,1)
        self._delay_layout = Qt.QVBoxLayout()
        self._delay_tool_bar = Qt.QToolBar(self)
        self._delay_layout.addWidget(self._delay_tool_bar)
        self._delay_tool_bar.addWidget(Qt.QLabel("Delay"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._delay_counter = qwt_counter_pyslot()
        self._delay_counter.setRange(0, 200, 1)
        self._delay_counter.setNumButtons(2)
        self._delay_counter.setValue(self.delay)
        self._delay_tool_bar.addWidget(self._delay_counter)
        self._delay_counter.valueChanged.connect(self.set_delay)
        self._delay_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._delay_slider.setRange(0, 200, 1)
        self._delay_slider.setValue(self.delay)
        self._delay_slider.setMinimumWidth(200)
        self._delay_slider.valueChanged.connect(self.set_delay)
        self._delay_layout.addWidget(self._delay_slider)
        self.top_grid_layout.addLayout(self._delay_layout, 1,0,1,1)
        self.tutorial_my_qpsk_demod_cb_1 = tutorial.my_qpsk_demod_cb(True)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	500, #size
        	samp_rate, #samp_rate
        	"", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 2)
        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 2,1,1,1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	500, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 4)
        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)
        
        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.received_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win,  0,0,1,1)
        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.enable_autoscale(False)
        
        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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win,  0,0,1,1)
        self._freq_bw_layout = Qt.QVBoxLayout()
        self._freq_bw_label = Qt.QLabel("Frequency Bandwidth")
        self._freq_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._freq_bw_slider.setRange(0.0, 1.0, 0.01)
        self._freq_bw_slider.setValue(self.freq_bw)
        self._freq_bw_slider.setMinimumWidth(200)
        self._freq_bw_slider.valueChanged.connect(self.set_freq_bw)
        self._freq_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._freq_bw_layout.addWidget(self._freq_bw_label)
        self._freq_bw_layout.addWidget(self._freq_bw_slider)
        self.controls_grid_layout_1.addLayout(self._freq_bw_layout,  0,3,1,1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2)
        self.digital_map_bb_0 = digital.map_bb(([0,1,3,2]))
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity)
        self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble), (matched_filter), sps)
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=qpsk,
          differential=True,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=excess_bw,
          verbose=False,
          log=False,
          )
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=noise_volt,
        	frequency_offset=freq_offset,
        	epsilon=time_offset,
        	taps=(taps),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b(map(lambda x: (-x+1)/2, preamble), True, 1, [])
        self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)/8,payload_size))
        self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/franchz/tcc/gnuradio/tx_teste.txt", True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/franchz/tcc/gnuradio/rx_teste.txt", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, int(delay))
        self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_char_to_float_0_0_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_mux_0_0_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.digital_correlate_and_sync_cc_0, 0))
        self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_mux_0_0_0, 1))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0))
        self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.tutorial_my_qpsk_demod_cb_1, 0), (self.digital_map_bb_0, 0))
        self.connect((self.digital_map_bb_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.tutorial_my_qpsk_demod_cb_1, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
Esempio n. 36
0
    def __init__(self,
                 ip='127.0.0.1',
                 iq_file='./rocksat_125kbd_500ksps_date_comment.dat',
                 meta_rate=.1,
                 port='52001',
                 record_iq=0,
                 record_rfo=0,
                 record_snr=0,
                 rfo_file='./rocksat_rfo_date_comment.meta',
                 snr_file='./rocksat_snr_date_comment.meta'):
        gr.top_block.__init__(self, "VTGS Rocksat Receiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("VTGS Rocksat Receiver")
        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", "vtgs_rx_1")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.ip = ip
        self.iq_file = iq_file
        self.meta_rate = meta_rate
        self.port = port
        self.record_iq = record_iq
        self.record_rfo = record_rfo
        self.record_snr = record_snr
        self.rfo_file = rfo_file
        self.snr_file = snr_file

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250e3
        self.baud = baud = 125e3 / 2
        self.samps_per_symb = samps_per_symb = int(samp_rate / baud)
        self.rx_freq = rx_freq = 2395e6
        self.alpha = alpha = 0.5
        self.tuned_center = tuned_center = 'baud_0'
        self.rx_offset = rx_offset = 250e3
        self.rx_gain = rx_gain = 10

        self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine(
            32, 1.0, 1.0 / (samps_per_symb * 32), alpha, samps_per_symb * 32)

        self.noise = noise = 0
        self.mult = mult = (samp_rate) / 2 / 3.141593

        self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate,
                                                   samp_rate / 2, 1000,
                                                   firdes.WIN_HAMMING, 6.76)

        self.lo = lo = 1833e6
        self.khz_offset = khz_offset = 0
        self.center_freq_lbl = center_freq_lbl = rx_freq / 1e6

        ##################################################
        # Blocks
        ##################################################
        self._noise_range = Range(0, 1, 0.00001, 0, 200)
        self._noise_win = RangeWidget(self._noise_range, self.set_noise,
                                      "noise", "counter_slider", float)
        self.top_layout.addWidget(self._noise_win)
        self._khz_offset_range = Range(-150, 150, 1, 0, 200)
        self._khz_offset_win = RangeWidget(self._khz_offset_range,
                                           self.set_khz_offset, 'Offset [kHz]',
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._khz_offset_win, 7, 8, 1, 4)
        self.vtgs_mult_descrambler_0 = vtgs.mult_descrambler(17, 0x3FFFF)
        self.vtgs_ao40_decoder_0_0 = vtgs.ao40_decoder()
        self._tuned_center_tool_bar = Qt.QToolBar(self)

        if None:
            self._tuned_center_formatter = None
        else:
            self._tuned_center_formatter = lambda x: x

        self._tuned_center_tool_bar.addWidget(
            Qt.QLabel('        Tuned Center [MHz]' + ": "))
        self._tuned_center_label = Qt.QLabel(
            str(self._tuned_center_formatter(self.tuned_center)))
        self._tuned_center_tool_bar.addWidget(self._tuned_center_label)
        self.top_grid_layout.addWidget(self._tuned_center_tool_bar, 1, 8, 1, 2)

        self._rx_gain_range = Range(0, 86, 1, 10, 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, 6, 8, 1, 4)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            '',  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(True)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not False:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

        labels = ['pre-d', 'post', '', '', '', '', '', '', '', '']
        colors = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-130, -20)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 8,
                                       0, 8, 8)
        self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_1.set_update_time(0.10)
        self.qtgui_number_sink_1.set_title("")

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

        self.qtgui_number_sink_1.enable_autoscale(False)
        self._qtgui_number_sink_1_win = sip.wrapinstance(
            self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_1_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024 * 4,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.0010)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -20)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        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 = ['pre-d', 'post', '', '', '', '', '', '', '', '']
        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(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 8,
                                       8)
        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(-1, 1)
        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(True)
        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_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 8, 8, 8,
                                       4)
        self.mapper_demapper_soft_0 = mapper.demapper_soft(
            mapper.BPSK, ([0, 1]))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000,
                            firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (lpf_taps), khz_offset * 1000, samp_rate)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(
            samps_per_symb, math.pi * 2 / 100, (rrc_filter_taps), 32, 16, 1.5,
            1)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            math.pi * 2 / 100, 2, False)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            math.pi * 2 / 100, 2, False)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self._center_freq_lbl_tool_bar = Qt.QToolBar(self)

        if None:
            self._center_freq_lbl_formatter = None
        else:
            self._center_freq_lbl_formatter = lambda x: x

        self._center_freq_lbl_tool_bar.addWidget(
            Qt.QLabel('Center Frequency [MHz]' + ": "))
        self._center_freq_lbl_label = Qt.QLabel(
            str(self._center_freq_lbl_formatter(self.center_freq_lbl)))
        self._center_freq_lbl_tool_bar.addWidget(self._center_freq_lbl_label)
        self.top_grid_layout.addWidget(self._center_freq_lbl_tool_bar, 0, 8, 1,
                                       2)

        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", ip, port,
                                                     1024, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, ))
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
            itemsize=gr.sizeof_gr_complex * 1,
            addr='127.0.0.1',
            port=5000,
            server=True,
        )
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, noise, 0)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.vtgs_ao40_decoder_0_0, 'valid_frames'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blks2_tcp_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_agc2_xx_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_number_sink_1, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.mapper_demapper_soft_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 1),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.vtgs_mult_descrambler_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.mapper_demapper_soft_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.vtgs_mult_descrambler_0, 0),
                     (self.vtgs_ao40_decoder_0_0, 0))
Esempio n. 37
0
	def __init__(
		self,
		parent,
		title='',
		sample_rate=1,
		size=const_window.DEFAULT_WIN_SIZE,
		frame_rate=const_window.DEFAULT_FRAME_RATE,
		const_size=const_window.DEFAULT_CONST_SIZE,
		#mpsk recv params
		M=4,
		theta=0,
		loop_bw=6.28/100.0,
		fmax=0.06,
		mu=0.5,
		gain_mu=0.005,
		symbol_rate=1,
		omega_limit=0.005,
	):
		#init
		gr.hier_block2.__init__(
			self,
			"const_sink",
			gr.io_signature(1, 1, gr.sizeof_gr_complex),
			gr.io_signature(0, 0, 0),
		)
		#blocks
		sd = blks2.stream_to_vector_decimator(
			item_size=gr.sizeof_gr_complex,
			sample_rate=sample_rate,
			vec_rate=frame_rate,
			vec_len=const_size,
		)
		fmin = -fmax
		gain_omega = .25*gain_mu**2 #redundant, will be updated
		omega = 1 #set_sample_rate will update this
		# Costas frequency/phase recovery loop
		# Critically damped 2nd order PLL
		self._costas = digital.costas_loop_cc(loop_bw, M)
		# Timing recovery loop
		# Critically damped 2nd order DLL
		self._retime = digital.clock_recovery_mm_cc(omega,
							    gain_omega,
							    mu, gain_mu,
							    omega_limit)
		#sync = gr.mpsk_receiver_cc(
		#	M, #psk order
		#	theta,
		#	alpha,
		#	beta,
		#	fmin,
		#	fmax,
		#	mu,
		#	gain_mu,
		#	omega,
		#	gain_omega,
		#	omega_limit,
		#)
		agc = gr.feedforward_agc_cc(16, 1)
		msgq = gr.msg_queue(2)
		sink = gr.message_sink(gr.sizeof_gr_complex*const_size, msgq, True)
		#controller
		def setter(p, k, x): p[k] = x
		self.controller = pubsub()
		self.controller.subscribe(LOOP_BW_KEY, self._costas.set_loop_bandwidth)
		self.controller.publish(LOOP_BW_KEY, self._costas.get_loop_bandwidth)
		self.controller.subscribe(GAIN_MU_KEY, self._retime.set_gain_mu)
		self.controller.publish(GAIN_MU_KEY, self._retime.gain_mu)
		self.controller.subscribe(OMEGA_KEY, self._retime.set_omega)
		self.controller.publish(OMEGA_KEY, self._retime.omega)
		self.controller.subscribe(GAIN_OMEGA_KEY, self._retime.set_gain_omega)
		self.controller.publish(GAIN_OMEGA_KEY, self._retime.gain_omega)
		self.controller.subscribe(SAMPLE_RATE_KEY, sd.set_sample_rate)
		self.controller.subscribe(SAMPLE_RATE_KEY, lambda x: setter(self.controller, OMEGA_KEY, float(x)/symbol_rate))
		self.controller.publish(SAMPLE_RATE_KEY, sd.sample_rate)
		#initial update
		self.controller[SAMPLE_RATE_KEY] = sample_rate
		#start input watcher
		common.input_watcher(msgq, self.controller, MSG_KEY)
		#create window
		self.win = const_window.const_window(
			parent=parent,
			controller=self.controller,
			size=size,
			title=title,
			msg_key=MSG_KEY,
			loop_bw_key=LOOP_BW_KEY,
			gain_mu_key=GAIN_MU_KEY,
			gain_omega_key=GAIN_OMEGA_KEY,
			omega_key=OMEGA_KEY,
			sample_rate_key=SAMPLE_RATE_KEY,
		)
		common.register_access_methods(self, self.win)
		#connect
		self.wxgui_connect(self, self._costas, self._retime, agc, sd, sink)
Esempio n. 38
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")

        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.variable_cc_encoder_def_0 = variable_cc_encoder_def_0 = map(
            (lambda a: fec.cc_encoder_make(4096, 7, 2, ([79, 109]), 0, fec.
                                           CC_STREAMING, False)), range(0, 1))

        self.variable_cc_decoder_def_0 = variable_cc_decoder_def_0 = map(
            (lambda a: fec.cc_decoder.make(4096, 7, 2, ([79, 109]), 0, -1, fec.
                                           CC_STREAMING, False)), range(0, 1))
        self.samp_rate = samp_rate = 500000
        self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001'

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

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.limesdr_source_0 = limesdr.source('1D424A48F1332A', 0, '')
        self.limesdr_source_0.set_sample_rate(samp_rate)
        self.limesdr_source_0.set_center_freq(1.43e9, 0)
        self.limesdr_source_0.set_bandwidth(5e6, 0)
        self.limesdr_source_0.set_digital_filter(500e3, 0)
        self.limesdr_source_0.set_gain(20, 0)
        self.limesdr_source_0.set_antenna(255, 0)

        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=2,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(5e-3, 2, False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/beam/Desktop/SHADE/GnuRadio/out.txt',
            False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code=code1,
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_gmsk_demod_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.limesdr_source_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
Esempio n. 39
0
    def __init__(self, options):
        
        gr.hier_block2.__init__(self, "bpsk_demodulator",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature(0, 0, 0))                    # Output signature
        
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        
        self._samples_per_symbol = options.samples_per_symbol
        
        # Number of bits per symbol
        self._bits_per_symbol = 1
        # Create AGC to scale input to unity
        self._agc = gr.agc_cc(1e-5, 1.0, 1.0, 1.0)
        # Create RRC with specified excess bandwidth
        taps = gr.firdes.root_raised_cosine(1.0,       # Gain
                        self._samples_per_symbol,      # Sampling rate
                        1.0,                           # Symbol rate
                        0.35,                          # Roll-off factor
                        11*self._samples_per_symbol)                  # Number of taps
        
        self._rrc = gr.fir_filter_ccf(1, taps)
        
        # Create a Costas loop frequency/phase recovery block
        self._costas = digital.costas_loop_cc(6.28/100.0, 2)
        self.gr_null_sink_f1 = gr.null_sink(gr.sizeof_float*1)
        
        
        # Create a M&M bit synchronization retiming block        
        self._mm = digital.clock_recovery_mm_cc(self._samples_per_symbol,       # Initial samples/symbol
                                           1e-06,  # Second order gain
                                           0.5,          # Initial symbol phase
                                           0.001,     # First order gain
                                           0.0001) # Maximum timing offset
        
        # Add an SNR probe on the demodulated constellation
        #self._snr_probe = gr.probe_mpsk_snr_c(10.0/symbol_rate)
        self._symbol_rate = options.data_rate / self._bits_per_symbol
        #self._snr_probe = digital.mpsk_snr_est_cc(0, 10000, 0.001) # 0 at the first mean Simple
        
        self._snr_probe = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, alpha=10.0/self._symbol_rate)
        #self._snr_probe = digital.mpsk_snr_est_cc(digital.SNR_EST_SIMPLE, alpha=10.0/self._symbol_rate)
    
  
        # Slice the resulting constellation into bits.
        # Get inphase channel and make decision about 0
        self._c2r = gr.complex_to_real()
        self._slicer = digital.binary_slicer_fb() 
        
        # Descramble BERT sequence.  A channel error will create 3 incorrect bits
        self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 31) # CCSDS 7-bit descrambler

        # Measure BER by the density of 0s in the stream
        # self._ber = gr.probe_density_b(1.0/symbol_rate)
        self._ber = grc_blks2.error_rate(type='BER', 
                                         win_size=1000,
                                         bits_per_symbol=1)
        
        #self.create_number_sink(self._samples_per_symbol)
        self.gr_null_sink_f2 = gr.null_sink(gr.sizeof_float*1)
        
        #Create a vector source reference to calculate BER
        self._vector_source_ref = gr.vector_source_b(([1,]), True, 1)
        
        #create a comparator 
        self.comparator = howto.compare_vector_cci((1, 1, 1, 1 ,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1), (0,0, 1, 1, 0,0), 5, 0, True)
        
        
        #Connection of blocks
        #"""""""""""""""""""""""""""""""""-->_snr_probe-->gr_null_sink_cc
        # agc --> _rrc --> costas --> _mm --> _c2r  -->  _slicer  -->   _descrambler --> _ber --> gr_null_sink_f2
        #"""""""""""""""""""""""""--> gr_null_sink_f1 ""           _vector_source_ref-->
        
#        
#        self.connect(self, self._agc, self._rrc, self._costas, self._mm, 
#                     self._c2r, self._slicer, self._descrambler, self.comparator, (self._ber, 1))
#        
                
        self.connect(self, self._agc, self._rrc, self._costas, self._mm, 
                     self._c2r, self._slicer, self._descrambler, (self._ber, 1))
        
        
        self.connect((self._costas, 1), (self.gr_null_sink_f1, 0))
        self.connect(self._mm, self._snr_probe)
        
        self.connect(self._vector_source_ref, (self._ber,0)) 
        self.connect(self._ber, self.gr_null_sink_f2)
Esempio n. 40
0
    def __init__(self):
        gr.top_block.__init__(self, "Byte Construction")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Byte Construction")
        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", "byte_construction")

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

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0
        self.time_offset = time_offset = 1.00
        self.taps = taps = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j]
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.phase_bw = phase_bw = 6.28 / 100.0
        self.noise_volt = noise_volt = 0.0001
        self.freq_offset = freq_offset = 0
        self.excess_bw = excess_bw = 0.35
        self.eq_gain = eq_gain = 0.01
        self.delay = delay = 58
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self.controls = Qt.QTabWidget()
        self.controls_widget_0 = Qt.QWidget()
        self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.controls_widget_0)
        self.controls_grid_layout_0 = Qt.QGridLayout()
        self.controls_layout_0.addLayout(self.controls_grid_layout_0)
        self.controls.addTab(self.controls_widget_0, 'Channel')
        self.controls_widget_1 = Qt.QWidget()
        self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.controls_widget_1)
        self.controls_grid_layout_1 = Qt.QGridLayout()
        self.controls_layout_1.addLayout(self.controls_grid_layout_1)
        self.controls.addTab(self.controls_widget_1, 'Receiver')
        self.top_grid_layout.addWidget(self.controls, 0, 0, 1, 2)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)]
        self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200)
        self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range,
                                               self.set_timing_loop_bw,
                                               'Time: BW', "slider", float)
        self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0, 0,
                                              1, 1)
        [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)]
        [
            self.controls_grid_layout_1.setColumnStretch(c, 1)
            for c in range(0, 1)
        ]
        self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range,
                                            self.set_time_offset,
                                            'Timing Offset', "counter_slider",
                                            float)
        self.controls_grid_layout_0.addWidget(self._time_offset_win, 0, 2, 1,
                                              1)
        [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)]
        [
            self.controls_grid_layout_0.setColumnStretch(c, 1)
            for c in range(2, 3)
        ]
        self.received = Qt.QTabWidget()
        self.received_widget_0 = Qt.QWidget()
        self.received_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.received_widget_0)
        self.received_grid_layout_0 = Qt.QGridLayout()
        self.received_layout_0.addLayout(self.received_grid_layout_0)
        self.received.addTab(self.received_widget_0, 'Constellation')
        self.received_widget_1 = Qt.QWidget()
        self.received_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.received_widget_1)
        self.received_grid_layout_1 = Qt.QGridLayout()
        self.received_layout_1.addLayout(self.received_grid_layout_1)
        self.received.addTab(self.received_widget_1, 'Symbols')
        self.top_grid_layout.addWidget(self.received, 2, 0, 1, 1)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)]
        self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200)
        self._phase_bw_win = RangeWidget(self._phase_bw_range,
                                         self.set_phase_bw, 'Phase: Bandwidth',
                                         "slider", float)
        self.controls_grid_layout_1.addWidget(self._phase_bw_win, 0, 2, 1, 1)
        [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)]
        [
            self.controls_grid_layout_1.setColumnStretch(c, 1)
            for c in range(2, 3)
        ]
        self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200)
        self._noise_volt_win = RangeWidget(self._noise_volt_range,
                                           self.set_noise_volt,
                                           'Noise Voltage', "counter_slider",
                                           float)
        self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1)
        [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)]
        [
            self.controls_grid_layout_0.setColumnStretch(c, 1)
            for c in range(0, 1)
        ]
        self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range,
                                            self.set_freq_offset,
                                            'Frequency Offset',
                                            "counter_slider", float)
        self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0, 1, 1,
                                              1)
        [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)]
        [
            self.controls_grid_layout_0.setColumnStretch(c, 1)
            for c in range(1, 2)
        ]
        self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200)
        self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain,
                                        'Equalizer: rate', "slider", float)
        self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0, 1, 1, 1)
        [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)]
        [
            self.controls_grid_layout_1.setColumnStretch(c, 1)
            for c in range(1, 2)
        ]
        self._delay_range = Range(0, 200, 1, 58, 200)
        self._delay_win = RangeWidget(self._delay_range, self.set_delay,
                                      'Delay', "counter_slider", float)
        self.top_grid_layout.addWidget(self._delay_win, 1, 0, 1, 1)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)]
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "Input mins Output stream",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            500,  #size
            samp_rate,  #samp_rate
            '',  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 2)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 2, 1,
                                       1, 1)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)]
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            500,  #size
            samp_rate,  #samp_rate
            '',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 4)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['Symbols', '', '', '', '', '', '', '', '', '']
        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.received_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0,
                                              0, 1, 1)
        [self.received_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)]
        [
            self.received_grid_layout_1.setColumnStretch(c, 1)
            for c in range(0, 1)
        ]
        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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win,
                                              0, 0, 1, 1)
        [self.received_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)]
        [
            self.received_grid_layout_0.setColumnStretch(c, 1)
            for c in range(0, 1)
        ]
        self.myblocks_qpsk_demod_v2_0 = myblocks.qpsk_demod_v2(0)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_map_bb_0 = digital.map_bb(([0, 3, 2, 1]))
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            phase_bw, arity, False)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=qpsk,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=excess_bw,
            verbose=False,
            log=False,
        )
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, eq_gain, 2)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise_volt,
            frequency_offset=freq_offset,
            epsilon=time_offset,
            taps=(taps),
            noise_seed=0,
            block_tags=False)
        self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        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, int(delay))
        self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 256, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_unpack_k_bits_bb_0_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_char_to_float_0_0_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0_0, 0),
                     (self.blocks_char_to_float_0_0_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_modulator_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.myblocks_qpsk_demod_v2_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.myblocks_qpsk_demod_v2_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.myblocks_qpsk_demod_v2_0, 0),
                     (self.digital_map_bb_0, 0))
Esempio n. 41
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.sps = sps = 4
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11 * nfilts * sps
        self.excess_bw = excess_bw = 0.4
        self.tx_taps = tx_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.1, excess_bw, ntaps)
        self.timing_bw = timing_bw = 2 * pi / 100
        self.samp_rate = samp_rate = 80000
        self.rx_taps = rx_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.1, excess_bw, ntaps)
        self.gain2 = gain2 = 0
        self.gain = gain = 0.22
        self.freq_bw = freq_bw = 2 * pi / 100
        self.const_points = const_points = 8

        ##################################################
        # Blocks
        ##################################################
        self._gain2_layout = Qt.QVBoxLayout()
        self._gain2_tool_bar = Qt.QToolBar(self)
        self._gain2_layout.addWidget(self._gain2_tool_bar)
        self._gain2_tool_bar.addWidget(Qt.QLabel("gain2" + ": "))

        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)

            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)

        self._gain2_counter = qwt_counter_pyslot()
        self._gain2_counter.setRange(-100e6, 100e6, 100e3)
        self._gain2_counter.setNumButtons(2)
        self._gain2_counter.setValue(self.gain2)
        self._gain2_tool_bar.addWidget(self._gain2_counter)
        self._gain2_counter.valueChanged.connect(self.set_gain2)
        self._gain2_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal,
                                           Qwt.QwtSlider.BottomScale,
                                           Qwt.QwtSlider.BgSlot)
        self._gain2_slider.setRange(-100e6, 100e6, 100e3)
        self._gain2_slider.setValue(self.gain2)
        self._gain2_slider.setMinimumWidth(200)
        self._gain2_slider.valueChanged.connect(self.set_gain2)
        self._gain2_layout.addWidget(self._gain2_slider)
        self.top_layout.addLayout(self._gain2_layout)
        self._gain_layout = Qt.QVBoxLayout()
        self._gain_tool_bar = Qt.QToolBar(self)
        self._gain_layout.addWidget(self._gain_tool_bar)
        self._gain_tool_bar.addWidget(Qt.QLabel("gain" + ": "))

        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)

            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)

        self._gain_counter = qwt_counter_pyslot()
        self._gain_counter.setRange(0, 1, 0.001)
        self._gain_counter.setNumButtons(2)
        self._gain_counter.setValue(self.gain)
        self._gain_tool_bar.addWidget(self._gain_counter)
        self._gain_counter.valueChanged.connect(self.set_gain)
        self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal,
                                          Qwt.QwtSlider.BottomScale,
                                          Qwt.QwtSlider.BgSlot)
        self._gain_slider.setRange(0, 1, 0.001)
        self._gain_slider.setValue(self.gain)
        self._gain_slider.setMinimumWidth(200)
        self._gain_slider.valueChanged.connect(self.set_gain)
        self._gain_layout.addWidget(self._gain_slider)
        self.top_layout.addLayout(self._gain_layout)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "")
        self.rtlsdr_source_0.set_sample_rate(1600e3)
        self.rtlsdr_source_0.set_center_freq(1.2e9 + gain2, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(50, 0)
        self.rtlsdr_source_0.set_if_gain(50, 0)
        self.rtlsdr_source_0.set_bb_gain(50, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "QT GUI Plot",  #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)

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 1)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(
            4, 0.4, 55, freq_bw)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(freq_bw, 8)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            10, 1, gain, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
Esempio n. 42
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.sps = sps = 45
        self.nfilts = nfilts = 25
        self.samp_rate = samp_rate = 44.1E3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts)
        self.fc_slider = fc_slider = 2200
        self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]),
                                                          4, 1).base()

        ##################################################
        # Blocks
        ##################################################
        self._fc_slider_range = Range(0, 18200, 200, 2200, 150)
        self._fc_slider_win = RangeWidget(self._fc_slider_range,
                                          self.set_fc_slider, "fc",
                                          "counter_slider", float)
        self.top_layout.addWidget(self._fc_slider_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "Sinal capturado pelo mic",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.5)
        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(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.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1.1E3, .6E3, firdes.WIN_HAMMING,
                            6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, .063, (rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(
            8, .01, 1, BPSK)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.05, 2, False)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
            itemsize=gr.sizeof_char * 1,
            addr="127.0.0.1",
            port=1234,
            server=False,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code="",
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )
        self.audio_source_0 = audio.source(44100, "", True)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0)
        self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_feedforward_agc_cc_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.audio_source_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blks2_tcp_sink_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_lms_dd_equalizer_cc_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_feedforward_agc_cc_0, 0))
Esempio n. 43
0
    def __init__(self, channel_noise, img_path):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.taps = taps = [1]
        self.size_packed_file = size_packed_file = os.path.getsize(
            "/home/rcampello/Main/FixedPath/OOT Gnuradio/Material/GnuRadio/Scripts/BPSK/{}"
            .format(str(img_path)))
        self.samp_rate = samp_rate = 32000 * 20
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            32, 32, 1.0 / float(2), 0.35, 11 * 2 * 32)
        self.noise = noise = channel_noise
        self.eq_gain = eq_gain = 0
        self.delay2 = delay2 = int(8)
        self.delay = delay = int(2)

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

        ##################################################
        # Blocks
        ##################################################
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            4, 62.8e-3, (rrc_taps), 32, 16, 1.5, 2)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            62.8e-3, 2, False)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=BPSK,
            differential=False,
            samples_per_symbol=4,
            pre_diff_code=True,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            BPSK)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, eq_gain, 2)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(taps),
            noise_seed=0,
            block_tags=False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_char * 1,
                                                   int(size_packed_file * 0.1))
        self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_head_0_0 = blocks.head(gr.sizeof_char * 1,
                                           int(size_packed_file * 2))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/rcampello/Main/FixedPath/OOT Gnuradio/Material/GnuRadio/Scripts/BPSK/{}'
            .format(str(img_path)), True)
        self.sink = blocks.vector_sink_b()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_head_0_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.sink, 0))
        self.connect((self.blocks_pack_k_bits_bb_1, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_skiphead_0_0, 0), (self.blocks_head_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_skiphead_0_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.blocks_pack_k_bits_bb_1, 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_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
Esempio n. 44
0
    def __init__(self, options):
	grc_wxgui.top_block_gui.__init__(self, title="DSSDR")

	self.initialized = False
	self.stopped = False

	self.options = copy.copy(options)
	self._constellation = digital.constellation_bpsk()
	self._excess_bw = options.excess_bw
	self._phase_bw = options.phase_bw
	self._freq_bw = options.freq_bw
	self._timing_bw = options.timing_bw
	self._if_freq = options.if_freq
	self._timing_max_dev= 1.5
	self._demod_class = digital.bpsk_demod  # the demodulator_class we're using
	self._chbw_factor = options.chbw_factor # channel filter bandwidth factor
	self._samples_per_second = 2e6
	self._nav_samples_per_second = 16e6
	self._down_decim = 1
	self._down_samples_per_second = self._scope_sample_rate = self._samples_per_second/self._down_decim
	self._up_samples_per_second = 1e6
	self._asm_threshold = 0
	self._access_code = None
	self._tm_packet_id = 4
	self._timestamp_id = 5
	self._down_bitrate = options.bitrate
	self._up_bitrate = options.up_bitrate
	self._up_samples_per_symbol = self._up_samples_per_second/self._up_bitrate
	self._samples_per_symbol = self._samples_per_second/self._down_decim/self._down_bitrate
	self._down_sub_freq = options.down_sub_freq
	self._up_sub_freq = 25e3
	self._tm_len = 8920
	self._up_tm_len = 8920
	self._coding_method = options.coding_method
	self._up_coding_method = 'None'
	self._up_subcarrier = 'Square'
	self._rs_i = 1
	self._ccsds_channel = 38
	self._uhd_carrier_offset = 10e3
	self._turn_div = 749
	self._turn_mult = 880
	self._modulation_index = 'pi/3'
	self._up_modulation_index = 1.047
	self._max_carrier_offset = 0.1
	self._dssdr_mixer_freq = options.rf_freq
	self._up_coding_rate = '1'
	self._down_coding_rate = '1'
	self._down_conv_en = "False"
	self._down_randomizer_en = options.down_randomizer_en
	self._down_manchester_en = options.down_manchester_en
	self._up_conv_en = "False"
	self._up_idle_sequence = "\\x55"
	self._down_default_gain = 64
	self._up_default_gain = 44
	self._up_en = True

        if self._access_code is None:
            self._access_code = packet_utils.default_access_code

	#Construct the lookup table for parameter-setting functions
	self.param_setters = {
		"DSSDR_CHANNEL": self.setChannel,
		"DSSDR_LO_FREQ": self.setLOFreq,
		"DSSDR_REF_FREQ": self.setRefFreq,
		"DSSDR_TURN_MULT": self.setTurnMult,
		"DSSDR_TURN_DIV": self.setTurnDiv,
		"DSSDR_UP_GAIN": self.setUpGain,
		"DSSDR_DOWN_GAIN": self.setDownGain,
		"DSSDR_UP_BITRATE": self.setUpBitrate,
		"DSSDR_DOWN_BITRATE": self.setDownBitrate,
		"DSSDR_DOWN_SAMPLE_RATE": self.setSampRate,
		"DSSDR_UP_SUB_FREQ": self.setUpSubFreq,
		"DSSDR_DOWN_SUB_FREQ": self.setDownSubFreq,
		"DSSDR_DOPPLER_REPORT": self.dopplerReport,
		"DSSDR_PN_RANGE": self.rangePN,
		"DSSDR_SEQUENTIAL_RANGE": self.rangeSequential,
		"DSSDR_DOWN_CODING_METHOD": self.setDownCodingMethod,
		"DSSDR_UP_CODING_METHOD": self.setUpCodingMethod,
		"DSSDR_DOWN_TM_LEN": self.setTMLen,
		"DSSDR_UP_TM_LEN": self.setUpTMLen,
		"DSSDR_DOWN_MOD_IDX": self.setDownModulationIndex,
		"DSSDR_UP_MOD_IDX": self.setUpModulationIndex,
		"DSSDR_DOWN_CONV_EN": self.setDownConvEn,
		"DSSDR_UP_CONV_EN": self.setUpConvEn,
		"DSSDR_ASM_TOL": self.setASMThreshold,
		"DSSDR_UP_SWEEP": self.freqSweep,
		"DSSDR_UP_IDLE": self.setUpIdleSequence,
		"DSSDR_UP_EN": self.setUpEn,
		"DSSDR_SYNC_TIME": self.syncSDRTime,
		"DSSDR_UP_SWEEP": self.freqSweep,
		"DSSDR_DOWN_ACQUIRE": self.acquireCarrier,
		"DSSDR_INPUT_SELECT": self.setPanelSelect,
		"DSSDR_REF_SELECT": self.setRefSelect,
		"DSSDR_PPS_SELECT": self.setPPSSelect
	}

	#TODO:Add status fields for things like DSSDR_REF_LOCK

	self._dssdr_channels = {
		3: [7149597994, 8400061729],
		4: [7150753857, 8401419752],
		5: [7151909723, 8402777779],
		6: [7153065586, 8404135802],
		7: [7154221449, 8405493825],
		8: [7155377316, 8406851853],
		9: [7156533179, 8408209877],
		10: [7157689045, 8409567903],
		11: [7158844908, 8410925927],
		12: [7160000771, 8412283950],
		13: [7161156637, 8413641977],
		14: [7162312500, 8415000000],
		15: [7163468363, 8416358023],
		16: [7164624229, 8417716050],
		17: [7165780092, 8419074073],
		18: [7166935955, 8420432097],
		19: [7168091821, 8421790123],
		20: [7169247684, 8423148147],
		21: [7170403551, 8424506175],
		22: [7171559414, 8425864198],
		23: [7172715277, 8427222221],
		24: [7173871143, 8428580248],
		25: [7175027006, 8429938271],
		26: [7176182869, 8431296295],
		27: [7177338735, 8432654321],
		28: [7178494598, 8434012345],
		29: [7179650464, 8435370372],
		30: [7180806327, 8436728395],
		31: [7181962190, 8438086418],
		32: [7183118057, 8439444446],
		33: [7184273920, 8440802469],
		34: [7185429783, 8442160493],
		35: [7186585649, 8443518520],
		36: [7187741512, 8444876543],
		37: [7188897378, 8446234570],
		38: [7190000000, 8450000000],
	}

	#FLOWGRAPH STUFF
	if options.test == True:
		self.u = blks2.tcp_source(
			itemsize=gr.sizeof_gr_complex*1,
			addr="",
			port=12905,
			server=True
		)
	elif options.fromfile == True:
		self.u2 = blocks.file_meta_source("iq_in.dat")
		self.u = blocks.throttle(gr.sizeof_gr_complex*1, self._samples_per_second)
	elif options.frombitlog == True:
		self.u3 = blocks.file_source(gr.sizeof_char, "bitstream_recording.in", True)
		self.u2 = blocks.uchar_to_float()
		self.u1 = blocks.throttle(gr.sizeof_float*1, self._down_bitrate)
		self.u = blocks.add_const_ff(-0.5)
	else:
		self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
		self.u.set_clock_source("external")
		self.u.set_time_source("external")
		self.u.set_samp_rate(self._samples_per_second)
		self.u.set_antenna("RX2")
		self.u.set_gain(self._down_default_gain)

		self.frontend = dfi.dssdrFrontendInterface(self.u)

	if options.debug_pps == True:
		self.debug_pps = blocks.tag_debug(gr.sizeof_gr_complex, "debug-pps", "rx_time")

	if options.tofile == True:
		self.u_tx = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_out.dat", self._up_samples_per_second)
	elif options.tonull == True:
		self.u_tx = blocks.null_sink(gr.sizeof_gr_complex)
	else:
		self.u_tx = uhd.usrp_sink(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
		self.u_tx.set_clock_source("external")
		self.u_tx.set_time_source("external")
		self.u_tx.set_samp_rate(self._up_samples_per_second)
		self.u_tx.set_antenna("TX/RX")
		self.u_tx.set_gain(self._up_default_gain)

	#GUI STUFF
	if options.graphics == True:
		self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "RX")
		self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "TX")
		self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Nav")
		self.Add(self.nb0)
		self.constellation_scope = scopesink2.scope_sink_c(
			self.nb0.GetPage(0).GetWin(),
			title="Scope Plot",
			sample_rate=self._scope_sample_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=True,
			num_inputs=1,
			trig_mode=wxgui.TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
	        self.nb0.GetPage(0).Add(self.constellation_scope.win)
		#self.constellation_scope.win.set_marker('plus')
		self._scope_is_fft = False
		self.time_scope = scopesink2.scope_sink_f(
			self.nb0.GetPage(0).GetWin(),
			title="Scope Plot",
			sample_rate=self._scope_sample_rate,
			v_scale=0,
			v_offset=0,
			t_scale=.005,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=wxgui.TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.nb0.GetPage(0).Add(self.time_scope.win)
		self.nb0.GetPage(0).GetWin()._box.Hide(self.time_scope.win)
		self.fft_scope = fftsink2.fft_sink_c(
			self.nb0.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=self._scope_sample_rate,
			fft_size=1024,
		 	fft_rate=15,
			average=False,
			avg_alpha=None,
			title="FFT Plot",
			peak_hold=False,
		)
		self.nb0.GetPage(0).Add(self.fft_scope.win)
		self.nb0.GetPage(0).GetWin()._box.Hide(self.fft_scope.win)
	
		self.row1_sizer = wx.BoxSizer(wx.HORIZONTAL)
		self.recording_onoff_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Off',
			callback=self.setRecording,
			label="IQ Recording",
			choices=['Off','On'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.front_panel_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='RF',
			callback=self.setPanelSelect,
			label="Input Select",
			choices=['RF','IF'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.ref_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Internal',
			callback=self.setRefSelect,
			label="Ref Select",
			choices=['Internal','External'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.pps_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Internal',
			callback=self.setPPSSelect,
			label="PPS Select",
			choices=['Internal','External'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)

		self.sync_button = forms.button(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Sync to PPS',
			callback=self.syncSDRTime,
			choices=['Sync to PPS'],
			style=wx.RA_HORIZONTAL,
		)
		self.ref_locked_text = forms.static_text(
			parent=self.nb0.GetPage(0).GetWin(),
			value="",
			callback=self.setRefLocked,
			label="",
			converter=forms.str_converter(),
		)
		self.row1_sizer.Add(self.recording_onoff_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.front_panel_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.ref_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.pps_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.sync_button, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.ref_locked_text, flag=wx.ALIGN_CENTER)
		self.nb0.GetPage(0).Add(self.row1_sizer)
		self.complex_scope_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Constellation',
			callback=self.setComplexScopeStyle,
			label="Complex Scope",
			choices=['Constellation','FFT'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self.complex_scope_chooser)
		self.scope_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='USRP',
			callback=self.setScopePoint,
			label="Scope Probe Point",
			choices=['USRP','Carrier Tracking','Sub-Carrier Costas','Sub-Carrier Sync','Data Sync'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self.scope_chooser)
		self._bitrate_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_bitrate,
			callback=self.setDownBitrate,
			label="Symbol Rate",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._bitrate_text_box)
		self._samprate_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._samples_per_second,
			callback=self.setSampRate,
			label="Sampling Rate",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._samprate_text_box)
		self._subcfreq_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_sub_freq,
			callback=self.setDownSubFreq,
			label="Downlink Subcarrier Frequency",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._subcfreq_text_box)
		self._mod_index_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._modulation_index,
			callback=self.setDownModulationIndex,
			label="Modulation Index",
			choices=['pi/2', 'pi/3'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self._mod_index_chooser)
		self._pktlen_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._tm_len,
			callback=self.setTMLen,
			label="Downlink Packet Length (bits)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._pktlen_text_box)
		self._coding_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._coding_method,
			callback=self.setDownCodingMethod,
			label="Coding",
			choices=['None', 'RS', 'Turbo 1/2', 'Turbo 1/3', 'Turbo 1/4', 'Turbo 1/6'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self._coding_chooser)
		self._down_conv_check_box = forms.check_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_conv_en,
			callback=self.setDownConvEn,
			label="Convolutional Decode",
			true="True",
			false="False",
		)
		self.nb0.GetPage(0).Add(self._down_conv_check_box)
		self._down_randomizer_check_box = forms.check_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_randomizer_en,
			callback=self.setDownRandomizerEn,
			label="De-randomizer",
			true=True,
			false=False,
		)
		self.nb0.GetPage(0).Add(self._down_randomizer_check_box)
		self._down_manchester_check_box = forms.check_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_manchester_en,
			callback=self.setDownManchesterEn,
			label="Manchester Decode",
			true=True,
			false=False,
		)
		self.nb0.GetPage(0).Add(self._down_manchester_check_box)
		self._pktlen_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._asm_threshold,
			callback=self.setASMThreshold,
			label="ASM Error Tolerance (bits)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._pktlen_text_box)
		self._coding_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._rs_i,
			callback=self.setRSI,
			label="Reed-Solomon Interleaving Depth",
			choices=[1,5],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self._coding_chooser)
		self._ccsds_chan_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._ccsds_channel,
			callback=self.setChannel,
			label="CCSDS Channel",
			converter=forms.int_converter(),
		)
		self.nb0.GetPage(0).Add(self._ccsds_chan_text_box)
		self.setChannel(self._ccsds_channel)
	
		if options.test == True or options.fromfile == True or options.frombitlog == True:
			glow = 0.0
			ghigh = 1.0
			cur_g = 0.5
		else:
			g = self.u.get_gain_range()
			cur_g = self._down_default_gain
		
			# some configurations don't have gain control
			if g.stop() <= g.start():
				glow = 0.0
				ghigh = 1.0
		
			else:
				glow = g.start()
				ghigh = g.stop()
		
		self._uhd_gain_slider = wx.BoxSizer(wx.HORIZONTAL)
		form.slider_field(
			parent=self.nb0.GetPage(0).GetWin(),
			sizer=self._uhd_gain_slider,
			label="USRP RX Gain",
			weight=3,
			min=int(glow), 
			max=int(ghigh),
			value=cur_g,
			callback=self.setDownGain
		)
		self.nb0.GetPage(0).Add(self._uhd_gain_slider)

		#TX chain GUI components
		if options.test == True or options.tofile == True or options.tonull == True:
			gtxlow = 0.0
			gtxhigh = 1.0
			cur_gtx = 0.5
		else:
			gtx = self.u_tx.get_gain_range()
			cur_gtx = self._up_default_gain
		
			# some configurations don't have gain control
			if gtx.stop() <= gtx.start():
				gtxlow = 0.0
				gtxhigh = 1.0
		
			else:
				gtxlow = gtx.start()
				gtxhigh = gtx.stop()

		self._up_en_chooser = forms.check_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value='True',
			callback=self.setUpEn,
			label="TX Enable",
			true='True',
			false='False',
		)
		self.nb0.GetPage(1).Add(self._up_en_chooser)

		self._uhd_tx_gain_slider = wx.BoxSizer(wx.HORIZONTAL)
		form.slider_field(
			parent=self.nb0.GetPage(1).GetWin(),
			sizer=self._uhd_tx_gain_slider,
			label="USRP TX Gain",
			weight=3,
			min=int(gtxlow), 
			max=int(gtxhigh),
			value=cur_gtx,
			callback=self.setUpGain
		)
		self.nb0.GetPage(1).Add(self._uhd_tx_gain_slider)
		self._subcfreq_up_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_sub_freq,
			callback=self.setUpSubFreq,
			label="Uplink Subcarrier Frequency",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._subcfreq_up_text_box)
		self._up_bitrate_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_bitrate,
			callback=self.setUpBitrate,
			label="Uplink Bitrate",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_bitrate_text_box)
		self._up_data_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value="1234ABCD",
			callback=self.txData,
			label="TX Data",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_data_text_box)
		self._up_mod_index_chooser = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_modulation_index,
			callback=self.setUpModulationIndex,
			label="Uplink Modulation Index",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_mod_index_chooser)
		self._up_coding_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_coding_method,
			callback=self.setUpCodingMethod,
			label="Coding",
			choices=['None', 'RS'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(1).Add(self._up_coding_chooser)
		self._subcarrier_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_subcarrier,
			callback=self.setUpSubcarrier,
			label="Subcarrier Type",
			choices=['Square','Sine'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(1).Add(self._subcarrier_chooser)
		self._up_conv_check_box = forms.check_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_conv_en,
			callback=self.setUpConvEn,
			label="Convolutional Encode",
			true="True",
			false="False",
		)
		self.nb0.GetPage(1).Add(self._up_conv_check_box)
		self._up_pktlen_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_tm_len,
			callback=self.setUpTMLen,
			label="Uplink Packet Length (bits)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_pktlen_text_box)
		self._uhd_offset_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._uhd_carrier_offset,
			callback=self.setUHDCarrierOffset,
			label="USRP Offset Frequency (Hz)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._uhd_offset_text_box)
		self._sweep_gen_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value="rf2_1",
			callback=self.freqSweep,
			label="Frequency Sweep Profile",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(1).Add(self._sweep_gen_text_box)
		self._idle_sequence_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_idle_sequence,
			callback=self.setUpIdleSequence,
			label="Uplink Idle Sequence",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(1).Add(self._idle_sequence_text_box)
		self._pn_ranging_text_box = forms.text_box(
			parent=self.nb0.GetPage(2).GetWin(),
			value="",
			callback=self.rangePN,
			label="Queue PN Ranging",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(2).Add(self._pn_ranging_text_box)
		self._sequential_ranging_text_box = forms.text_box(
			parent=self.nb0.GetPage(2).GetWin(),
			value="",
			callback=self.rangeSequential,
			label="Queue Sequential Ranging",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(2).Add(self._sequential_ranging_text_box)
		self.row2_sizer = wx.BoxSizer(wx.HORIZONTAL)
		self.freq_acq_button = forms.button(
			parent=self.nb0.GetPage(2).GetWin(),
			value='Acquire Carrier Offset',
			callback=self.acquireCarrier,
			choices=['Acquire Carrier Offset'],
			style=wx.RA_HORIZONTAL,
		)
		self.carrier_offset_text = forms.static_text(
			parent=self.nb0.GetPage(2).GetWin(),
			value="",
			label="",
			converter=forms.str_converter(),
		)
		self.row2_sizer.Add(self.freq_acq_button, flag=wx.ALIGN_CENTER)
		self.row2_sizer.Add(self.carrier_offset_text, flag=wx.ALIGN_CENTER)
		self.nb0.GetPage(2).Add(self.row2_sizer)


	self.file_sink = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_recording.dat", self._samples_per_second)
	self.file_sink.close()
	self.iq_recording_ctr = 0

	# Selection logic to switch between recording and normal flowgraph routes
	# NOTE: u_valve logic is implemented backwards in GNURadio....
	#self.u_valve = blks2.valve(
	#	item_size=gr.sizeof_gr_complex,
	#	open=False
	#)

	# Temporary code used to verify coherent turnaround
	self.turnaround_mixer = blocks.multiply_cc()
	self.turnaround_mixer_source = analog.sig_source_c(self._down_samples_per_second, analog.GR_SIN_WAVE, -25e3, 1.0)
	self.turnaround_iir = filter.single_pole_iir_filter_cc(0.0001)
	self.turnaround_null = blocks.null_sink(gr.sizeof_float)

	# PLL and associated carrier for tracking carrier frequency if residual carrier is used
	self.carrier_tracking = sdrp.pll_freq_acq_cc(math.pi/2000, math.pi, -math.pi, int(options.acq_samples))
	self.imag_to_float = blocks.complex_to_imag()

	#Suppressed carrier requires costas after subcarrier mixer
	self.subcarrier_costas = digital.costas_loop_cc(0.001, 2)
	self.real_to_float = blocks.complex_to_real()

	#Square wave subcarrier sync
	self.subcarrier_sync = sdrp.square_sub_tracker_ff(0.001, 2*self._down_sub_freq/self._down_samples_per_second*1.0001, 2*self._down_sub_freq/self._down_samples_per_second*0.9999)

	#Data sync
	self.data_sync = sdrp.square_data_tracker_ff(0.001, self._down_bitrate/self._down_samples_per_second*1.001, self._down_bitrate/self._down_samples_per_second*0.999)

	#Data framing
	self.soft_correlator = sdrp.correlate_soft_access_tag_ff(conv_packed_binary_string_to_1_0_string('\x1A\xCF\xFC\x1D'), self._asm_threshold, "asm_corr")
	self.conv_decoder = sdrp.ccsds_tm_conv_decoder("asm_corr")
	self.de_randomizer = sdrp.ccsds_tm_derandomizer("asm_corr")
	self.tm_framer = sdrp.ccsds_tm_framer(self._tm_packet_id, self._timestamp_id, "asm_corr", "rx_time", self._down_bitrate)
	self.tm_framer.setFrameLength(self._tm_len)

	self._current_scope_block = None
	self._current_scoped_block = self.u
	self._current_scoped_block_port = 0

	self._recording = 'Off'

	#TX path in flowgraph
	self.pkt_gen_msgq = gr.msg_queue(10)
        self.pkt_gen = sdrp.ccsds_tm_tx(self._tm_packet_id, self._timestamp_id, 1.0, 16, self.pkt_gen_msgq)
	self.conj = blocks.conjugate_cc()

	#Sweep generator for transponder lock
	self.sweep_gen = sdrp.sweep_generator_cc(self._up_samples_per_second)

	# DSSDR subcarrier mixer (either 25 kHz or 0 kHz depending on baud rate)
	self.up_subcarrier_mixer = blocks.multiply_ff()
	self.subcarrier_mixer_source_tx = analog.sig_source_f(self._up_samples_per_second, analog.GR_SQR_WAVE, 25e3, 2.0, -1.0)
	self.phase_mod_tx = analog.phase_modulator_fc(self._up_modulation_index)
	self.tx_attenuator = blocks.multiply_const_cc((0.1+0.0j))

	#Add in bit recorder if needed
	if self.options.bitlog:
		self.bit_slicer = digital.binary_slicer_fb()
		self.bit_recorder = blocks.file_sink(1, "bitstream_recording.out")


	self.setDownCodingMethod(self._coding_method)
	self.setUpCodingMethod("None")
	self.setUpSubcarrier(self._up_subcarrier)
	self.setDownBitrate(self._down_bitrate)
	self.setUpBitrate(self._up_bitrate)
	self.setDownModulationIndex(self._modulation_index)
	self.setUpModulationIndex(self._up_modulation_index)
	self.setDownConvEn(self._down_conv_en)
	self.setUpConvEn(self._up_conv_en)
	self.setUpIdleSequence(self._up_idle_sequence)
	self.setDownRandomizerEn(self._down_randomizer_en)
	self.setDownManchesterEn(self._down_manchester_en)

	#Connection to outside world
	self.socket_pdu = blocks.socket_pdu("TCP_SERVER", "127.0.0.1", "12902", 10000)
	self.sdrp_interpreter = sdrp.sdrp_packet_interpreter()
	self.msg_connect(self.tm_framer, "tm_frame_out", self.sdrp_interpreter, "sdrp_pdu_in")
	self.msg_connect(self.sdrp_interpreter, "socket_pdu_out", self.socket_pdu, "pdus")
	self.msg_connect(self.socket_pdu, "pdus", self.sdrp_interpreter, "socket_pdu_in")
	self.msg_connect(self.sdrp_interpreter,"sdrp_pdu_out", self.pkt_gen, "ccsds_tx_msg_in")

	if options.test == False and options.fromfile == False and options.frombitlog == False:
		_threading.Thread(target=self.watchRef).start()

	self.initialized = True
	print "DS-SDR Initialized"
Esempio n. 45
0
    def __init__(self):
        gr.top_block.__init__(self, "MPSK Receiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("MPSK Receiver")
        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", "mpsk_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.eb = eb = 0.35
        self.usrp_gain = usrp_gain = 40
        self.timing_loop_bw = timing_loop_bw = 0.01
        self.samp_rate = samp_rate = 1e6
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1]
        self.phase_bw = phase_bw = 0.1
        self.n = n = 4
        self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts))
        self.eq_gain = eq_gain = 0.01
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self._usrp_gain_layout = Qt.QVBoxLayout()
        self._usrp_gain_tool_bar = Qt.QToolBar(self)
        self._usrp_gain_layout.addWidget(self._usrp_gain_tool_bar)
        self._usrp_gain_tool_bar.addWidget(Qt.QLabel("USRP Gain"+": "))
        self._usrp_gain_counter = Qwt.QwtCounter()
        self._usrp_gain_counter.setRange(0, 100, 1)
        self._usrp_gain_counter.setNumButtons(2)
        self._usrp_gain_counter.setValue(self.usrp_gain)
        self._usrp_gain_tool_bar.addWidget(self._usrp_gain_counter)
        self._usrp_gain_counter.valueChanged.connect(self.set_usrp_gain)
        self._usrp_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._usrp_gain_slider.setRange(0, 100, 1)
        self._usrp_gain_slider.setValue(self.usrp_gain)
        self._usrp_gain_slider.setMinimumWidth(200)
        self._usrp_gain_slider.valueChanged.connect(self.set_usrp_gain)
        self._usrp_gain_layout.addWidget(self._usrp_gain_slider)
        self.top_layout.addLayout(self._usrp_gain_layout)
        self._timing_loop_bw_layout = Qt.QVBoxLayout()
        self._timing_loop_bw_label = Qt.QLabel("Time: BW")
        self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005)
        self._timing_loop_bw_slider.setValue(self.timing_loop_bw)
        self._timing_loop_bw_slider.setMinimumWidth(200)
        self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw)
        self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label)
        self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider)
        self.top_grid_layout.addLayout(self._timing_loop_bw_layout, 0,0,1,1)
        self._phase_bw_layout = Qt.QVBoxLayout()
        self._phase_bw_label = Qt.QLabel("Phase: Bandwidth")
        self._phase_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._phase_bw_slider.setRange(0.0, 1.0, 0.01)
        self._phase_bw_slider.setValue(self.phase_bw)
        self._phase_bw_slider.setMinimumWidth(200)
        self._phase_bw_slider.valueChanged.connect(self.set_phase_bw)
        self._phase_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._phase_bw_layout.addWidget(self._phase_bw_label)
        self._phase_bw_layout.addWidget(self._phase_bw_slider)
        self.top_grid_layout.addLayout(self._phase_bw_layout, 0,2,1,1)
        self._eq_gain_layout = Qt.QVBoxLayout()
        self._eq_gain_label = Qt.QLabel("Equalizer: rate")
        self._eq_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._eq_gain_slider.setRange(0.0, 0.1, 0.001)
        self._eq_gain_slider.setValue(self.eq_gain)
        self._eq_gain_slider.setMinimumWidth(200)
        self._eq_gain_slider.valueChanged.connect(self.set_eq_gain)
        self._eq_gain_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._eq_gain_layout.addWidget(self._eq_gain_label)
        self._eq_gain_layout.addWidget(self._eq_gain_slider)
        self.top_grid_layout.addLayout(self._eq_gain_layout, 0,1,1,1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(2.4e9, 0)
        self.uhd_usrp_source_0.set_gain(usrp_gain, 0)
        self.qtgui_sink_x_1 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"QT GUI Plot", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_1.set_update_time(1.0/10)
        self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_1_win)
        
        
        self.qtgui_sink_x_0 = qtgui.sink_f(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"QT GUI Plot", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0/10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)
        
        
        self.frame_detection_deinterleaver_bb_0 = frame_detection.deinterleaver_bb(n, n)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), 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(phase_bw, arity)
        self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble), (matched_filter), sps)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/ubuntu/rx_message", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_null_sink_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.digital_correlate_and_sync_cc_0, 0))
        self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_sink_x_1, 0))
        self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.frame_detection_deinterleaver_bb_0, 0))
        self.connect((self.frame_detection_deinterleaver_bb_0, 0), (self.blocks_file_sink_0, 0))
Esempio n. 46
0
    def __init__(self,
                 ip='127.0.0.1',
                 iq_file='./rocksat_125kbd_500ksps_date_comment.dat',
                 meta_rate=.1,
                 port='52001',
                 pre_bits=[
                     0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,
                     1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1,
                     1, 0, 0, 1, 1, 1, 1, 1, 1, 0
                 ],
                 record_iq=0,
                 record_rfo=0,
                 record_snr=0,
                 rfo_file='./rocksat_rfo_date_comment.meta',
                 snr_file='./rocksat_snr_date_comment.meta'):
        gr.top_block.__init__(self, "MGS Rocksat Receiver v1.0")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("MGS Rocksat Receiver v1.0")
        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", "mgs_rx_hdlc_1")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.ip = ip
        self.iq_file = iq_file
        self.meta_rate = meta_rate
        self.port = port
        self.pre_bits = pre_bits
        self.record_iq = record_iq
        self.record_rfo = record_rfo
        self.record_snr = record_snr
        self.rfo_file = rfo_file
        self.snr_file = snr_file

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 500e3
        self.baud = baud = 125e3
        self.samps_per_symb = samps_per_symb = int(samp_rate / baud)
        self.rx_offset = rx_offset = 250e3
        self.rx_gain = rx_gain = 25
        self.rx_freq = rx_freq = 2395e6
        self.mult = mult = (samp_rate) / 2 / 3.141593

        self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate,
                                                   samp_rate / 2, 1000,
                                                   firdes.WIN_HAMMING, 6.76)

        self.lo = lo = 1833e6
        self.khz_offset = khz_offset = 0
        self.alpha = alpha = 0.5

        ##################################################
        # Blocks
        ##################################################
        self._rx_gain_range = Range(0, 86, 1, 25, 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, 0, 8, 1, 4)
        self._khz_offset_range = Range(-150, 150, 1, 0, 200)
        self._khz_offset_win = RangeWidget(self._khz_offset_range,
                                           self.set_khz_offset, 'Offset [kHz]',
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._khz_offset_win, 1, 8, 1, 4)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(rx_freq, rx_offset), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            '',  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(True)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not False:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

        labels = ['pre-d', 'post', '', '', '', '', '', '', '', '']
        colors = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-130, -60)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 8,
                                       0, 8, 8)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

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

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024 * 4,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.0010)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -20)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        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 = ['pre-d', 'post', '', '', '', '', '', '', '', '']
        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(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 8,
                                       8)
        self.pyqt_trim_tail_0 = pyqt.trim_tail(20)
        self.pyqt_time_plot_1_0_0 = pyqt.time_plot('Soft Bits')
        self._pyqt_time_plot_1_0_0_win = self.pyqt_time_plot_1_0_0
        self.top_grid_layout.addWidget(self._pyqt_time_plot_1_0_0_win, 4, 8, 1,
                                       4)
        self.pyqt_time_plot_1_0 = pyqt.time_plot('Hard Bits')
        self._pyqt_time_plot_1_0_win = self.pyqt_time_plot_1_0
        self.top_grid_layout.addWidget(self._pyqt_time_plot_1_0_win, 5, 8, 1,
                                       4)
        self.pyqt_text_output_0 = pyqt.text_output()
        self._pyqt_text_output_0_win = self.pyqt_text_output_0
        self.top_grid_layout.addWidget(self._pyqt_text_output_0_win, 6, 8, 4,
                                       4)
        self.pyqt_skip_head_0 = pyqt.skip_head(100)
        self.pyqt_head_0 = pyqt.head(1024)
        self.pyqt_cpower_plot_0_0 = pyqt.cpower_plot('Burst Post Length-D')
        self._pyqt_cpower_plot_0_0_win = self.pyqt_cpower_plot_0_0
        self.top_grid_layout.addWidget(self._pyqt_cpower_plot_0_0_win, 2, 8, 1,
                                       4)
        self.pyqt_const_plot_0_0 = pyqt.const_plot(label='Symbols')
        self._pyqt_const_plot_0_0_win = self.pyqt_const_plot_0_0
        self.top_grid_layout.addWidget(self._pyqt_const_plot_0_0_win, 3, 8, 1,
                                       4)
        self.mapper_demapper_soft_0 = mapper.demapper_soft(
            mapper.BPSK, ([0, 1]))
        self.mapper_demapper_msg_0_0 = mapper.demapper_msg(
            mapper.BPSK, ([0, 1]))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000,
                            firdes.WIN_HAMMING, 6.76))
        self.kiss_nrzi_decode_0 = kiss.nrzi_decode()
        self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True,
                                                       max_length=1024)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (lpf_taps), khz_offset * 1000, samp_rate)
        self.es_trigger_edge_f_0 = es.trigger_edge_f(-1, 256 * 16, 100,
                                                     gr.sizeof_gr_complex, 500)
        self.es_sink_0 = es.sink(1 * [gr.sizeof_gr_complex], 4, 128, 0, 2, 0)
        self.es_handler_pdu_0 = es.es_make_handler_pdu(
            es.es_handler_print.TYPE_C32)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            math.pi * 2 / 100, 2, False)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            math.pi * 2 / 100, 2, False)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(
            samps_per_symb * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175,
            0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.burst_slicer_0 = burst.slicer()
        self.burst_preamble_correlator_0 = burst.preamble_correlator(
            4, 0.5, (pre_bits))
        self.burst_length_detect_c_0 = burst.length_detect_c()
        (self.burst_length_detect_c_0).set_min_output_buffer(20800)
        self.burst_correlator_filter_0 = burst.correlator_filter(
            100, 1e-4, -10)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", ip, port,
                                                     1024, False)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, 'pl2')
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((10, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.burst_length_detect_c_0, 'cpdus'),
                         (self.mapper_demapper_msg_0_0, 'cpdus'))
        self.msg_connect((self.burst_length_detect_c_0, 'cpdus'),
                         (self.pyqt_const_plot_0_0, 'cpdus'))
        self.msg_connect((self.burst_length_detect_c_0, 'cpdus'),
                         (self.pyqt_cpower_plot_0_0, 'cpdus'))
        self.msg_connect((self.burst_length_detect_c_0, 'cpdus'),
                         (self.pyqt_trim_tail_0, 'pdus'))
        self.msg_connect((self.burst_slicer_0, 'pdus'),
                         (self.pyqt_time_plot_1_0, 'pdus'))
        self.msg_connect((self.es_handler_pdu_0, 'pdus_out'),
                         (self.burst_length_detect_c_0, 'cpdus'))
        self.msg_connect((self.es_trigger_edge_f_0, 'edge_event'),
                         (self.es_handler_pdu_0, 'handle_event'))
        self.msg_connect((self.es_trigger_edge_f_0, 'which_stream'),
                         (self.es_sink_0, 'schedule_event'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'),
                         (self.pyqt_text_output_0, 'pdus'))
        self.msg_connect((self.mapper_demapper_msg_0_0, 'fpdus'),
                         (self.burst_slicer_0, 'fpdus'))
        self.msg_connect((self.mapper_demapper_msg_0_0, 'fpdus'),
                         (self.pyqt_time_plot_1_0_0, 'pdus'))
        self.msg_connect((self.pyqt_head_0, 'pdus'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.pyqt_skip_head_0, 'pdus'),
                         (self.pyqt_head_0, 'pdus'))
        self.msg_connect((self.pyqt_trim_tail_0, 'pdus'),
                         (self.pyqt_skip_head_0, 'pdus'))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.burst_correlator_filter_0, 0),
                     (self.es_trigger_edge_f_0, 0))
        self.connect((self.burst_preamble_correlator_0, 0),
                     (self.burst_correlator_filter_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.burst_preamble_correlator_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.es_trigger_edge_f_0, 1))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.mapper_demapper_soft_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.kiss_nrzi_decode_0, 0))
        self.connect((self.es_trigger_edge_f_0, 0), (self.es_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_agc2_xx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.kiss_nrzi_decode_0, 0),
                     (self.kiss_hdlc_deframer_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.mapper_demapper_soft_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Esempio n. 47
0
    def __init__(self, puncpat='11'):
        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")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22

        self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, eb, 5 * sps * nfilts)

        self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500,
            882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952
        ]
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.k = k = 7
        self.vector = vector = [int(random.random() * 4) for i in range(49600)]
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 39
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50
        self.samp_rate = samp_rate = samp_rate_array_MCR[2]

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts)

        self.pld_enc = pld_enc = map(
            (lambda a: fec.cc_encoder_make(440, k, rate,
                                           (polys), 0, fec.CC_TERMINATED, True)
             ), range(0, 8))

        self.pld_dec = pld_dec = map((lambda a: fec.cc_decoder.make(
            440, k, rate, (polys), 0, -1, fec.CC_TERMINATED, True)),
                                     range(0, 4))
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 39, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0,
                                       2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._variable_qtgui_range_0_range = Range(0, 90, 1, 50, 200)
        self._variable_qtgui_range_0_win = RangeWidget(
            self._variable_qtgui_range_0_range,
            self.set_variable_qtgui_range_0, 'Gain_TX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_win, 0, 1,
                                       1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("serial=F5EAC0", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_source_0.set_gain(variable_qtgui_range_0_1, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0.set_auto_iq_balance(True, 0)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAE1", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0, 0)
        self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0)
        self.qtgui_time_sink_x_2_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "After CAC",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2_0.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0.set_y_axis(0, 1.5)

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

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

        if not True:
            self.qtgui_time_sink_x_2_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_2_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_2_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_win, 2, 4,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_2 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "Defore CAC",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2.set_update_time(0.10)
        self.qtgui_time_sink_x_2.set_y_axis(0, 1.5)

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

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

        if not True:
            self.qtgui_time_sink_x_2.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_2.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_2.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_win, 2, 3, 1,
                                       1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "RX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 4,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

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

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 3, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Rx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256)

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

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

        if not True:
            self.qtgui_time_sink_x_0_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 5,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Tx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 256)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 1, 1,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c(
            1024,  #size
            "RX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_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_0_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2,
                                       1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "TX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_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_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 1,
                                       2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "RX Treated",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                       qtgui.TRIG_SLOPE_POS,
                                                       0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_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_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2,
                                       2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            sps, taps=(tx_rrc_taps), flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay)

        self.fec_extended_encoder_0 = fec.extended_encoder(
            encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat)
        self.fec_extended_decoder_0_0_1_0_1_0 = fec.extended_decoder(
            decoder_obj_list=pld_dec,
            threading='capillary',
            ann=None,
            puncpat=puncpat,
            integration_period=10000)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 400.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_map_bb_1_0 = digital.map_bb((pld_const.pre_diff_code()))
        self.digital_map_bb_0_0_0_0_0 = digital.map_bb(([-1, 1]))
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(4)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            6.28 / 200.0, pld_const.arity(), False)
        self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts(
            digital.packet_utils.default_access_code, 1, 'packet_len')
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            pld_const)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (pld_const.points()), 1)
        self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True,
                                                                   1, [])
        self.blocks_vector_source_x_0 = blocks.vector_source_b([0], True, 1,
                                                               [])
        self.blocks_vector_insert_x_0 = blocks.vector_insert_b((vector),
                                                               496000000, 0)
        self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, 992, "packet_len")
        self.blocks_stream_mux_0_1_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (96, 896))
        self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1,
                                                       (892, 4))
        self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char * 1,
                                                     (440, 2))
        self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb(
            8, 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb(
            1, 2, "packet_len", False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb(
            1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            2, 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_keep_m_in_n_0_1_1_0 = blocks.keep_m_in_n(
            gr.sizeof_char, 440, 442, 0)
        self.blocks_keep_m_in_n_0_0_2_0 = blocks.keep_m_in_n(
            gr.sizeof_char, 892, 896, 0)
        self.blocks_file_source_0_0_1_0_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/andre/Downloads/lion-sample.mts', False)
        self.blocks_file_source_0_0_1_0_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0_0_0_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/andre/Desktop/transmitido/depois.mts',
            False)
        self.blocks_file_sink_0_0_0_0_0.set_unbuffered(False)
        self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_2_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.acode_1104 = blocks.vector_source_b([
            0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1,
            0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x0
        ], True, 1, [])

        ##################################################
        # Connections
        ##################################################
        self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_2, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_2_0, 0))
        self.connect((self.blocks_char_to_float_0_2_0_0, 0),
                     (self.fec_extended_decoder_0_0_1_0_1_0, 0))
        self.connect((self.blocks_char_to_float_1_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_char_to_float_1_0_1, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_file_source_0_0_1_0_0, 0),
                     (self.blocks_char_to_float_1_0_0, 0))
        self.connect((self.blocks_file_source_0_0_1_0_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_1, 0))
        self.connect((self.blocks_keep_m_in_n_0_0_2_0, 0),
                     (self.digital_map_bb_0_0_0_0_0, 0))
        self.connect((self.blocks_keep_m_in_n_0_1_1_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_const_sink_x_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.uhd_usrp_sink_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_correlate_access_code_xx_ts_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_file_sink_0_0_0_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0),
                     (self.blocks_vector_insert_x_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0),
                     (self.blocks_stream_mux_0, 0))
        self.connect((self.blocks_stream_mux_0, 0),
                     (self.fec_extended_encoder_0, 0))
        self.connect((self.blocks_stream_mux_0_0, 0),
                     (self.blocks_stream_mux_0_1_0, 1))
        self.connect((self.blocks_stream_mux_0_1_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_0, 0))
        self.connect((self.blocks_vector_insert_x_0, 0),
                     (self.digital_map_bb_1_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_mux_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_0, 0),
                     (self.blocks_stream_mux_0_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0),
                     (self.blocks_keep_m_in_n_0_0_2_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_map_bb_0_0_0_0_0, 0),
                     (self.blocks_char_to_float_0_2_0_0, 0))
        self.connect((self.digital_map_bb_1_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.fec_extended_decoder_0_0_1_0_1_0, 0),
                     (self.blocks_keep_m_in_n_0_1_1_0, 0))
        self.connect((self.fec_extended_encoder_0, 0),
                     (self.blocks_stream_mux_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
Esempio n. 48
0
    def __init__(self,
                 hdr_format=digital.header_format_default(
                     digital.packet_utils.default_access_code, 0)):
        grc_wxgui.top_block_gui.__init__(self, title="QPSK")

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

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.excess_bw = excess_bw = 0.35
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            1, sps, 1, excess_bw, 45)

        self.qpsk1 = qpsk1 = digital.constellation_qpsk().base()

        self.our_txt = our_txt = 0
        self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001'

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_f(
            self.GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_2.win)
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0_0.win)
        self.pluto_source_0 = iio.pluto_source('ip:pluto.local',
                                               int(800000000), int(2084000),
                                               int(20000000), 0x8000, True,
                                               True, True, "manual", 15, '',
                                               True)
        self.pluto_sink_2 = iio.pluto_sink('ip:pluto.local', int(800000000),
                                           int(2084000), int(20000000), 0x8000,
                                           False, 0, '', True)
        self._our_txt_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.our_txt,
            callback=self.set_our_txt,
            label='our_txt',
            converter=forms.str_converter(),
        )
        self.Add(self._our_txt_text_box)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab1")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab2")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab3")
        self.Add(self.notebook_0)
        self.low_pass_filter_2 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, 2084000, 1000000, 500000, firdes.WIN_HAMMING,
                            6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 0.0682, (rrc_taps), 64, 16, 1.5, sps)
        self.digital_map_bb_0 = digital.map_bb(([0, 1, 2, 3]))
        self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(
            21, 0.050, sps, qpsk1)
        self.digital_diff_decoder_bb_1 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(0.0628, 4, True)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=qpsk1,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=excess_bw,
            verbose=False,
            log=False,
        )
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            qpsk1)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/Users/cake/Desktop/Projects/plutoSDR/2byte.txt', True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_1 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/Users/cake/Desktop/Projects/plutoSDR/out.txt', False)
        self.blocks_file_sink_1.set_unbuffered(True)
        self.blocks_char_to_float_1 = blocks.char_to_float(1, 1)
        self.blks2_packet_encoder_0_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=1,
                bits_per_symbol=1,
                preamble='',
                access_code=code1,
                pad_for_usrp=False,
            ),
            payload_length=8,
        )
        self.blks2_packet_decoder_0_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code=code1,
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0_0.
                recv_pkt(ok, payload),
            ), )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blks2_packet_encoder_0_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_char_to_float_1, 0),
                     (self.wxgui_scopesink2_2, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blks2_packet_encoder_0_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blks2_packet_decoder_0_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_char_to_float_1, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_map_bb_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.pluto_sink_2, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.wxgui_scopesink2_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_1, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.digital_diff_decoder_bb_1, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_lms_dd_equalizer_cc_0, 0))
        self.connect((self.low_pass_filter_2, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.pluto_source_0, 0), (self.low_pass_filter_2, 0))
Esempio n. 49
0
    def __init__(self):
        gr.top_block.__init__(self, "Mpsk Stage6")


        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.variable_0 = variable_0 = 0
        self.timing_loop_bw = timing_loop_bw = 6.28/100.0
        self.time_offset = time_offset = 1.00
        self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j]
        # ntaps = 7
        # taps = numpy.random.random(ntaps-1) + 1j*numpy.random.random(ntaps-1)
        # self.taps = taps = numpy.concatenate((numpy.ones(1), taps))
        # self.taps = taps
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.phase_bw = phase_bw = 6.28/100.0
        self.noise_volt = noise_volt = 0
        self.freq_offset = freq_offset = 0
        self.excess_bw = excess_bw = 0.35
        self.eq_gain = eq_gain = 0.01
        self.delay = delay = 58
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self.tutorial_my_qpsk_demod_cb_1 = tutorial.my_qpsk_demod_cb(True)
        self.iq_vector_sink = blocks.vector_sink_c(1)
        self.raw_vector_sink = blocks.vector_sink_f(1)
        self.decoded_vector_sink = blocks.vector_sink_f(1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2)
        self.digital_map_bb_0 = digital.map_bb(([0,1,3,2]))
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity, False)
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=qpsk,
          differential=False,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=excess_bw,
          verbose=False,
          log=False,
          )
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2)
        # snr = 18
        # noise_amp = 10**(-snr/10.0)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=self.noise_volt,
        	frequency_offset=freq_offset,
        	epsilon=time_offset,
        	taps=(taps),
        	noise_seed=0,
        	block_tags=False
        )

        self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_file_sink_0_1 = blocks.file_sink(gr.sizeof_gr_complex*1, 'iq_qpsk.txt', False)
        self.blocks_file_sink_0_1.set_unbuffered(True)
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_float*1, 'decoded_qpsk.txt', False)
        self.blocks_file_sink_0_0_0.set_unbuffered(False)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float*1, 'ground_truth_qpsk.txt', False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, 'ber_qpsk.txt', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_delay_0_1 = blocks.delay(gr.sizeof_char*1, int(delay))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, int(delay))
        self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blks2_error_rate = grc_blks2.error_rate(
        	type='BER',
        	win_size=int(1e4),
        	bits_per_symbol=1,
        )
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 100000)), True)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0))
        self.connect((self.blks2_error_rate, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_delay_0_1, 0), (self.blks2_error_rate, 1))
        self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_error_rate, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_char_to_float_0_0_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_delay_0_1, 0))
        self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.iq_vector_sink, 0))

        self.connect((self.blocks_char_to_float_0_0, 0), (self.decoded_vector_sink, 0))
        self.connect((self.blocks_delay_0, 0), (self.raw_vector_sink, 0))

        self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_file_sink_0_1, 0))
        self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.tutorial_my_qpsk_demod_cb_1, 0))
        self.connect((self.digital_map_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.tutorial_my_qpsk_demod_cb_1, 0), (self.digital_map_bb_0, 0))
Esempio n. 50
0
    def __init__(self, n_filts=32, bits_per_sym=2, alpha_probe=0.1, th_probe=0, constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(), samp_per_sym=5, bw_costas=2*math.pi/100, bw_clock_sync=2*math.pi/100, bw_fll=2*math.pi/100, len_sym_srrc=11, alfa=0.45):
        grc_wxgui.top_block_gui.__init__(self, title="Test Hier Rx Usrp")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.n_filts = n_filts
        self.bits_per_sym = bits_per_sym
        self.alpha_probe = alpha_probe
        self.th_probe = th_probe
        self.constellation = constellation
        self.samp_per_sym = samp_per_sym
        self.bw_costas = bw_costas
        self.bw_clock_sync = bw_clock_sync
        self.bw_fll = bw_fll
        self.len_sym_srrc = len_sym_srrc
        self.alfa = alfa

        ##################################################
        # Variables
        ##################################################
        self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts)

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=250000/samp_per_sym,
        	v_scale=0.3,
        	v_offset=0,
        	t_scale=0.3,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(50000*samp_per_sym)
        self.uhd_usrp_source_0.set_center_freq(850000000, 0)
        self.uhd_usrp_source_0.set_gain(18, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, bw_clock_sync, (filtro_srrc), n_filts, 16, 5, 1)
        self.digital_mpsk_snr_est_cc_0 = digital.mpsk_snr_est_cc(2, 1000, 0.1)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, bw_fll)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym)
        self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(bw_costas, 2**bits_per_sym)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation)
        self.blocks_vector_sink_x_0 = blocks.vector_sink_b(1)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/belza/pruebasUSRP/file_rx_sym", False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.analog_agc2_xx_0 = analog.agc2_cc(0.6e-1, 1e-3, 2, 15)
        self.analog_agc2_xx_0.set_max_gain(15)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_vector_sink_x_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_mpsk_snr_est_cc_0, 0))
        self.connect((self.digital_mpsk_snr_est_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0))
Esempio n. 51
0
    def __init__(self):
        gr.top_block.__init__(self, "Demod")

        # the commented elements below did not work in testing so leave them alone!
        bitmappings = [
            [0, 1, 2, 3],
            # [ 0, 1, 3, 2],
            [0, 2, 1, 3],
            # [ 0, 2, 3, 1],
            # [ 0, 3, 1, 2],
            [0, 3, 2, 1],
            [1, 0, 2, 3],
            [1, 0, 3, 2],
            # [ 1, 2, 0, 3],
            # [ 1, 2, 3, 0],
            # [ 1, 3, 0, 2],
            # [ 1, 3, 2, 0],
            # [ 2, 0, 1, 3],
            # [ 2, 0, 3, 1],
            [2, 1, 0, 3],
            # [ 2, 1, 3, 0],
            [2, 3, 0, 1],
            # [ 2, 3, 1, 0],
            # [ 3, 0, 1, 2],
            # [ 3, 0, 2, 1],
            # [ 3, 1, 0, 2],
            [3, 1, 2, 0],
            # [ 3, 2, 0, 1],
            [3, 2, 1, 0],
        ]

        constellation_map = random.choice(bitmappings)

        # override the above for now until figure out how to make the solver work dynamically
        constellation_map = [2, 3, 0, 1]

        # sys.stderr.write('{}'.format(constellation_map))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.nfilts = nfilts = 32
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), (constellation_map), 4, 2, 2, 1, 1).base()
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 62.8e-3, (rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_map_bb_0 = digital.map_bb((constellation_map))
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            62.8e-3, arity, False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            qpsk)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, 10e-3, 2)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            sys.argv[1], False)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   sys.argv[2], False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -8e3, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.digital_map_bb_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_file_sink_0, 0))
Esempio n. 52
0
    def __init__(self):
        gr.top_block.__init__(self, "Audio Tx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Audio 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", "audio_tx")

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

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 1
        self.nfilts = nfilts = 25
        self.samp_rate = samp_rate = 32E3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.phase_bw = phase_bw = 6.28 / 100.0
        self.excess_bw = excess_bw = 0.35

        self.BPSK = BPSK = digital.constellation_qpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200)
        self._phase_bw_win = RangeWidget(self._phase_bw_range,
                                         self.set_phase_bw, 'Phase: Bandwidth',
                                         "slider", float)
        self.top_layout.addWidget(self._phase_bw_win)
        self.qtgui_time_sink_x_1_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1_1.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_1.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_1_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_1_win)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_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_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

        for i in xrange(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_const_sink_x_0_0 = qtgui.const_sink_c(
            1024,  #size
            "demod",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(True)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_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_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "Rx",  #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(True)
        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_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 1,
                                       1)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)]
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1.6E3, .6E3, firdes.WIN_HAMMING,
                            6.76))
        self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, .063, (rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(
            8, .01, 1, BPSK)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            phase_bw, 4, False)
        self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(
            BPSK, phase_bw, 0, 2 * 3.14)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=BPSK,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=2,
            verbose=False,
            log=False,
        )
        self.blocks_multiply_xx_3_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_3 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_2_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_2_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_2_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/peter/Desktop/acoustic_radio/test_input.txt', True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/peter/Desktop/output.txt', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_imag_1 = blocks.complex_to_imag(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_3 = blocks.add_vff(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=sps,
                bits_per_symbol=1,
                preamble='',
                access_code='',
                pad_for_usrp=False,
            ),
            payload_length=1,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code='',
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )
        self.analog_sig_source_x_0_1_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0)
        self.analog_sig_source_x_0_1_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0)
        self.analog_sig_source_x_0_1 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0)
        self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(
            1024, 1.55)
        self.analog_const_source_x_0_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, -1)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, -1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_multiply_xx_3, 1))
        self.connect((self.analog_const_source_x_0_0, 0),
                     (self.blocks_multiply_xx_3_0, 1))
        self.connect((self.analog_feedforward_agc_cc_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_3_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_3, 0))
        self.connect((self.analog_sig_source_x_0_1, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.analog_sig_source_x_0_1_0, 0),
                     (self.blocks_multiply_xx_2_0, 1))
        self.connect((self.analog_sig_source_x_0_1_0_0, 0),
                     (self.blocks_multiply_xx_2_0_0, 1))
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_xx_2_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_add_xx_3, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_complex_to_imag_1, 0),
                     (self.blocks_add_xx_3, 1))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_multiply_xx_2_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_multiply_xx_2_0_0, 0),
                     (self.blocks_complex_to_imag_1, 0))
        self.connect((self.blocks_multiply_xx_2_1, 0),
                     (self.blocks_add_xx_3, 0))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_2_1, 1))
        self.connect((self.blocks_multiply_xx_3_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 4),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 3),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 1),
                     (self.qtgui_time_sink_x_1_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 2),
                     (self.qtgui_time_sink_x_1_1, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_lms_dd_equalizer_cc_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0),
                     (self.digital_constellation_receiver_cb_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_xx_2_0, 0))
        self.connect((self.hilbert_fc_0, 0),
                     (self.blocks_multiply_xx_2_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_feedforward_agc_cc_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Meteor QPSK LRPT")

        # get some variables in place for inputs
        #
        # Arguments:
        #   1. Full path and name of stream file (including file extension)
        #   2. Gain to be used
        #   3. Frequency offset (PPM)
        #   4. SDR Device ID from settings.yml (for RTL-SDR source block)
        #   5. Bias-T (0/1 for RTL-SDR)

        stream_name = sys.argv[1]
        gain = float(sys.argv[2])
        freq_offset = int(sys.argv[3])
        sdr_dev_id = sys.argv[4]
        bias_t_string = sys.argv[5]
        bias_t = "1"
        if not bias_t_string:
            bias_t = "0"

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_airspy = samp_rate_airspy = 1250000
        self.decim = decim = 8
        self.symb_rate = symb_rate = 72000
        self.samp_rate = samp_rate = samp_rate_airspy / decim
        self.sps = sps = (samp_rate * 1.0) / (symb_rate * 1.0)
        self.pll_alpha = pll_alpha = 0.006
        self.freq = freq = 137100000
        self.clock_alpha = clock_alpha = 0.002
        self.bitstream_name = bitstream_name = stream_name

        ##############################################################################################################################################
        # Blocks -- *** NOTE HOW THE VARIABLES ARE CARRIED IN FROM settings.yml - this has to be re-done every time you export the .py from gnuradio
        ###############################################################################################################################################

        self.rtlsdr_source_0 = osmosdr.source(args='numchan=' + str(1) + ' ' +
                                              'rtl=' + str(sdr_dev_id) +
                                              ',bias=' + bias_t + '')
        self.rtlsdr_source_0.set_sample_rate(samp_rate_airspy)
        self.rtlsdr_source_0.set_center_freq(freq, 0)
        self.rtlsdr_source_0.set_freq_corr(freq_offset, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        # determine if gain is specified or if auto-gain should be used
        if (gain == 0):
            self.rtlsdr_source_0.set_gain_mode(True, 0)
        else:
            self.rtlsdr_source_0.set_gain_mode(False, 0)
            self.rtlsdr_source_0.set_gain(gain, 0)
        self.rtlsdr_source_0.set_if_gain(0, 0)
        self.rtlsdr_source_0.set_bb_gain(0, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(1500000, 0)

        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 0.6, 361))
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            pll_alpha, 4, False)
        self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf(
            digital.constellation_calcdist(
                ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4,
                1).base())
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(
            sps, clock_alpha**2 / 4.0, 0.5, clock_alpha, 0.005)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 127)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   bitstream_name, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_rail_ff_0 = analog.rail_ff(-1, 1)
        self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0)
        self.analog_agc_xx_0.set_max_gain(4000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.analog_rail_ff_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_constellation_soft_decoder_cf_1, 0))
        self.connect((self.digital_constellation_soft_decoder_cf_1, 0),
                     (self.analog_rail_ff_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_agc_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
Esempio n. 54
0
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Eve")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Eve")
        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", "eve")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952, 200000
        ]
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22
        self.H_dec = H_dec = fec.ldpc_H_matrix(
            '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist',
            24)
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 56
        self.samp_rate = samp_rate = samp_rate_array_MCR[15]

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts)

        self.pld_dec = pld_dec = map(
            (lambda a: fec.ldpc_bit_flip_decoder.make(H_dec.get_base_sptr(), 7)
             ), range(0, 8))
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 24e8
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 56, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0,
                                       2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("serial=F5EB09", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0)
        self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0)
        self.qtgui_time_sink_x_2_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "After CAC",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2_0.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0.set_y_axis(0, 1.5)

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

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

        if not True:
            self.qtgui_time_sink_x_2_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_2_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_2_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_win, 2, 2,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "RX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 2,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Rx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256)

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

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

        if not True:
            self.qtgui_time_sink_x_0_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c(
            1024,  #size
            "RX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_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_0_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 1,
                                       3, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "RX Treated",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                       qtgui.TRIG_SLOPE_POS,
                                                       0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_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_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2,
                                       1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(
            pld_const.arity())
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            6.28 / 100.0, pld_const.arity(), False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            pld_const)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, 0.01, 2)
        self.cac_cpp_cac_bb_0 = cac_cpp.cac_bb(
            digital.packet_utils.default_access_code, 1)
        self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb(
            1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_file_sink_0_0_0_0_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/andre/ELI/1/EVE_55_8000_BRUTO.txt',
            False)
        self.blocks_file_sink_0_0_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 1, '/home/andre/ELI/1/EVE_EVM.txt', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_2_0, 0))
        self.connect((self.blocks_char_to_float_1_0_1, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.cac_cpp_cac_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_file_sink_0_0_0_0_0, 0))
        self.connect((self.cac_cpp_cac_bb_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.cac_cpp_cac_bb_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0_1_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_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.uhd_usrp_source_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
Esempio n. 55
0
    def __init__(self):
        gr.hier_block2.__init__(
            self, "Hier Tx Ch Rx",
            gr.io_signature(1, 1, gr.sizeof_char*1),
            gr.io_signature(1, 1, gr.sizeof_char*1),
        )

        ##################################################
        # Variables
        ##################################################
        self.samp_per_sym = samp_per_sym = 3
        self.n_filts = n_filts = 32
        self.len_sym_srrc = len_sym_srrc = 7
        self.alfa = alfa = 0.35
        self.pulso = pulso = firdes.root_raised_cosine(samp_per_sym,samp_per_sym,1.0,alfa,samp_per_sym*len_sym_srrc)
        self.gain = gain = 15
        self.frec = frec = 850e3
        self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts)
        self.bits_per_sym = bits_per_sym = 2

        ##################################################
        # Blocks
        ##################################################
        self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf(
        	  samp_per_sym,
        	  (pulso),
        	  100)
        	
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, 2*math.pi/100, (filtro_srrc), n_filts, 16, 5, 1)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, math.pi/1600)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2**bits_per_sym)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym)
        self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(2*math.pi/100, 2**bits_per_sym)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base())
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(([-1-1j,1-1j, 1+1j, -1+1j]), 1)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=0.0,
        	frequency_offset=0.0,
        	epsilon=1.00,
        	taps=(1+0.5j, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bits_per_sym, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.4, ))
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=samp_per_sym,
        		bits_per_symbol=bits_per_sym,
        		preamble="",
        		access_code="",
        		pad_for_usrp=True,
        	),
        	payload_length=1,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.pfb_interpolator_ccf_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_interpolator_ccf_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.channels_channel_model_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_packet_decoder_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0), (self, 0))
        self.connect((self, 0), (self.blks2_packet_encoder_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0_0, 0))
Esempio n. 56
0
    def __init__(self,
                 antenna=satnogs.not_set_antenna,
                 baudrate=9600.0,
                 bb_gain=satnogs.not_set_rx_bb_gain,
                 decoded_data_file_path='/tmp/.satnogs/data/data',
                 dev_args=satnogs.not_set_dev_args,
                 doppler_correction_per_sec=1000,
                 enable_iq_dump=0,
                 excess_bw=0.35,
                 file_path='test.wav',
                 if_gain=satnogs.not_set_rx_if_gain,
                 iq_file_path='/tmp/iq.dat',
                 lo_offset=100e3,
                 max_cfo=1000.0,
                 ppm=0,
                 rf_gain=satnogs.not_set_rx_rf_gain,
                 rigctl_port=4532,
                 rx_freq=100e6,
                 rx_sdr_device='usrpb200',
                 samp_rate_rx=satnogs.not_set_samp_rate_rx,
                 udp_IP='127.0.0.1',
                 udp_port=16887,
                 waterfall_file_path='/tmp/waterfall.dat'):
        gr.top_block.__init__(self, "satnogs_bpsk_ax25")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.baudrate = baudrate
        self.bb_gain = bb_gain
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.excess_bw = excess_bw
        self.file_path = file_path
        self.if_gain = if_gain
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.max_cfo = max_cfo
        self.ppm = ppm
        self.rf_gain = rf_gain
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.rx_sdr_device = rx_sdr_device
        self.samp_rate_rx = samp_rate_rx
        self.udp_IP = udp_IP
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), excess_bw, 11 * sps * nfilts)

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

        self.audio_samp_rate = audio_samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(
            audio_samp_rate, 0.0, 10, 1024, waterfall_file_path, 1)
        self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(
            udp_IP, udp_port, 1500)
        self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source(
            "127.0.0.1", rigctl_port, False, 1000, 1500)
        self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(
            file_path, audio_samp_rate, 1.0)
        self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False,
                                                 enable_iq_dump)
        self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink(
            decoded_data_file_path, 0)
        self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(
            rx_freq, satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx))
        self.satnogs_ax25_decoder_bm_0_0 = satnogs.ax25_decoder_bm(
            'GND', 0, True, False, 1024)
        self.satnogs_ax25_decoder_bm_0 = satnogs.ax25_decoder_bm(
            'GND', 0, True, True, 1024)
        self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(
            (1.0 * sps * baudrate) /
            satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx),
            taps=None,
            flt_size=32)
        self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            audio_samp_rate /
            satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx),
            taps=None,
            flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " +
            satnogs.handle_rx_dev_args(rx_sdr_device, dev_args))
        self.osmosdr_source_0.set_sample_rate(
            satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx))
        self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0)
        self.osmosdr_source_0.set_freq_corr(ppm, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(
            satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0)
        self.osmosdr_source_0.set_if_gain(
            satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0)
        self.osmosdr_source_0.set_bb_gain(
            satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0)
        self.osmosdr_source_0.set_antenna(
            satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0)
        self.osmosdr_source_0.set_bandwidth(
            satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), 0)

        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, audio_samp_rate,
                            ((1.0 + excess_bw) * baudrate / 2.0) +
                            min(baudrate, abs(max_cfo)), baudrate / 10.0,
                            firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, sps * baudrate,
                            ((1.0 + excess_bw) * baudrate / 2.0) +
                            min(baudrate, abs(max_cfo)), baudrate / 10.0,
                            firdes.WIN_HAMMING, 6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 2.0 * math.pi / 100.0, (rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            2.0 * math.pi / 100.0, 2, True)
        self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(
            bpsk_constellation, 2.0 * math.pi / 100.0, -0.25, 0.25)
        self.blocks_rotator_cc_0_0 = blocks.rotator_cc(
            2.0 * math.pi * (1200.0 / audio_samp_rate))
        self.blocks_rotator_cc_0 = blocks.rotator_cc(
            -2.0 * math.pi *
            (lo_offset /
             satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx)))
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-3, 0.5, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'),
                         (self.satnogs_frame_file_sink_0_1_0, 'frame'))
        self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'),
                         (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_ax25_decoder_bm_0_0, 'pdu'),
                         (self.satnogs_frame_file_sink_0_1_0, 'frame'))
        self.msg_connect((self.satnogs_ax25_decoder_bm_0_0, 'pdu'),
                         (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'),
                         (self.satnogs_coarse_doppler_correction_cc_0, 'freq'))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0_0, 0))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.satnogs_ogg_encoder_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.satnogs_coarse_doppler_correction_cc_0, 0))
        self.connect((self.blocks_rotator_cc_0_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0),
                     (self.satnogs_ax25_decoder_bm_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0),
                     (self.satnogs_ax25_decoder_bm_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_constellation_receiver_cb_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_rotator_cc_0_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.analog_agc2_xx_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.satnogs_iq_sink_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.satnogs_waterfall_sink_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
Esempio n. 57
0
    def __init__(self, freq=0, gain=40, loopbw=100, loopbw_0=100, fllbw=0.002):
        gr.top_block.__init__(self, "Rx Gui")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rx Gui")
        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", "rx_gui")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.freq = freq
        self.gain = gain
        self.loopbw = loopbw
        self.loopbw_0 = loopbw_0
        self.fllbw = fllbw

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.excess_bw = excess_bw = 0.25
        self.target_samp_rate = target_samp_rate = sps*(200e3/(1 + excess_bw))
        
        self.qpsk_const = qpsk_const = digital.constellation_qpsk().base()
        
        self.dsp_rate = dsp_rate = 100e6
        self.const_choice = const_choice = "qpsk"
        
        self.bpsk_const = bpsk_const = digital.constellation_bpsk().base()
        
        self.barker_code_two_dim = barker_code_two_dim = [-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j]
        self.barker_code_one_dim = barker_code_one_dim = sqrt(2)*numpy.real([-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j,  1.0000 + 1.0000j, -1.0000 - 1.0000j])
        self.rrc_delay = rrc_delay = int(round(-44*excess_bw + 33))
        self.nfilts = nfilts = 32
        self.n_barker_rep = n_barker_rep = 10
        self.dec_factor = dec_factor = ceil(dsp_rate/target_samp_rate)
        self.constellation = constellation = qpsk_const if (const_choice=="qpsk") else bpsk_const
        self.barker_code = barker_code = barker_code_two_dim if (const_choice == "qpsk") else barker_code_one_dim
        self.preamble_syms = preamble_syms = numpy.matlib.repmat(barker_code, 1, n_barker_rep)[0]
        self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps*nfilts)
        self.n_codewords = n_codewords = 1
        self.even_dec_factor = even_dec_factor = dec_factor if (dec_factor % 1 == 1) else (dec_factor+1)
        self.const_order = const_order = pow(2,constellation.bits_per_symbol())
        self.codeword_len = codeword_len = 18444
        self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2"
        self.samp_rate = samp_rate = dsp_rate/even_dec_factor
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, excess_bw, n_rrc_taps)
        self.rf_center_freq = rf_center_freq = 1428.4309e6
        self.preamble_size = preamble_size = len(preamble_syms)
        self.pmf_peak_threshold = pmf_peak_threshold = 0.6
        self.payload_size = payload_size = codeword_len*n_codewords/int(numpy.log2(const_order))
        self.dataword_len = dataword_len = 6144
        self.barker_len = barker_len = 13

        ##################################################
        # Blocks
        ##################################################
        self.tabs = Qt.QTabWidget()
        self.tabs_widget_0 = Qt.QWidget()
        self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0)
        self.tabs_grid_layout_0 = Qt.QGridLayout()
        self.tabs_layout_0.addLayout(self.tabs_grid_layout_0)
        self.tabs.addTab(self.tabs_widget_0, 'PMF Out')
        self.tabs_widget_1 = Qt.QWidget()
        self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1)
        self.tabs_grid_layout_1 = Qt.QGridLayout()
        self.tabs_layout_1.addLayout(self.tabs_grid_layout_1)
        self.tabs.addTab(self.tabs_widget_1, 'Abs PMF Out')
        self.tabs_widget_2 = Qt.QWidget()
        self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2)
        self.tabs_grid_layout_2 = Qt.QGridLayout()
        self.tabs_layout_2.addLayout(self.tabs_grid_layout_2)
        self.tabs.addTab(self.tabs_widget_2, 'FLL In')
        self.tabs_widget_3 = Qt.QWidget()
        self.tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_3)
        self.tabs_grid_layout_3 = Qt.QGridLayout()
        self.tabs_layout_3.addLayout(self.tabs_grid_layout_3)
        self.tabs.addTab(self.tabs_widget_3, 'FLL Out')
        self.tabs_widget_4 = Qt.QWidget()
        self.tabs_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_4)
        self.tabs_grid_layout_4 = Qt.QGridLayout()
        self.tabs_layout_4.addLayout(self.tabs_grid_layout_4)
        self.tabs.addTab(self.tabs_widget_4, 'FLL State')
        self.tabs_widget_5 = Qt.QWidget()
        self.tabs_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_5)
        self.tabs_grid_layout_5 = Qt.QGridLayout()
        self.tabs_layout_5.addLayout(self.tabs_grid_layout_5)
        self.tabs.addTab(self.tabs_widget_5, 'PFB Sync Out')
        self.tabs_widget_6 = Qt.QWidget()
        self.tabs_layout_6 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_6)
        self.tabs_grid_layout_6 = Qt.QGridLayout()
        self.tabs_layout_6.addLayout(self.tabs_grid_layout_6)
        self.tabs.addTab(self.tabs_widget_6, 'Costas State')
        self.tabs_widget_7 = Qt.QWidget()
        self.tabs_layout_7 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_7)
        self.tabs_grid_layout_7 = Qt.QGridLayout()
        self.tabs_layout_7.addLayout(self.tabs_grid_layout_7)
        self.tabs.addTab(self.tabs_widget_7, 'Demod Bits')
        self.tabs_widget_8 = Qt.QWidget()
        self.tabs_layout_8 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_8)
        self.tabs_grid_layout_8 = Qt.QGridLayout()
        self.tabs_layout_8.addLayout(self.tabs_grid_layout_8)
        self.tabs.addTab(self.tabs_widget_8, 'Costas  Sym Out')
        self.tabs_widget_9 = Qt.QWidget()
        self.tabs_layout_9 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_9)
        self.tabs_grid_layout_9 = Qt.QGridLayout()
        self.tabs_layout_9.addLayout(self.tabs_grid_layout_9)
        self.tabs.addTab(self.tabs_widget_9, 'Payload Symbols')
        self.top_layout.addWidget(self.tabs)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(freq, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(gain, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.qtgui_time_sink_x_2 = qtgui.time_sink_c(
        	preamble_size + payload_size, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_2.set_update_time(0.10)
        self.qtgui_time_sink_x_2.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_2.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_2.enable_tags(-1, True)
        self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_2.enable_autoscale(True)
        self.qtgui_time_sink_x_2.enable_grid(False)
        self.qtgui_time_sink_x_2.enable_axis_labels(True)
        self.qtgui_time_sink_x_2.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_2.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2*1):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_2.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_2.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_2.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget)
        self.tabs_layout_0.addWidget(self._qtgui_time_sink_x_2_win)
        self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0.set_y_axis(-128, 128)
        
        self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_1_0_0.enable_tags(-1, False)
        self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1_0_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget)
        self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_0_win)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_1_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1_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_1_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
        	8192, #size
        	samp_rate, #samp_rate
        	"", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1.disable_legend()
        
        labels = ['FLL Freq (PI Output)', 'FLL Phase Accum', 'FLL Error', '', '',
                  '', '', '', '', '']
        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(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tabs_layout_4.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0_3 = qtgui.time_sink_f(
        	1024*4, #size
        	samp_rate, #samp_rate
        	"Error", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_3.set_update_time(0.10)
        self.qtgui_time_sink_x_0_3.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0_3.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_0_3.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_3.enable_autoscale(False)
        self.qtgui_time_sink_x_0_3.enable_grid(False)
        self.qtgui_time_sink_x_0_3.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_3.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0_3.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_3.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_3.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_3.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_3.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_3.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_3.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_3.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_3_win = sip.wrapinstance(self.qtgui_time_sink_x_0_3.pyqwidget(), Qt.QWidget)
        self.tabs_layout_6.addWidget(self._qtgui_time_sink_x_0_3_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	preamble_size + payload_size, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0_0.disable_legend()
        
        labels = ['Mag Sq', 'Mag', '', '', '',
                  '', '', '', '', '']
        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_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tabs_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_sink_x_5 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	False, #plotwaterfall
        	False, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_5.set_update_time(1.0/10)
        self._qtgui_sink_x_5_win = sip.wrapinstance(self.qtgui_sink_x_5.pyqwidget(), Qt.QWidget)
        self.tabs_layout_3.addWidget(self._qtgui_sink_x_5_win)
        
        self.qtgui_sink_x_5.enable_rf_freq(False)
        
        
          
        self.qtgui_sink_x_1 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	False, #plotwaterfall
        	False, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_1.set_update_time(1.0/10)
        self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tabs_layout_2.addWidget(self._qtgui_sink_x_1_win)
        
        self.qtgui_sink_x_1.enable_rf_freq(False)
        
        
          
        self.qtgui_sink_x_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	False, #plotfreq
        	False, #plotwaterfall
        	False, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0/10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tabs_layout_5.addWidget(self._qtgui_sink_x_0_win)
        
        self.qtgui_sink_x_0.enable_rf_freq(False)
        
        
          
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #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_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.tabs_layout_2.addWidget(self._qtgui_freq_sink_x_0_win)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1.enable_grid(False)
        self.qtgui_const_sink_x_1.enable_axis_labels(True)
        
        if not True:
          self.qtgui_const_sink_x_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_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tabs_layout_9.addWidget(self._qtgui_const_sink_x_1_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.tabs_layout_8.addWidget(self._qtgui_const_sink_x_0_win)
        self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len)
        self.mods_frame_sync_fast_0 = mods.frame_sync_fast(pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order))
        self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx')
        self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(1, ( numpy.ones(n_barker_rep*barker_len)))
        self.interp_fir_filter_xxx_0_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, ( numpy.flipud(numpy.conj(preamble_syms))))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*pi/50, (rrc_taps), nfilts, nfilts/2, pi/8, 1)
        self.digital_map_bb_0_0_0 = digital.map_bb(([1,- 1]))
        self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc(sps, excess_bw, rrc_delay * int(sps) + 1, fllbw)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*pi/loopbw, 2**constellation.bits_per_symbol(), False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation.base())
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(constellation.bits_per_symbol())
        self.blocks_rms_xx_1 = blocks.rms_cf(0.0001)
        self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1.0/sqrt(2), ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1.0/(preamble_size*sqrt(2)), ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_1 = blocks.divide_ff(1)
        self.blocks_divide_xx_0 = blocks.divide_cc(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)
        self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu'))    
        self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))    
        self.connect((self.blocks_char_to_float_0_1, 0), (self.qtgui_time_sink_x_1_0_0, 0))    
        self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_sink_x_1, 0))    
        self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_2, 0))    
        self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0))    
        self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_char_to_float_0_1, 0))    
        self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0))    
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0))    
        self.connect((self.digital_costas_loop_cc_0, 1), (self.qtgui_time_sink_x_0_3, 0))    
        self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_char_to_float_0_0, 0))    
        self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0))    
        self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0))    
        self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0))    
        self.connect((self.digital_fll_band_edge_cc_1, 0), (self.qtgui_sink_x_5, 0))    
        self.connect((self.digital_fll_band_edge_cc_1, 3), (self.qtgui_time_sink_x_1, 2))    
        self.connect((self.digital_fll_band_edge_cc_1, 1), (self.qtgui_time_sink_x_1, 0))    
        self.connect((self.digital_fll_band_edge_cc_1, 2), (self.qtgui_time_sink_x_1, 1))    
        self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_sink_x_0, 0))    
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0))    
        self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1))    
        self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0))    
        self.connect((self.mods_frame_sync_fast_0, 0), (self.qtgui_const_sink_x_1, 0))    
        self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))    
Esempio n. 58
0
    def __init__(self,
                 baudrate,
                 samp_rate,
                 iq,
                 f_offset=None,
                 differential=False,
                 manchester=False,
                 dump_path=None,
                 options=None):
        gr.hier_block2.__init__(
            self, "bpsk_demodulator",
            gr.io_signature(1, 1,
                            gr.sizeof_gr_complex if iq else gr.sizeof_float),
            gr.io_signature(1, 1, gr.sizeof_float))
        options_block.__init__(self, options)

        if dump_path is not None:
            dump_path = pathlib.Path(dump_path)

        if manchester:
            baudrate *= 2

        # prevent problems due to baudrate too high
        if baudrate >= samp_rate / 4:
            print(
                f'Sample rate {samp_rate} sps insufficient for {baudrate} baud BPSK demodulation. Demodulator will not work.',
                file=sys.stderr)
            baudrate = samp_rate / 4

        sps = samp_rate / baudrate
        max_sps = 10
        if sps > max_sps:
            decimation = ceil(sps / max_sps)
        else:
            decimation = 1
        sps /= decimation

        filter_cutoff = baudrate * 2.0
        filter_transition = baudrate * 0.2

        if f_offset is None:
            f_offset = self.options.f_offset
        if f_offset is None:
            if iq:
                f_offset = 0
            elif baudrate <= 2400:
                f_offset = 1500
            else:
                f_offset = 12000

        taps = firdes.low_pass(1, samp_rate, filter_cutoff, filter_transition)
        f = filter.freq_xlating_fir_filter_ccf if iq else filter.freq_xlating_fir_filter_fcf
        self.xlating = f(decimation, taps, f_offset, samp_rate)

        agc_constant = 2e-2 / sps  # This gives a time constant of 50 symbols
        self.agc = rms_agc(agc_constant, 1)

        if dump_path is not None:
            self.agc_in = blocks.file_sink(gr.sizeof_gr_complex,
                                           str(dump_path / 'agc_in.c64'),
                                           False)
            self.agc_out = blocks.file_sink(gr.sizeof_gr_complex,
                                            str(dump_path / 'agc_out.c64'),
                                            False)
            self.connect(self.xlating, self.agc_in)
            self.connect(self.agc, self.agc_out)

        if not self.options.disable_fll:
            fll_bw = 2 * pi * decimation / samp_rate * self.options.fll_bw
            self.fll = digital.fll_band_edge_cc(sps, self.options.rrc_alpha,
                                                100, fll_bw)

            if dump_path is not None:
                self.fll_freq = blocks.file_sink(
                    gr.sizeof_float, str(dump_path / 'fll_freq.f32'), False)
                self.fll_phase = blocks.file_sink(
                    gr.sizeof_float, str(dump_path / 'fll_phase.f32'), False)
                self.fll_error = blocks.file_sink(
                    gr.sizeof_float, str(dump_path / 'fll_error.f32'), False)
                self.connect((self.fll, 1), self.fll_freq)
                self.connect((self.fll, 2), self.fll_phase)
                self.connect((self.fll, 3), self.fll_error)

        nfilts = 16
        rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0 / float(sps),
                                             self.options.rrc_alpha,
                                             int(ceil(11 * sps * nfilts)))
        ted_gain = 0.5  # "empiric" formula for TED gain of a PFB MF TED for complex BPSK 0.5 sample^{-1}
        damping = 1.0
        self.clock_recovery = digital.symbol_sync_cc(
            digital.TED_SIGNAL_TIMES_SLOPE_ML, sps, self.options.clk_bw,
            damping, ted_gain, self.options.clk_limit * sps, 1,
            digital.constellation_bpsk().base(), digital.IR_PFB_MF, nfilts,
            rrc_taps)

        if dump_path is not None:
            self.clock_recovery_out = blocks.file_sink(
                gr.sizeof_gr_complex,
                str(dump_path / 'clock_recovery_out.c64'), False)
            self.clock_recovery_err = blocks.file_sink(
                gr.sizeof_float, str(dump_path / 'clock_recovery_err.f32'),
                False)
            self.clock_recovery_T_inst = blocks.file_sink(
                gr.sizeof_float, str(dump_path / 'clock_recovery_T_inst.f32'),
                False)
            self.clock_recovery_T_avg = blocks.file_sink(
                gr.sizeof_float, str(dump_path / 'clock_recovery_T_avg.f32'),
                False)
            self.connect(self.clock_recovery, self.clock_recovery_out)
            self.connect((self.clock_recovery, 1), self.clock_recovery_err)
            self.connect((self.clock_recovery, 2), self.clock_recovery_T_inst)
            self.connect((self.clock_recovery, 3), self.clock_recovery_T_avg)

        self.connect(self, self.xlating, self.agc)
        if self.options.disable_fll:
            self.connect(self.agc, self.clock_recovery)
        else:
            self.connect(self.agc, self.fll, self.clock_recovery)

        self.complex_to_real = blocks.complex_to_real(1)

        if manchester:
            self.manchester = manchester_sync(self.options.manchester_history)
            self.connect(self.clock_recovery, self.manchester)
        else:
            self.manchester = self.clock_recovery

        if differential:
            self.delay = blocks.delay(gr.sizeof_gr_complex, 1)
            self.multiply_conj = blocks.multiply_conjugate_cc(1)
            sign = -1 if manchester else 1
            self.multiply_const = blocks.multiply_const_ff(
                sign, 1)  # take care about inverion in Manchester
            self.connect(self.manchester, (self.multiply_conj, 0))
            self.connect(self.manchester, self.delay, (self.multiply_conj, 1))
            self.connect(self.multiply_conj, self.complex_to_real,
                         self.multiply_const, self)
        else:
            costas_bw = 2 * pi / baudrate * self.options.costas_bw
            self.costas = digital.costas_loop_cc(costas_bw, 2, False)

            if dump_path is not None:
                self.costas_out = blocks.file_sink(
                    gr.sizeof_gr_complex, str(dump_path / 'costas_out.c64'),
                    False)
                self.costas_frequency = blocks.file_sink(
                    gr.sizeof_float, str(dump_path / 'costas_frequency.f32'),
                    False)
                self.costas_phase = blocks.file_sink(
                    gr.sizeof_float, str(dump_path / 'costas_phase.f32'),
                    False)
                self.costas_error = blocks.file_sink(
                    gr.sizeof_float, str(dump_path / 'costas_error.f32'),
                    False)
                self.connect(self.costas, self.costas_out)
                self.connect((self.costas, 1), self.costas_frequency)
                self.connect((self.costas, 2), self.costas_phase)
                self.connect((self.costas, 3), self.costas_error)

            self.connect(self.manchester, self.costas, self.complex_to_real,
                         self)
	def __init__(self):
		gr.top_block.__init__(self, "Uhd Snr Receiver")
		Qt.QWidget.__init__(self)
		self.setWindowTitle("Uhd Snr Receiver")
		self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
		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", "uhd_snr_receiver")
		self.restoreGeometry(self.settings.value("geometry").toByteArray())


		##################################################
		# Variables
		##################################################
		self.sps = sps = 4
		self.nfilts = nfilts = 32
		self.samp_rate = samp_rate = 1e6
		self.rrc_taps = rrc_taps = filter.firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts)
		self.gain = gain = 15
		self.freq = freq = 520e6
		self.fine_freq = fine_freq = -28400

		##################################################
		# Blocks
		##################################################
		self._gain_layout = Qt.QVBoxLayout()
		self._gain_tool_bar = Qt.QToolBar(self)
		self._gain_layout.addWidget(self._gain_tool_bar)
		self._gain_tool_bar.addWidget(Qt.QLabel("RX Gain"+": "))
		self._gain_counter = Qwt.QwtCounter()
		self._gain_counter.setRange(0, 31.5, 0.5)
		self._gain_counter.setNumButtons(2)
		self._gain_counter.setValue(self.gain)
		self._gain_tool_bar.addWidget(self._gain_counter)
		self._gain_counter.valueChanged.connect(self.set_gain)
		self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
		self._gain_slider.setRange(0, 31.5, 0.5)
		self._gain_slider.setValue(self.gain)
		self._gain_slider.setMinimumWidth(200)
		self._gain_slider.valueChanged.connect(self.set_gain)
		self._gain_layout.addWidget(self._gain_slider)
		self.top_layout.addLayout(self._gain_layout)
		self._freq_layout = Qt.QVBoxLayout()
		self._freq_tool_bar = Qt.QToolBar(self)
		self._freq_layout.addWidget(self._freq_tool_bar)
		self._freq_tool_bar.addWidget(Qt.QLabel("Frequency"+": "))
		self._freq_counter = Qwt.QwtCounter()
		self._freq_counter.setRange(514e6, 526e6, 1e6)
		self._freq_counter.setNumButtons(2)
		self._freq_counter.setValue(self.freq)
		self._freq_tool_bar.addWidget(self._freq_counter)
		self._freq_counter.valueChanged.connect(self.set_freq)
		self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
		self._freq_slider.setRange(514e6, 526e6, 1e6)
		self._freq_slider.setValue(self.freq)
		self._freq_slider.setMinimumWidth(200)
		self._freq_slider.valueChanged.connect(self.set_freq)
		self._freq_layout.addWidget(self._freq_slider)
		self.top_grid_layout.addLayout(self._freq_layout, 2,0,1,1)
		self._fine_freq_layout = Qt.QVBoxLayout()
		self._fine_freq_tool_bar = Qt.QToolBar(self)
		self._fine_freq_layout.addWidget(self._fine_freq_tool_bar)
		self._fine_freq_tool_bar.addWidget(Qt.QLabel("Fine Frequency"+": "))
		self._fine_freq_counter = Qwt.QwtCounter()
		self._fine_freq_counter.setRange(-50e3, 50e3, 100)
		self._fine_freq_counter.setNumButtons(2)
		self._fine_freq_counter.setValue(self.fine_freq)
		self._fine_freq_tool_bar.addWidget(self._fine_freq_counter)
		self._fine_freq_counter.valueChanged.connect(self.set_fine_freq)
		self._fine_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
		self._fine_freq_slider.setRange(-50e3, 50e3, 100)
		self._fine_freq_slider.setValue(self.fine_freq)
		self._fine_freq_slider.setMinimumWidth(200)
		self._fine_freq_slider.valueChanged.connect(self.set_fine_freq)
		self._fine_freq_layout.addWidget(self._fine_freq_slider)
		self.top_grid_layout.addLayout(self._fine_freq_layout, 2,1,1,1)
		self.uhd_usrp_source_0 = uhd.usrp_source(
			device_addr="",
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_source_0.set_samp_rate(samp_rate)
		self.uhd_usrp_source_0.set_center_freq(freq + fine_freq, 0)
		self.uhd_usrp_source_0.set_gain(gain, 0)
		self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
		self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
			500, #size
			samp_rate, #bw
			"QT GUI Plot", #name
			3 #number of inputs
		)
		self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
		self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 0,0,1,1)
		self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
			1024, #size
			firdes.WIN_BLACKMAN_hARRIS, #wintype
			0, #fc
			samp_rate, #bw
			"QT GUI Plot", #name
			1 #number of inputs
		)
		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, 1,0,1,2)
		self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
			1024, #size
			"QT GUI Plot", #name
			2 #number of inputs
		)
		self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
		self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0,1,1,1)
		self.gr_multiply_xx_0 = gr.multiply_vcc(1)
		self.gr_agc2_xx_0 = gr.agc2_cc(1e-1, 1e-2, 1.0, 1.0, 0.0)
		self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*3.14/100.0, (rrc_taps), nfilts, nfilts/2, 1.5, 1)
		self.digital_mpsk_snr_est_cc_0_1 = digital.mpsk_snr_est_cc(3, 10000, 0.001)
		self.digital_mpsk_snr_est_cc_0_0 = digital.mpsk_snr_est_cc(2, 10000, 0.001)
		self.digital_mpsk_snr_est_cc_0 = digital.mpsk_snr_est_cc(0, 10000, 0.001)
		self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(15, 0.010, 1, digital.constellation_qpsk().base())
		self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*3.14/100.0, 4)

		##################################################
		# Connections
		##################################################
		self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0, 0))
		self.connect((self.gr_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
		self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 1))
		self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 3))
		self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 2))
		self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 1))
		self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 0))
		self.connect((self.gr_agc2_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
		self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0))
		self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0))
		self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0))
		self.connect((self.uhd_usrp_source_0, 0), (self.gr_agc2_xx_0, 0))
		self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0_0, 0))
		self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0_1, 0))
		self.connect((self.digital_mpsk_snr_est_cc_0, 0), (self.qtgui_time_sink_x_0_0, 0))
		self.connect((self.digital_mpsk_snr_est_cc_0_0, 0), (self.qtgui_time_sink_x_0_0, 1))
		self.connect((self.digital_mpsk_snr_est_cc_0_1, 0), (self.qtgui_time_sink_x_0_0, 2))